-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbattleboxmainwindow.cpp
More file actions
1104 lines (938 loc) · 45.2 KB
/
battleboxmainwindow.cpp
File metadata and controls
1104 lines (938 loc) · 45.2 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
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#include "battleboxmainwindow.h"
#include "./ui_battleboxmainwindow.h"
#include <QPushButton>
#include <QLineEdit>
#include <QString>
#include <QFileDialog>
#include <QGraphicsOpacityEffect>
#include <QPropertyAnimation>
#include <QSequentialAnimationGroup>
#include <QFileSystemWatcher>
#include <QTimer>
#include <QVariant>
#include <iostream>
#include "mediadialog.h"
#include "app_state/deathmatchconfig.h"
#include "app_state/applicationstate.h"
#include "configurationwidget.h"
#include "app_state/screen.h"
// sudo chmod a+rw /dev/ttyACM0
static const char *GREEN_BG_STYLE_SHEET = "background-color:green;";
static const char *RED_BG_STYLE_SHEET = "background-color:red;";
static const char *DEATHMATCH_QUICK_LOAD_FOLDER = "/home/battlbox/DeathMatchConfig";
static const char *SOCCER_QUICK_LOAD_FOLDER = "/home/battlbox/SoccerConfig";
BattleBoxMainWindow::BattleBoxMainWindow(QWidget *parent)
: QMainWindow(parent)
, ui(new Ui::BattleBoxMainWindow)
, m_state(new ApplicationState(this))
, m_dmcdAnimationGroup(new QSequentialAnimationGroup(this))
, m_scdAnimationGroup(new QSequentialAnimationGroup(this))
, m_dirWatcher(new QFileSystemWatcher(this))
, m_mediaScreen(new MediaDialog(m_state, this))
{
ui->setupUi(this);
connectScreenSlots();
m_mediaScreen->loadSettingsDependentResources();
initializeSystemConfigurationScreen();
initMediaDialog();
// Quick load widgets
initQuickSelectWidgets();
// Game selection
initGameSelectScreen();
// Connecting all signals to the LED controller.
initLEDController();
// DeathMatch
initDeathMatchConfigScreen();
initDeathMatchPlayersReadyScreen();
initDeathMatchCountDownScreen();
initDeathMatchRunningScreen();
initDeathMatchWinnerScreen();
// Soccer
initSoccerConfigScreen();
initSoccerPlayersReadyScreen();
initSoccerCountDownScreen();
initSoccerRunningScreen();
initSoccerGameOverScreen();
// Setting the current scren.
m_state->screen()->changeToGameSelectScreen();
m_state->data()->saveSettings();
}
void BattleBoxMainWindow::closeEvent(QCloseEvent *event) {
qDebug() << "Received a close event!";
m_state->physicalState()->connectionManager()->consumeUntilQuiet(1000);
m_state->physicalState()->connectionManager()->blockingSendData("LEDAllSetBrightness 0");
m_state->physicalState()->connectionManager()->blockingSendData("LEDAllShow");
QMainWindow::closeEvent(event);
}
BattleBoxMainWindow::~BattleBoxMainWindow() {
delete ui;
}
DeathMatchConfig *BattleBoxMainWindow::deathMatchConfig() const {
return m_state->data()->deathMatchConfig();
}
void BattleBoxMainWindow::connectScreenSlots() {
#define SCREEN_CONNECT(NAME)\
connect(m_state->screen(), &Screen::NAME,\
this, &BattleBoxMainWindow::NAME);
SCREEN_CONNECT(enterConfigurationScreen);
SCREEN_CONNECT(leaveConfigurationScreen);
SCREEN_CONNECT(enterGameSelectScreen);
SCREEN_CONNECT(leaveGameSelectScreen);
SCREEN_CONNECT(enterDMConfigScreen);
SCREEN_CONNECT(leaveDMConfigScreen);
SCREEN_CONNECT(enterDMCountDownScreen);
SCREEN_CONNECT(postEnterDMCountDownScreen)
SCREEN_CONNECT(leaveDMCountDownScreen);
SCREEN_CONNECT(enterDMPlayersReadyScreen);
SCREEN_CONNECT(leaveDMPlayersReadyScreen);
SCREEN_CONNECT(enterDMRunningScreen);
SCREEN_CONNECT(leaveDMRunningScreen);
SCREEN_CONNECT(enterDMWinnerDisplayScreen);
SCREEN_CONNECT(leaveDMWinnerDisplayScreen);
SCREEN_CONNECT(enterSoccerConfigScreen);
SCREEN_CONNECT(leaveSoccerConfigScreen);
SCREEN_CONNECT(leaveSoccerPlayersReadyScreen);
SCREEN_CONNECT(enterSoccerPlayersReadyScreen);
SCREEN_CONNECT(enterSoccerRunningScreen);
SCREEN_CONNECT(leaveSoccerRunningScreen);
SCREEN_CONNECT(enterSoccerCountDownScreen);
SCREEN_CONNECT(leaveSoccerCountDownScreen);
SCREEN_CONNECT(enterSoccerGameOverScreen);
SCREEN_CONNECT(leaveSoccerGameOverScreen);
#undef SCREEN_CONNECT
}
void BattleBoxMainWindow::initializeSystemConfigurationScreen() {
// Configure the system configuration screen. This may require
// things like back buttons, and access to the current data
connect(ui->configuration, &ConfigurationWidget::clickedBack,
m_state->screen(), &Screen::changeToGameSelectScreen);
ui->configuration->init(m_state, m_mediaScreen);
}
void BattleBoxMainWindow::initMediaDialog() {
m_mediaScreen->setModal(false);
m_mediaScreen->show();
}
void BattleBoxMainWindow::initGameSelectScreen() {
// Slot Connections.
connect(ui->dmConfigButton, &QPushButton::clicked,
m_state->screen(), &Screen::changeToDMConfigScreen);
connect(ui->soccerConfigButton, &QPushButton::clicked,
m_state->screen(), &Screen::changeToSoccerConfigScreen);
connect(ui->systemConfigurationButton, &QPushButton::clicked,
m_state->screen(), &Screen::changeToConfigurationScreen);
}
void BattleBoxMainWindow::initQuickSelectWidgets() {
// TODO: Move some this into the application state.
// Setting up directory watcher for quick loading for both
// death match and soccer.
connect(m_dirWatcher, &QFileSystemWatcher::directoryChanged,
this, &BattleBoxMainWindow::updateQuickLoadFiles);
m_dirWatcher->addPath(DEATHMATCH_QUICK_LOAD_FOLDER);
loadQuickLoadFiles(DEATHMATCH_QUICK_LOAD_FOLDER);
m_dirWatcher->addPath(SOCCER_QUICK_LOAD_FOLDER);
loadQuickLoadFiles(SOCCER_QUICK_LOAD_FOLDER);
}
void BattleBoxMainWindow::initLEDController() {
// Connecting count down signals.
connect(this, &BattleBoxMainWindow::DMCDstart3,
m_state->ledController(), &LEDController::DMCDstart3);
connect(this, &BattleBoxMainWindow::DMCDstart2,
m_state->ledController(), &LEDController::DMCDstart2);
connect(this, &BattleBoxMainWindow::DMCDstart1,
m_state->ledController(), &LEDController::DMCDstart1);
connect(this, &BattleBoxMainWindow::DMCDstartFight,
m_state->ledController(), &LEDController::DMCDstartFight);
// Connecting death match player wins screen light signals.
connect(this, &BattleBoxMainWindow::dmPlayerOneWins,
m_state->ledController(), &LEDController::dmPlayerOneWins);
connect(this, &BattleBoxMainWindow::dmPlayerTwoWins,
m_state->ledController(), &LEDController::dmPlayerTwoWins);
// Connecting player ready screen signals.
connect(this, &BattleBoxMainWindow::dmPlayerOneReady,
m_state->ledController(), &LEDController::dmPlayerOneReady);
connect(this, &BattleBoxMainWindow::dmPlayerOneCancelledReady,
m_state->ledController(), &LEDController::dmPlayerOneCancelledReady);
connect(this, &BattleBoxMainWindow::dmPlayerOneCantBeReady,
m_state->ledController(), &LEDController::dmPlayerOneCantBeReady);
connect(this, &BattleBoxMainWindow::dmPlayerTwoReady,
m_state->ledController(), &LEDController::dmPlayerTwoReady);
connect(this, &BattleBoxMainWindow::dmPlayerTwoCancelledReady,
m_state->ledController(), &LEDController::dmPlayerTwoCancelledReady);
connect(this, &BattleBoxMainWindow::dmPlayerTwoCantBeReady,
m_state->ledController(), &LEDController::dmPlayerTwoCantBeReady);
// Connecting the deathmatch countdown trigger signals from the
// death match runtime.
connect(m_state->data()->deathMatchRuntime(), &DeathMatchRuntime::doorDropCountDown,
m_state->ledController(), &LEDController::dmDoorDropCountDown);
connect(m_state->data()->deathMatchRuntime(), &DeathMatchRuntime::doorDropCountDown,
this, [this](int) { dmDoorDropSpotLightFlash(); });
connect(m_state->data()->deathMatchRuntime(), &DeathMatchRuntime::matchOverCountDown,
m_state->ledController(), &LEDController::dmMatchOverCountDown);
}
void BattleBoxMainWindow::initDeathMatchConfigScreen() {
// Death match configuration screen slots
// Other slot
connect(ui->dmCfgSaveButton, &QPushButton::clicked,
this, &BattleBoxMainWindow::on_dmCfgSaveButton_clicked);
connect(ui->dmCfgLoadButton, &QPushButton::clicked,
this, &BattleBoxMainWindow::on_dmCfgLoadButton_clicked);
connect(ui->dmStart, &QPushButton::clicked,
m_state->screen(), &Screen::changeToDMPlayersReadyScreen);
connect(ui->dmCancel, &QPushButton::clicked,
m_state->screen(), &Screen::changeToGameSelectScreen);
connect(ui->dmCfgReset, &QPushButton::clicked,
m_state->data(), &BattleBoxViewModel::resetDeathMatchConfig);
// Setting up bidirectional connections between the deathmatch configuration
// and the configuration screen.
// Connecting player one name edit
ui->playerOneNameLineEdit->setText(m_state->data()->deathMatchConfig()->playerOneName());
connect(ui->playerOneNameLineEdit, &QLineEdit::textChanged,
m_state->data()->deathMatchConfig(), &DeathMatchConfig::setPlayerOneName);
connect(m_state->data()->deathMatchConfig(), &DeathMatchConfig::playerOneNameChanged,
ui->playerOneNameLineEdit, &QLineEdit::setText);
// Connecting player two name edit
ui->playerTwoNameLineEdit->setText(m_state->data()->deathMatchConfig()->playerTwoName());
connect(ui->playerTwoNameLineEdit, &QLineEdit::textChanged,
m_state->data()->deathMatchConfig(), &DeathMatchConfig::setPlayerTwoName);
connect(m_state->data()->deathMatchConfig(), &DeathMatchConfig::playerTwoNameChanged,
ui->playerTwoNameLineEdit, &QLineEdit::setText);
// Connecting match duration widget
ui->matchDurationWidget->setDuration(m_state->data()->deathMatchConfig()->matchDuration());
connect(ui->matchDurationWidget, &DurationWidget::durationChanged,
m_state->data()->deathMatchConfig(), &DeathMatchConfig::setMatchDuration);
connect(m_state->data()->deathMatchConfig(), &DeathMatchConfig::matchDurationChanged,
ui->matchDurationWidget, &DurationWidget::setDuration);
// Connecting door drop time duration widget
ui->doorDropTimeWidget->setDuration(m_state->data()->deathMatchConfig()->doorDropTime());
connect(ui->doorDropTimeWidget, &DurationWidget::durationChanged,
m_state->data()->deathMatchConfig(), &DeathMatchConfig::setDoorDropTime);
connect(m_state->data()->deathMatchConfig(), &DeathMatchConfig::doorDropChanged,
ui->doorDropTimeWidget, &DurationWidget::setDuration);
// Connecting drop down with kind
ui->doorDropKindComboBox->setCurrentIndex((int)m_state->data()->deathMatchConfig()->doorDropKind());
connect(ui->doorDropKindComboBox, &QComboBox::currentIndexChanged,
m_state->data()->deathMatchConfig(), &DeathMatchConfig::setDoorDropKindFromInt);
connect(m_state->data()->deathMatchConfig(), &DeathMatchConfig::doorDropKindChangedInt,
ui->doorDropKindComboBox, &QComboBox::setCurrentIndex);
// Keep "Drop <Name> Door" combobox items in sync with configured player names
auto updateDoorDropComboNames = [this]() {
auto p1 = m_state->data()->deathMatchConfig()->playerOneName();
auto p2 = m_state->data()->deathMatchConfig()->playerTwoName();
ui->doorDropKindComboBox->setItemText(4, QString("Drop %1 Door").arg(p1.isEmpty() ? "Player One" : p1));
ui->doorDropKindComboBox->setItemText(5, QString("Drop %1 Door").arg(p2.isEmpty() ? "Player Two" : p2));
};
updateDoorDropComboNames();
connect(m_state->data()->deathMatchConfig(), &DeathMatchConfig::playerOneNameChanged,
this, [updateDoorDropComboNames](QString) { updateDoorDropComboNames(); });
connect(m_state->data()->deathMatchConfig(), &DeathMatchConfig::playerTwoNameChanged,
this, [updateDoorDropComboNames](QString) { updateDoorDropComboNames(); });
// Connecting do matchOverWarningTime
ui->matchOverWarningTime->setValue(m_state->data()->deathMatchConfig()->matchOverWarningTime());
connect(ui->matchOverWarningTime, &QSpinBox::valueChanged,
m_state->data()->deathMatchConfig(), &DeathMatchConfig::setMatchOverWarningTime);
connect(m_state->data()->deathMatchConfig(), &DeathMatchConfig::matchOverWarningTimeChanged,
ui->matchOverWarningTime, &QSpinBox::setValue);
// Connecting do doorDropWarningTime
ui->doorDropWarningTime->setValue(m_state->data()->deathMatchConfig()->doorDropWarningTime());
connect(ui->doorDropWarningTime, &QSpinBox::valueChanged,
m_state->data()->deathMatchConfig(), &DeathMatchConfig::setDoorDropWarningTime);
connect(m_state->data()->deathMatchConfig(), &DeathMatchConfig::doorDropWarningTimeChanged,
ui->doorDropWarningTime, &QSpinBox::setValue);
// Connecting quick load slot
connect(ui->dmQuickLoadButton, &QPushButton::clicked,
[&] {
auto items = ui->dmQuickLoadListWidget->selectedItems();
if(items.size() != 1) {
return;
}
QString path = DEATHMATCH_QUICK_LOAD_FOLDER + QString("/") + items[0]->text();
this->m_state->data()->deathMatchConfig()->loadFromFile(path);
});
// Error signal connection.
connect(this->m_state->data()->deathMatchConfig(), &DeathMatchConfig::error,
this, &BattleBoxMainWindow::receivedError);
// Configuring default values
m_state->data()->deathMatchConfig()->setMatchDuration(180);
m_state->data()->deathMatchConfig()->setDoorDropTime(60);
}
void BattleBoxMainWindow::initDeathMatchPlayersReadyScreen() {
// Make sure to only only handle input while
// m_state->screen()->currentScreen() == Screen::ScreenKind::DMPlayersReadyScreen
// is true.
// Connecting buttons.
connect(ui->dmprPlayerOneReadyButton, &QPushButton::clicked,
[&] {
m_state->data()->deathMatchPlayerOneReady()->setPlayerReady(true);
m_state->arduinoClient()->setP1SpotLight(true);
});
connect(ui->dmprPlayerTwoReadyButton, &QPushButton::clicked,
[&] {
m_state->data()->deathMatchPlayerTwoReady()->setPlayerReady(true);
m_state->arduinoClient()->setP2SpotLight(true);
});
// Screen changing buttons
connect(ui->dmprStart, &QPushButton::clicked,
m_state->screen(), &Screen::changeToDMCountDownScreen);
connect(ui->dmprCancel, &QPushButton::clicked,
m_state->screen(), &Screen::changeToDMConfigScreen);
// Connecting battle box to UI screen
// Connecting player one to battle box UI screen controls
connect(m_state->physicalState()->playerOne()->readyButton(), &PhysicalButton::stateChanged,
[&] (bool arg) {
if (m_state->screen()->currentScreen() == Screen::ScreenKind::DMPlayersReadyScreen) {
m_state->data()->deathMatchPlayerOneReady()->setPlayerReadyForRound(arg);
m_state->arduinoClient()->setP1SpotLight(true);
}
});
connect(m_state->physicalState()->playerOne()->doorButton(), &PhysicalButton::stateChanged,
m_state->data()->deathMatchPlayerOneReady(), &DeathMatchPlayerReadyModel::setDoorClosedForRound);
connect(m_state->physicalState()->playerOne()->conceedButton(), &PhysicalButton::stateChanged,
[&] {
if (m_state->screen()->currentScreen() == Screen::ScreenKind::DMPlayersReadyScreen) {
m_state->data()->deathMatchPlayerOneReady()->cancelPlayerReadyForRound();
m_state->arduinoClient()->setP1SpotLight(false);
}
});
// Connecting player two to battle box UI screen controls
connect(m_state->physicalState()->playerTwo()->readyButton(), &PhysicalButton::stateChanged,
[&] (bool arg) {
if (m_state->screen()->currentScreen() == Screen::ScreenKind::DMPlayersReadyScreen) {
m_state->data()->deathMatchPlayerTwoReady()->setPlayerReadyForRound(arg);
m_state->arduinoClient()->setP2SpotLight(true);
}
});
connect(m_state->physicalState()->playerTwo()->doorButton(), &PhysicalButton::stateChanged,
m_state->data()->deathMatchPlayerTwoReady(), &DeathMatchPlayerReadyModel::setDoorClosedForRound);
connect(m_state->physicalState()->playerTwo()->conceedButton(), &PhysicalButton::stateChanged,
[&] {
if (m_state->screen()->currentScreen() == Screen::ScreenKind::DMPlayersReadyScreen) {
m_state->data()->deathMatchPlayerTwoReady()->cancelPlayerReadyForRound();
m_state->arduinoClient()->setP2SpotLight(false);
}
});
connect(m_state->data()->deathMatchPlayerOneReady(), &DeathMatchPlayerReadyModel::readyTextChanged,
this, &BattleBoxMainWindow::dmprUpdateP1ReadyText);
connect(m_state->data()->deathMatchPlayerTwoReady(), &DeathMatchPlayerReadyModel::readyTextChanged,
this, &BattleBoxMainWindow::dmprUpdateP2ReadyText);
connect(m_state->data()->deathMatchPlayerOneReady(), &DeathMatchPlayerReadyModel::doorTextChanged,
this, &BattleBoxMainWindow::dmprUpdateP1DoorText);
connect(m_state->data()->deathMatchPlayerTwoReady(), &DeathMatchPlayerReadyModel::doorTextChanged,
this, &BattleBoxMainWindow::dmprUpdateP2DoorText);
// Connecting the door not closed indicator to player ready indicator.
connect(this->m_state->data()->deathMatchPlayerOneReady(), &DeathMatchPlayerReadyModel::doorNotClosed,
this, &BattleBoxMainWindow::receivedError);
connect(this->m_state->data()->deathMatchPlayerTwoReady(), &DeathMatchPlayerReadyModel::doorNotClosed,
this, &BattleBoxMainWindow::receivedError);
// Set ready button text from configured player names
auto updateP1ReadyButton = [this]() {
auto name = m_state->data()->deathMatchConfig()->playerOneName();
ui->dmprPlayerOneReadyButton->setText((name.isEmpty() ? "Player One" : name) + " Ready");
};
auto updateP2ReadyButton = [this]() {
auto name = m_state->data()->deathMatchConfig()->playerTwoName();
ui->dmprPlayerTwoReadyButton->setText((name.isEmpty() ? "Player Two" : name) + " Ready");
};
updateP1ReadyButton();
updateP2ReadyButton();
connect(m_state->data()->deathMatchConfig(), &DeathMatchConfig::playerOneNameChanged,
this, [updateP1ReadyButton](QString) { updateP1ReadyButton(); });
connect(m_state->data()->deathMatchConfig(), &DeathMatchConfig::playerTwoNameChanged,
this, [updateP2ReadyButton](QString) { updateP2ReadyButton(); });
}
void BattleBoxMainWindow::initDeathMatchCountDownScreen() {
QGraphicsOpacityEffect *eff1 = new QGraphicsOpacityEffect(ui->dmCDCountDownLabel);
ui->dmCDCountDownLabel->setGraphicsEffect(eff1);
{
QPropertyAnimation *a = new QPropertyAnimation(eff1, "opacity");
a->setDuration(1000);
a->setStartValue(0);
a->setEndValue(1);
a->setEasingCurve(QEasingCurve::InBack);
connect(a, &QPropertyAnimation::stateChanged,
[&](QAbstractAnimation::State newState, QAbstractAnimation::State) {
if(newState == QAbstractAnimation::State::Running) {
qDebug() << "Emitting DMCDStart3";
emit DMCDstart3();
qDebug() << "Finished Emitting DMCDStart3";
ui->dmCDCountDownLabel->setText("3");
}
});
m_dmcdAnimationGroup->addAnimation(a);
}
{
QPropertyAnimation *a = new QPropertyAnimation(eff1, "opacity");
a->setDuration(1000);
a->setStartValue(0);
a->setEndValue(1);
a->setEasingCurve(QEasingCurve::InBack);
connect(a, &QPropertyAnimation::stateChanged,
[&](QAbstractAnimation::State newState, QAbstractAnimation::State) {
if(newState == QAbstractAnimation::State::Running) {
emit DMCDstart2();
ui->dmCDCountDownLabel->setText("2");
}
});
m_dmcdAnimationGroup->addAnimation(a);
}
{
QPropertyAnimation *a = new QPropertyAnimation(eff1, "opacity");
a->setDuration(1000);
a->setStartValue(0);
a->setEndValue(1);
a->setEasingCurve(QEasingCurve::InBack);
connect(a, &QPropertyAnimation::stateChanged,
[&](QAbstractAnimation::State newState, QAbstractAnimation::State) {
if(newState == QAbstractAnimation::State::Running) {
emit DMCDstart1();
ui->dmCDCountDownLabel->setText("1");
}
});
m_dmcdAnimationGroup->addAnimation(a);
}
{
QPropertyAnimation *a = new QPropertyAnimation(eff1, "opacity");
a->setDuration(1000);
a->setStartValue(0);
a->setEndValue(1);
a->setEasingCurve(QEasingCurve::InBack);
connect(a, &QPropertyAnimation::stateChanged,
[&](QAbstractAnimation::State newState, QAbstractAnimation::State) {
if(newState == QAbstractAnimation::State::Running) {
emit DMCDstartFight();
ui->dmCDCountDownLabel->setText("FIGHT!!!");
m_state->physicalState()->playerOne()->spotLight()->setState(false);
m_state->physicalState()->playerTwo()->spotLight()->setState(false);
m_state->arduinoClient()->setP1SpotLight(false);
m_state->arduinoClient()->setP2SpotLight(false);
}
});
m_dmcdAnimationGroup->addAnimation(a);
}
// Connecting final part of the animation signal
connect(m_dmcdAnimationGroup, &QSequentialAnimationGroup::finished,
[&] {
m_state->screen()->changeToDMRunningScreen();
});
// Connecting cancel.
connect(ui->dmcdCancel, &QPushButton::clicked,
[&]{
m_state->screen()->changeToDMConfigScreen();
});
}
void BattleBoxMainWindow::initDeathMatchRunningScreen() {
ui->dmrCountDownWidget->setup(deathMatchConfig(), m_state->data()->deathMatchRuntime());
// Configuring buttons
connect(ui->dmrPlayerOneWinsButton, &QPushButton::clicked,
[&] {
if(m_state->data()->deathMatchConfig()->playerOneName() == "") {
m_state->data()->setDeathMatchWinner("Player One");
} else {
m_state->data()->setDeathMatchWinner(m_state->data()->deathMatchConfig()->playerOneName());
}
m_state->screen()->changeToDMWinnerDisplayScreen(m_state->data()->deathMatchWinner());
});
connect(ui->dmrPlayerTwoWinsButton, &QPushButton::clicked,
[&] {
if(m_state->data()->deathMatchConfig()->playerTwoName() == "") {
m_state->data()->setDeathMatchWinner("Player Two");
} else {
m_state->data()->setDeathMatchWinner(m_state->data()->deathMatchConfig()->playerTwoName());
}
m_state->screen()->changeToDMWinnerDisplayScreen(m_state->data()->deathMatchWinner());
});
// Naviaging buttons
connect(ui->dmrBackToDMConfigButton, &QPushButton::clicked,
m_state->screen(), &Screen::changeToDMConfigScreen);
connect(ui->dmrRestartMatchButton, &QPushButton::clicked,
m_state->screen(), &Screen::changeToDMPlayersReadyScreen);
connect(ui->dmrCancel, &QPushButton::clicked,
m_state->screen(), &Screen::changeToGameSelectScreen);
}
void BattleBoxMainWindow::initDeathMatchWinnerScreen() {
connect(ui->dmwRestartButton, &QPushButton::clicked,
m_state->screen(), &Screen::changeToDMPlayersReadyScreen);
connect(ui->dmwToDMCButton, &QPushButton::clicked,
m_state->screen(), &Screen::changeToDMConfigScreen);
connect(ui->dmwToGameSelectButton, &QPushButton::clicked,
m_state->screen(), &Screen::changeToGameSelectScreen);
connect(m_state->data(), &BattleBoxViewModel::notifyDeathMatchWinnerChanged,
[&](QString arg) {
ui->dmWinnerDisplayLabel->setText(QString("%1\nWINS!!").arg(arg));
});
}
void BattleBoxMainWindow::initSoccerConfigScreen() {
// Configuring buttons
connect(ui->soccerCfgStartButton, &QPushButton::clicked,
[&] { m_state->screen()->changeToSoccerPlayersReadyScreen(); });
connect(ui->soccerCfgCancelButton, &QPushButton::clicked,
[&] { m_state->screen()->changeToGameSelectScreen(); });
connect(ui->soccerCfgResetButton, &QPushButton::clicked,
m_state->data(), &BattleBoxViewModel::resetSoccerConfig);
connect(ui->soccerCfgSaveFileButton, &QPushButton::clicked,
this, &BattleBoxMainWindow::on_soccerCfgSaveButton_clicked);
connect(ui->soccerCfgOpenFileButton, &QPushButton::clicked,
this, &BattleBoxMainWindow::on_soccerCfgLoadButton_clicked);
// Connecting team one name edit
ui->soccerCfgTeamOneNameLineEdit->setText(m_state->data()->soccerConfig()->teamOneName());
connect(ui->soccerCfgTeamOneNameLineEdit, &QLineEdit::textChanged,
m_state->data()->soccerConfig(), &SoccerConfig::setTeamOneName);
connect(m_state->data()->soccerConfig(), &SoccerConfig::notifyTeamOneNameChanged,
ui->soccerCfgTeamOneNameLineEdit, &QLineEdit::setText);
// Connecting team two name edit
ui->soccerCfgTeamTwoNameLineEdit->setText(m_state->data()->soccerConfig()->teamTwoName());
connect(ui->soccerCfgTeamTwoNameLineEdit, &QLineEdit::textChanged,
m_state->data()->soccerConfig(), &SoccerConfig::setTeamTwoName);
connect(m_state->data()->soccerConfig(), &SoccerConfig::notifyTeamTwoNameChanged,
ui->soccerCfgTeamTwoNameLineEdit, &QLineEdit::setText);
// Connecting match duration widget
ui->soccerCfgMatchDurationWidget->setDuration(m_state->data()->soccerConfig()->matchDuration());
connect(ui->soccerCfgMatchDurationWidget, &DurationWidget::durationChanged,
m_state->data()->soccerConfig(), &SoccerConfig::setMatchDuration);
connect(m_state->data()->soccerConfig(), &SoccerConfig::notifyMatchDurationChanged,
ui->soccerCfgMatchDurationWidget, &DurationWidget::setDuration);
// Connecting match score
ui->soccerCfgGameScoreSpinBox->setValue(m_state->data()->soccerConfig()->maxScore());
connect(ui->soccerCfgGameScoreSpinBox, &QSpinBox::valueChanged,
m_state->data()->soccerConfig(), &SoccerConfig::setMaxScore);
connect(m_state->data()->soccerConfig(), &SoccerConfig::notifyMaxScoreChanged,
ui->soccerCfgGameScoreSpinBox, &QSpinBox::setValue);
// Error signal connection.
connect(this->m_state->data()->soccerConfig(), &SoccerConfig::error,
this, &BattleBoxMainWindow::receivedError);
// Connecting quick load slot
connect(ui->soccerCfgQuickLoadButton, &QPushButton::clicked,
[&] {
auto items = ui->soccerCfgQuickLoadListWidget->selectedItems();
if(items.size() != 1) {
return;
}
QString path = SOCCER_QUICK_LOAD_FOLDER + QString("/") + items[0]->text();
this->m_state->data()->soccerConfig()->loadFromFile(path);
});
}
void BattleBoxMainWindow::initSoccerPlayersReadyScreen() {
// Soccer players ready screen
connect(ui->sprStartButton, &QPushButton::clicked,
[&] { m_state->screen()->changeToSoccerCountDownScreen(); });
connect(ui->sprCancelButton, &QPushButton::clicked,
[&] { m_state->screen()->changeToSoccerConfigScreen(); });
connect(ui->sprTeamOneReadyButton, &QPushButton::clicked,
[&] { m_state->data()->soccerTeamOneReady()->setTeamReady(true); });
connect(ui->sprTeamTwoReadyButton, &QPushButton::clicked,
[&] { m_state->data()->soccerTeamTwoReady()->setTeamReady(true); });
// Screen changing buttons
connect(m_state->data()->soccerTeamOneReady(), &SoccerTeamReady::readyTextChanged,
this, &BattleBoxMainWindow::sprUpdateT1ReadyText);
connect(m_state->data()->soccerTeamTwoReady(), &SoccerTeamReady::readyTextChanged,
this, &BattleBoxMainWindow::sprUpdateT2ReadyText);
}
void BattleBoxMainWindow::initSoccerCountDownScreen() {
QGraphicsOpacityEffect *eff1 = new QGraphicsOpacityEffect(ui->scdLabel);
ui->scdLabel->setGraphicsEffect(eff1);
// TODO: consider emitting signals from here.
{
QPropertyAnimation *a = new QPropertyAnimation(eff1, "opacity");
a->setDuration(1000);
a->setStartValue(0);
a->setEndValue(1);
a->setEasingCurve(QEasingCurve::InBack);
connect(a, &QPropertyAnimation::stateChanged,
[&](QAbstractAnimation::State newState, QAbstractAnimation::State) {
if(newState == QAbstractAnimation::State::Running) {
ui->scdLabel->setText("3");
}
});
m_scdAnimationGroup->addAnimation(a);
}
{
QPropertyAnimation *a = new QPropertyAnimation(eff1, "opacity");
a->setDuration(1000);
a->setStartValue(0);
a->setEndValue(1);
a->setEasingCurve(QEasingCurve::InBack);
connect(a, &QPropertyAnimation::stateChanged,
[&](QAbstractAnimation::State newState, QAbstractAnimation::State) {
if(newState == QAbstractAnimation::State::Running) {
ui->scdLabel->setText("2");
}
});
m_scdAnimationGroup->addAnimation(a);
}
{
QPropertyAnimation *a = new QPropertyAnimation(eff1, "opacity");
a->setDuration(1000);
a->setStartValue(0);
a->setEndValue(1);
a->setEasingCurve(QEasingCurve::InBack);
connect(a, &QPropertyAnimation::stateChanged,
[&](QAbstractAnimation::State newState, QAbstractAnimation::State) {
if(newState == QAbstractAnimation::State::Running) {
ui->scdLabel->setText("1");
}
});
m_scdAnimationGroup->addAnimation(a);
}
{
QPropertyAnimation *a = new QPropertyAnimation(eff1, "opacity");
a->setDuration(1000);
a->setStartValue(0);
a->setEndValue(1);
a->setEasingCurve(QEasingCurve::InBack);
connect(a, &QPropertyAnimation::stateChanged,
[&](QAbstractAnimation::State newState, QAbstractAnimation::State) {
if(newState == QAbstractAnimation::State::Running) {
ui->scdLabel->setText("GO!!!");
}
});
m_scdAnimationGroup->addAnimation(a);
}
// Connecting final part of the animation signal
connect(m_scdAnimationGroup, &QSequentialAnimationGroup::finished,
[&] { m_state->screen()->changeToSoccerRunningScreen(); });
// Connecting cancel.
connect(ui->scdCancelButton, &QPushButton::clicked,
[&]{ m_state->screen()->changeToSoccerConfigScreen(); });
}
void BattleBoxMainWindow::initSoccerRunningScreen() {
ui->srRunningWidget->setup(m_state->data()->soccerMatch());
// Connecting the resume button.
connect(ui->srResumeButton, &QPushButton::clicked,
[&] {
ui->srStackedWidget->setCurrentWidget(ui->srResumeCountDownWidget);
ui->srResumeCountDownWidget->start();
ui->srResumeButton->setEnabled(false);
});
connect(ui->srMatchEndsInDrawButton, &QPushButton::clicked,
[&] {
qDebug() << "Trigger draw";
});
connect(ui->srT1GoalButton, &QPushButton::clicked,
[&] {
ui->srRunningWidget->pause();
ui->srGoalScoredLabel->setText("Team One scorred a goal with " + msToTimeRep(ui->srRunningWidget->remainingMS()) + "s remaining");
ui->srResumeButton->setEnabled(true);
ui->srStackedWidget->setCurrentWidget(ui->srGoalScoredWidget);
if(m_state->data()->soccerMatch()->teamOneScore() >= 1000) {
m_state->data()->soccerMatch()->setTeamOneScore(1000);
} else {
m_state->data()->soccerMatch()->setTeamOneScore(m_state->data()->soccerMatch()->teamOneScore() + 1);
}
});
connect(ui->srTeamOneWinsButton, &QPushButton::clicked,
[&] {
});
connect(ui->srT1ScorePlusOneButton, &QPushButton::clicked,
[&] {
if(m_state->data()->soccerMatch()->teamOneScore() >= 1000) {
m_state->data()->soccerMatch()->setTeamOneScore(1000);
} else {
m_state->data()->soccerMatch()->setTeamOneScore(m_state->data()->soccerMatch()->teamOneScore() + 1);
}
});
connect(ui->srT1ScoreMinusOneButton, &QPushButton::clicked,
[&] {
if(m_state->data()->soccerMatch()->teamOneScore() <= 0) {
m_state->data()->soccerMatch()->setTeamOneScore(0);
} else {
m_state->data()->soccerMatch()->setTeamOneScore(m_state->data()->soccerMatch()->teamOneScore() - 1);
}
});
connect(ui->srTeamTwoWinsButton, &QPushButton::clicked,
[&] {
qDebug() << "Team two wins!";
});
connect(ui->srT2GoalButton, &QPushButton::clicked,
[&] {
ui->srRunningWidget->pause();
ui->srGoalScoredLabel->setText("Team Two scorred a goal with " + msToTimeRep(ui->srRunningWidget->remainingMS()) + "s remaining");
ui->srResumeButton->setEnabled(true);
ui->srStackedWidget->setCurrentWidget(ui->srGoalScoredWidget);
if(m_state->data()->soccerMatch()->teamTwoScore() >= 1000) {
m_state->data()->soccerMatch()->setTeamTwoScore(1000);
} else {
m_state->data()->soccerMatch()->setTeamTwoScore(m_state->data()->soccerMatch()->teamTwoScore() + 1);
}
});
connect(ui->srT2ScorePlusOneButton, &QPushButton::clicked,
[&] {
if(m_state->data()->soccerMatch()->teamTwoScore() >= 1000) {
m_state->data()->soccerMatch()->setTeamTwoScore(1000);
} else {
m_state->data()->soccerMatch()->setTeamTwoScore(m_state->data()->soccerMatch()->teamTwoScore() + 1);
}
});
connect(ui->srT2ScoreMinusOneButton, &QPushButton::clicked,
[&] {
if(m_state->data()->soccerMatch()->teamTwoScore() <= 0) {
m_state->data()->soccerMatch()->setTeamTwoScore(0);
} else {
m_state->data()->soccerMatch()->setTeamTwoScore(m_state->data()->soccerMatch()->teamTwoScore() - 1);
}
});
// Naviaging buttons
connect(ui->srRestartMatchButton, &QPushButton::clicked,
[&] { m_state->screen()->changeToSoccerPlayersReadyScreen(); });
connect(ui->srCancelGameSelectionButton, &QPushButton::clicked,
[&] { m_state->screen()->changeToGameSelectScreen(); });
connect(ui->srCancelConfigButton, &QPushButton::clicked,
[&] { m_state->screen()->changeToSoccerConfigScreen(); });
// Binding the reumed button.
connect(ui->srResumeCountDownWidget, &SoccerResumeCountDownWidget::resumed,
[&] {
ui->srStackedWidget->setCurrentWidget(ui->srRunningWidget);
ui->srRunningWidget->resume();
ui->srResumeButton->setEnabled(false);
});
connect(ui->srRunningWidget, &SoccerRunningClockWidget::gameOver,
[&] {
ui->srRunningWidget->stop();
ui->srStackedWidget->setCurrentWidget(ui->srGameOverWidget);
});
}
void BattleBoxMainWindow::initSoccerGameOverScreen() {
}
// TODO: Move this into the application state instead of here.
void BattleBoxMainWindow::loadQuickLoadFiles(QString dir) {
QDir directory(dir);
auto files = directory.entryList();
QListWidget *toLoad;
if (dir == DEATHMATCH_QUICK_LOAD_FOLDER) {
toLoad = ui->dmQuickLoadListWidget;
} else if(dir == SOCCER_QUICK_LOAD_FOLDER) {
toLoad = ui->soccerCfgQuickLoadListWidget;
} else {
qWarning() << "Received an unknown directory " << dir <<"\n";
return;
}
toLoad->clear();
for(auto &f : files) {
if(f.startsWith(".")) {
continue;
}
toLoad->addItem(f);
}
}
// TODO: Move this into the application state.
void BattleBoxMainWindow::on_dmCfgSaveButton_clicked() {
auto fileName = QFileDialog::getSaveFileName(
this,
tr("Open File"),
DEATHMATCH_QUICK_LOAD_FOLDER,
tr("Json Files (*.json)"));
this->m_state->data()->deathMatchConfig()->saveToFile(fileName);
}
// TODO: Move this into the application state.
void BattleBoxMainWindow::on_dmCfgLoadButton_clicked() {
auto fileName = QFileDialog::getOpenFileName(
this,
tr("Open File"),
DEATHMATCH_QUICK_LOAD_FOLDER,
tr("Json Files (*.json)"));
this->m_state->data()->deathMatchConfig()->loadFromFile(fileName);
}
void BattleBoxMainWindow::receivedError(QString msg) {
std::cout << "Received error message: " << msg.toStdString() << std::endl;
}
void BattleBoxMainWindow::enterConfigurationScreen() {
ui->mainDisplay->setCurrentWidget(ui->configuration);
}
void BattleBoxMainWindow::leaveConfigurationScreen() {
}
void BattleBoxMainWindow::enterGameSelectScreen() {
ui->mainDisplay->setCurrentWidget(ui->gameSelection);
}
void BattleBoxMainWindow::leaveGameSelectScreen() {
}
void BattleBoxMainWindow::enterDMConfigScreen() {
ui->mainDisplay->setCurrentWidget(ui->deathMatchConfig);
}
void BattleBoxMainWindow::leaveDMConfigScreen() {
}
void BattleBoxMainWindow::enterDMCountDownScreen() {
ui->mainDisplay->setCurrentWidget(ui->deathMatchCountDown);
}
void BattleBoxMainWindow::postEnterDMCountDownScreen() {
m_dmcdAnimationGroup->start();
}
void BattleBoxMainWindow::leaveDMCountDownScreen() {
m_dmcdAnimationGroup->stop();
}
void BattleBoxMainWindow::enterDMPlayersReadyScreen() {
ui->mainDisplay->setCurrentWidget(ui->deathMatchPlayersReady);
// TODO: Refactor everything from here into the application state and attach it to
// the signal in a different way. This shouldn't be part of the main window code base.
m_state->data()->deathMatchPlayerOneReady()->reset();
m_state->data()->deathMatchPlayerOneReady()->setDoorClosed(m_state->physicalState()->playerOne()->doorButton()->state());
m_state->data()->deathMatchPlayerTwoReady()->reset();
m_state->data()->deathMatchPlayerTwoReady()->setDoorClosed(m_state->physicalState()->playerTwo()->doorButton()->state());
m_state->arduinoClient()->setP1SpotLight(false);
m_state->arduinoClient()->setP2SpotLight(false);
// Force labels and buttons to reflect current player names regardless of signal guards.
auto p1 = m_state->data()->deathMatchConfig()->playerOneName();
auto p2 = m_state->data()->deathMatchConfig()->playerTwoName();
auto p1Name = p1.isEmpty() ? "Player One" : p1;
auto p2Name = p2.isEmpty() ? "Player Two" : p2;
ui->dmprPlayerOneReadyButton->setText(p1Name + " Ready");
ui->dmprPlayerTwoReadyButton->setText(p2Name + " Ready");
ui->dmprPlayerOneReadyLabel->setText(p1Name + ": Not Ready");
ui->dmprPlayerTwoReadyLabel->setText(p2Name + ": Not Ready");
}
void BattleBoxMainWindow::dmDoorDropSpotLightFlash() {
ArduinoClient *client = m_state->arduinoClient();
for (int i = 0; i < 5; ++i) {
QTimer::singleShot(i * 1000, this, [client]{ client->setSpotLights(true, true); });
QTimer::singleShot(i * 1000 + 500, this, [client]{ client->setSpotLights(false, false); });
}
}
void BattleBoxMainWindow::leaveDMPlayersReadyScreen() {
qDebug() << "Rewached here";
// TODO: Refactor everything from here into the application state and attach it to
// the signal in a different way. This shouldn't be part of the main window code base.
m_state->physicalState()->playerOne()->spotLight()->setState(false);
m_state->physicalState()->playerTwo()->spotLight()->setState(false);
m_state->arduinoClient()->setP1SpotLight(false);
m_state->arduinoClient()->setP2SpotLight(false);
}
void BattleBoxMainWindow::enterDMRunningScreen() {
ui->mainDisplay->setCurrentWidget(ui->deathMatchRunning);
ui->dmrStackedWidget->setCurrentWidget(ui->dmrCountDownWidget);
ui->dmrCountDownWidget->start();
}
void BattleBoxMainWindow::leaveDMRunningScreen() {
ui->dmrCountDownWidget->stop();
}
void BattleBoxMainWindow::enterDMWinnerDisplayScreen(QString playerName) {
ui->mainDisplay->setCurrentWidget(ui->deathMatchWinner);
if (playerName == m_state->data()->deathMatchConfig()->playerOneName()) {
emit dmPlayerOneWins(playerName);
} else {
emit dmPlayerTwoWins(playerName);
}
}
void BattleBoxMainWindow::leaveDMWinnerDisplayScreen() {
}
void BattleBoxMainWindow::enterSoccerConfigScreen() {
ui->mainDisplay->setCurrentWidget(ui->soccerConfig);
}
void BattleBoxMainWindow::leaveSoccerConfigScreen() {
}
void BattleBoxMainWindow::leaveSoccerPlayersReadyScreen() {
}
void BattleBoxMainWindow::enterSoccerPlayersReadyScreen() {
// TODO: Refactor everything from here into the application state and attach it to
// the signal in a different way. This shouldn't be part of the main window code base.
m_state->data()->resetSoccerTeamOneReady();
m_state->data()->resetSoccerTeamTwoReady();
// This is not part of the application state.
ui->mainDisplay->setCurrentWidget(ui->soccerPlayersReady);
}
void BattleBoxMainWindow::enterSoccerRunningScreen() {
// TODO: Refactor everything from here into the application state and attach it to
// the signal in a different way. This shouldn't be part of the main window code base.
m_state->data()->soccerMatch()->loadSoccerConfig(m_state->data()->soccerConfig());
// Loading new soccer match data
ui->srStackedWidget->setCurrentWidget(ui->srRunningWidget);
ui->mainDisplay->setCurrentWidget(ui->soccerRunning);
ui->srRunningWidget->start();
ui->srResumeButton->setEnabled(false);
}
void BattleBoxMainWindow::leaveSoccerRunningScreen() {
ui->srResumeCountDownWidget->cancel();
ui->srRunningWidget->stop();
}
void BattleBoxMainWindow::enterSoccerCountDownScreen() {
ui->mainDisplay->setCurrentWidget(ui->soccerCountDown);
m_scdAnimationGroup->start();
}