-
Notifications
You must be signed in to change notification settings - Fork 0
/
trackcircuit.hxx
46 lines (41 loc) · 1.35 KB
/
trackcircuit.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
#ifndef TRACKCIRCUIT_HXX
#define TRACKCIRCUIT_HXX
#include <QSvgWidget>
#include <QSoundEffect>
#include <QMap>
#include <QDebug>
#include "global_params.hxx"
namespace EWRB {
class TrackCircuit {
private:
TrackCircuitStatus state_ = TrackCircuitStatus::Clear;
const QString label_ = "";
QSvgWidget* lit_ = nullptr;
QSoundEffect* indicator_sound_ = new QSoundEffect;
int position_[2] = {0, 0};
public:
TrackCircuit(const QString& label, QWidget* parent, const QString& image_path) : label_(label), lit_(new QSvgWidget(image_path, parent)) {
indicator_sound_->setSource(QUrl::fromLocalFile(":/audio/audio/track_circuit_indicator.wav"));
}
void PlaceAt(const int& x, const int& y){
position_[0] = x; position_[1] = y;
lit_->move(x, y);
}
void SetSize(const int& x, const int& y) {
lit_->setFixedSize(x, y);
}
void update() {
if(state_ == TrackCircuitStatus::Clear) lit_->show();
else lit_->hide();
}
TrackCircuitStatus getState() const {
return state_;
}
void SetState(TrackCircuitStatus state) {
state_ = state;
update();
}
};
QMap<QString, TrackCircuit*> TrackCircuits(QWidget* parent);
};
#endif // TRACKCIRCUIT_HXX