-
Notifications
You must be signed in to change notification settings - Fork 0
/
framelever.cxx
87 lines (74 loc) · 1.98 KB
/
framelever.cxx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
#include "framelever.hxx"
EWRB::PointsChange::PointsChange(EWRB::FrameLever* parent)
{
connect(_timer, SIGNAL(timeout()), this, SLOT(timerEnded()));
_parent = parent;
_sound_effect->setSource(QUrl::fromLocalFile(":/audio/audio/air_release.wav"));
}
bool EWRB::PointsChange::getState()
{
if(_sound_finished)
{
_sound_finished = false;
return true;
}
return _sound_finished;
}
void EWRB::FrameLever::PlaceAt(const int &x, const int &y)
{
_coords[0] = x; _coords[1] = y;
for(auto svg : _svgs) svg->move(_coords[0], _coords[1]);
}
void EWRB::FrameLever::moveLever(EWRB::LeverState state, bool points_delay)
{
_svgs[_current_state]->hide();
if(state == EWRB::LeverState::Mid && _current_state != state)
{
_prev_state = _current_state;
_current_state = state;
_svgs[_current_state]->show();
return;
}
if(_current_state == LeverState::Off)
{
_prev_state = _current_state;
if(points_delay)
{
_current_state = LeverState::Mid;
_svgs[_current_state]->show();
_points_change->run();
}
else _current_state = LeverState::On;
}
else if(_current_state == LeverState::Mid)
{
_current_state = (_locked) ? _prev_state : reverse(_prev_state);
}
else
{
_prev_state = _current_state;
if(points_delay)
{
_current_state = LeverState::Mid;
_svgs[_current_state]->show();
_points_change->run();
}
else _current_state = LeverState::Off;
}
_svgs[_current_state]->show();
}
void EWRB::FrameLever::pointsChangedFinished()
{
_svgs[_current_state]->hide();
emit sendCurrentLeverDestination(reverse(_prev_state));
_current_state = reverse(_prev_state);
_svgs[_current_state]->show();
}
void EWRB::FrameLever::hideSVG()
{
_svgs[_current_state]->hide();
}
void EWRB::FrameLever::showSVG()
{
_svgs[_current_state]->show();
}