-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathlevelcompletionwidget.cpp
More file actions
86 lines (65 loc) · 2.4 KB
/
levelcompletionwidget.cpp
File metadata and controls
86 lines (65 loc) · 2.4 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
#include "levelcompletionwidget.h"
#include <QHBoxLayout>
#include <QVBoxLayout>
LevelCompletionWidget::LevelCompletionWidget(QWidget *parent) : QWidget(parent)
{
QHBoxLayout* mainLayout = new QHBoxLayout();
QVBoxLayout* compFlagsLayout = new QVBoxLayout();
// Completion Flags
normalExit = new QCheckBox("Normal Exit", this);
connect(normalExit, SIGNAL(toggled(bool)), this, SLOT(normalExitToggled(bool)));
compFlagsLayout->addWidget(normalExit);
secretExit = new QCheckBox("Secret Exit", this);
connect(secretExit, SIGNAL(toggled(bool)), this, SLOT(secretExitToggled(bool)));
compFlagsLayout->addWidget(secretExit);
mainLayout->addLayout(compFlagsLayout);
QVBoxLayout* otherFlags = new QVBoxLayout();
// Assist Flag
assistUsed = new QCheckBox("Assist Used", this);
connect(assistUsed, SIGNAL(toggled(bool)), this, SLOT(assistUsedToggled(bool)));
otherFlags->addWidget(assistUsed);
// Unknown Flag
unknownFlag = new QCheckBox("Unknown Flag", this);
connect(unknownFlag, SIGNAL(toggled(bool)), this, SLOT(unknownFlagToggled(bool)));
otherFlags->addWidget(unknownFlag);
mainLayout->addLayout(otherFlags);
this->setLayout(mainLayout);
}
void LevelCompletionWidget::loadLevel(quint8 level)
{
this->level = level;
blockAllSignals(true);
normalExit->setChecked((level >> 0x00) & 1);
secretExit->setChecked((level >> 0x01) & 1);
assistUsed->setChecked((level >> 0x02) & 1);
unknownFlag->setChecked((level >> 0x04) & 1);
blockAllSignals(false);
}
void LevelCompletionWidget::blockAllSignals(bool block)
{
normalExit->blockSignals(block);
secretExit->blockSignals(block);
assistUsed->blockSignals(block);
unknownFlag->blockSignals(block);
}
// SLOTS ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
void LevelCompletionWidget::normalExitToggled(bool toggle)
{
level ^= (-static_cast<int>(toggle) ^ level) & (1 << 0x00);
emit valueChanged(level);
}
void LevelCompletionWidget::secretExitToggled(bool toggle)
{
level ^= (-static_cast<int>(toggle) ^ level) & (1 << 0x01);
emit valueChanged(level);
}
void LevelCompletionWidget::assistUsedToggled(bool toggle)
{
level ^= (-static_cast<int>(toggle) ^ level) & (1 << 0x02);
emit valueChanged(level);
}
void LevelCompletionWidget::unknownFlagToggled(bool toggle)
{
level ^= (-static_cast<int>(toggle) ^ level) & (1 << 0x04);
emit valueChanged(level);
}