author | Wuzzy <almikes@aol.com> |
Tue, 26 Sep 2017 22:54:11 +0200 | |
changeset 12543 | 9fda510f0bc4 |
parent 11910 | 245163aa3674 |
child 12897 | fc47fc4af6bd |
permissions | -rw-r--r-- |
184 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
6700 | 3 |
* Copyright (c) 2006-2012 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 |
|
10108
c68cf030eded
update FSF address. note: two sdl include files (by Sam Lantinga) still have the old FSF address in their copyright - but I ain't gonna touch their copyright headers
sheepluva
parents:
9745
diff
changeset
|
16 |
* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA |
184 | 17 |
*/ |
18 |
||
10462
dd3cf0c91cc9
A slider for controlling things like bumpiness of map and tunnel sizes.
nemo
parents:
10394
diff
changeset
|
19 |
#include <QBitmap> |
184 | 20 |
#include <QBuffer> |
21 |
#include <QColor> |
|
8377 | 22 |
#include <QDebug> |
23 |
#include <QFile> |
|
24 |
#include <QFileDialog> |
|
10462
dd3cf0c91cc9
A slider for controlling things like bumpiness of map and tunnel sizes.
nemo
parents:
10394
diff
changeset
|
25 |
#include <QIcon> |
8377 | 26 |
#include <QInputDialog> |
10462
dd3cf0c91cc9
A slider for controlling things like bumpiness of map and tunnel sizes.
nemo
parents:
10394
diff
changeset
|
27 |
#include <QLabel> |
dd3cf0c91cc9
A slider for controlling things like bumpiness of map and tunnel sizes.
nemo
parents:
10394
diff
changeset
|
28 |
#include <QLinearGradient> |
dd3cf0c91cc9
A slider for controlling things like bumpiness of map and tunnel sizes.
nemo
parents:
10394
diff
changeset
|
29 |
#include <QLineEdit> |
dd3cf0c91cc9
A slider for controlling things like bumpiness of map and tunnel sizes.
nemo
parents:
10394
diff
changeset
|
30 |
#include <QListView> |
dd3cf0c91cc9
A slider for controlling things like bumpiness of map and tunnel sizes.
nemo
parents:
10394
diff
changeset
|
31 |
#include <QListWidget> |
dd3cf0c91cc9
A slider for controlling things like bumpiness of map and tunnel sizes.
nemo
parents:
10394
diff
changeset
|
32 |
#include <QListWidgetItem> |
8377 | 33 |
#include <QMessageBox> |
10462
dd3cf0c91cc9
A slider for controlling things like bumpiness of map and tunnel sizes.
nemo
parents:
10394
diff
changeset
|
34 |
#include <QPainter> |
dd3cf0c91cc9
A slider for controlling things like bumpiness of map and tunnel sizes.
nemo
parents:
10394
diff
changeset
|
35 |
#include <QPushButton> |
dd3cf0c91cc9
A slider for controlling things like bumpiness of map and tunnel sizes.
nemo
parents:
10394
diff
changeset
|
36 |
#include <QSlider> |
dd3cf0c91cc9
A slider for controlling things like bumpiness of map and tunnel sizes.
nemo
parents:
10394
diff
changeset
|
37 |
#include <QStringListModel> |
dd3cf0c91cc9
A slider for controlling things like bumpiness of map and tunnel sizes.
nemo
parents:
10394
diff
changeset
|
38 |
#include <QTextStream> |
dd3cf0c91cc9
A slider for controlling things like bumpiness of map and tunnel sizes.
nemo
parents:
10394
diff
changeset
|
39 |
#include <QUuid> |
dd3cf0c91cc9
A slider for controlling things like bumpiness of map and tunnel sizes.
nemo
parents:
10394
diff
changeset
|
40 |
#include <QVBoxLayout> |
249 | 41 |
|
42 |
#include "hwconsts.h" |
|
788
00720357601f
- Get rid of PageSimpleGame, now pressing 'quick game' just starts round
unc0rr
parents:
682
diff
changeset
|
43 |
#include "mapContainer.h" |
8377 | 44 |
#include "themeprompt.h" |
45 |
#include "seedprompt.h" |
|
1209 | 46 |
#include "igbox.h" |
5252 | 47 |
#include "HWApplication.h" |
7258 | 48 |
#include "ThemeModel.h" |
184 | 49 |
|
8377 | 50 |
|
51 |
||
184 | 52 |
HWMapContainer::HWMapContainer(QWidget * parent) : |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
53 |
QWidget(parent), |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
54 |
mainLayout(this), |
3133 | 55 |
pMap(0), |
7017
19a434fc91fc
visually indicate when map preview generation is in progress.
sheepluva
parents:
7014
diff
changeset
|
56 |
mapgen(MAPGEN_REGULAR), |
19a434fc91fc
visually indicate when map preview generation is in progress.
sheepluva
parents:
7014
diff
changeset
|
57 |
m_previewSize(256, 128) |
184 | 58 |
{ |
9739
c2c9dd2544b8
make lazy loading of map preview a little bit less of a hack
sheepluva
parents:
9735
diff
changeset
|
59 |
// don't show preview anything until first show event |
c2c9dd2544b8
make lazy loading of map preview a little bit less of a hack
sheepluva
parents:
9735
diff
changeset
|
60 |
m_previewEnabled = false; |
9744 | 61 |
m_missionsViewSetup = false; |
62 |
m_staticViewSetup = false; |
|
10159 | 63 |
m_script = QString(); |
10477
b219c5a2317f
Fiddling with slider, unbreak maze. Next to mess around w/ perlin params.
nemo
parents:
10472
diff
changeset
|
64 |
m_prevMapFeatureSize = 12; |
b219c5a2317f
Fiddling with slider, unbreak maze. Next to mess around w/ perlin params.
nemo
parents:
10472
diff
changeset
|
65 |
m_mapFeatureSize = 12; |
11757
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
66 |
m_withoutDLC = false; |
9739
c2c9dd2544b8
make lazy loading of map preview a little bit less of a hack
sheepluva
parents:
9735
diff
changeset
|
67 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
68 |
hhSmall.load(":/res/hh_small.png"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
69 |
hhLimit = 18; |
1797 | 70 |
templateFilter = 0; |
8377 | 71 |
m_master = true; |
2377 | 72 |
|
7017
19a434fc91fc
visually indicate when map preview generation is in progress.
sheepluva
parents:
7014
diff
changeset
|
73 |
linearGrad = QLinearGradient(QPoint(128, 0), QPoint(128, 128)); |
19a434fc91fc
visually indicate when map preview generation is in progress.
sheepluva
parents:
7014
diff
changeset
|
74 |
linearGrad.setColorAt(1, QColor(0, 0, 192)); |
19a434fc91fc
visually indicate when map preview generation is in progress.
sheepluva
parents:
7014
diff
changeset
|
75 |
linearGrad.setColorAt(0, QColor(66, 115, 225)); |
19a434fc91fc
visually indicate when map preview generation is in progress.
sheepluva
parents:
7014
diff
changeset
|
76 |
|
5252 | 77 |
mainLayout.setContentsMargins(HWApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin), |
8424
225ede46e3dc
On pagenetgame, when window is too small the map/game options becomes a tabbed interface to allow for a few lines of chat to always be visible.
dag10
parents:
8401
diff
changeset
|
78 |
10, |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
79 |
HWApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin), |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
80 |
HWApplication::style()->pixelMetric(QStyle::PM_LayoutBottomMargin)); |
2377 | 81 |
|
8377 | 82 |
m_staticMapModel = DataManager::instance().staticMapModel(); |
83 |
m_missionMapModel = DataManager::instance().missionMapModel(); |
|
84 |
m_themeModel = DataManager::instance().themeModel(); |
|
4557
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
85 |
|
8377 | 86 |
/* Layouts */ |
249 | 87 |
|
8886
5c521d1fdd63
Fixed map preview overlap on certain locales (Fixes issue 549).
dag10
parents:
8695
diff
changeset
|
88 |
QWidget * topWidget = new QWidget(); |
5c521d1fdd63
Fixed map preview overlap on certain locales (Fixes issue 549).
dag10
parents:
8695
diff
changeset
|
89 |
QHBoxLayout * topLayout = new QHBoxLayout(topWidget); |
5c521d1fdd63
Fixed map preview overlap on certain locales (Fixes issue 549).
dag10
parents:
8695
diff
changeset
|
90 |
topWidget->setContentsMargins(0, 0, 0, 0); |
5c521d1fdd63
Fixed map preview overlap on certain locales (Fixes issue 549).
dag10
parents:
8695
diff
changeset
|
91 |
topLayout->setContentsMargins(0, 0, 0, 0); |
5c521d1fdd63
Fixed map preview overlap on certain locales (Fixes issue 549).
dag10
parents:
8695
diff
changeset
|
92 |
|
8377 | 93 |
QHBoxLayout * twoColumnLayout = new QHBoxLayout(); |
94 |
QVBoxLayout * leftLayout = new QVBoxLayout(); |
|
95 |
QVBoxLayout * rightLayout = new QVBoxLayout(); |
|
96 |
twoColumnLayout->addLayout(leftLayout, 0); |
|
97 |
twoColumnLayout->addStretch(1); |
|
98 |
twoColumnLayout->addLayout(rightLayout, 0); |
|
99 |
QVBoxLayout * drawnControls = new QVBoxLayout(); |
|
100 |
||
101 |
/* Map type combobox */ |
|
4487 | 102 |
|
8886
5c521d1fdd63
Fixed map preview overlap on certain locales (Fixes issue 549).
dag10
parents:
8695
diff
changeset
|
103 |
topLayout->setSpacing(10); |
5c521d1fdd63
Fixed map preview overlap on certain locales (Fixes issue 549).
dag10
parents:
8695
diff
changeset
|
104 |
topLayout->addWidget(new QLabel(tr("Map type:")), 0); |
8377 | 105 |
cType = new QComboBox(this); |
8886
5c521d1fdd63
Fixed map preview overlap on certain locales (Fixes issue 549).
dag10
parents:
8695
diff
changeset
|
106 |
topLayout->addWidget(cType, 1); |
8377 | 107 |
cType->insertItem(0, tr("Image map"), MapModel::StaticMap); |
108 |
cType->insertItem(1, tr("Mission map"), MapModel::MissionMap); |
|
109 |
cType->insertItem(2, tr("Hand-drawn"), MapModel::HandDrawnMap); |
|
110 |
cType->insertItem(3, tr("Randomly generated"), MapModel::GeneratedMap); |
|
111 |
cType->insertItem(4, tr("Random maze"), MapModel::GeneratedMaze); |
|
10391 | 112 |
cType->insertItem(5, tr("Random perlin"), MapModel::GeneratedPerlin); |
11744
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
10959
diff
changeset
|
113 |
cType->insertItem(6, tr("Forts"), MapModel::FortsMap); |
8377 | 114 |
connect(cType, SIGNAL(currentIndexChanged(int)), this, SLOT(mapTypeChanged(int))); |
115 |
m_childWidgets << cType; |
|
249 | 116 |
|
8377 | 117 |
/* Randomize button */ |
1802 | 118 |
|
8886
5c521d1fdd63
Fixed map preview overlap on certain locales (Fixes issue 549).
dag10
parents:
8695
diff
changeset
|
119 |
topLayout->addStretch(1); |
8377 | 120 |
const QIcon& lp = QIcon(":/res/dice.png"); |
121 |
QSize sz = lp.actualSize(QSize(65535, 65535)); |
|
122 |
btnRandomize = new QPushButton(); |
|
123 |
btnRandomize->setText(tr("Random")); |
|
124 |
btnRandomize->setIcon(lp); |
|
125 |
btnRandomize->setFixedHeight(30); |
|
126 |
btnRandomize->setIconSize(sz); |
|
127 |
btnRandomize->setFlat(true); |
|
128 |
btnRandomize->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
129 |
connect(btnRandomize, SIGNAL(clicked()), this, SLOT(setRandomMap())); |
|
11785 | 130 |
|
8377 | 131 |
m_childWidgets << btnRandomize; |
132 |
btnRandomize->setStyleSheet("padding: 5px;"); |
|
133 |
btnRandomize->setFixedHeight(cType->height()); |
|
8886
5c521d1fdd63
Fixed map preview overlap on certain locales (Fixes issue 549).
dag10
parents:
8695
diff
changeset
|
134 |
topLayout->addWidget(btnRandomize, 1); |
1802 | 135 |
|
8377 | 136 |
/* Seed button */ |
8886
5c521d1fdd63
Fixed map preview overlap on certain locales (Fixes issue 549).
dag10
parents:
8695
diff
changeset
|
137 |
|
8377 | 138 |
btnSeed = new QPushButton(parentWidget()->parentWidget()); |
139 |
btnSeed->setText(tr("Seed")); |
|
11809
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
140 |
btnSeed->setWhatsThis(tr("View and edit the seed, the source of randomness in the game")); |
8377 | 141 |
btnSeed->setStyleSheet("padding: 5px;"); |
142 |
btnSeed->setFixedHeight(cType->height()); |
|
143 |
connect(btnSeed, SIGNAL(clicked()), this, SLOT(showSeedPrompt())); |
|
8886
5c521d1fdd63
Fixed map preview overlap on certain locales (Fixes issue 549).
dag10
parents:
8695
diff
changeset
|
144 |
topLayout->addWidget(btnSeed, 0); |
1802 | 145 |
|
8377 | 146 |
/* Map preview label */ |
147 |
||
148 |
QLabel * lblMapPreviewText = new QLabel(this); |
|
149 |
lblMapPreviewText->setText(tr("Map preview:")); |
|
8424
225ede46e3dc
On pagenetgame, when window is too small the map/game options becomes a tabbed interface to allow for a few lines of chat to always be visible.
dag10
parents:
8401
diff
changeset
|
150 |
leftLayout->addWidget(lblMapPreviewText, 0); |
8377 | 151 |
|
152 |
/* Map Preview */ |
|
4562 | 153 |
|
8467 | 154 |
mapPreview = new QPushButton(this); |
8377 | 155 |
mapPreview->setObjectName("mapPreview"); |
8886
5c521d1fdd63
Fixed map preview overlap on certain locales (Fixes issue 549).
dag10
parents:
8695
diff
changeset
|
156 |
mapPreview->setFlat(true); |
10161 | 157 |
mapPreview->setFixedSize(256 + 6, 128 + 6); |
8467 | 158 |
mapPreview->setContentsMargins(0, 0, 0, 0); |
8377 | 159 |
leftLayout->addWidget(mapPreview, 0); |
8467 | 160 |
connect(mapPreview, SIGNAL(clicked()), this, SLOT(previewClicked())); |
8377 | 161 |
|
162 |
/* Bottom-Left layout */ |
|
3133 | 163 |
|
8377 | 164 |
QVBoxLayout * bottomLeftLayout = new QVBoxLayout(); |
165 |
leftLayout->addLayout(bottomLeftLayout, 1); |
|
166 |
||
167 |
/* Map list label */ |
|
168 |
||
10394 | 169 |
lblMapList = new QLabel(this); |
8377 | 170 |
rightLayout->addWidget(lblMapList, 0); |
171 |
||
172 |
/* Static maps list */ |
|
1248 | 173 |
|
10394 | 174 |
staticMapList = new QListView(this); |
8377 | 175 |
rightLayout->addWidget(staticMapList, 1); |
176 |
m_childWidgets << staticMapList; |
|
5289
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5252
diff
changeset
|
177 |
|
8377 | 178 |
/* Mission maps list */ |
1802 | 179 |
|
9744 | 180 |
missionMapList = new QListView(this); |
8377 | 181 |
rightLayout->addWidget(missionMapList, 1); |
182 |
m_childWidgets << missionMapList; |
|
183 |
||
184 |
/* Map load and edit buttons */ |
|
185 |
||
186 |
drawnControls->addStretch(1); |
|
2377 | 187 |
|
8377 | 188 |
btnLoadMap = new QPushButton(tr("Load map drawing")); |
189 |
btnLoadMap->setStyleSheet("padding: 20px;"); |
|
190 |
drawnControls->addWidget(btnLoadMap, 0); |
|
191 |
m_childWidgets << btnLoadMap; |
|
192 |
connect(btnLoadMap, SIGNAL(clicked()), this, SLOT(loadDrawing())); |
|
193 |
||
194 |
btnEditMap = new QPushButton(tr("Edit map drawing")); |
|
195 |
btnEditMap->setStyleSheet("padding: 20px;"); |
|
196 |
drawnControls->addWidget(btnEditMap, 0); |
|
197 |
m_childWidgets << btnEditMap; |
|
198 |
connect(btnEditMap, SIGNAL(clicked()), this, SIGNAL(drawMapRequested())); |
|
199 |
||
200 |
drawnControls->addStretch(1); |
|
201 |
||
202 |
rightLayout->addLayout(drawnControls); |
|
203 |
||
204 |
/* Generator style list */ |
|
2377 | 205 |
|
10394 | 206 |
generationStyles = new QListWidget(this); |
8377 | 207 |
new QListWidgetItem(tr("All"), generationStyles); |
208 |
new QListWidgetItem(tr("Small"), generationStyles); |
|
209 |
new QListWidgetItem(tr("Medium"), generationStyles); |
|
210 |
new QListWidgetItem(tr("Large"), generationStyles); |
|
211 |
new QListWidgetItem(tr("Cavern"), generationStyles); |
|
212 |
new QListWidgetItem(tr("Wacky"), generationStyles); |
|
213 |
connect(generationStyles, SIGNAL(currentRowChanged(int)), this, SLOT(setTemplateFilter(int))); |
|
214 |
m_childWidgets << generationStyles; |
|
215 |
rightLayout->addWidget(generationStyles, 1); |
|
216 |
||
217 |
/* Maze style list */ |
|
4557
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
218 |
|
10394 | 219 |
mazeStyles = new QListWidget(this); |
8377 | 220 |
new QListWidgetItem(tr("Small tunnels"), mazeStyles); |
221 |
new QListWidgetItem(tr("Medium tunnels"), mazeStyles); |
|
8695 | 222 |
new QListWidgetItem(tr("Large tunnels"), mazeStyles); |
8377 | 223 |
new QListWidgetItem(tr("Small islands"), mazeStyles); |
224 |
new QListWidgetItem(tr("Medium islands"), mazeStyles); |
|
225 |
new QListWidgetItem(tr("Large islands"), mazeStyles); |
|
226 |
connect(mazeStyles, SIGNAL(currentRowChanged(int)), this, SLOT(setMazeSize(int))); |
|
227 |
m_childWidgets << mazeStyles; |
|
228 |
rightLayout->addWidget(mazeStyles, 1); |
|
4557
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
229 |
|
10471
d968b1ac130c
sheepluva and unc0rr didn't like the idea of slider over preview.
nemo
parents:
10465
diff
changeset
|
230 |
mapFeatureSize = new QSlider(Qt::Horizontal, this); |
d968b1ac130c
sheepluva and unc0rr didn't like the idea of slider over preview.
nemo
parents:
10465
diff
changeset
|
231 |
mapFeatureSize->setObjectName("mapFeatureSize"); |
d968b1ac130c
sheepluva and unc0rr didn't like the idea of slider over preview.
nemo
parents:
10465
diff
changeset
|
232 |
//mapFeatureSize->setTickPosition(QSlider::TicksBelow); |
10477
b219c5a2317f
Fiddling with slider, unbreak maze. Next to mess around w/ perlin params.
nemo
parents:
10472
diff
changeset
|
233 |
mapFeatureSize->setMaximum(25); |
10471
d968b1ac130c
sheepluva and unc0rr didn't like the idea of slider over preview.
nemo
parents:
10465
diff
changeset
|
234 |
mapFeatureSize->setMinimum(1); |
d968b1ac130c
sheepluva and unc0rr didn't like the idea of slider over preview.
nemo
parents:
10465
diff
changeset
|
235 |
//mapFeatureSize->setFixedWidth(259); |
10472
8d04cebedb16
Partially hook up feature size so horrorcat has something to test.
nemo
parents:
10471
diff
changeset
|
236 |
mapFeatureSize->setValue(m_mapFeatureSize); |
10471
d968b1ac130c
sheepluva and unc0rr didn't like the idea of slider over preview.
nemo
parents:
10465
diff
changeset
|
237 |
mapFeatureSize->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
d968b1ac130c
sheepluva and unc0rr didn't like the idea of slider over preview.
nemo
parents:
10465
diff
changeset
|
238 |
bottomLeftLayout->addWidget(mapFeatureSize, 0); |
10480 | 239 |
connect(mapFeatureSize, SIGNAL(valueChanged(int)), this, SLOT(setFeatureSize(int))); |
10521 | 240 |
m_childWidgets << mapFeatureSize; |
10471
d968b1ac130c
sheepluva and unc0rr didn't like the idea of slider over preview.
nemo
parents:
10465
diff
changeset
|
241 |
|
8377 | 242 |
/* Mission description */ |
4557
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
243 |
|
8377 | 244 |
lblDesc = new QLabel(); |
245 |
lblDesc->setWordWrap(true); |
|
246 |
lblDesc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
247 |
lblDesc->setAlignment(Qt::AlignTop | Qt::AlignLeft); |
|
8393
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
248 |
lblDesc->setStyleSheet("font: 10px;"); |
8467 | 249 |
bottomLeftLayout->addWidget(lblDesc, 100); |
8377 | 250 |
|
8393
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
251 |
/* Add stretch above theme button */ |
8377 | 252 |
|
253 |
bottomLeftLayout->addStretch(1); |
|
254 |
||
255 |
/* Theme chooser */ |
|
11910
245163aa3674
Fix Qt warnings about QLayout (Fixes #127)
Wuzzy <almikes@aol.com>
parents:
11864
diff
changeset
|
256 |
QHBoxLayout * themeHBox = new QHBoxLayout(); |
11785 | 257 |
|
258 |
btnRandTheme = new QPushButton(); |
|
11809
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
259 |
btnRandTheme->setWhatsThis(tr("Randomize the theme")); |
11785 | 260 |
btnRandTheme->setIcon(lp); |
261 |
btnRandTheme->setIconSize(QSize(24, 24)); |
|
262 |
btnRandTheme->setFixedHeight(30); |
|
263 |
btnRandTheme->setFixedWidth(30); |
|
264 |
connect(btnRandTheme, SIGNAL(clicked()), this, SLOT(setRandomTheme())); |
|
11864
bff919afc63f
fix a typo back from may that apparently completely broke online-multiplayer due to causing a frontend crash on joining somebody else's room
sheepluva
parents:
11811
diff
changeset
|
265 |
m_childWidgets << btnRandTheme; |
11785 | 266 |
themeHBox->addWidget(btnRandTheme, 0); |
1215 | 267 |
|
10394 | 268 |
btnTheme = new QPushButton(this); |
11809
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
269 |
btnTheme->setWhatsThis(tr("Choose a theme")); |
8886
5c521d1fdd63
Fixed map preview overlap on certain locales (Fixes issue 549).
dag10
parents:
8695
diff
changeset
|
270 |
btnTheme->setFlat(true); |
10471
d968b1ac130c
sheepluva and unc0rr didn't like the idea of slider over preview.
nemo
parents:
10465
diff
changeset
|
271 |
btnTheme->setIconSize(QSize(30, 30)); |
d968b1ac130c
sheepluva and unc0rr didn't like the idea of slider over preview.
nemo
parents:
10465
diff
changeset
|
272 |
btnTheme->setFixedHeight(30); |
11785 | 273 |
btnTheme->setMaximumWidth(222); |
8377 | 274 |
connect(btnTheme, SIGNAL(clicked()), this, SLOT(showThemePrompt())); |
275 |
m_childWidgets << btnTheme; |
|
11785 | 276 |
themeHBox->addWidget(btnTheme, 1); |
277 |
||
278 |
bottomLeftLayout->addLayout(themeHBox); |
|
4699 | 279 |
|
8377 | 280 |
/* Add everything to main layout */ |
281 |
||
8886
5c521d1fdd63
Fixed map preview overlap on certain locales (Fixes issue 549).
dag10
parents:
8695
diff
changeset
|
282 |
mainLayout.addWidget(topWidget, 0); |
5c521d1fdd63
Fixed map preview overlap on certain locales (Fixes issue 549).
dag10
parents:
8695
diff
changeset
|
283 |
mainLayout.addLayout(twoColumnLayout, 1); |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
284 |
|
8377 | 285 |
/* Set defaults */ |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
286 |
|
8377 | 287 |
setRandomSeed(); |
288 |
setMazeSize(0); |
|
289 |
setTemplateFilter(0); |
|
290 |
staticMapChanged(m_staticMapModel->index(0, 0)); |
|
291 |
missionMapChanged(m_missionMapModel->index(0, 0)); |
|
8393
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
292 |
changeMapType(MapModel::GeneratedMap); |
184 | 293 |
} |
294 |
||
10161 | 295 |
void HWMapContainer::setImage(const QPixmap &newImage) |
184 | 296 |
{ |
10161 | 297 |
addInfoToPreview(newImage); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
298 |
pMap = 0; |
8377 | 299 |
|
300 |
cType->setEnabled(isMaster()); |
|
249 | 301 |
} |
302 |
||
1790 | 303 |
void HWMapContainer::setHHLimit(int newHHLimit) |
304 |
{ |
|
305 |
hhLimit = newHHLimit; |
|
306 |
} |
|
307 |
||
308 |
// Should this add text to identify map size? |
|
10161 | 309 |
void HWMapContainer::addInfoToPreview(const QPixmap &image) |
1790 | 310 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
311 |
QPixmap finalImage = QPixmap(image.size()); |
10161 | 312 |
//finalImage.fill(QColor(0, 0, 0, 0)); |
2377 | 313 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
314 |
QPainter p(&finalImage); |
10161 | 315 |
p.fillRect(finalImage.rect(), linearGrad); |
316 |
p.drawPixmap(finalImage.rect(), image); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
317 |
//p.setPen(QColor(0xf4,0x9e,0xe9)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
318 |
p.setPen(QColor(0xff,0xcc,0x00)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
319 |
p.setBrush(QColor(0, 0, 0)); |
10161 | 320 |
p.drawRect(finalImage.rect().width() - hhSmall.rect().width() - 28, 3, 40, 20); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
321 |
p.setFont(QFont("MS Shell Dlg", 10)); |
7017
19a434fc91fc
visually indicate when map preview generation is in progress.
sheepluva
parents:
7014
diff
changeset
|
322 |
QString text = (hhLimit > 0) ? QString::number(hhLimit) : "?"; |
10161 | 323 |
p.drawText(finalImage.rect().width() - hhSmall.rect().width() - 14 - (hhLimit > 9 ? 10 : 0), 18, text); |
324 |
p.drawPixmap(finalImage.rect().width() - hhSmall.rect().width() - 5, 5, hhSmall.rect().width(), hhSmall.rect().height(), hhSmall); |
|
1790 | 325 |
|
8467 | 326 |
// Shrink, crop, and center preview image |
10161 | 327 |
/*QPixmap centered(QSize(m_previewSize.width() - 6, m_previewSize.height() - 6)); |
8467 | 328 |
QPainter pc(¢ered); |
329 |
pc.fillRect(centered.rect(), linearGrad); |
|
10161 | 330 |
pc.drawPixmap(-3, -3, finalImage);*/ |
8467 | 331 |
|
10161 | 332 |
mapPreview->setIcon(QIcon(finalImage)); |
333 |
mapPreview->setIconSize(finalImage.size()); |
|
184 | 334 |
} |
335 |
||
4562 | 336 |
void HWMapContainer::askForGeneratedPreview() |
184 | 337 |
{ |
8070
66bc20d089fc
Okay, remove previous request only if it has same parent
unc0rr
parents:
8049
diff
changeset
|
338 |
pMap = new HWMap(this); |
10161 | 339 |
connect(pMap, SIGNAL(ImageReceived(QPixmap)), this, SLOT(setImage(QPixmap))); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
340 |
connect(pMap, SIGNAL(HHLimitReceived(int)), this, SLOT(setHHLimit(int))); |
7008
25563f054ef3
fix a previewmap-related QObject::disconnect segfault
sheepluva
parents:
6983
diff
changeset
|
341 |
connect(pMap, SIGNAL(destroyed(QObject *)), this, SLOT(onPreviewMapDestroyed(QObject *))); |
4562 | 342 |
pMap->getImage(m_seed, |
343 |
getTemplateFilter(), |
|
344 |
get_mapgen(), |
|
4941 | 345 |
getMazeSize(), |
10150
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10108
diff
changeset
|
346 |
getDrawnMapData(), |
10472
8d04cebedb16
Partially hook up feature size so horrorcat has something to test.
nemo
parents:
10471
diff
changeset
|
347 |
m_script, |
10959
1225f42f61e2
Pass ScriptParams to preview to support techracer. Proof of concept for techracer, generate a preview for m=4
nemo
parents:
10521
diff
changeset
|
348 |
m_scriptparam, |
10477
b219c5a2317f
Fiddling with slider, unbreak maze. Next to mess around w/ perlin params.
nemo
parents:
10472
diff
changeset
|
349 |
m_mapFeatureSize |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
350 |
); |
7017
19a434fc91fc
visually indicate when map preview generation is in progress.
sheepluva
parents:
7014
diff
changeset
|
351 |
|
19a434fc91fc
visually indicate when map preview generation is in progress.
sheepluva
parents:
7014
diff
changeset
|
352 |
setHHLimit(0); |
19a434fc91fc
visually indicate when map preview generation is in progress.
sheepluva
parents:
7014
diff
changeset
|
353 |
|
19a434fc91fc
visually indicate when map preview generation is in progress.
sheepluva
parents:
7014
diff
changeset
|
354 |
const QPixmap waitIcon(":/res/iconTime.png"); |
19a434fc91fc
visually indicate when map preview generation is in progress.
sheepluva
parents:
7014
diff
changeset
|
355 |
|
19a434fc91fc
visually indicate when map preview generation is in progress.
sheepluva
parents:
7014
diff
changeset
|
356 |
QPixmap waitImage(m_previewSize); |
19a434fc91fc
visually indicate when map preview generation is in progress.
sheepluva
parents:
7014
diff
changeset
|
357 |
QPainter p(&waitImage); |
19a434fc91fc
visually indicate when map preview generation is in progress.
sheepluva
parents:
7014
diff
changeset
|
358 |
|
19a434fc91fc
visually indicate when map preview generation is in progress.
sheepluva
parents:
7014
diff
changeset
|
359 |
p.fillRect(waitImage.rect(), linearGrad); |
19a434fc91fc
visually indicate when map preview generation is in progress.
sheepluva
parents:
7014
diff
changeset
|
360 |
int x = (waitImage.width() - waitIcon.width()) / 2; |
19a434fc91fc
visually indicate when map preview generation is in progress.
sheepluva
parents:
7014
diff
changeset
|
361 |
int y = (waitImage.height() - waitIcon.height()) / 2; |
19a434fc91fc
visually indicate when map preview generation is in progress.
sheepluva
parents:
7014
diff
changeset
|
362 |
p.drawPixmap(QPoint(x, y), waitIcon); |
19a434fc91fc
visually indicate when map preview generation is in progress.
sheepluva
parents:
7014
diff
changeset
|
363 |
|
19a434fc91fc
visually indicate when map preview generation is in progress.
sheepluva
parents:
7014
diff
changeset
|
364 |
addInfoToPreview(waitImage); |
184 | 365 |
|
8377 | 366 |
cType->setEnabled(false); |
1215 | 367 |
} |
368 |
||
8467 | 369 |
void HWMapContainer::previewClicked() |
370 |
{ |
|
9452 | 371 |
if (isMaster()) // should only perform these if master, but disabling the button when not, causes an unattractive preview. |
372 |
switch (m_mapInfo.type) |
|
373 |
{ |
|
374 |
case MapModel::HandDrawnMap: |
|
375 |
emit drawMapRequested(); |
|
376 |
break; |
|
377 |
default: |
|
378 |
setRandomMap(); |
|
379 |
break; |
|
380 |
} |
|
8467 | 381 |
} |
382 |
||
184 | 383 |
QString HWMapContainer::getCurrentSeed() const |
384 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
385 |
return m_seed; |
184 | 386 |
} |
387 |
||
249 | 388 |
QString HWMapContainer::getCurrentMap() const |
389 |
{ |
|
8377 | 390 |
switch (m_mapInfo.type) |
391 |
{ |
|
392 |
case MapModel::StaticMap: |
|
393 |
case MapModel::MissionMap: |
|
394 |
return m_curMap; |
|
395 |
default: |
|
396 |
return QString(); |
|
397 |
} |
|
249 | 398 |
} |
399 |
||
400 |
QString HWMapContainer::getCurrentTheme() const |
|
401 |
{ |
|
6940
211aca8c1f4f
decouple current theme from map theme (fixes theme confusion bugs of last commit)
sheepluva
parents:
6939
diff
changeset
|
402 |
return(m_theme); |
3008 | 403 |
} |
404 |
||
405 |
bool HWMapContainer::getCurrentIsMission() const |
|
406 |
{ |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
407 |
return(m_mapInfo.type == MapModel::MissionMap); |
1790 | 408 |
} |
409 |
||
410 |
int HWMapContainer::getCurrentHHLimit() const |
|
411 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
412 |
return hhLimit; |
249 | 413 |
} |
414 |
||
4513
1dd97c710f5a
added general scripts to multiplayer and added option for scripts to allow user set schemes or weapon sets.
Henek
parents:
4511
diff
changeset
|
415 |
QString HWMapContainer::getCurrentScheme() const |
1dd97c710f5a
added general scripts to multiplayer and added option for scripts to allow user set schemes or weapon sets.
Henek
parents:
4511
diff
changeset
|
416 |
{ |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
417 |
return(m_mapInfo.scheme); |
4513
1dd97c710f5a
added general scripts to multiplayer and added option for scripts to allow user set schemes or weapon sets.
Henek
parents:
4511
diff
changeset
|
418 |
} |
1dd97c710f5a
added general scripts to multiplayer and added option for scripts to allow user set schemes or weapon sets.
Henek
parents:
4511
diff
changeset
|
419 |
|
1dd97c710f5a
added general scripts to multiplayer and added option for scripts to allow user set schemes or weapon sets.
Henek
parents:
4511
diff
changeset
|
420 |
QString HWMapContainer::getCurrentWeapons() const |
1dd97c710f5a
added general scripts to multiplayer and added option for scripts to allow user set schemes or weapon sets.
Henek
parents:
4511
diff
changeset
|
421 |
{ |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
422 |
return(m_mapInfo.weapons); |
4513
1dd97c710f5a
added general scripts to multiplayer and added option for scripts to allow user set schemes or weapon sets.
Henek
parents:
4511
diff
changeset
|
423 |
} |
1dd97c710f5a
added general scripts to multiplayer and added option for scripts to allow user set schemes or weapon sets.
Henek
parents:
4511
diff
changeset
|
424 |
|
1802 | 425 |
quint32 HWMapContainer::getTemplateFilter() const |
426 |
{ |
|
8377 | 427 |
return generationStyles->currentRow(); |
1802 | 428 |
} |
429 |
||
10472
8d04cebedb16
Partially hook up feature size so horrorcat has something to test.
nemo
parents:
10471
diff
changeset
|
430 |
quint32 HWMapContainer::getFeatureSize() const |
8d04cebedb16
Partially hook up feature size so horrorcat has something to test.
nemo
parents:
10471
diff
changeset
|
431 |
{ |
8d04cebedb16
Partially hook up feature size so horrorcat has something to test.
nemo
parents:
10471
diff
changeset
|
432 |
return m_mapFeatureSize; |
8d04cebedb16
Partially hook up feature size so horrorcat has something to test.
nemo
parents:
10471
diff
changeset
|
433 |
} |
8d04cebedb16
Partially hook up feature size so horrorcat has something to test.
nemo
parents:
10471
diff
changeset
|
434 |
|
184 | 435 |
void HWMapContainer::resizeEvent ( QResizeEvent * event ) |
436 |
{ |
|
4560
5d6c7f88db73
- Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents:
4557
diff
changeset
|
437 |
Q_UNUSED(event); |
184 | 438 |
} |
320 | 439 |
|
4936
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4701
diff
changeset
|
440 |
void HWMapContainer::intSetSeed(const QString & seed) |
320 | 441 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
442 |
m_seed = seed; |
4936
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4701
diff
changeset
|
443 |
} |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4701
diff
changeset
|
444 |
|
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4701
diff
changeset
|
445 |
void HWMapContainer::setSeed(const QString & seed) |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4701
diff
changeset
|
446 |
{ |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4701
diff
changeset
|
447 |
intSetSeed(seed); |
10391 | 448 |
if ((m_mapInfo.type == MapModel::GeneratedMap) |
449 |
|| (m_mapInfo.type == MapModel::GeneratedMaze) |
|
450 |
|| (m_mapInfo.type == MapModel::GeneratedPerlin)) |
|
4562 | 451 |
updatePreview(); |
320 | 452 |
} |
453 |
||
10959
1225f42f61e2
Pass ScriptParams to preview to support techracer. Proof of concept for techracer, generate a preview for m=4
nemo
parents:
10521
diff
changeset
|
454 |
void HWMapContainer::setScript(const QString & script, const QString & scriptparam) |
10150
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10108
diff
changeset
|
455 |
{ |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10108
diff
changeset
|
456 |
m_script = script; |
10959
1225f42f61e2
Pass ScriptParams to preview to support techracer. Proof of concept for techracer, generate a preview for m=4
nemo
parents:
10521
diff
changeset
|
457 |
m_scriptparam = scriptparam; |
10391 | 458 |
if ((m_mapInfo.type == MapModel::GeneratedMap) |
459 |
|| (m_mapInfo.type == MapModel::GeneratedMaze) |
|
460 |
|| (m_mapInfo.type == MapModel::GeneratedPerlin) |
|
461 |
|| (m_mapInfo.type == MapModel::HandDrawnMap)) |
|
10171
00f41ff0bf2d
Script might well override a static map, but can't risk it not doing it, and preview completely failing. Better to just not try it for static maps. Some script cfg might help. Could also avoid unnnecessary preview regenerations even if the script was doing nothing at all.
nemo
parents:
10169
diff
changeset
|
462 |
updatePreview(); |
10150
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10108
diff
changeset
|
463 |
} |
fa5c83fd0ad9
Allow lua drawn maps (shoppamap, tunnels, diagonal maze etc) to generate previews.
nemo
parents:
10108
diff
changeset
|
464 |
|
4936
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4701
diff
changeset
|
465 |
void HWMapContainer::intSetMap(const QString & map) |
320 | 466 |
{ |
8377 | 467 |
if (map == "+rnd+") |
468 |
{ |
|
10336 | 469 |
//changeMapType(MapModel::GeneratedMap); |
8377 | 470 |
} |
471 |
else if (map == "+maze+") |
|
472 |
{ |
|
10336 | 473 |
//changeMapType(MapModel::GeneratedMaze); |
8377 | 474 |
} |
10391 | 475 |
else if (map == "+perlin+") |
476 |
{ |
|
477 |
//changeMapType(MapModel::GeneratedPerlin); |
|
478 |
} |
|
8377 | 479 |
else if (map == "+drawn+") |
480 |
{ |
|
10336 | 481 |
//changeMapType(MapModel::HandDrawnMap); |
8377 | 482 |
} |
11744
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
10959
diff
changeset
|
483 |
else if (map == "+forts+") |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
10959
diff
changeset
|
484 |
{ |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
10959
diff
changeset
|
485 |
//nuffin |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
10959
diff
changeset
|
486 |
} |
8377 | 487 |
else if (m_staticMapModel->mapExists(map)) |
488 |
{ |
|
489 |
changeMapType(MapModel::StaticMap, m_staticMapModel->index(m_staticMapModel->findMap(map), 0)); |
|
490 |
} |
|
491 |
else if (m_missionMapModel->mapExists(map)) |
|
492 |
{ |
|
493 |
changeMapType(MapModel::MissionMap, m_missionMapModel->index(m_missionMapModel->findMap(map), 0)); |
|
494 |
} else |
|
495 |
{ |
|
496 |
qDebug() << "HWMapContainer::intSetMap: Map doesn't exist: " << map; |
|
497 |
} |
|
320 | 498 |
} |
499 |
||
7018
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
500 |
void HWMapContainer::setMap(const QString & map) |
4936
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4701
diff
changeset
|
501 |
{ |
7018
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
502 |
if ((m_mapInfo.type == MapModel::Invalid) || (map != m_mapInfo.name)) |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
503 |
intSetMap(map); |
4936
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4701
diff
changeset
|
504 |
} |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4701
diff
changeset
|
505 |
|
320 | 506 |
void HWMapContainer::setTheme(const QString & theme) |
507 |
{ |
|
8475
f605bc59c603
Initial theme selection is now random. Theme prompt now has a search input and no longer uses FlowLayout. (Resolves issue 520)
dag10
parents:
8467
diff
changeset
|
508 |
QModelIndexList mdl = m_themeModel->match(m_themeModel->index(0), ThemeModel::ActualNameRole, theme); |
5289
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5252
diff
changeset
|
509 |
|
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5252
diff
changeset
|
510 |
if(mdl.size()) |
8377 | 511 |
updateTheme(mdl.at(0)); |
8393
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
512 |
else |
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
513 |
intSetIconlessTheme(theme); |
320 | 514 |
} |
4562 | 515 |
|
4337 | 516 |
void HWMapContainer::setRandomMap() |
517 |
{ |
|
8619
253750e192e7
Made pressing the button in mapContainer only randomize things if client is master. Fixes issue 545. Also synchronized themes. Fixes issue 547.
dag10
parents:
8475
diff
changeset
|
518 |
if (!m_master) return; |
8924 | 519 |
|
4419 | 520 |
setRandomSeed(); |
11757
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
521 |
|
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
522 |
QSortFilterProxyModel * mmodel = NULL; |
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
523 |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
524 |
switch(m_mapInfo.type) |
4337 | 525 |
{ |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
526 |
case MapModel::GeneratedMap: |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
527 |
case MapModel::GeneratedMaze: |
10391 | 528 |
case MapModel::GeneratedPerlin: |
11744
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
10959
diff
changeset
|
529 |
case MapModel::FortsMap: |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
530 |
setRandomTheme(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
531 |
break; |
8377 | 532 |
case MapModel::MissionMap: |
11757
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
533 |
if (m_withoutDLC) |
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
534 |
{ |
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
535 |
mmodel = m_missionMapModel->withoutDLC(); |
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
536 |
missionMapChanged(mmodel->mapToSource(mmodel->index(rand() % mmodel->rowCount(),0))); |
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
537 |
} |
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
538 |
else |
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
539 |
missionMapChanged(m_missionMapModel->index(rand() % m_missionMapModel->rowCount(),0)); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
540 |
break; |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
541 |
case MapModel::StaticMap: |
11757
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
542 |
if (m_withoutDLC) |
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
543 |
{ |
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
544 |
mmodel = m_staticMapModel->withoutDLC(); |
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
545 |
staticMapChanged(mmodel->mapToSource(mmodel->index(rand() % mmodel->rowCount(),0))); |
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
546 |
} |
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
547 |
else |
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
548 |
staticMapChanged(m_staticMapModel->index(rand() % m_staticMapModel->rowCount(),0)); |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
549 |
break; |
8377 | 550 |
default: |
551 |
break; |
|
4337 | 552 |
} |
553 |
} |
|
554 |
||
320 | 555 |
void HWMapContainer::setRandomSeed() |
556 |
{ |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
557 |
setSeed(QUuid::createUuid().toString()); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
558 |
emit seedChanged(m_seed); |
320 | 559 |
} |
1318 | 560 |
|
11757
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
561 |
void HWMapContainer::setRandomWithoutDLC(bool withoutDLC) |
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
562 |
{ |
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
563 |
m_withoutDLC = withoutDLC; |
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
564 |
} |
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
565 |
|
1318 | 566 |
void HWMapContainer::setRandomTheme() |
567 |
{ |
|
11757
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
568 |
QAbstractItemModel * tmodel; |
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
569 |
|
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
570 |
if (m_withoutDLC) |
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
571 |
tmodel = m_themeModel->withoutDLC(); |
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
572 |
else |
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
573 |
tmodel = m_themeModel; |
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
574 |
|
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
575 |
if(!tmodel->rowCount()) return; |
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
576 |
quint32 themeNum = rand() % tmodel->rowCount(); |
6874644a2d00
in non-local games, don't include DLC-themes/maps/missions during random selection. thanks to unC0Rr for helping me realize that I was stupid in a different way than I thought :P
sheepluva
parents:
11754
diff
changeset
|
577 |
updateTheme(tmodel->index(themeNum,0)); |
8619
253750e192e7
Made pressing the button in mapContainer only randomize things if client is master. Fixes issue 545. Also synchronized themes. Fixes issue 547.
dag10
parents:
8475
diff
changeset
|
578 |
emit themeChanged(m_theme); |
1318 | 579 |
} |
1797 | 580 |
|
4941 | 581 |
void HWMapContainer::intSetTemplateFilter(int filter) |
582 |
{ |
|
8377 | 583 |
generationStyles->setCurrentRow(filter); |
4941 | 584 |
emit newTemplateFilter(filter); |
585 |
} |
|
586 |
||
1797 | 587 |
void HWMapContainer::setTemplateFilter(int filter) |
588 |
{ |
|
4941 | 589 |
intSetTemplateFilter(filter); |
7018
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
590 |
if (m_mapInfo.type == MapModel::GeneratedMap) |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
591 |
updatePreview(); |
1802 | 592 |
} |
593 |
||
3133 | 594 |
MapGenerator HWMapContainer::get_mapgen(void) const |
595 |
{ |
|
596 |
return mapgen; |
|
597 |
} |
|
598 |
||
4941 | 599 |
int HWMapContainer::getMazeSize(void) const |
3133 | 600 |
{ |
8377 | 601 |
return mazeStyles->currentRow(); |
3133 | 602 |
} |
603 |
||
4941 | 604 |
void HWMapContainer::intSetMazeSize(int size) |
3133 | 605 |
{ |
8377 | 606 |
mazeStyles->setCurrentRow(size); |
4941 | 607 |
emit mazeSizeChanged(size); |
608 |
} |
|
609 |
||
610 |
void HWMapContainer::setMazeSize(int size) |
|
611 |
{ |
|
612 |
intSetMazeSize(size); |
|
7018
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
613 |
if (m_mapInfo.type == MapModel::GeneratedMaze) |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
614 |
updatePreview(); |
3133 | 615 |
} |
616 |
||
4936
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4701
diff
changeset
|
617 |
void HWMapContainer::intSetMapgen(MapGenerator m) |
3133 | 618 |
{ |
7018
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
619 |
if (mapgen != m) |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
620 |
{ |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
621 |
mapgen = m; |
5793
401ab167bd9f
This should be a real fix (7643cbb88f09 reverted). Not tested.
unc0rr
parents:
5789
diff
changeset
|
622 |
|
10463 | 623 |
bool f = false; |
7018
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
624 |
switch (m) |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
625 |
{ |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
626 |
case MAPGEN_REGULAR: |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
627 |
m_mapInfo.type = MapModel::GeneratedMap; |
10463 | 628 |
f = true; |
7018
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
629 |
break; |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
630 |
case MAPGEN_MAZE: |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
631 |
m_mapInfo.type = MapModel::GeneratedMaze; |
10463 | 632 |
f = true; |
7018
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
633 |
break; |
10391 | 634 |
case MAPGEN_PERLIN: |
635 |
m_mapInfo.type = MapModel::GeneratedPerlin; |
|
10463 | 636 |
f = true; |
10391 | 637 |
break; |
7018
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
638 |
case MAPGEN_DRAWN: |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
639 |
m_mapInfo.type = MapModel::HandDrawnMap; |
10463 | 640 |
f = true; |
7018
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
641 |
break; |
11744
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
10959
diff
changeset
|
642 |
case MAPGEN_FORTS: |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
10959
diff
changeset
|
643 |
m_mapInfo.type = MapModel::FortsMap; |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
10959
diff
changeset
|
644 |
f = true; |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
10959
diff
changeset
|
645 |
break; |
7018
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
646 |
case MAPGEN_MAP: |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
647 |
switch (m_mapInfo.type) |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
648 |
{ |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
649 |
case MapModel::GeneratedMap: |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
650 |
case MapModel::GeneratedMaze: |
10391 | 651 |
case MapModel::GeneratedPerlin: |
7018
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
652 |
case MapModel::HandDrawnMap: |
11744
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
10959
diff
changeset
|
653 |
case MapModel::FortsMap: |
7018
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
654 |
m_mapInfo.type = MapModel::Invalid; |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
655 |
default: |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
656 |
break; |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
657 |
} |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
658 |
break; |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
659 |
} |
5793
401ab167bd9f
This should be a real fix (7643cbb88f09 reverted). Not tested.
unc0rr
parents:
5789
diff
changeset
|
660 |
|
10463 | 661 |
if(f) |
662 |
changeMapType(m_mapInfo.type, QModelIndex()); |
|
7018
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
663 |
} |
4936
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4701
diff
changeset
|
664 |
} |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4701
diff
changeset
|
665 |
|
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4701
diff
changeset
|
666 |
void HWMapContainer::setMapgen(MapGenerator m) |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4701
diff
changeset
|
667 |
{ |
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4701
diff
changeset
|
668 |
intSetMapgen(m); |
7018
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
669 |
if(m != MAPGEN_MAP) |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
670 |
updatePreview(); |
3133 | 671 |
} |
4489 | 672 |
|
4537 | 673 |
void HWMapContainer::setDrawnMapData(const QByteArray & ar) |
674 |
{ |
|
675 |
drawMapScene.decode(ar); |
|
4562 | 676 |
updatePreview(); |
4537 | 677 |
} |
678 |
||
4489 | 679 |
QByteArray HWMapContainer::getDrawnMapData() |
680 |
{ |
|
4520
e7882bd1a894
Allow to draw maps in frontend and play them (only locally, some bugs to fix)
unc0rr
parents:
4519
diff
changeset
|
681 |
return drawMapScene.encode(); |
4513
1dd97c710f5a
added general scripts to multiplayer and added option for scripts to allow user set schemes or weapon sets.
Henek
parents:
4511
diff
changeset
|
682 |
} |
4519 | 683 |
|
8377 | 684 |
void HWMapContainer::setNewSeed(const QString & newSeed) |
4519 | 685 |
{ |
8377 | 686 |
setSeed(newSeed); |
687 |
emit seedChanged(newSeed); |
|
4519 | 688 |
} |
4520
e7882bd1a894
Allow to draw maps in frontend and play them (only locally, some bugs to fix)
unc0rr
parents:
4519
diff
changeset
|
689 |
|
e7882bd1a894
Allow to draw maps in frontend and play them (only locally, some bugs to fix)
unc0rr
parents:
4519
diff
changeset
|
690 |
DrawMapScene * HWMapContainer::getDrawMapScene() |
e7882bd1a894
Allow to draw maps in frontend and play them (only locally, some bugs to fix)
unc0rr
parents:
4519
diff
changeset
|
691 |
{ |
e7882bd1a894
Allow to draw maps in frontend and play them (only locally, some bugs to fix)
unc0rr
parents:
4519
diff
changeset
|
692 |
return &drawMapScene; |
e7882bd1a894
Allow to draw maps in frontend and play them (only locally, some bugs to fix)
unc0rr
parents:
4519
diff
changeset
|
693 |
} |
4525 | 694 |
|
695 |
void HWMapContainer::mapDrawingFinished() |
|
696 |
{ |
|
4526 | 697 |
emit drawnMapChanged(getDrawnMapData()); |
4525 | 698 |
|
4562 | 699 |
updatePreview(); |
4550
d300ea498486
added set button to seed edit so maps won't regenerate as often
Henek
parents:
4537
diff
changeset
|
700 |
} |
4562 | 701 |
|
9739
c2c9dd2544b8
make lazy loading of map preview a little bit less of a hack
sheepluva
parents:
9735
diff
changeset
|
702 |
void HWMapContainer::showEvent(QShowEvent * event) |
9735
6312152d92ad
don't generate any map previews until they are actually visible. this should improve hedgewars startup performance on weak machines
sheepluva
parents:
9452
diff
changeset
|
703 |
{ |
9739
c2c9dd2544b8
make lazy loading of map preview a little bit less of a hack
sheepluva
parents:
9735
diff
changeset
|
704 |
if (!m_previewEnabled) { |
c2c9dd2544b8
make lazy loading of map preview a little bit less of a hack
sheepluva
parents:
9735
diff
changeset
|
705 |
m_previewEnabled = true; |
9745 | 706 |
setRandomTheme(); |
9735
6312152d92ad
don't generate any map previews until they are actually visible. this should improve hedgewars startup performance on weak machines
sheepluva
parents:
9452
diff
changeset
|
707 |
updatePreview(); |
9739
c2c9dd2544b8
make lazy loading of map preview a little bit less of a hack
sheepluva
parents:
9735
diff
changeset
|
708 |
} |
c2c9dd2544b8
make lazy loading of map preview a little bit less of a hack
sheepluva
parents:
9735
diff
changeset
|
709 |
QWidget::showEvent(event); |
9735
6312152d92ad
don't generate any map previews until they are actually visible. this should improve hedgewars startup performance on weak machines
sheepluva
parents:
9452
diff
changeset
|
710 |
} |
6312152d92ad
don't generate any map previews until they are actually visible. this should improve hedgewars startup performance on weak machines
sheepluva
parents:
9452
diff
changeset
|
711 |
|
4562 | 712 |
void HWMapContainer::updatePreview() |
713 |
{ |
|
9739
c2c9dd2544b8
make lazy loading of map preview a little bit less of a hack
sheepluva
parents:
9735
diff
changeset
|
714 |
// abort if the widget isn't supposed to show anything yet |
c2c9dd2544b8
make lazy loading of map preview a little bit less of a hack
sheepluva
parents:
9735
diff
changeset
|
715 |
if (!m_previewEnabled) |
9735
6312152d92ad
don't generate any map previews until they are actually visible. this should improve hedgewars startup performance on weak machines
sheepluva
parents:
9452
diff
changeset
|
716 |
return; |
6312152d92ad
don't generate any map previews until they are actually visible. this should improve hedgewars startup performance on weak machines
sheepluva
parents:
9452
diff
changeset
|
717 |
|
7018
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
718 |
if (pMap) |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
719 |
{ |
10175
c92668840ea8
Remove game/preview functions split in library mode, just let normal procedure run instead:
unc0rr
parents:
10171
diff
changeset
|
720 |
disconnect(pMap, 0, this, SLOT(setImage(const QPixmap))); |
7018
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
721 |
disconnect(pMap, 0, this, SLOT(setHHLimit(int))); |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
722 |
pMap = 0; |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
723 |
} |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
724 |
|
7014
c0b32404ef74
+ display lack of map in a nice way, don't generate bogus preview in the background
sheepluva
parents:
7008
diff
changeset
|
725 |
QPixmap failIcon; |
c0b32404ef74
+ display lack of map in a nice way, don't generate bogus preview in the background
sheepluva
parents:
7008
diff
changeset
|
726 |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
727 |
switch(m_mapInfo.type) |
4562 | 728 |
{ |
7014
c0b32404ef74
+ display lack of map in a nice way, don't generate bogus preview in the background
sheepluva
parents:
7008
diff
changeset
|
729 |
case MapModel::Invalid: |
c0b32404ef74
+ display lack of map in a nice way, don't generate bogus preview in the background
sheepluva
parents:
7008
diff
changeset
|
730 |
failIcon = QPixmap(":/res/btnDisabled.png"); |
8467 | 731 |
mapPreview->setIcon(QIcon(failIcon)); |
732 |
mapPreview->setIconSize(failIcon.size()); |
|
7014
c0b32404ef74
+ display lack of map in a nice way, don't generate bogus preview in the background
sheepluva
parents:
7008
diff
changeset
|
733 |
break; |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
734 |
case MapModel::GeneratedMap: |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
735 |
case MapModel::GeneratedMaze: |
10391 | 736 |
case MapModel::GeneratedPerlin: |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
737 |
case MapModel::HandDrawnMap: |
11744
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
10959
diff
changeset
|
738 |
case MapModel::FortsMap: |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
739 |
askForGeneratedPreview(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
740 |
break; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
741 |
default: |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
742 |
QPixmap mapImage; |
8049 | 743 |
bool success = mapImage.load("physfs://Maps/" + m_mapInfo.name + "/preview.png"); |
6939
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
744 |
|
970389573788
MapModel converted to QStandardItemList; separators fixed; changed used data format (human-readable struct instead of magic list) for map info in HwMapContainer (+ various small cleanups in that class)
sheepluva
parents:
6938
diff
changeset
|
745 |
if(!success) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
746 |
{ |
8467 | 747 |
mapPreview->setIcon(QIcon()); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
748 |
return; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
749 |
} |
4562 | 750 |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
751 |
hhLimit = m_mapInfo.limit; |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
752 |
addInfoToPreview(mapImage); |
4562 | 753 |
} |
754 |
} |
|
4936
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4701
diff
changeset
|
755 |
|
10480 | 756 |
void HWMapContainer::setAllMapParameters(const QString &map, MapGenerator m, int mazesize, const QString &seed, int tmpl, int featureSize) |
4936
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4701
diff
changeset
|
757 |
{ |
5793
401ab167bd9f
This should be a real fix (7643cbb88f09 reverted). Not tested.
unc0rr
parents:
5789
diff
changeset
|
758 |
intSetMapgen(m); |
4941 | 759 |
intSetMazeSize(mazesize); |
760 |
intSetSeed(seed); |
|
761 |
intSetTemplateFilter(tmpl); |
|
7018
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
762 |
// this one last because it will refresh the preview |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
763 |
intSetMap(map); |
10480 | 764 |
intSetMazeSize(mazesize); |
765 |
intSetFeatureSize(featureSize); |
|
4936
d65d438acd23
Merge MAP, MAPGEN and SEED params into one on room join, so engine isn't spawned three times for a preview. Not tested as I'm unable to see my rooms (why?)
unc0rr
parents:
4701
diff
changeset
|
766 |
} |
6933
78d194a30520
mapContainer: use DataManager, reload maps after data update (e.g. by DLC)
sheepluva
parents:
6700
diff
changeset
|
767 |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
768 |
void HWMapContainer::updateModelViews() |
6933
78d194a30520
mapContainer: use DataManager, reload maps after data update (e.g. by DLC)
sheepluva
parents:
6700
diff
changeset
|
769 |
{ |
6960
822f8269e13f
map, theme & style selection won't be lost on data updata now (except the selected map/theme/style is deleted ofc). enabling F5 key to reload data :>
sheepluva
parents:
6947
diff
changeset
|
770 |
// restore theme selection |
822f8269e13f
map, theme & style selection won't be lost on data updata now (except the selected map/theme/style is deleted ofc). enabling F5 key to reload data :>
sheepluva
parents:
6947
diff
changeset
|
771 |
// do this before map selection restore, because map may overwrite theme |
822f8269e13f
map, theme & style selection won't be lost on data updata now (except the selected map/theme/style is deleted ofc). enabling F5 key to reload data :>
sheepluva
parents:
6947
diff
changeset
|
772 |
if (!m_theme.isEmpty()) |
822f8269e13f
map, theme & style selection won't be lost on data updata now (except the selected map/theme/style is deleted ofc). enabling F5 key to reload data :>
sheepluva
parents:
6947
diff
changeset
|
773 |
{ |
822f8269e13f
map, theme & style selection won't be lost on data updata now (except the selected map/theme/style is deleted ofc). enabling F5 key to reload data :>
sheepluva
parents:
6947
diff
changeset
|
774 |
QModelIndexList mdl = m_themeModel->match(m_themeModel->index(0), Qt::DisplayRole, m_theme); |
822f8269e13f
map, theme & style selection won't be lost on data updata now (except the selected map/theme/style is deleted ofc). enabling F5 key to reload data :>
sheepluva
parents:
6947
diff
changeset
|
775 |
if (mdl.size() > 0) |
8377 | 776 |
updateTheme(mdl.at(0)); |
6960
822f8269e13f
map, theme & style selection won't be lost on data updata now (except the selected map/theme/style is deleted ofc). enabling F5 key to reload data :>
sheepluva
parents:
6947
diff
changeset
|
777 |
else |
822f8269e13f
map, theme & style selection won't be lost on data updata now (except the selected map/theme/style is deleted ofc). enabling F5 key to reload data :>
sheepluva
parents:
6947
diff
changeset
|
778 |
setRandomTheme(); |
822f8269e13f
map, theme & style selection won't be lost on data updata now (except the selected map/theme/style is deleted ofc). enabling F5 key to reload data :>
sheepluva
parents:
6947
diff
changeset
|
779 |
} |
822f8269e13f
map, theme & style selection won't be lost on data updata now (except the selected map/theme/style is deleted ofc). enabling F5 key to reload data :>
sheepluva
parents:
6947
diff
changeset
|
780 |
|
822f8269e13f
map, theme & style selection won't be lost on data updata now (except the selected map/theme/style is deleted ofc). enabling F5 key to reload data :>
sheepluva
parents:
6947
diff
changeset
|
781 |
// restore map selection |
8377 | 782 |
if (!m_curMap.isEmpty()) |
7018
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
783 |
intSetMap(m_curMap); |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
784 |
else |
6a1f46c026bf
some tweaks/fixes/etc to the map preview and reload stuff
sheepluva
parents:
7017
diff
changeset
|
785 |
updatePreview(); |
6933
78d194a30520
mapContainer: use DataManager, reload maps after data update (e.g. by DLC)
sheepluva
parents:
6700
diff
changeset
|
786 |
} |
7008
25563f054ef3
fix a previewmap-related QObject::disconnect segfault
sheepluva
parents:
6983
diff
changeset
|
787 |
|
25563f054ef3
fix a previewmap-related QObject::disconnect segfault
sheepluva
parents:
6983
diff
changeset
|
788 |
|
25563f054ef3
fix a previewmap-related QObject::disconnect segfault
sheepluva
parents:
6983
diff
changeset
|
789 |
void HWMapContainer::onPreviewMapDestroyed(QObject * map) |
25563f054ef3
fix a previewmap-related QObject::disconnect segfault
sheepluva
parents:
6983
diff
changeset
|
790 |
{ |
25563f054ef3
fix a previewmap-related QObject::disconnect segfault
sheepluva
parents:
6983
diff
changeset
|
791 |
if (map == pMap) |
25563f054ef3
fix a previewmap-related QObject::disconnect segfault
sheepluva
parents:
6983
diff
changeset
|
792 |
pMap = 0; |
25563f054ef3
fix a previewmap-related QObject::disconnect segfault
sheepluva
parents:
6983
diff
changeset
|
793 |
} |
8377 | 794 |
|
795 |
void HWMapContainer::mapTypeChanged(int index) |
|
796 |
{ |
|
797 |
changeMapType((MapModel::MapType)cType->itemData(index).toInt()); |
|
798 |
} |
|
799 |
||
11809
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
800 |
void HWMapContainer::updateHelpTexts(MapModel::MapType type) |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
801 |
{ |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
802 |
QString randomAll = tr("Randomize the map, theme and seed"); |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
803 |
QString randomNoMap = tr("Randomize the theme and seed"); |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
804 |
QString randomSeed = tr("Randomize the seed"); |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
805 |
QString randomAllPrev = tr("Click to randomize the map, theme and seed"); |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
806 |
QString randomNoMapPrev = tr("Click to randomize the theme and seed"); |
11811
f9a4f4d11c3a
Fix problems with dynamic whats this texts
Wuzzy <almikes@aol.com>
parents:
11809
diff
changeset
|
807 |
QString mfsComplex = QString(tr("Adjust the complexity of the generated map")); |
f9a4f4d11c3a
Fix problems with dynamic whats this texts
Wuzzy <almikes@aol.com>
parents:
11809
diff
changeset
|
808 |
QString mfsFortsDistance = QString(tr("Adjust the distance between forts")); |
11809
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
809 |
switch (type) |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
810 |
{ |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
811 |
case MapModel::GeneratedMap: |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
812 |
case MapModel::GeneratedPerlin: |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
813 |
case MapModel::GeneratedMaze: |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
814 |
mapPreview->setWhatsThis(randomAllPrev); |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
815 |
mapFeatureSize->setWhatsThis(mfsComplex); |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
816 |
btnRandomize->setWhatsThis(randomAll); |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
817 |
break; |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
818 |
case MapModel::MissionMap: |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
819 |
case MapModel::StaticMap: |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
820 |
mapPreview->setWhatsThis(randomAllPrev); |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
821 |
btnRandomize->setWhatsThis(randomAll); |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
822 |
break; |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
823 |
case MapModel::HandDrawnMap: |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
824 |
mapPreview->setWhatsThis(tr("Click to edit")); |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
825 |
btnRandomize->setWhatsThis(randomSeed); |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
826 |
break; |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
827 |
case MapModel::FortsMap: |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
828 |
mapPreview->setWhatsThis(randomNoMapPrev); |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
829 |
mapFeatureSize->setWhatsThis(mfsFortsDistance); |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
830 |
btnRandomize->setWhatsThis(randomNoMap); |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
831 |
break; |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
832 |
default: |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
833 |
break; |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
834 |
} |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
835 |
} |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
836 |
|
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
837 |
|
8377 | 838 |
void HWMapContainer::changeMapType(MapModel::MapType type, const QModelIndex & newMap) |
839 |
{ |
|
840 |
staticMapList->hide(); |
|
841 |
missionMapList->hide(); |
|
842 |
lblMapList->hide(); |
|
843 |
generationStyles->hide(); |
|
844 |
mazeStyles->hide(); |
|
845 |
lblDesc->hide(); |
|
846 |
btnLoadMap->hide(); |
|
847 |
btnEditMap->hide(); |
|
10471
d968b1ac130c
sheepluva and unc0rr didn't like the idea of slider over preview.
nemo
parents:
10465
diff
changeset
|
848 |
mapFeatureSize->show(); |
8377 | 849 |
|
850 |
switch (type) |
|
851 |
{ |
|
852 |
case MapModel::GeneratedMap: |
|
853 |
mapgen = MAPGEN_REGULAR; |
|
854 |
setMapInfo(MapModel::MapInfoRandom); |
|
855 |
lblMapList->setText(tr("Map size:")); |
|
856 |
lblMapList->show(); |
|
857 |
generationStyles->show(); |
|
858 |
break; |
|
859 |
case MapModel::GeneratedMaze: |
|
860 |
mapgen = MAPGEN_MAZE; |
|
861 |
setMapInfo(MapModel::MapInfoMaze); |
|
862 |
lblMapList->setText(tr("Maze style:")); |
|
863 |
lblMapList->show(); |
|
864 |
mazeStyles->show(); |
|
865 |
break; |
|
10391 | 866 |
case MapModel::GeneratedPerlin: |
867 |
mapgen = MAPGEN_PERLIN; |
|
868 |
setMapInfo(MapModel::MapInfoPerlin); |
|
869 |
lblMapList->setText(tr("Style:")); |
|
870 |
lblMapList->show(); |
|
871 |
mazeStyles->show(); |
|
872 |
break; |
|
8377 | 873 |
case MapModel::HandDrawnMap: |
874 |
mapgen = MAPGEN_DRAWN; |
|
875 |
setMapInfo(MapModel::MapInfoDrawn); |
|
876 |
btnLoadMap->show(); |
|
10480 | 877 |
mapFeatureSize->hide(); |
8377 | 878 |
btnEditMap->show(); |
879 |
break; |
|
880 |
case MapModel::MissionMap: |
|
9744 | 881 |
setupMissionMapsView(); |
8377 | 882 |
mapgen = MAPGEN_MAP; |
883 |
missionMapChanged(newMap.isValid() ? newMap : missionMapList->currentIndex()); |
|
884 |
lblMapList->setText(tr("Mission:")); |
|
885 |
lblMapList->show(); |
|
886 |
missionMapList->show(); |
|
10480 | 887 |
mapFeatureSize->hide(); |
8377 | 888 |
lblDesc->setText(m_mapInfo.desc); |
889 |
lblDesc->show(); |
|
890 |
emit mapChanged(m_curMap); |
|
891 |
break; |
|
892 |
case MapModel::StaticMap: |
|
9744 | 893 |
setupStaticMapsView(); |
8377 | 894 |
mapgen = MAPGEN_MAP; |
895 |
staticMapChanged(newMap.isValid() ? newMap : staticMapList->currentIndex()); |
|
896 |
lblMapList->setText(tr("Map:")); |
|
897 |
lblMapList->show(); |
|
10480 | 898 |
mapFeatureSize->hide(); |
8377 | 899 |
staticMapList->show(); |
900 |
emit mapChanged(m_curMap); |
|
901 |
break; |
|
11744
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
10959
diff
changeset
|
902 |
case MapModel::FortsMap: |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
10959
diff
changeset
|
903 |
mapgen = MAPGEN_FORTS; |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
10959
diff
changeset
|
904 |
setMapInfo(MapModel::MapInfoForts); |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
10959
diff
changeset
|
905 |
lblMapList->hide(); |
ac58a063d26a
Added "Forts" to map type selection. This makes the mode easier selectable/discoverable. Also the slider can be used to adjust the distance between forts.
sheepluva
parents:
10959
diff
changeset
|
906 |
break; |
8377 | 907 |
default: |
908 |
break; |
|
909 |
} |
|
910 |
||
8393
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
911 |
// Update theme button size |
10477
b219c5a2317f
Fiddling with slider, unbreak maze. Next to mess around w/ perlin params.
nemo
parents:
10472
diff
changeset
|
912 |
updateThemeButtonSize(); |
8393
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
913 |
|
11809
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
914 |
// Update “What's This?” help texts |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
915 |
updateHelpTexts(type); |
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
916 |
|
8377 | 917 |
// Update cType combobox |
918 |
for (int i = 0; i < cType->count(); i++) |
|
919 |
{ |
|
920 |
if ((MapModel::MapType)cType->itemData(i).toInt() == type) |
|
921 |
{ |
|
922 |
cType->setCurrentIndex(i); |
|
923 |
break; |
|
924 |
} |
|
925 |
} |
|
926 |
||
8467 | 927 |
repaint(); |
928 |
||
8377 | 929 |
emit mapgenChanged(mapgen); |
930 |
} |
|
931 |
||
10480 | 932 |
void HWMapContainer::intSetFeatureSize(int val) |
933 |
{ |
|
934 |
mapFeatureSize->setValue(val); |
|
11809
f412d539284e
Add various “What's This?” texts to multiplayer, net and team editor frontend pages
Wuzzy <almikes@aol.com>
parents:
11785
diff
changeset
|
935 |
updateHelpTexts((MapModel::MapType)cType->itemData(cType->currentIndex()).toInt()); |
10480 | 936 |
emit mapFeatureSizeChanged(val); |
937 |
} |
|
938 |
void HWMapContainer::setFeatureSize(int val) |
|
10471
d968b1ac130c
sheepluva and unc0rr didn't like the idea of slider over preview.
nemo
parents:
10465
diff
changeset
|
939 |
{ |
10477
b219c5a2317f
Fiddling with slider, unbreak maze. Next to mess around w/ perlin params.
nemo
parents:
10472
diff
changeset
|
940 |
m_mapFeatureSize = val; |
10480 | 941 |
intSetFeatureSize(val); |
10477
b219c5a2317f
Fiddling with slider, unbreak maze. Next to mess around w/ perlin params.
nemo
parents:
10472
diff
changeset
|
942 |
//m_mapFeatureSize = val>>2<<2; |
b219c5a2317f
Fiddling with slider, unbreak maze. Next to mess around w/ perlin params.
nemo
parents:
10472
diff
changeset
|
943 |
//if (qAbs(m_prevMapFeatureSize-m_mapFeatureSize) > 4) |
10472
8d04cebedb16
Partially hook up feature size so horrorcat has something to test.
nemo
parents:
10471
diff
changeset
|
944 |
{ |
10477
b219c5a2317f
Fiddling with slider, unbreak maze. Next to mess around w/ perlin params.
nemo
parents:
10472
diff
changeset
|
945 |
m_prevMapFeatureSize = m_mapFeatureSize; |
b219c5a2317f
Fiddling with slider, unbreak maze. Next to mess around w/ perlin params.
nemo
parents:
10472
diff
changeset
|
946 |
updatePreview(); |
10472
8d04cebedb16
Partially hook up feature size so horrorcat has something to test.
nemo
parents:
10471
diff
changeset
|
947 |
} |
10471
d968b1ac130c
sheepluva and unc0rr didn't like the idea of slider over preview.
nemo
parents:
10465
diff
changeset
|
948 |
} |
d968b1ac130c
sheepluva and unc0rr didn't like the idea of slider over preview.
nemo
parents:
10465
diff
changeset
|
949 |
|
d968b1ac130c
sheepluva and unc0rr didn't like the idea of slider over preview.
nemo
parents:
10465
diff
changeset
|
950 |
// unused because I needed the space for the slider |
8393
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
951 |
void HWMapContainer::updateThemeButtonSize() |
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
952 |
{ |
10480 | 953 |
if (m_mapInfo.type != MapModel::StaticMap && m_mapInfo.type != MapModel::HandDrawnMap) |
8393
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
954 |
{ |
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
955 |
btnTheme->setIconSize(QSize(30, 30)); |
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
956 |
btnTheme->setFixedHeight(30); |
11785 | 957 |
btnRandTheme->setFixedHeight(30); |
958 |
btnRandTheme->setIconSize(QSize(24, 24)); |
|
8393
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
959 |
} |
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
960 |
else |
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
961 |
{ |
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
962 |
QSize iconSize = btnTheme->icon().actualSize(QSize(65535, 65535)); |
11785 | 963 |
btnRandTheme->setFixedHeight(64); |
8430
5a5c34a75e1a
Aesthetic improvements to chat widget. Also fixed the ghosting issue in a few areas by using repaint().
dag10
parents:
8424
diff
changeset
|
964 |
btnTheme->setFixedHeight(64); |
8393
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
965 |
btnTheme->setIconSize(iconSize); |
11785 | 966 |
btnRandTheme->setIconSize(QSize(32, 32)); |
8393
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
967 |
} |
8430
5a5c34a75e1a
Aesthetic improvements to chat widget. Also fixed the ghosting issue in a few areas by using repaint().
dag10
parents:
8424
diff
changeset
|
968 |
|
5a5c34a75e1a
Aesthetic improvements to chat widget. Also fixed the ghosting issue in a few areas by using repaint().
dag10
parents:
8424
diff
changeset
|
969 |
repaint(); |
8393
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
970 |
} |
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
971 |
|
8377 | 972 |
void HWMapContainer::showThemePrompt() |
973 |
{ |
|
8475
f605bc59c603
Initial theme selection is now random. Theme prompt now has a search input and no longer uses FlowLayout. (Resolves issue 520)
dag10
parents:
8467
diff
changeset
|
974 |
ThemePrompt prompt(m_themeID, this); |
8377 | 975 |
int theme = prompt.exec() - 1; // Since 0 means canceled, so all indexes are +1'd |
976 |
if (theme < 0) return; |
|
977 |
||
978 |
QModelIndex current = m_themeModel->index(theme, 0); |
|
979 |
updateTheme(current); |
|
980 |
emit themeChanged(m_theme); |
|
981 |
} |
|
982 |
||
983 |
void HWMapContainer::updateTheme(const QModelIndex & current) |
|
984 |
{ |
|
8475
f605bc59c603
Initial theme selection is now random. Theme prompt now has a search input and no longer uses FlowLayout. (Resolves issue 520)
dag10
parents:
8467
diff
changeset
|
985 |
m_theme = selectedTheme = current.data(ThemeModel::ActualNameRole).toString(); |
f605bc59c603
Initial theme selection is now random. Theme prompt now has a search input and no longer uses FlowLayout. (Resolves issue 520)
dag10
parents:
8467
diff
changeset
|
986 |
m_themeID = current.row(); |
f605bc59c603
Initial theme selection is now random. Theme prompt now has a search input and no longer uses FlowLayout. (Resolves issue 520)
dag10
parents:
8467
diff
changeset
|
987 |
QIcon icon = qVariantValue<QIcon>(current.data(Qt::DecorationRole)); |
10471
d968b1ac130c
sheepluva and unc0rr didn't like the idea of slider over preview.
nemo
parents:
10465
diff
changeset
|
988 |
//QSize iconSize = icon.actualSize(QSize(65535, 65535)); |
d968b1ac130c
sheepluva and unc0rr didn't like the idea of slider over preview.
nemo
parents:
10465
diff
changeset
|
989 |
//btnTheme->setFixedHeight(64); |
d968b1ac130c
sheepluva and unc0rr didn't like the idea of slider over preview.
nemo
parents:
10465
diff
changeset
|
990 |
//btnTheme->setIconSize(iconSize); |
8377 | 991 |
btnTheme->setIcon(icon); |
8941 | 992 |
btnTheme->setText(tr("Theme: %1").arg(current.data(Qt::DisplayRole).toString())); |
10477
b219c5a2317f
Fiddling with slider, unbreak maze. Next to mess around w/ perlin params.
nemo
parents:
10472
diff
changeset
|
993 |
updateThemeButtonSize(); |
8377 | 994 |
} |
995 |
||
996 |
void HWMapContainer::staticMapChanged(const QModelIndex & map, const QModelIndex & old) |
|
997 |
{ |
|
998 |
mapChanged(map, 0, old); |
|
999 |
} |
|
1000 |
||
1001 |
void HWMapContainer::missionMapChanged(const QModelIndex & map, const QModelIndex & old) |
|
1002 |
{ |
|
1003 |
mapChanged(map, 1, old); |
|
1004 |
} |
|
1005 |
||
1006 |
// Type: 0 = static, 1 = mission |
|
1007 |
void HWMapContainer::mapChanged(const QModelIndex & map, int type, const QModelIndex & old) |
|
1008 |
{ |
|
1009 |
QListView * mapList; |
|
1010 |
||
1011 |
if (type == 0) mapList = staticMapList; |
|
1012 |
else if (type == 1) mapList = missionMapList; |
|
1013 |
else return; |
|
1014 |
||
1015 |
// Make sure it is a valid index |
|
1016 |
if (!map.isValid()) |
|
1017 |
{ |
|
1018 |
if (old.isValid()) |
|
1019 |
{ |
|
1020 |
mapList->setCurrentIndex(old); |
|
1021 |
mapList->scrollTo(old); |
|
1022 |
} |
|
1023 |
else |
|
1024 |
{ |
|
1025 |
m_mapInfo.type = MapModel::Invalid; |
|
1026 |
updatePreview(); |
|
1027 |
} |
|
1028 |
||
1029 |
return; |
|
1030 |
} |
|
1031 |
||
1032 |
// If map changed, update list selection |
|
1033 |
if (mapList->currentIndex() != map) |
|
1034 |
{ |
|
1035 |
mapList->setCurrentIndex(map); |
|
1036 |
mapList->scrollTo(map); |
|
1037 |
} |
|
1038 |
||
10463 | 1039 |
Q_ASSERT(map.data(Qt::UserRole + 1).canConvert<MapModel::MapInfo>()); // Houston, we have a problem. |
1040 |
setMapInfo(map.data(Qt::UserRole + 1).value<MapModel::MapInfo>()); |
|
8377 | 1041 |
} |
1042 |
||
1043 |
void HWMapContainer::setMapInfo(MapModel::MapInfo mapInfo) |
|
1044 |
{ |
|
1045 |
m_mapInfo = mapInfo; |
|
1046 |
m_curMap = m_mapInfo.name; |
|
1047 |
||
1048 |
// the map has no pre-defined theme, so let's use the selected one |
|
1049 |
if (m_mapInfo.theme.isEmpty()) |
|
1050 |
{ |
|
8393
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
1051 |
if (!selectedTheme.isEmpty()) |
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
1052 |
{ |
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
1053 |
setTheme(selectedTheme); |
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
1054 |
emit themeChanged(selectedTheme); |
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
1055 |
} |
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
1056 |
} |
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
1057 |
else |
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
1058 |
{ |
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
1059 |
setTheme(m_mapInfo.theme); |
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
1060 |
emit themeChanged(m_mapInfo.theme); |
8377 | 1061 |
} |
1062 |
||
1063 |
lblDesc->setText(mapInfo.desc); |
|
1064 |
||
1065 |
updatePreview(); |
|
1066 |
emit mapChanged(m_curMap); |
|
1067 |
} |
|
1068 |
||
1069 |
void HWMapContainer::loadDrawing() |
|
1070 |
{ |
|
1071 |
QString fileName = QFileDialog::getOpenFileName(NULL, tr("Load drawn map"), ".", tr("Drawn Maps") + " (*.hwmap);;" + tr("All files") + " (*)"); |
|
1072 |
||
1073 |
if(fileName.isEmpty()) return; |
|
1074 |
||
1075 |
QFile f(fileName); |
|
1076 |
||
1077 |
if(!f.open(QIODevice::ReadOnly)) |
|
1078 |
{ |
|
1079 |
QMessageBox errorMsg(parentWidget()); |
|
1080 |
errorMsg.setIcon(QMessageBox::Warning); |
|
1081 |
errorMsg.setWindowTitle(QMessageBox::tr("File error")); |
|
1082 |
errorMsg.setText(QMessageBox::tr("Cannot open '%1' for reading").arg(fileName)); |
|
1083 |
errorMsg.setWindowModality(Qt::WindowModal); |
|
1084 |
errorMsg.exec(); |
|
1085 |
} |
|
1086 |
else |
|
1087 |
{ |
|
1088 |
drawMapScene.decode(qUncompress(QByteArray::fromBase64(f.readAll()))); |
|
1089 |
mapDrawingFinished(); |
|
1090 |
} |
|
1091 |
} |
|
1092 |
||
1093 |
void HWMapContainer::showSeedPrompt() |
|
1094 |
{ |
|
1095 |
SeedPrompt prompt(parentWidget()->parentWidget(), getCurrentSeed(), isMaster()); |
|
1096 |
connect(&prompt, SIGNAL(seedSelected(const QString &)), this, SLOT(setNewSeed(const QString &))); |
|
1097 |
prompt.exec(); |
|
1098 |
} |
|
1099 |
||
1100 |
bool HWMapContainer::isMaster() |
|
1101 |
{ |
|
1102 |
return m_master; |
|
1103 |
} |
|
1104 |
||
1105 |
void HWMapContainer::setMaster(bool master) |
|
1106 |
{ |
|
8467 | 1107 |
if (master == m_master) return; |
8377 | 1108 |
m_master = master; |
8434 | 1109 |
|
8377 | 1110 |
foreach (QWidget *widget, m_childWidgets) |
1111 |
widget->setEnabled(master); |
|
1112 |
} |
|
8393
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
1113 |
|
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
1114 |
void HWMapContainer::intSetIconlessTheme(const QString & name) |
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
1115 |
{ |
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
1116 |
if (name.isEmpty()) return; |
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
1117 |
|
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
1118 |
m_theme = name; |
85bd6c7b2641
Can now change theme for static and mission maps.
dag10 <gottlieb.drew@gmail.com>
parents:
8377
diff
changeset
|
1119 |
btnTheme->setIcon(QIcon()); |
8941 | 1120 |
btnTheme->setText(tr("Theme: %1").arg(name)); |
8401
87410ae372f6
Server messages localization using Qt's l10n subsystem:
unc0rr
parents:
8393
diff
changeset
|
1121 |
} |
9744 | 1122 |
|
1123 |
void HWMapContainer::setupMissionMapsView() |
|
1124 |
{ |
|
1125 |
if(m_missionsViewSetup) return; |
|
1126 |
m_missionsViewSetup = true; |
|
1127 |
||
1128 |
m_missionMapModel->loadMaps(); |
|
1129 |
missionMapList->setModel(m_missionMapModel); |
|
1130 |
missionMapList->setEditTriggers(QAbstractItemView::NoEditTriggers); |
|
1131 |
QItemSelectionModel * missionSelectionModel = missionMapList->selectionModel(); |
|
1132 |
connect(missionSelectionModel, |
|
1133 |
SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)), |
|
1134 |
this, |
|
1135 |
SLOT(missionMapChanged(const QModelIndex &, const QModelIndex &))); |
|
1136 |
missionSelectionModel->setCurrentIndex(m_missionMapModel->index(0, 0), QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent); |
|
1137 |
} |
|
1138 |
||
1139 |
void HWMapContainer::setupStaticMapsView() |
|
1140 |
{ |
|
1141 |
if(m_staticViewSetup) return; |
|
1142 |
m_staticViewSetup = true; |
|
1143 |
||
1144 |
m_staticMapModel->loadMaps(); |
|
1145 |
staticMapList->setModel(m_staticMapModel); |
|
1146 |
staticMapList->setEditTriggers(QAbstractItemView::NoEditTriggers); |
|
1147 |
QItemSelectionModel * staticSelectionModel = staticMapList->selectionModel(); |
|
1148 |
connect(staticSelectionModel, |
|
1149 |
SIGNAL(currentRowChanged(const QModelIndex &, const QModelIndex &)), |
|
1150 |
this, |
|
1151 |
SLOT(staticMapChanged(const QModelIndex &, const QModelIndex &))); |
|
1152 |
staticSelectionModel->setCurrentIndex(m_staticMapModel->index(0, 0), QItemSelectionModel::Clear | QItemSelectionModel::SelectCurrent); |
|
1153 |
} |