-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathspriteseditor.cpp
92 lines (71 loc) · 2.83 KB
/
spriteseditor.cpp
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
#include "spriteseditor.h"
#include <QGridLayout>
#include <QLabel>
SpritesEditor::SpritesEditor(Map* map, QWidget* parent) : QWidget(parent)
{
this->map = map;
QStringList types;
types << "Hammer Bro." << "Red Flying ? Block";
QGridLayout* layout = new QGridLayout();
layout->addWidget(new QLabel("Sprite 1 Type:"), 0, 0, 1, 1, Qt::AlignRight);
sprite1Type = new QComboBox(this);
sprite1Type->addItems(types);
sprite1Type->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
connect(sprite1Type, SIGNAL(currentIndexChanged(int)), this, SLOT(sprite1TypeChanged(int)));
layout->addWidget(sprite1Type, 0, 1);
layout->addWidget(new QLabel("Sprite 1 Start Node:"), 1, 0, 1, 1, Qt::AlignRight);
sprite1StartNode = new QSpinBox(this);
sprite1StartNode->setRange(0, 255);
connect(sprite1StartNode, SIGNAL(valueChanged(int)), this, SLOT(sprite1StartNodeChanged(int)));
layout->addWidget(sprite1StartNode, 1, 1);
layout->addWidget(new HorLine(), 2, 0, 1, 2);
layout->addWidget(new QLabel("Sprite 2 Type:"), 3, 0, 1, 1, Qt::AlignRight);
sprite2Type = new QComboBox(this);
sprite2Type->addItems(types);
sprite2Type->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
connect(sprite2Type, SIGNAL(currentIndexChanged(int)), this, SLOT(sprite2TypeChanged(int)));
layout->addWidget(sprite2Type, 3, 1);
layout->addWidget(new QLabel("Sprite 2 Start Node:"), 4, 0, 1, 1, Qt::AlignRight);
sprite2StartNode = new QSpinBox(this);
sprite2StartNode->setRange(0, 255);
connect(sprite2StartNode, SIGNAL(valueChanged(int)), this, SLOT(sprite2StartNodeChanged(int)));
layout->addWidget(sprite2StartNode, 4, 1);
this->setLayout(layout);
setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed);
}
void SpritesEditor::setMap(Map* map)
{
this->map = map;
updateInfo();
}
void SpritesEditor::updateInfo()
{
sprite1Type->blockSignals(true);
sprite2Type->blockSignals(true);
sprite1StartNode->blockSignals(true);
sprite2StartNode->blockSignals(true);
sprite1Type->setCurrentIndex(map->sprite1Type);
sprite2Type->setCurrentIndex(map->sprite2Type);
sprite1StartNode->setValue(map->sprite1StartNode);
sprite2StartNode->setValue(map->sprite2StartNode);
sprite1Type->blockSignals(false);
sprite2Type->blockSignals(false);
sprite1StartNode->blockSignals(false);
sprite2StartNode->blockSignals(false);
}
void SpritesEditor::sprite1TypeChanged(int sprite1Type)
{
map->sprite1Type = sprite1Type;
}
void SpritesEditor::sprite1StartNodeChanged(int sprite1StartNode)
{
map->sprite1StartNode = sprite1StartNode;
}
void SpritesEditor::sprite2TypeChanged(int sprite2Type)
{
map->sprite2Type = sprite2Type;
}
void SpritesEditor::sprite2StartNodeChanged(int sprite2StartNode)
{
map->sprite2StartNode = sprite2StartNode;
}