author | sheepluva |
Fri, 27 Apr 2012 22:22:04 +0200 | |
changeset 6939 | 970389573788 |
parent 6938 | 217ed62e872c |
child 6940 | 211aca8c1f4f |
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 |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*/ |
|
18 |
||
19 |
#include <QPushButton> |
|
20 |
#include <QBuffer> |
|
21 |
#include <QUuid> |
|
22 |
#include <QBitmap> |
|
23 |
#include <QPainter> |
|
24 |
#include <QLinearGradient> |
|
25 |
#include <QColor> |
|
249 | 26 |
#include <QTextStream> |
1209 | 27 |
#include <QLabel> |
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
|
28 |
#include <QListView> |
1209 | 29 |
#include <QVBoxLayout> |
1224 | 30 |
#include <QIcon> |
4519 | 31 |
#include <QLineEdit> |
4562 | 32 |
#include <QMessageBox> |
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
|
33 |
#include <QStringListModel> |
249 | 34 |
|
35 |
#include "hwconsts.h" |
|
788
00720357601f
- Get rid of PageSimpleGame, now pressing 'quick game' just starts round
unc0rr
parents:
682
diff
changeset
|
36 |
#include "mapContainer.h" |
1209 | 37 |
#include "igbox.h" |
5252 | 38 |
#include "HWApplication.h" |
184 | 39 |
|
40 |
HWMapContainer::HWMapContainer(QWidget * parent) : |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
41 |
QWidget(parent), |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
42 |
mainLayout(this), |
3133 | 43 |
pMap(0), |
4562 | 44 |
mapgen(MAPGEN_REGULAR) |
184 | 45 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
46 |
hhSmall.load(":/res/hh_small.png"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
47 |
hhLimit = 18; |
1797 | 48 |
templateFilter = 0; |
2377 | 49 |
|
5252 | 50 |
mainLayout.setContentsMargins(HWApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin), |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
51 |
1, |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
52 |
HWApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin), |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
53 |
HWApplication::style()->pixelMetric(QStyle::PM_LayoutBottomMargin)); |
2377 | 54 |
|
4557
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
55 |
QWidget* mapWidget = new QWidget(this); |
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
56 |
mainLayout.addWidget(mapWidget, 0, 0, Qt::AlignHCenter); |
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
57 |
|
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
58 |
QGridLayout* mapLayout = new QGridLayout(mapWidget); |
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
59 |
mapLayout->setMargin(0); |
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
60 |
|
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
61 |
imageButt = new QPushButton(mapWidget); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
62 |
imageButt->setObjectName("imageButt"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
63 |
imageButt->setFixedSize(256 + 6, 128 + 6); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
64 |
imageButt->setFlat(true); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
65 |
imageButt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);//QSizePolicy::Minimum, QSizePolicy::Minimum); |
4557
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
66 |
mapLayout->addWidget(imageButt, 0, 0, 1, 2); |
4337 | 67 |
connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomMap())); |
249 | 68 |
|
4557
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
69 |
chooseMap = new QComboBox(mapWidget); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
70 |
chooseMap->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
71 |
m_mapModel = DataManager::instance().mapModel(); |
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
|
72 |
chooseMap->setEditable(false); |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
73 |
chooseMap->setModel(m_mapModel); |
4487 | 74 |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
75 |
// update model views after model changes (to e.g. re-adjust separators) |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
76 |
connect(&DataManager::instance(), SIGNAL(updated()), this, SLOT(updateModelViews())); |
2377 | 77 |
|
4557
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
78 |
mapLayout->addWidget(chooseMap, 1, 1); |
249 | 79 |
|
4557
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
80 |
QLabel * lblMap = new QLabel(tr("Map"), mapWidget); |
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
81 |
mapLayout->addWidget(lblMap, 1, 0); |
1209 | 82 |
|
4557
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
83 |
lblFilter = new QLabel(tr("Filter"), mapWidget); |
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
84 |
mapLayout->addWidget(lblFilter, 2, 0); |
1802 | 85 |
|
4941 | 86 |
cbTemplateFilter = new QComboBox(mapWidget); |
87 |
cbTemplateFilter->addItem(tr("All"), 0); |
|
88 |
cbTemplateFilter->addItem(tr("Small"), 1); |
|
89 |
cbTemplateFilter->addItem(tr("Medium"), 2); |
|
90 |
cbTemplateFilter->addItem(tr("Large"), 3); |
|
91 |
cbTemplateFilter->addItem(tr("Cavern"), 4); |
|
92 |
cbTemplateFilter->addItem(tr("Wacky"), 5); |
|
93 |
mapLayout->addWidget(cbTemplateFilter, 2, 1); |
|
1802 | 94 |
|
4941 | 95 |
connect(cbTemplateFilter, SIGNAL(activated(int)), this, SLOT(setTemplateFilter(int))); |
1802 | 96 |
|
4557
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
97 |
maze_size_label = new QLabel(tr("Type"), mapWidget); |
5434
99078dea3a8f
fix wrong location of "Type"-label in map-selection
sheepluva
parents:
5289
diff
changeset
|
98 |
mapLayout->addWidget(maze_size_label, 2, 0); |
3133 | 99 |
maze_size_label->hide(); |
4941 | 100 |
cbMazeSize = new QComboBox(mapWidget); |
101 |
cbMazeSize->addItem(tr("Small tunnels"), 0); |
|
102 |
cbMazeSize->addItem(tr("Medium tunnels"), 1); |
|
103 |
cbMazeSize->addItem(tr("Large tunnels"), 2); |
|
104 |
cbMazeSize->addItem(tr("Small floating islands"), 3); |
|
105 |
cbMazeSize->addItem(tr("Medium floating islands"), 4); |
|
106 |
cbMazeSize->addItem(tr("Large floating islands"), 5); |
|
107 |
cbMazeSize->setCurrentIndex(1); |
|
4562 | 108 |
|
4941 | 109 |
mapLayout->addWidget(cbMazeSize, 2, 1); |
110 |
cbMazeSize->hide(); |
|
111 |
connect(cbMazeSize, SIGNAL(activated(int)), this, SLOT(setMazeSize(int))); |
|
3133 | 112 |
|
4557
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
113 |
gbThemes = new IconedGroupBox(mapWidget); |
4701 | 114 |
gbThemes->setTitleTextPadding(80); |
115 |
gbThemes->setContentTopPadding(15); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
116 |
gbThemes->setTitle(tr("Themes")); |
1248 | 117 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
118 |
//gbThemes->setStyleSheet("padding: 0px"); // doesn't work - stylesheet is set with icon |
4557
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
119 |
mapLayout->addWidget(gbThemes, 0, 2, 3, 1); |
2377 | 120 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
121 |
QVBoxLayout * gbTLayout = new QVBoxLayout(gbThemes); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
122 |
gbTLayout->setContentsMargins(0, 0, 0 ,0); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
123 |
gbTLayout->setSpacing(0); |
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
|
124 |
lvThemes = new QListView(mapWidget); |
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5252
diff
changeset
|
125 |
lvThemes->setMinimumHeight(30); |
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5252
diff
changeset
|
126 |
lvThemes->setFixedWidth(140); |
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6933
diff
changeset
|
127 |
m_themeModel = DataManager::instance().themeModel(); |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6933
diff
changeset
|
128 |
lvThemes->setModel(m_themeModel); |
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
|
129 |
lvThemes->setIconSize(QSize(16, 16)); |
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5252
diff
changeset
|
130 |
lvThemes->setEditTriggers(QListView::NoEditTriggers); |
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5252
diff
changeset
|
131 |
|
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5252
diff
changeset
|
132 |
connect(lvThemes->selectionModel(), SIGNAL(currentRowChanged( const QModelIndex &, const QModelIndex &)), this, SLOT(themeSelected( const QModelIndex &, const QModelIndex &))); |
1802 | 133 |
|
134 |
// override default style to tighten up theme scroller |
|
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
|
135 |
lvThemes->setStyleSheet(QString( |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
136 |
"QListView{" |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
137 |
"border: solid;" |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
138 |
"border-width: 0px;" |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
139 |
"border-radius: 0px;" |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
140 |
"border-color: transparent;" |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
141 |
"background-color: #0d0544;" |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
142 |
"color: #ffcc00;" |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
143 |
"font: bold 13px;" |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
144 |
"}" |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
145 |
) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
146 |
); |
2377 | 147 |
|
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
|
148 |
gbTLayout->addWidget(lvThemes); |
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5252
diff
changeset
|
149 |
lvThemes->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum); |
2377 | 150 |
|
4557
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
151 |
mapLayout->setSizeConstraint(QLayout::SetFixedSize); |
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
152 |
|
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
153 |
QWidget* seedWidget = new QWidget(this); |
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
154 |
mainLayout.addWidget(seedWidget, 1, 0); |
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
155 |
|
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
156 |
QGridLayout* seedLayout = new QGridLayout(seedWidget); |
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
157 |
seedLayout->setMargin(0); |
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
158 |
|
4699 | 159 |
seedLabel = new QLabel(tr("Seed"), seedWidget); |
4557
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
160 |
seedLayout->addWidget(seedLabel, 3, 0); |
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
161 |
seedEdit = new QLineEdit(seedWidget); |
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
162 |
seedEdit->setMaxLength(54); |
4550
d300ea498486
added set button to seed edit so maps won't regenerate as often
Henek
parents:
4537
diff
changeset
|
163 |
connect(seedEdit, SIGNAL(returnPressed()), this, SLOT(seedEdited())); |
4557
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
164 |
seedLayout->addWidget(seedEdit, 3, 1); |
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
165 |
seedLayout->setColumnStretch(1, 5); |
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
166 |
seedSet = new QPushButton(seedWidget); |
4699 | 167 |
seedSet->setText(QPushButton::tr("more")); |
4550
d300ea498486
added set button to seed edit so maps won't regenerate as often
Henek
parents:
4537
diff
changeset
|
168 |
connect(seedSet, SIGNAL(clicked()), this, SLOT(seedEdited())); |
4557
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
169 |
seedLayout->setColumnStretch(2, 1); |
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
170 |
seedLayout->addWidget(seedSet, 3, 2); |
1215 | 171 |
|
4699 | 172 |
seedLabel->setVisible(false); |
173 |
seedEdit->setVisible(false); |
|
174 |
||
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
175 |
setRandomSeed(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
176 |
setRandomTheme(); |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
177 |
|
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
178 |
chooseMap->setCurrentIndex(0); |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
179 |
mapChanged(0); |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
180 |
connect(chooseMap, SIGNAL(activated(int)), this, SLOT(mapChanged(int))); |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
181 |
|
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
182 |
updateModelViews(); |
184 | 183 |
} |
184 |
||
185 |
void HWMapContainer::setImage(const QImage newImage) |
|
186 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
187 |
QPixmap px(256, 128); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
188 |
QPixmap pxres(256, 128); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
189 |
QPainter p(&pxres); |
184 | 190 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
191 |
px.fill(Qt::yellow); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
192 |
QBitmap bm = QBitmap::fromImage(newImage); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
193 |
px.setMask(bm); |
184 | 194 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
195 |
QLinearGradient linearGrad(QPoint(128, 0), QPoint(128, 128)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
196 |
linearGrad.setColorAt(1, QColor(0, 0, 192)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
197 |
linearGrad.setColorAt(0, QColor(66, 115, 225)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
198 |
p.fillRect(QRect(0, 0, 256, 128), linearGrad); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
199 |
p.drawPixmap(QPoint(0, 0), px); |
184 | 200 |
|
1790 | 201 |
addInfoToPreview(pxres); |
4561 | 202 |
//chooseMap->setCurrentIndex(mapgen); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
203 |
pMap = 0; |
249 | 204 |
} |
205 |
||
1790 | 206 |
void HWMapContainer::setHHLimit(int newHHLimit) |
207 |
{ |
|
208 |
hhLimit = newHHLimit; |
|
209 |
} |
|
210 |
||
249 | 211 |
void HWMapContainer::mapChanged(int index) |
212 |
{ |
|
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
|
213 |
Q_ASSERT(chooseMap->itemData(index, Qt::UserRole + 1).canConvert<MapModel::MapInfo>()); |
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
|
214 |
m_mapInfo = chooseMap->itemData(chooseMap->currentIndex(), Qt::UserRole + 1).value<MapModel::MapInfo>(); |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
215 |
|
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
216 |
switch(m_mapInfo.type) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
217 |
{ |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
218 |
case MapModel::GeneratedMap: |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
219 |
mapgen = MAPGEN_REGULAR; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
220 |
updatePreview(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
221 |
gbThemes->show(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
222 |
lblFilter->show(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
223 |
cbTemplateFilter->show(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
224 |
maze_size_label->hide(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
225 |
cbMazeSize->hide(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
226 |
break; |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
227 |
case MapModel::GeneratedMaze: |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
228 |
mapgen = MAPGEN_MAZE; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
229 |
updatePreview(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
230 |
gbThemes->show(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
231 |
lblFilter->hide(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
232 |
cbTemplateFilter->hide(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
233 |
maze_size_label->show(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
234 |
cbMazeSize->show(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
235 |
break; |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
236 |
case MapModel::HandDrawnMap: |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
237 |
mapgen = MAPGEN_DRAWN; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
238 |
updatePreview(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
239 |
gbThemes->show(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
240 |
lblFilter->hide(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
241 |
cbTemplateFilter->hide(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
242 |
maze_size_label->hide(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
243 |
cbMazeSize->hide(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
244 |
break; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
245 |
default: |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
246 |
mapgen = MAPGEN_MAP; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
247 |
updatePreview(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
248 |
gbThemes->hide(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
249 |
lblFilter->hide(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
250 |
cbTemplateFilter->hide(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
251 |
maze_size_label->hide(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
252 |
cbMazeSize->hide(); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
253 |
} |
5794 | 254 |
|
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
|
255 |
if (m_mapInfo.theme.isEmpty()) |
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
|
256 |
emit themeChanged(lvThemes->currentIndex().data().toString()); |
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
|
257 |
emit mapChanged(m_mapInfo.name); |
5794 | 258 |
emit mapgenChanged(mapgen); |
331 | 259 |
} |
260 |
||
1790 | 261 |
// Should this add text to identify map size? |
262 |
void HWMapContainer::addInfoToPreview(QPixmap image) |
|
263 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
264 |
QPixmap finalImage = QPixmap(image.size()); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
265 |
finalImage.fill(QColor(0, 0, 0, 0)); |
2377 | 266 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
267 |
QPainter p(&finalImage); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
268 |
p.drawPixmap(image.rect(), image); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
269 |
//p.setPen(QColor(0xf4,0x9e,0xe9)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
270 |
p.setPen(QColor(0xff,0xcc,0x00)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
271 |
p.setBrush(QColor(0, 0, 0)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
272 |
p.drawRect(image.rect().width() - hhSmall.rect().width() - 28, 3, 40, 20); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
273 |
p.setFont(QFont("MS Shell Dlg", 10)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
274 |
p.drawText(image.rect().width() - hhSmall.rect().width() - 14 - (hhLimit > 9 ? 10 : 0), 18, QString::number(hhLimit)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
275 |
p.drawPixmap(image.rect().width() - hhSmall.rect().width() - 5, 5, hhSmall.rect().width(), hhSmall.rect().height(), hhSmall); |
1790 | 276 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
277 |
imageButt->setIcon(finalImage); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
278 |
imageButt->setIconSize(image.size()); |
184 | 279 |
} |
280 |
||
4562 | 281 |
void HWMapContainer::askForGeneratedPreview() |
184 | 282 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
283 |
if (pMap) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
284 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
285 |
disconnect(pMap, 0, this, SLOT(setImage(const QImage))); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
286 |
disconnect(pMap, 0, this, SLOT(setHHLimit(int))); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
287 |
pMap = 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
288 |
} |
2021 | 289 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
290 |
pMap = new HWMap(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
291 |
connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage))); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
292 |
connect(pMap, SIGNAL(HHLimitReceived(int)), this, SLOT(setHHLimit(int))); |
4562 | 293 |
pMap->getImage(m_seed, |
294 |
getTemplateFilter(), |
|
295 |
get_mapgen(), |
|
4941 | 296 |
getMazeSize(), |
4562 | 297 |
getDrawnMapData() |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
298 |
); |
184 | 299 |
} |
300 |
||
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
|
301 |
void HWMapContainer::themeSelected(const QModelIndex & current, const QModelIndex &) |
1215 | 302 |
{ |
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
|
303 |
m_mapInfo.theme = current.data().toString(); |
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
|
304 |
|
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5252
diff
changeset
|
305 |
gbThemes->setIcon(qVariantValue<QIcon>(current.data(Qt::UserRole))); |
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
|
306 |
emit themeChanged(m_mapInfo.theme); |
1215 | 307 |
} |
308 |
||
184 | 309 |
QString HWMapContainer::getCurrentSeed() const |
310 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
311 |
return m_seed; |
184 | 312 |
} |
313 |
||
249 | 314 |
QString HWMapContainer::getCurrentMap() const |
315 |
{ |
|
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
|
316 |
if(chooseMap->currentIndex() < MAPGEN_MAP) return QString(); |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
317 |
return(m_mapInfo.name); |
249 | 318 |
} |
319 |
||
320 |
QString HWMapContainer::getCurrentTheme() const |
|
321 |
{ |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
322 |
return(m_mapInfo.theme); |
3008 | 323 |
} |
324 |
||
325 |
bool HWMapContainer::getCurrentIsMission() const |
|
326 |
{ |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
327 |
return(m_mapInfo.type == MapModel::MissionMap); |
1790 | 328 |
} |
329 |
||
330 |
int HWMapContainer::getCurrentHHLimit() const |
|
331 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
332 |
return hhLimit; |
249 | 333 |
} |
334 |
||
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
|
335 |
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
|
336 |
{ |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
337 |
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
|
338 |
} |
1dd97c710f5a
added general scripts to multiplayer and added option for scripts to allow user set schemes or weapon sets.
Henek
parents:
4511
diff
changeset
|
339 |
|
1dd97c710f5a
added general scripts to multiplayer and added option for scripts to allow user set schemes or weapon sets.
Henek
parents:
4511
diff
changeset
|
340 |
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
|
341 |
{ |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
342 |
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
|
343 |
} |
1dd97c710f5a
added general scripts to multiplayer and added option for scripts to allow user set schemes or weapon sets.
Henek
parents:
4511
diff
changeset
|
344 |
|
1802 | 345 |
quint32 HWMapContainer::getTemplateFilter() const |
346 |
{ |
|
4941 | 347 |
return cbTemplateFilter->itemData(cbTemplateFilter->currentIndex()).toInt(); |
1802 | 348 |
} |
349 |
||
184 | 350 |
void HWMapContainer::resizeEvent ( QResizeEvent * event ) |
351 |
{ |
|
4560
5d6c7f88db73
- Some work on drawMap widget and scene to allow undo, clear, save and load operations
unc0rr
parents:
4557
diff
changeset
|
352 |
Q_UNUSED(event); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
353 |
//imageButt->setIconSize(imageButt->size()); |
184 | 354 |
} |
320 | 355 |
|
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
|
356 |
void HWMapContainer::intSetSeed(const QString & seed) |
320 | 357 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
358 |
m_seed = seed; |
4519 | 359 |
if (seed != seedEdit->text()) |
360 |
seedEdit->setText(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
|
361 |
} |
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
|
362 |
|
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
|
363 |
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
|
364 |
{ |
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
|
365 |
intSetSeed(seed); |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
366 |
if ((m_mapInfo.type == MapModel::GeneratedMap) || (m_mapInfo.type == MapModel::GeneratedMaze)) |
4562 | 367 |
updatePreview(); |
320 | 368 |
} |
369 |
||
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
|
370 |
void HWMapContainer::intSetMap(const QString & map) |
320 | 371 |
{ |
3008 | 372 |
int id = 0; |
373 |
for(int i = 0; i < chooseMap->count(); i++) |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
374 |
{ |
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
|
375 |
// skip separators |
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
|
376 |
if (chooseMap->itemData(i, Qt::AccessibleDescriptionRole) == QLatin1String("separator")) |
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
|
377 |
continue; |
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
|
378 |
Q_ASSERT(chooseMap->itemData(i, Qt::UserRole + 1).canConvert<MapModel::MapInfo>()); |
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
|
379 |
MapModel::MapInfo mapInfo = chooseMap->itemData(i, Qt::UserRole + 1).value<MapModel::MapInfo>(); |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
380 |
|
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
|
381 |
if (mapInfo.name == map) |
3008 | 382 |
{ |
383 |
id = i; |
|
384 |
break; |
|
385 |
} |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
386 |
} |
3008 | 387 |
|
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
388 |
if(id > 0) |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
389 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
390 |
if (pMap) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
391 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
392 |
disconnect(pMap, 0, this, SLOT(setImage(const QImage))); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
393 |
disconnect(pMap, 0, this, SLOT(setHHLimit(int))); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
394 |
pMap = 0; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
395 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
396 |
chooseMap->setCurrentIndex(id); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
397 |
} |
320 | 398 |
} |
399 |
||
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
|
400 |
void HWMapContainer::setMap(const QString &map) |
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
|
401 |
{ |
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
|
402 |
intSetMap(map); |
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
|
403 |
updatePreview(); |
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
|
404 |
} |
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
|
405 |
|
320 | 406 |
void HWMapContainer::setTheme(const QString & theme) |
407 |
{ |
|
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6933
diff
changeset
|
408 |
QModelIndexList mdl = m_themeModel->match(m_themeModel->index(0), Qt::DisplayRole, 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
|
409 |
|
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5252
diff
changeset
|
410 |
if(mdl.size()) |
9d18b61bd3eb
- Implement ThemesModel (load theme icons once, store in memory, don't reload from disk every time selection changes)
unc0rr
parents:
5252
diff
changeset
|
411 |
lvThemes->setCurrentIndex(mdl.at(0)); |
320 | 412 |
} |
4562 | 413 |
|
4337 | 414 |
void HWMapContainer::setRandomMap() |
415 |
{ |
|
4419 | 416 |
setRandomSeed(); |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
417 |
switch(m_mapInfo.type) |
4337 | 418 |
{ |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
419 |
case MapModel::GeneratedMap: |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
420 |
case MapModel::GeneratedMaze: |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
421 |
setRandomTheme(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
422 |
break; |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
423 |
case MapModel::HandDrawnMap: |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
424 |
emit drawMapRequested(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
425 |
break; |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
426 |
case MapModel::MissionMap: |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
427 |
setRandomMission(); |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
428 |
break; |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
429 |
case MapModel::StaticMap: |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
430 |
setRandomStatic(); |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
431 |
break; |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
432 |
case MapModel::Invalid: |
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
433 |
Q_ASSERT(false); |
4337 | 434 |
} |
435 |
} |
|
436 |
||
437 |
void HWMapContainer::setRandomStatic() |
|
438 |
{ |
|
4566 | 439 |
int i = MAPGEN_MAP + 3 + numMissions + rand() % (chooseMap->count() - MAPGEN_MAP - 3 - numMissions); |
440 |
chooseMap->setCurrentIndex(i); |
|
5993
412ada3d2041
randomly selected static/mission maps weren't properly reported to others in room (only new seed was)
sheepluva
parents:
5795
diff
changeset
|
441 |
mapChanged(i); |
4337 | 442 |
} |
443 |
||
444 |
void HWMapContainer::setRandomMission() |
|
445 |
{ |
|
4566 | 446 |
int i = MAPGEN_MAP + 2 + rand() % numMissions; |
447 |
chooseMap->setCurrentIndex(i); |
|
5993
412ada3d2041
randomly selected static/mission maps weren't properly reported to others in room (only new seed was)
sheepluva
parents:
5795
diff
changeset
|
448 |
mapChanged(i); |
4337 | 449 |
} |
320 | 450 |
|
451 |
void HWMapContainer::setRandomSeed() |
|
452 |
{ |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
453 |
setSeed(QUuid::createUuid().toString()); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2377
diff
changeset
|
454 |
emit seedChanged(m_seed); |
320 | 455 |
} |
1318 | 456 |
|
457 |
void HWMapContainer::setRandomTheme() |
|
458 |
{ |
|
6937
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6933
diff
changeset
|
459 |
if(!m_themeModel->rowCount()) return; |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6933
diff
changeset
|
460 |
quint32 themeNum = rand() % m_themeModel->rowCount(); |
7f77fa908a4e
messing with the theme model a bit (gets now auto-updated after DLC download too)
sheepluva
parents:
6933
diff
changeset
|
461 |
lvThemes->setCurrentIndex(m_themeModel->index(themeNum)); |
1318 | 462 |
} |
1797 | 463 |
|
4941 | 464 |
void HWMapContainer::intSetTemplateFilter(int filter) |
465 |
{ |
|
466 |
cbTemplateFilter->setCurrentIndex(filter); |
|
467 |
emit newTemplateFilter(filter); |
|
468 |
} |
|
469 |
||
1797 | 470 |
void HWMapContainer::setTemplateFilter(int filter) |
471 |
{ |
|
4941 | 472 |
intSetTemplateFilter(filter); |
4562 | 473 |
updatePreview(); |
1802 | 474 |
} |
475 |
||
3133 | 476 |
MapGenerator HWMapContainer::get_mapgen(void) const |
477 |
{ |
|
478 |
return mapgen; |
|
479 |
} |
|
480 |
||
4941 | 481 |
int HWMapContainer::getMazeSize(void) const |
3133 | 482 |
{ |
4941 | 483 |
return cbMazeSize->currentIndex(); |
3133 | 484 |
} |
485 |
||
4941 | 486 |
void HWMapContainer::intSetMazeSize(int size) |
3133 | 487 |
{ |
4941 | 488 |
cbMazeSize->setCurrentIndex(size); |
489 |
emit mazeSizeChanged(size); |
|
490 |
} |
|
491 |
||
492 |
void HWMapContainer::setMazeSize(int size) |
|
493 |
{ |
|
494 |
intSetMazeSize(size); |
|
4562 | 495 |
updatePreview(); |
3133 | 496 |
} |
497 |
||
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
|
498 |
void HWMapContainer::intSetMapgen(MapGenerator m) |
3133 | 499 |
{ |
500 |
mapgen = m; |
|
5793
401ab167bd9f
This should be a real fix (7643cbb88f09 reverted). Not tested.
unc0rr
parents:
5789
diff
changeset
|
501 |
|
401ab167bd9f
This should be a real fix (7643cbb88f09 reverted). Not tested.
unc0rr
parents:
5789
diff
changeset
|
502 |
if(m != MAPGEN_MAP) |
401ab167bd9f
This should be a real fix (7643cbb88f09 reverted). Not tested.
unc0rr
parents:
5789
diff
changeset
|
503 |
chooseMap->setCurrentIndex(m); |
401ab167bd9f
This should be a real fix (7643cbb88f09 reverted). Not tested.
unc0rr
parents:
5789
diff
changeset
|
504 |
|
3133 | 505 |
emit mapgenChanged(m); |
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
|
506 |
} |
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
|
507 |
|
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
|
508 |
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
|
509 |
{ |
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
|
510 |
intSetMapgen(m); |
4562 | 511 |
updatePreview(); |
3133 | 512 |
} |
4489 | 513 |
|
4537 | 514 |
void HWMapContainer::setDrawnMapData(const QByteArray & ar) |
515 |
{ |
|
516 |
drawMapScene.decode(ar); |
|
4562 | 517 |
updatePreview(); |
4537 | 518 |
} |
519 |
||
4489 | 520 |
QByteArray HWMapContainer::getDrawnMapData() |
521 |
{ |
|
4520
e7882bd1a894
Allow to draw maps in frontend and play them (only locally, some bugs to fix)
unc0rr
parents:
4519
diff
changeset
|
522 |
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
|
523 |
} |
4519 | 524 |
|
4550
d300ea498486
added set button to seed edit so maps won't regenerate as often
Henek
parents:
4537
diff
changeset
|
525 |
void HWMapContainer::seedEdited() |
4519 | 526 |
{ |
4699 | 527 |
if (seedLabel->isVisible() == false ) |
528 |
{ |
|
529 |
seedLabel->setVisible(true); |
|
530 |
seedEdit->setVisible(true); |
|
531 |
seedSet->setText(tr("Set")); |
|
532 |
return; |
|
533 |
} |
|
534 |
||
4557
4004bef2aa9d
fix layout in game config widget as per nemo's request
Henek
parents:
4550
diff
changeset
|
535 |
if (seedEdit->text().isEmpty()) |
4519 | 536 |
seedEdit->setText(m_seed); |
537 |
else |
|
538 |
{ |
|
4550
d300ea498486
added set button to seed edit so maps won't regenerate as often
Henek
parents:
4537
diff
changeset
|
539 |
setSeed(seedEdit->text()); |
d300ea498486
added set button to seed edit so maps won't regenerate as often
Henek
parents:
4537
diff
changeset
|
540 |
emit seedChanged(seedEdit->text()); |
4519 | 541 |
} |
542 |
} |
|
4520
e7882bd1a894
Allow to draw maps in frontend and play them (only locally, some bugs to fix)
unc0rr
parents:
4519
diff
changeset
|
543 |
|
e7882bd1a894
Allow to draw maps in frontend and play them (only locally, some bugs to fix)
unc0rr
parents:
4519
diff
changeset
|
544 |
DrawMapScene * HWMapContainer::getDrawMapScene() |
e7882bd1a894
Allow to draw maps in frontend and play them (only locally, some bugs to fix)
unc0rr
parents:
4519
diff
changeset
|
545 |
{ |
e7882bd1a894
Allow to draw maps in frontend and play them (only locally, some bugs to fix)
unc0rr
parents:
4519
diff
changeset
|
546 |
return &drawMapScene; |
e7882bd1a894
Allow to draw maps in frontend and play them (only locally, some bugs to fix)
unc0rr
parents:
4519
diff
changeset
|
547 |
} |
4525 | 548 |
|
549 |
void HWMapContainer::mapDrawingFinished() |
|
550 |
{ |
|
4526 | 551 |
emit drawnMapChanged(getDrawnMapData()); |
4525 | 552 |
|
4562 | 553 |
updatePreview(); |
4550
d300ea498486
added set button to seed edit so maps won't regenerate as often
Henek
parents:
4537
diff
changeset
|
554 |
} |
4562 | 555 |
|
556 |
void HWMapContainer::updatePreview() |
|
557 |
{ |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
558 |
switch(m_mapInfo.type) |
4562 | 559 |
{ |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
560 |
case MapModel::GeneratedMap: |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
561 |
askForGeneratedPreview(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
562 |
break; |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
563 |
case MapModel::GeneratedMaze: |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
564 |
askForGeneratedPreview(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
565 |
break; |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
566 |
case MapModel::HandDrawnMap: |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
567 |
askForGeneratedPreview(); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
568 |
break; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
569 |
default: |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
570 |
QPixmap mapImage; |
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
|
571 |
bool success = mapImage.load( |
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
|
572 |
DataManager::instance().findFileForRead( |
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
|
573 |
"Maps/" + m_mapInfo.name + "/preview.png") |
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
|
574 |
); |
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
|
575 |
|
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
|
576 |
if(!success) |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
577 |
{ |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
578 |
imageButt->setIcon(QIcon()); |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
579 |
return; |
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
580 |
} |
4562 | 581 |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
582 |
hhLimit = m_mapInfo.limit; |
6616
f77bb02b669f
astyle -C -S -L -N --style=allman --recursive "QTfrontend/*.cpp" "QTfrontend/*.h"
nemo
parents:
6157
diff
changeset
|
583 |
addInfoToPreview(mapImage); |
4562 | 584 |
} |
585 |
} |
|
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
|
586 |
|
4941 | 587 |
void HWMapContainer::setAllMapParameters(const QString &map, MapGenerator m, int mazesize, const QString &seed, int tmpl) |
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
|
588 |
{ |
4941 | 589 |
intSetMap(map); |
5793
401ab167bd9f
This should be a real fix (7643cbb88f09 reverted). Not tested.
unc0rr
parents:
5789
diff
changeset
|
590 |
intSetMapgen(m); |
4941 | 591 |
intSetMazeSize(mazesize); |
592 |
intSetSeed(seed); |
|
593 |
intSetTemplateFilter(tmpl); |
|
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
|
594 |
|
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
|
595 |
updatePreview(); |
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
|
596 |
} |
6933
78d194a30520
mapContainer: use DataManager, reload maps after data update (e.g. by DLC)
sheepluva
parents:
6700
diff
changeset
|
597 |
|
78d194a30520
mapContainer: use DataManager, reload maps after data update (e.g. by DLC)
sheepluva
parents:
6700
diff
changeset
|
598 |
|
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
599 |
void HWMapContainer::updateModelViews() |
6933
78d194a30520
mapContainer: use DataManager, reload maps after data update (e.g. by DLC)
sheepluva
parents:
6700
diff
changeset
|
600 |
{ |
6938
217ed62e872c
MapModel, various cleanups. TODO/FIXME: QComboBox separator not working with custom models
sheepluva
parents:
6937
diff
changeset
|
601 |
numMissions = m_mapModel->missionCount(); |
6933
78d194a30520
mapContainer: use DataManager, reload maps after data update (e.g. by DLC)
sheepluva
parents:
6700
diff
changeset
|
602 |
|
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
|
603 |
if (!m_mapInfo.name.isEmpty()) |
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
|
604 |
intSetMap(m_mapInfo.name); |
6933
78d194a30520
mapContainer: use DataManager, reload maps after data update (e.g. by DLC)
sheepluva
parents:
6700
diff
changeset
|
605 |
} |