author | unc0rr |
Wed, 08 Dec 2010 22:18:50 +0300 | |
changeset 4489 | c4ca9ced258b |
parent 4487 | dbf69c7c5e00 |
child 4494 | 9585435e20f7 |
permissions | -rw-r--r-- |
184 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
883 | 3 |
* Copyright (c) 2006-2008 Igor Ulyanov <iulyanov@gmail.com> |
184 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*/ |
|
18 |
||
19 |
#include <QPushButton> |
|
20 |
#include <QBuffer> |
|
21 |
#include <QUuid> |
|
22 |
#include <QBitmap> |
|
23 |
#include <QPainter> |
|
24 |
#include <QLinearGradient> |
|
25 |
#include <QColor> |
|
249 | 26 |
#include <QTextStream> |
677
9d0bcc3c903a
Save some vertical pixels using fewer margin in HWMapContainer
unc0rr
parents:
530
diff
changeset
|
27 |
#include <QApplication> |
1209 | 28 |
#include <QLabel> |
29 |
#include <QListWidget> |
|
30 |
#include <QVBoxLayout> |
|
1224 | 31 |
#include <QIcon> |
249 | 32 |
|
33 |
#include "hwconsts.h" |
|
788
00720357601f
- Get rid of PageSimpleGame, now pressing 'quick game' just starts round
unc0rr
parents:
682
diff
changeset
|
34 |
#include "mapContainer.h" |
1209 | 35 |
#include "igbox.h" |
184 | 36 |
|
37 |
HWMapContainer::HWMapContainer(QWidget * parent) : |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
38 |
QWidget(parent), |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
39 |
mainLayout(this), |
3133 | 40 |
pMap(0), |
41 |
mapgen(MAPGEN_REGULAR), |
|
4489 | 42 |
maze_size(0), |
43 |
drawnMapData(QByteArray::fromBase64("BHoGw4IEegbjAgR6BuwCCnYEaIIJKwRIgglLBEgCCXgERAIJoQQ/AgnBBDsCCeUEMgIKCQQpAgopBCQCCk0ELQIKXwRIAgo/BE0CCiAEVgIJ+wRfAgnOBGgCCaoEbQIJfQRxAgldBHYCCTkEdgIJFARxAgj+BIgCCOwEqAIJEASsAgkwBJ8CCV0ElgIJhgSWAgmqBJYCCcoElgIJ7gSMAgoOBIwCCNAE2YII2QS1AgjsBJYCCPUEdgIJAgRWAgkQBDYCCScEIAIJSwQXAgl0BAkCCZgEAAIJuAP3AgncA/ICCgUD7gIKJAPlAgo/A/cCClYEDgIKbQQkAgqDBDsCCpoEUgIKrARbAghIBP6CCGgE/gIIjAT1AgixBOwCCNUE5wII9QTjAgkUBNkCCTkE0AIJWATHAgl4BMMCCZgEvgIJvAS1AgncBKwCCgAEowIKIASaAgo/BJECCl8EiAIKfwSDAgqfBHYCCscEbQIK5wRoAgr5BGQCCLUGcYIIzAaIAgjnBpoCCQcGrAIJKwa1AglUBroCCXgGvgIJmAa+Agm8Br4CCeAGvgIKAAa6AgogBrUCCj8GqAIKXwaWAgp6Bn8CCpEGaAIKnwZSAgotBZOCCjIFjwIJIgWTggk0BZwCCSsFmIIHYQeBggdhBNmCB2EFBwIHYQUrAgdhBUsCB2EFbwIHYQWqAgdhBc4CB2EF9wIHYQYgAgdhBlICB2EGegIHYQaaAgdhBswCB2EG/gIHYQcQAgZ/BimCBoMGKQIGfwaMggaDBrECBn8G1QIGfwb1AgZ/BwsCBbMFaoIFrgWKAgWqBa4CBaUF6QIFnAYSAgWYBjICBYoGbQIFfQaMAgV0BrUCBWoG3gIFagb+AgVhByICBWEHGQIEmgY2ggS+BkQCBOwGRAIFEAZEAgUwBj8CBVQGOwIFWAY7AgS1BUuCBLUFbwIErAWTAgSjBcECBJ8F+wIEkQYpAgSIBk0CBH8GegIEfwaoAgR6BrUC") |
|
44 |
) |
|
184 | 45 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
46 |
hhSmall.load(":/res/hh_small.png"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
47 |
hhLimit = 18; |
1797 | 48 |
templateFilter = 0; |
2377 | 49 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
50 |
mainLayout.setContentsMargins(QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin), |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
51 |
1, |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
52 |
QApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin), |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
53 |
QApplication::style()->pixelMetric(QStyle::PM_LayoutBottomMargin)); |
2377 | 54 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
55 |
imageButt = new QPushButton(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
56 |
imageButt->setObjectName("imageButt"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
57 |
imageButt->setFixedSize(256 + 6, 128 + 6); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
58 |
imageButt->setFlat(true); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
59 |
imageButt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);//QSizePolicy::Minimum, QSizePolicy::Minimum); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
60 |
mainLayout.addWidget(imageButt, 0, 0, 1, 2); |
4337 | 61 |
//connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomSeed())); |
62 |
//connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomTheme())); |
|
63 |
connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomMap())); |
|
249 | 64 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
65 |
chooseMap = new QComboBox(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
66 |
chooseMap->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
4125
877ecc9d9d82
Disable icons on maps/generated terrain dropdowns since they haven't been drawn yet. Add per-hog-ammo button
nemo
parents:
3951
diff
changeset
|
67 |
chooseMap->addItem( |
877ecc9d9d82
Disable icons on maps/generated terrain dropdowns since they haven't been drawn yet. Add per-hog-ammo button
nemo
parents:
3951
diff
changeset
|
68 |
// FIXME - need real icons. Disabling until then |
877ecc9d9d82
Disable icons on maps/generated terrain dropdowns since they haven't been drawn yet. Add per-hog-ammo button
nemo
parents:
3951
diff
changeset
|
69 |
//QIcon(":/res/mapRandom.png"), |
877ecc9d9d82
Disable icons on maps/generated terrain dropdowns since they haven't been drawn yet. Add per-hog-ammo button
nemo
parents:
3951
diff
changeset
|
70 |
QComboBox::tr("generated map...")); |
877ecc9d9d82
Disable icons on maps/generated terrain dropdowns since they haven't been drawn yet. Add per-hog-ammo button
nemo
parents:
3951
diff
changeset
|
71 |
chooseMap->addItem( |
877ecc9d9d82
Disable icons on maps/generated terrain dropdowns since they haven't been drawn yet. Add per-hog-ammo button
nemo
parents:
3951
diff
changeset
|
72 |
// FIXME - need real icons. Disabling until then |
877ecc9d9d82
Disable icons on maps/generated terrain dropdowns since they haven't been drawn yet. Add per-hog-ammo button
nemo
parents:
3951
diff
changeset
|
73 |
//QIcon(":/res/mapMaze.png"), |
877ecc9d9d82
Disable icons on maps/generated terrain dropdowns since they haven't been drawn yet. Add per-hog-ammo button
nemo
parents:
3951
diff
changeset
|
74 |
QComboBox::tr("generated maze...")); |
4487 | 75 |
|
76 |
chooseMap->addItem(QComboBox::tr("hand drawn map...")); |
|
77 |
chooseMap->insertSeparator(chooseMap->count()); // separator between generators and missions |
|
78 |
||
3185 | 79 |
chooseMap->insertSeparator(chooseMap->count()); // separator between generators and missions |
80 |
||
81 |
int missionindex = chooseMap->count(); |
|
4337 | 82 |
numMissions = 0; |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
83 |
for (int i = 0; i < mapList->size(); ++i) { |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
84 |
QString map = (*mapList)[i]; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
85 |
QFile mapCfgFile( |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
86 |
QString("%1/Maps/%2/map.cfg") |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
87 |
.arg(datadir->absolutePath()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
88 |
.arg(map)); |
3008 | 89 |
QFile mapLuaFile( |
90 |
QString("%1/Maps/%2/map.lua") |
|
91 |
.arg(datadir->absolutePath()) |
|
92 |
.arg(map)); |
|
1790 | 93 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
94 |
if (mapCfgFile.open(QFile::ReadOnly)) { |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
95 |
QString theme; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
96 |
quint32 limit = 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
97 |
QList<QVariant> mapInfo; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
98 |
QTextStream input(&mapCfgFile); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
99 |
input >> theme; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
100 |
input >> limit; |
3008 | 101 |
mapInfo.push_back(map); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
102 |
mapInfo.push_back(theme); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
103 |
if (limit) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
104 |
mapInfo.push_back(limit); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
105 |
else |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
106 |
mapInfo.push_back(18); |
3008 | 107 |
mapInfo.push_back(mapLuaFile.exists()); |
3185 | 108 |
if(mapLuaFile.exists()) |
4337 | 109 |
{ |
4125
877ecc9d9d82
Disable icons on maps/generated terrain dropdowns since they haven't been drawn yet. Add per-hog-ammo button
nemo
parents:
3951
diff
changeset
|
110 |
chooseMap->insertItem(missionindex++, |
877ecc9d9d82
Disable icons on maps/generated terrain dropdowns since they haven't been drawn yet. Add per-hog-ammo button
nemo
parents:
3951
diff
changeset
|
111 |
// FIXME - need real icons. Disabling until then |
877ecc9d9d82
Disable icons on maps/generated terrain dropdowns since they haven't been drawn yet. Add per-hog-ammo button
nemo
parents:
3951
diff
changeset
|
112 |
//QIcon(":/res/mapMission.png"), |
877ecc9d9d82
Disable icons on maps/generated terrain dropdowns since they haven't been drawn yet. Add per-hog-ammo button
nemo
parents:
3951
diff
changeset
|
113 |
QComboBox::tr("Mission") + ": " + map, mapInfo); |
4337 | 114 |
numMissions++; |
115 |
} |
|
3185 | 116 |
else |
4125
877ecc9d9d82
Disable icons on maps/generated terrain dropdowns since they haven't been drawn yet. Add per-hog-ammo button
nemo
parents:
3951
diff
changeset
|
117 |
chooseMap->addItem( |
877ecc9d9d82
Disable icons on maps/generated terrain dropdowns since they haven't been drawn yet. Add per-hog-ammo button
nemo
parents:
3951
diff
changeset
|
118 |
// FIXME - need real icons. Disabling until then |
4337 | 119 |
//QIcon(":/res/mapCustom.png"), |
120 |
map, mapInfo); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
121 |
mapCfgFile.close(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
122 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
123 |
} |
3185 | 124 |
chooseMap->insertSeparator(missionindex); // separator between missions and maps |
2377 | 125 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
126 |
connect(chooseMap, SIGNAL(currentIndexChanged(int)), this, SLOT(mapChanged(int))); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
127 |
mainLayout.addWidget(chooseMap, 1, 1); |
249 | 128 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
129 |
QLabel * lblMap = new QLabel(tr("Map"), this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
130 |
mainLayout.addWidget(lblMap, 1, 0); |
1209 | 131 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
132 |
lblFilter = new QLabel(tr("Filter"), this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
133 |
mainLayout.addWidget(lblFilter, 2, 0); |
1802 | 134 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
135 |
CB_TemplateFilter = new QComboBox(this); |
1802 | 136 |
CB_TemplateFilter->addItem(tr("All"), 0); |
137 |
CB_TemplateFilter->addItem(tr("Small"), 1); |
|
138 |
CB_TemplateFilter->addItem(tr("Medium"), 2); |
|
139 |
CB_TemplateFilter->addItem(tr("Large"), 3); |
|
140 |
CB_TemplateFilter->addItem(tr("Cavern"), 4); |
|
141 |
CB_TemplateFilter->addItem(tr("Wacky"), 5); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
142 |
mainLayout.addWidget(CB_TemplateFilter, 2, 1); |
1802 | 143 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
144 |
connect(CB_TemplateFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(templateFilterChanged(int))); |
1802 | 145 |
|
3181 | 146 |
maze_size_label = new QLabel(tr("Type"), this); |
3133 | 147 |
mainLayout.addWidget(maze_size_label, 2, 0); |
148 |
maze_size_label->hide(); |
|
149 |
maze_size_selection = new QComboBox(this); |
|
3181 | 150 |
maze_size_selection->addItem(tr("Small tunnels"), 0); |
151 |
maze_size_selection->addItem(tr("Medium tunnels"), 1); |
|
152 |
maze_size_selection->addItem(tr("Large tunnels"), 2); |
|
153 |
maze_size_selection->addItem(tr("Small floating islands"), 3); |
|
154 |
maze_size_selection->addItem(tr("Medium floating islands"), 4); |
|
155 |
maze_size_selection->addItem(tr("Large floating islands"), 5); |
|
3141
70d65353bd60
prg adds option to toggle girders in maze, adjusts some frontend strings
nemo
parents:
3133
diff
changeset
|
156 |
maze_size_selection->setCurrentIndex(1); |
70d65353bd60
prg adds option to toggle girders in maze, adjusts some frontend strings
nemo
parents:
3133
diff
changeset
|
157 |
maze_size = 1; |
3133 | 158 |
mainLayout.addWidget(maze_size_selection, 2, 1); |
159 |
maze_size_selection->hide(); |
|
160 |
connect(maze_size_selection, SIGNAL(currentIndexChanged(int)), this, SLOT(setMaze_size(int))); |
|
161 |
||
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
162 |
gbThemes = new IconedGroupBox(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
163 |
gbThemes->setTitleTextPadding(60); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
164 |
gbThemes->setContentTopPadding(6); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
165 |
gbThemes->setTitle(tr("Themes")); |
1248 | 166 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
167 |
//gbThemes->setStyleSheet("padding: 0px"); // doesn't work - stylesheet is set with icon |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
168 |
mainLayout.addWidget(gbThemes, 0, 2, 3, 1); |
2377 | 169 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
170 |
QVBoxLayout * gbTLayout = new QVBoxLayout(gbThemes); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
171 |
gbTLayout->setContentsMargins(0, 0, 0 ,0); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
172 |
gbTLayout->setSpacing(0); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
173 |
lwThemes = new QListWidget(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
174 |
lwThemes->setMinimumHeight(30); |
3951
c9a63db3e603
Correct another bug in slot switching, adjust width of theme list, really truly fix reset of weps (I hope) should also fix infinite teleport bug in place hogs mode. Slow update of health to 5s for inf attack mode.
nemo
parents:
3870
diff
changeset
|
175 |
lwThemes->setFixedWidth(140); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
176 |
for (int i = 0; i < Themes->size(); ++i) { |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
177 |
QListWidgetItem * lwi = new QListWidgetItem(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
178 |
lwi->setText(Themes->at(i)); |
3869 | 179 |
lwi->setIcon(QIcon(QString("%1/Themes/%2/icon.png").arg(datadir->absolutePath()).arg(Themes->at(i)))); |
180 |
//lwi->setTextAlignment(Qt::AlignHCenter); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
181 |
lwThemes->addItem(lwi); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
182 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
183 |
connect(lwThemes, SIGNAL(currentRowChanged(int)), this, SLOT(themeSelected(int))); |
1802 | 184 |
|
185 |
// override default style to tighten up theme scroller |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
186 |
lwThemes->setStyleSheet(QString( |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
187 |
"QListWidget{" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
188 |
"border: solid;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
189 |
"border-width: 0px;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
190 |
"border-radius: 0px;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
191 |
"border-color: transparent;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
192 |
"background-color: #0d0544;" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
193 |
"color: #ffcc00;" |
3869 | 194 |
"font: bold 13px;" |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
195 |
"}" |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
196 |
) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
197 |
); |
2377 | 198 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
199 |
gbTLayout->addWidget(lwThemes); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
200 |
lwThemes->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum); |
2377 | 201 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
202 |
mainLayout.setSizeConstraint(QLayout::SetFixedSize);//SetMinimumSize |
1215 | 203 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
204 |
setRandomSeed(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
205 |
setRandomTheme(); |
184 | 206 |
} |
207 |
||
208 |
void HWMapContainer::setImage(const QImage newImage) |
|
209 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
210 |
QPixmap px(256, 128); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
211 |
QPixmap pxres(256, 128); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
212 |
QPainter p(&pxres); |
184 | 213 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
214 |
px.fill(Qt::yellow); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
215 |
QBitmap bm = QBitmap::fromImage(newImage); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
216 |
px.setMask(bm); |
184 | 217 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
218 |
QLinearGradient linearGrad(QPoint(128, 0), QPoint(128, 128)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
219 |
linearGrad.setColorAt(1, QColor(0, 0, 192)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
220 |
linearGrad.setColorAt(0, QColor(66, 115, 225)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
221 |
p.fillRect(QRect(0, 0, 256, 128), linearGrad); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
222 |
p.drawPixmap(QPoint(0, 0), px); |
184 | 223 |
|
1790 | 224 |
addInfoToPreview(pxres); |
3133 | 225 |
chooseMap->setCurrentIndex(mapgen); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
226 |
pMap = 0; |
249 | 227 |
} |
228 |
||
1790 | 229 |
void HWMapContainer::setHHLimit(int newHHLimit) |
230 |
{ |
|
231 |
hhLimit = newHHLimit; |
|
232 |
} |
|
233 |
||
249 | 234 |
void HWMapContainer::mapChanged(int index) |
235 |
{ |
|
3133 | 236 |
switch(index) { |
237 |
case MAPGEN_REGULAR: |
|
238 |
mapgen = MAPGEN_REGULAR; |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
239 |
changeImage(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
240 |
gbThemes->show(); |
1802 | 241 |
lblFilter->show(); |
242 |
CB_TemplateFilter->show(); |
|
3133 | 243 |
maze_size_label->hide(); |
244 |
maze_size_selection->hide(); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
245 |
emit mapChanged("+rnd+"); |
3133 | 246 |
emit mapgenChanged(mapgen); |
247 |
emit themeChanged(chooseMap->itemData(index).toList()[1].toString()); |
|
248 |
break; |
|
249 |
case MAPGEN_MAZE: |
|
250 |
mapgen = MAPGEN_MAZE; |
|
251 |
changeImage(); |
|
252 |
gbThemes->show(); |
|
253 |
lblFilter->hide(); |
|
254 |
CB_TemplateFilter->hide(); |
|
255 |
maze_size_label->show(); |
|
256 |
maze_size_selection->show(); |
|
3141
70d65353bd60
prg adds option to toggle girders in maze, adjusts some frontend strings
nemo
parents:
3133
diff
changeset
|
257 |
emit mapChanged("+maze+"); |
3133 | 258 |
emit mapgenChanged(mapgen); |
259 |
emit themeChanged(chooseMap->itemData(index).toList()[1].toString()); |
|
260 |
break; |
|
4487 | 261 |
case MAPGEN_DRAWN: |
262 |
mapgen = MAPGEN_DRAWN; |
|
263 |
changeImage(); |
|
264 |
gbThemes->show(); |
|
265 |
lblFilter->hide(); |
|
266 |
CB_TemplateFilter->hide(); |
|
267 |
maze_size_label->hide(); |
|
268 |
maze_size_selection->hide(); |
|
269 |
emit mapChanged("+drawn+"); |
|
270 |
emit mapgenChanged(mapgen); |
|
271 |
emit themeChanged(chooseMap->itemData(index).toList()[1].toString()); |
|
272 |
break; |
|
3133 | 273 |
default: |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
274 |
loadMap(index); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
275 |
gbThemes->hide(); |
1802 | 276 |
lblFilter->hide(); |
277 |
CB_TemplateFilter->hide(); |
|
3133 | 278 |
maze_size_label->hide(); |
279 |
maze_size_selection->hide(); |
|
3009 | 280 |
emit mapChanged(chooseMap->itemData(index).toList()[0].toString()); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
281 |
} |
331 | 282 |
} |
283 |
||
284 |
void HWMapContainer::loadMap(int index) |
|
285 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
286 |
QPixmap mapImage; |
3008 | 287 |
if(!mapImage.load(datadir->absolutePath() + "/Maps/" + chooseMap->itemData(index).toList()[0].toString() + "/preview.png")) { |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
288 |
changeImage(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
289 |
chooseMap->setCurrentIndex(0); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
290 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
291 |
} |
1790 | 292 |
|
3008 | 293 |
hhLimit = chooseMap->itemData(index).toList()[2].toInt(); |
1790 | 294 |
addInfoToPreview(mapImage); |
295 |
} |
|
296 |
||
297 |
// Should this add text to identify map size? |
|
298 |
void HWMapContainer::addInfoToPreview(QPixmap image) |
|
299 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
300 |
QPixmap finalImage = QPixmap(image.size()); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
301 |
finalImage.fill(QColor(0, 0, 0, 0)); |
2377 | 302 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
303 |
QPainter p(&finalImage); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
304 |
p.drawPixmap(image.rect(), image); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
305 |
//p.setPen(QColor(0xf4,0x9e,0xe9)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
306 |
p.setPen(QColor(0xff,0xcc,0x00)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
307 |
p.setBrush(QColor(0, 0, 0)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
308 |
p.drawRect(image.rect().width() - hhSmall.rect().width() - 28, 3, 40, 20); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
309 |
p.setFont(QFont("MS Shell Dlg", 10)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
310 |
p.drawText(image.rect().width() - hhSmall.rect().width() - 14 - (hhLimit > 9 ? 10 : 0), 18, QString::number(hhLimit)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
311 |
p.drawPixmap(image.rect().width() - hhSmall.rect().width() - 5, 5, hhSmall.rect().width(), hhSmall.rect().height(), hhSmall); |
1790 | 312 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
313 |
imageButt->setIcon(finalImage); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
314 |
imageButt->setIconSize(image.size()); |
184 | 315 |
} |
316 |
||
317 |
void HWMapContainer::changeImage() |
|
318 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
319 |
if (pMap) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
320 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
321 |
disconnect(pMap, 0, this, SLOT(setImage(const QImage))); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
322 |
disconnect(pMap, 0, this, SLOT(setHHLimit(int))); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
323 |
pMap = 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
324 |
} |
2021 | 325 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
326 |
pMap = new HWMap(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
327 |
connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage))); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
328 |
connect(pMap, SIGNAL(HHLimitReceived(int)), this, SLOT(setHHLimit(int))); |
4489 | 329 |
pMap->getImage(m_seed.toStdString(), getTemplateFilter(), mapgen, maze_size, drawnMapData); |
184 | 330 |
} |
331 |
||
1215 | 332 |
void HWMapContainer::themeSelected(int currentRow) |
333 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
334 |
QString theme = Themes->at(currentRow); |
4487 | 335 |
QList<QVariant> mapInfo; |
336 |
mapInfo.push_back(QString("+rnd+")); |
|
337 |
mapInfo.push_back(theme); |
|
338 |
mapInfo.push_back(18); |
|
339 |
mapInfo.push_back(false); |
|
340 |
chooseMap->setItemData(0, mapInfo); |
|
341 |
mapInfo[0] = QString("+maze+"); |
|
342 |
chooseMap->setItemData(1, mapInfo); |
|
343 |
mapInfo[0] = QString("+drawn+"); |
|
344 |
chooseMap->setItemData(2, mapInfo); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
345 |
gbThemes->setIcon(QIcon(QString("%1/Themes/%2/icon.png").arg(datadir->absolutePath()).arg(theme))); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
346 |
emit themeChanged(theme); |
1215 | 347 |
} |
348 |
||
184 | 349 |
QString HWMapContainer::getCurrentSeed() const |
350 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
351 |
return m_seed; |
184 | 352 |
} |
353 |
||
249 | 354 |
QString HWMapContainer::getCurrentMap() const |
355 |
{ |
|
3133 | 356 |
if(chooseMap->currentIndex() <= 1) return QString(); |
3008 | 357 |
return chooseMap->itemData(chooseMap->currentIndex()).toList()[0].toString(); |
249 | 358 |
} |
359 |
||
360 |
QString HWMapContainer::getCurrentTheme() const |
|
361 |
{ |
|
3008 | 362 |
return chooseMap->itemData(chooseMap->currentIndex()).toList()[1].toString(); |
363 |
} |
|
364 |
||
365 |
bool HWMapContainer::getCurrentIsMission() const |
|
366 |
{ |
|
367 |
if(!chooseMap->currentIndex()) return false; |
|
368 |
return chooseMap->itemData(chooseMap->currentIndex()).toList()[3].toBool(); |
|
1790 | 369 |
} |
370 |
||
371 |
int HWMapContainer::getCurrentHHLimit() const |
|
372 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
373 |
return hhLimit; |
249 | 374 |
} |
375 |
||
1802 | 376 |
quint32 HWMapContainer::getTemplateFilter() const |
377 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
378 |
return CB_TemplateFilter->itemData(CB_TemplateFilter->currentIndex()).toInt(); |
1802 | 379 |
} |
380 |
||
184 | 381 |
void HWMapContainer::resizeEvent ( QResizeEvent * event ) |
382 |
{ |
|
383 |
//imageButt->setIconSize(imageButt->size()); |
|
384 |
} |
|
320 | 385 |
|
386 |
void HWMapContainer::setSeed(const QString & seed) |
|
387 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
388 |
m_seed = seed; |
4419 | 389 |
if (chooseMap->currentIndex() < MAPGEN_LAST) |
390 |
changeImage(); |
|
320 | 391 |
} |
392 |
||
393 |
void HWMapContainer::setMap(const QString & map) |
|
394 |
{ |
|
4487 | 395 |
if(map == "+rnd+" || map == "+maze+" || map == "+drawn+") |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
396 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
397 |
changeImage(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
398 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
399 |
} |
2377 | 400 |
|
3008 | 401 |
int id = 0; |
402 |
for(int i = 0; i < chooseMap->count(); i++) |
|
3195 | 403 |
if(!chooseMap->itemData(i).isNull() && chooseMap->itemData(i).toList()[0].toString() == map) |
3008 | 404 |
{ |
405 |
id = i; |
|
406 |
break; |
|
407 |
} |
|
408 |
||
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
409 |
if(id > 0) { |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
410 |
if (pMap) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
411 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
412 |
disconnect(pMap, 0, this, SLOT(setImage(const QImage))); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
413 |
disconnect(pMap, 0, this, SLOT(setHHLimit(int))); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
414 |
pMap = 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
415 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
416 |
chooseMap->setCurrentIndex(id); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
417 |
loadMap(id); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
418 |
} |
320 | 419 |
} |
420 |
||
421 |
void HWMapContainer::setTheme(const QString & theme) |
|
422 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
423 |
QList<QListWidgetItem *> items = lwThemes->findItems(theme, Qt::MatchExactly); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
424 |
if(items.size()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
425 |
lwThemes->setCurrentItem(items.at(0)); |
320 | 426 |
} |
4337 | 427 |
#include <QMessageBox> |
428 |
void HWMapContainer::setRandomMap() |
|
429 |
{ |
|
4419 | 430 |
setRandomSeed(); |
4337 | 431 |
switch(chooseMap->currentIndex()) |
432 |
{ |
|
433 |
case MAPGEN_REGULAR: |
|
434 |
case MAPGEN_MAZE: |
|
4487 | 435 |
case MAPGEN_DRAWN: |
4337 | 436 |
setRandomTheme(); |
437 |
break; |
|
438 |
default: |
|
4487 | 439 |
if(chooseMap->currentIndex() < numMissions + 4) |
4337 | 440 |
setRandomMission(); |
441 |
else |
|
442 |
setRandomStatic(); |
|
443 |
break; |
|
444 |
} |
|
445 |
} |
|
446 |
||
447 |
void HWMapContainer::setRandomStatic() |
|
448 |
{ |
|
449 |
chooseMap->setCurrentIndex(4 + numMissions + rand() % (chooseMap->count() - 4 - numMissions)); |
|
4419 | 450 |
setRandomSeed(); |
4337 | 451 |
} |
452 |
||
453 |
void HWMapContainer::setRandomMission() |
|
454 |
{ |
|
455 |
chooseMap->setCurrentIndex(3 + rand() % numMissions); |
|
4419 | 456 |
setRandomSeed(); |
4337 | 457 |
} |
320 | 458 |
|
459 |
void HWMapContainer::setRandomSeed() |
|
460 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
461 |
m_seed = QUuid::createUuid().toString(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
462 |
emit seedChanged(m_seed); |
4419 | 463 |
if (chooseMap->currentIndex() < MAPGEN_LAST) |
464 |
changeImage(); |
|
320 | 465 |
} |
1318 | 466 |
|
467 |
void HWMapContainer::setRandomTheme() |
|
468 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
469 |
if(!Themes->size()) return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
470 |
quint32 themeNum = rand() % Themes->size(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
471 |
lwThemes->setCurrentRow(themeNum); |
1318 | 472 |
} |
1797 | 473 |
|
474 |
void HWMapContainer::setTemplateFilter(int filter) |
|
475 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
476 |
CB_TemplateFilter->setCurrentIndex(filter); |
1797 | 477 |
} |
1802 | 478 |
|
479 |
void HWMapContainer::templateFilterChanged(int filter) |
|
480 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
481 |
emit newTemplateFilter(filter); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
482 |
changeImage(); |
1802 | 483 |
} |
484 |
||
3133 | 485 |
MapGenerator HWMapContainer::get_mapgen(void) const |
486 |
{ |
|
487 |
return mapgen; |
|
488 |
} |
|
489 |
||
490 |
int HWMapContainer::get_maze_size(void) const |
|
491 |
{ |
|
492 |
return maze_size; |
|
493 |
} |
|
494 |
||
495 |
void HWMapContainer::setMaze_size(int size) |
|
496 |
{ |
|
497 |
maze_size = size; |
|
3141
70d65353bd60
prg adds option to toggle girders in maze, adjusts some frontend strings
nemo
parents:
3133
diff
changeset
|
498 |
maze_size_selection->setCurrentIndex(size); |
3133 | 499 |
emit maze_sizeChanged(size); |
500 |
changeImage(); |
|
501 |
} |
|
502 |
||
503 |
void HWMapContainer::setMapgen(MapGenerator m) |
|
504 |
{ |
|
505 |
mapgen = m; |
|
506 |
emit mapgenChanged(m); |
|
507 |
changeImage(); |
|
508 |
} |
|
4489 | 509 |
|
510 |
QByteArray HWMapContainer::getDrawnMapData() |
|
511 |
{ |
|
512 |
return drawnMapData; |
|
513 |
} |