-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdeathmatchrunningclockwidget.cpp
More file actions
80 lines (67 loc) · 2.38 KB
/
deathmatchrunningclockwidget.cpp
File metadata and controls
80 lines (67 loc) · 2.38 KB
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
#include "deathmatchrunningclockwidget.h"
#include "ui_deathmatchrunningclockwidget.h"
#include "app_state/deathmatchconfig.h"
#include "app_state/deathmatchruntime.h"
#include <QPropertyAnimation>
#include <QParallelAnimationGroup>
#include "util.h"
DeathMatchRunningClockWidget::DeathMatchRunningClockWidget(QWidget *parent) :
QWidget(parent)
, ui(new Ui::DeathMatchRunningClockWidget)
, m_dmcfg(nullptr)
, m_dmRt(nullptr)
{
m_dmcdAnimationGroup = new QParallelAnimationGroup(this);
ui->setupUi(this);
}
DeathMatchRunningClockWidget::~DeathMatchRunningClockWidget()
{
delete ui;
}
void DeathMatchRunningClockWidget::setup(DeathMatchConfig *cfg, DeathMatchRuntime *runtime) {
assert(!m_dmcfg);
assert(!m_dmRt);
m_dmcfg = cfg;
m_dmRt = runtime;
// Connecting slots to the DeathMatchRuntime Model.
connect(m_dmRt, &DeathMatchRuntime::timeRemainingChanged,
this, &DeathMatchRunningClockWidget::updateRemainingTime);
connect(m_dmRt, &DeathMatchRuntime::doorDropTimeRemainingChanged,
this, &DeathMatchRunningClockWidget::updateDoorDropTime);
connect(m_dmRt, &DeathMatchRuntime::staringMatch,
this, &DeathMatchRunningClockWidget::staringMatch);
}
void DeathMatchRunningClockWidget::staringMatch(int duration, bool needsDoorDropTimer, int doorDropTime) {
if(needsDoorDropTimer) {
ui->doorDropTimeLabel->setText(msToTimeRep(doorDropTime));
ui->doorDropTimeRemainingLabel->setText("Waffles");
} else {
ui->doorDropTimeRemainingLabel->setText("n/a");
ui->doorDropTimeLabel->setText("n/a");
}
// Setting things up for the rest of the labels.
ui->initialMatchTime->setText(msToTimeRep(duration));
ui->doorDropSettingLabel->setText(m_dmcfg->doorDropKindAsString());
}
void DeathMatchRunningClockWidget::updateRemainingTime(int value) {
ui->timeRemainingLabel->setText(msToTimeRep(value));
}
void DeathMatchRunningClockWidget::updateDoorDropTime(int value) {
ui->doorDropTimeRemainingLabel->setText(msToTimeRep(value));
}
void DeathMatchRunningClockWidget::start() {
m_dmRt->start();
emit started();
}
void DeathMatchRunningClockWidget::pause() {
m_dmRt->pause();
emit paused();
}
void DeathMatchRunningClockWidget::resume() {
m_dmRt->resume();
emit resumed();
}
void DeathMatchRunningClockWidget::stop() {
m_dmRt->stop();
emit matchOver();
}