-
Notifications
You must be signed in to change notification settings - Fork 0
/
leverframe.hxx
98 lines (93 loc) · 3.91 KB
/
leverframe.hxx
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
88
89
90
91
92
93
94
95
96
97
98
#ifndef LEVERFRAME_HXX
#define LEVERFRAME_HXX
#include <QMap>
#include <QSvgWidget>
#include <QDebug>
#include <QGuiApplication>
#include <QScreen>
#include "framelever.hxx"
#include "scaling.hxx"
#include "pointsindicator.hxx"
#include "signalindicator.hxx"
#include "traindescriber.hxx"
#include "trackcircuit.hxx"
#include "scaling.hxx"
namespace EWRB
{
class LeverFrame : public QObject
{
Q_OBJECT
private:
QList<QSoundEffect*> _lever_sounds;
const Scaler* scaler_ = new Scaler;
QMap<QString, TrackCircuit*> track_circuits_;
QSoundEffect* _lever_failed = new QSoundEffect;
QWidget* _parent = nullptr;
QSvgWidget* _frame_svg = nullptr;
QMap<int, EWRB::FrameLever*> _levers;
QMap<int, EWRB::PointsIndicator*> _indicators;
QMap<int, EWRB::SignalPanelIndicator*> _sig_indicators;
QMap<int, EWRB::SignalMapIndicator*> _map_indicators;
QMap<int, EWRB::TrainDescriber*> _train_describers;
Dispatcher* _dispatcher = nullptr;
public:
LeverFrame(QWidget* parent);
void setDispatcher(Dispatcher* dispatcher) {_dispatcher = dispatcher;}
EWRB::FrameLever* operator[](const int& i)
{
return _levers[i];
}
QList<int> levers() const {return _levers.keys();}
void update(const int& i=-1);
void addSignalPanelIndicator(BlockSection* section)
{
_sig_indicators[section->id()] = new SignalPanelIndicator(_parent, section, section->id());
}
void addSignalMapIndicator(BlockSection* section, double angle=90)
{
_map_indicators[section->getBlockSignal()->id()] = new SignalMapIndicator(_parent, section, angle);
}
void addShuntMapIndicator(BlockSection* section, double angle=90)
{
_map_indicators[section->getBlockSignal()->id()] = new ShuntMapIndicator(_parent, section, angle);
}
void addCustomMapIndicator(SignalMapIndicator* indicator)
{
_map_indicators[indicator->getMirroredSignal()->id()] = indicator;
}
void addTrainDescriber(const int& id, const QString& type, const int& x, const int& y)
{
_train_describers[id] = new TrainDescriber(_train_describers.size(), _dispatcher, _parent, type);
_train_describers[id]->PlaceAt(x, y);
}
void moveLever(const int& i, EWRB::LeverState lever_state, bool points_move)
{
if(_levers[i]->getState() == EWRB::LeverState::Mid) _play_failed();
else if(lever_state != EWRB::LeverState::Mid)_play_random_lever_sound();
else _play_failed();
_levers[i]->moveLever(lever_state, points_move);
}
QMap<QString, TrackCircuit*> getTrackCircuits() {
return track_circuits_;
}
void placeSigIndicators();
void placeMapIndicators();
void placeTrackCircuitIndicators();
void placeDescribers();
void _play_random_lever_sound();
void _play_failed() {_lever_failed->play();}
public slots:
void updatePointsInd13(EWRB::LeverState);
void updatePointsInd14(EWRB::LeverState);
void updatePointsInd15(EWRB::LeverState);
void updatePointsInd17(EWRB::LeverState);
void updatePointsInd19(EWRB::LeverState);
void updatePointsInd20(EWRB::LeverState);
void updatePointsInd21(EWRB::LeverState);
void updatePointsInd22(EWRB::LeverState);
void updatePointsInd23(EWRB::LeverState);
void updatePointsInd26(EWRB::LeverState);
void updatePointsInd27(EWRB::LeverState);
};
};
#endif // LEVERFRAME_HXX