author | unc0rr |
Sun, 15 Feb 2009 14:38:02 +0000 | |
changeset 1797 | fedd8649fdd9 |
parent 1790 | c84223511ca8 |
child 1802 | dd148e2506e2 |
permissions | -rw-r--r-- |
184 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
883 | 3 |
* Copyright (c) 2006-2008 Igor Ulyanov <iulyanov@gmail.com> |
184 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*/ |
|
18 |
||
19 |
#include <QPushButton> |
|
20 |
#include <QBuffer> |
|
21 |
#include <QUuid> |
|
22 |
#include <QBitmap> |
|
23 |
#include <QPainter> |
|
24 |
#include <QLinearGradient> |
|
25 |
#include <QColor> |
|
249 | 26 |
#include <QTextStream> |
677
9d0bcc3c903a
Save some vertical pixels using fewer margin in HWMapContainer
unc0rr
parents:
530
diff
changeset
|
27 |
#include <QApplication> |
1209 | 28 |
#include <QLabel> |
29 |
#include <QListWidget> |
|
30 |
#include <QVBoxLayout> |
|
1224 | 31 |
#include <QIcon> |
249 | 32 |
|
33 |
#include "hwconsts.h" |
|
788
00720357601f
- Get rid of PageSimpleGame, now pressing 'quick game' just starts round
unc0rr
parents:
682
diff
changeset
|
34 |
#include "mapContainer.h" |
1209 | 35 |
#include "igbox.h" |
184 | 36 |
|
37 |
HWMapContainer::HWMapContainer(QWidget * parent) : |
|
1333
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
38 |
QWidget(parent), |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
39 |
mainLayout(this), |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
40 |
pMap(0) |
184 | 41 |
{ |
1790 | 42 |
hhSmall.load(":/res/hh_small.png"); |
43 |
hhLimit = 18; |
|
1797 | 44 |
templateFilter = 0; |
1790 | 45 |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
46 |
mainLayout.setContentsMargins(QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin), |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
47 |
1, |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
48 |
QApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin), |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
49 |
QApplication::style()->pixelMetric(QStyle::PM_LayoutBottomMargin)); |
1790 | 50 |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
51 |
imageButt = new QPushButton(this); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
52 |
imageButt->setObjectName("imageButt"); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
53 |
imageButt->setFixedSize(256 + 6, 128 + 6); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
54 |
imageButt->setFlat(true); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
55 |
imageButt->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed);//QSizePolicy::Minimum, QSizePolicy::Minimum); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
56 |
mainLayout.addWidget(imageButt, 0, 0, 1, 2); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
57 |
connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomSeed())); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
58 |
connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomTheme())); |
249 | 59 |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
60 |
chooseMap = new QComboBox(this); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
61 |
chooseMap->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
62 |
chooseMap->addItem(QComboBox::tr("generated map...")); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
63 |
for (int i = 0; i < mapList->size(); ++i) { |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
64 |
QString map = (*mapList)[i]; |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
65 |
QFile mapCfgFile( |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
66 |
QString("%1/Maps/%2/map.cfg") |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
67 |
.arg(datadir->absolutePath()) |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
68 |
.arg(map)); |
1790 | 69 |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
70 |
if (mapCfgFile.open(QFile::ReadOnly)) { |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
71 |
QString theme; |
1790 | 72 |
quint32 limit = 0; |
73 |
QList<QVariant> mapInfo; |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
74 |
QTextStream input(&mapCfgFile); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
75 |
input >> theme; |
1790 | 76 |
input >> limit; |
77 |
mapInfo.push_back(theme); |
|
78 |
if (limit) |
|
79 |
mapInfo.push_back(limit); |
|
80 |
else |
|
81 |
mapInfo.push_back(18); |
|
82 |
chooseMap->addItem(map, mapInfo); |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
83 |
mapCfgFile.close(); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
84 |
} |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
85 |
} |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
86 |
|
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
87 |
connect(chooseMap, SIGNAL(currentIndexChanged(int)), this, SLOT(mapChanged(int))); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
88 |
mainLayout.addWidget(chooseMap, 1, 1); |
249 | 89 |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
90 |
QLabel * lblMap = new QLabel(tr("Map"), this); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
91 |
mainLayout.addWidget(lblMap, 1, 0); |
1209 | 92 |
|
93 |
gbThemes = new IconedGroupBox(this); |
|
1248 | 94 |
gbThemes->setTitleTextPadding(60); |
1209 | 95 |
gbThemes->setTitle(tr("Themes")); |
1248 | 96 |
|
97 |
//gbThemes->setStyleSheet("padding: 0px"); // doesn't work - stylesheet is set with icon |
|
1209 | 98 |
mainLayout.addWidget(gbThemes, 0, 2, 2, 1); |
1210 | 99 |
|
1209 | 100 |
QVBoxLayout * gbTLayout = new QVBoxLayout(gbThemes); |
1228 | 101 |
gbTLayout->setContentsMargins(0, 0, 0 ,0); |
102 |
gbTLayout->setSpacing(0); |
|
1209 | 103 |
lwThemes = new QListWidget(this); |
1210 | 104 |
lwThemes->setMinimumHeight(30); |
1248 | 105 |
lwThemes->setFixedWidth(120); |
1211 | 106 |
for (int i = 0; i < Themes->size(); ++i) { |
107 |
QListWidgetItem * lwi = new QListWidgetItem(); |
|
108 |
lwi->setText(Themes->at(i)); |
|
109 |
lwi->setTextAlignment(Qt::AlignHCenter); |
|
110 |
lwThemes->addItem(lwi); |
|
111 |
} |
|
1215 | 112 |
connect(lwThemes, SIGNAL(currentRowChanged(int)), this, SLOT(themeSelected(int))); |
1210 | 113 |
|
1209 | 114 |
gbTLayout->addWidget(lwThemes); |
115 |
lwThemes->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum); |
|
116 |
||
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
117 |
mainLayout.setSizeConstraint(QLayout::SetFixedSize);//SetMinimumSize |
1215 | 118 |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
119 |
setRandomSeed(); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
120 |
setRandomTheme(); |
184 | 121 |
} |
122 |
||
123 |
void HWMapContainer::setImage(const QImage newImage) |
|
124 |
{ |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
125 |
QPixmap px(256, 128); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
126 |
QPixmap pxres(256, 128); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
127 |
QPainter p(&pxres); |
184 | 128 |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
129 |
px.fill(Qt::yellow); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
130 |
QBitmap bm = QBitmap::fromImage(newImage); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
131 |
px.setMask(bm); |
184 | 132 |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
133 |
QLinearGradient linearGrad(QPoint(128, 0), QPoint(128, 128)); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
134 |
linearGrad.setColorAt(1, QColor(0, 0, 192)); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
135 |
linearGrad.setColorAt(0, QColor(66, 115, 225)); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
136 |
p.fillRect(QRect(0, 0, 256, 128), linearGrad); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
137 |
p.drawPixmap(QPoint(0, 0), px); |
184 | 138 |
|
1790 | 139 |
addInfoToPreview(pxres); |
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
140 |
chooseMap->setCurrentIndex(0); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
141 |
pMap = 0; |
249 | 142 |
} |
143 |
||
1790 | 144 |
void HWMapContainer::setHHLimit(int newHHLimit) |
145 |
{ |
|
146 |
hhLimit = newHHLimit; |
|
147 |
} |
|
148 |
||
249 | 149 |
void HWMapContainer::mapChanged(int index) |
150 |
{ |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
151 |
if(!index) { |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
152 |
changeImage(); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
153 |
gbThemes->show(); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
154 |
emit mapChanged("+rnd+"); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
155 |
emit themeChanged(chooseMap->itemData(0).toString()); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
156 |
} else |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
157 |
{ |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
158 |
loadMap(index); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
159 |
gbThemes->hide(); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
160 |
emit mapChanged(chooseMap->currentText()); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
161 |
} |
331 | 162 |
} |
163 |
||
164 |
void HWMapContainer::loadMap(int index) |
|
165 |
{ |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
166 |
QPixmap mapImage; |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
167 |
if(!mapImage.load(datadir->absolutePath() + "/Maps/" + chooseMap->currentText() + "/preview.png")) { |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
168 |
changeImage(); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
169 |
chooseMap->setCurrentIndex(0); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
170 |
return; |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
171 |
} |
1790 | 172 |
|
173 |
hhLimit = chooseMap->itemData(index).toList()[1].toInt(); |
|
174 |
addInfoToPreview(mapImage); |
|
175 |
} |
|
176 |
||
177 |
// Should this add text to identify map size? |
|
178 |
void HWMapContainer::addInfoToPreview(QPixmap image) |
|
179 |
{ |
|
180 |
QPixmap finalImage = QPixmap(image.size()); |
|
181 |
finalImage.fill(QColor(0, 0, 0, 0)); |
|
182 |
||
183 |
QPainter p(&finalImage); |
|
184 |
p.drawPixmap(image.rect(), image); |
|
185 |
//p.setPen(QColor(0xf4,0x9e,0xe9)); |
|
186 |
p.setPen(QColor(0xff,0xcc,0x00)); |
|
187 |
p.setBrush(QColor(0, 0, 0)); |
|
188 |
p.drawRect(image.rect().width() - hhSmall.rect().width() - 28, 3, 40, 20); |
|
189 |
p.setFont(QFont("MS Shell Dlg", 10)); |
|
190 |
p.drawText(image.rect().width() - hhSmall.rect().width() - 14 - (hhLimit > 9 ? 10 : 0), 18, QString::number(hhLimit)); |
|
191 |
p.drawPixmap(image.rect().width() - hhSmall.rect().width() - 5, 5, hhSmall.rect().width(), hhSmall.rect().height(), hhSmall); |
|
192 |
||
193 |
imageButt->setIcon(finalImage); |
|
194 |
imageButt->setIconSize(image.size()); |
|
184 | 195 |
} |
196 |
||
197 |
void HWMapContainer::changeImage() |
|
198 |
{ |
|
1214 | 199 |
pMap = new HWMap(); |
200 |
connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage))); |
|
1790 | 201 |
connect(pMap, SIGNAL(HHLimitReceived(int)), this, SLOT(setHHLimit(int))); |
1797 | 202 |
pMap->getImage(m_seed.toStdString(), templateFilter); |
184 | 203 |
} |
204 |
||
1215 | 205 |
void HWMapContainer::themeSelected(int currentRow) |
206 |
{ |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
207 |
QString theme = Themes->at(currentRow); |
1790 | 208 |
QList<QVariant> mapInfo; |
209 |
mapInfo.push_back(theme); |
|
210 |
mapInfo.push_back(18); |
|
211 |
chooseMap->setItemData(0, mapInfo); |
|
1224 | 212 |
gbThemes->setIcon(QIcon(QString("%1/Themes/%2/icon.png").arg(datadir->absolutePath()).arg(theme))); |
1215 | 213 |
emit themeChanged(theme); |
214 |
} |
|
215 |
||
184 | 216 |
QString HWMapContainer::getCurrentSeed() const |
217 |
{ |
|
218 |
return m_seed; |
|
219 |
} |
|
220 |
||
249 | 221 |
QString HWMapContainer::getCurrentMap() const |
222 |
{ |
|
320 | 223 |
if(!chooseMap->currentIndex()) return QString(); |
249 | 224 |
return chooseMap->currentText(); |
225 |
} |
|
226 |
||
227 |
QString HWMapContainer::getCurrentTheme() const |
|
228 |
{ |
|
1790 | 229 |
return chooseMap->itemData(chooseMap->currentIndex()).toList()[0].toString(); |
230 |
} |
|
231 |
||
232 |
int HWMapContainer::getCurrentHHLimit() const |
|
233 |
{ |
|
234 |
return hhLimit; |
|
249 | 235 |
} |
236 |
||
184 | 237 |
void HWMapContainer::resizeEvent ( QResizeEvent * event ) |
238 |
{ |
|
239 |
//imageButt->setIconSize(imageButt->size()); |
|
240 |
} |
|
320 | 241 |
|
242 |
void HWMapContainer::setSeed(const QString & seed) |
|
243 |
{ |
|
244 |
m_seed = seed; |
|
245 |
changeImage(); |
|
246 |
} |
|
247 |
||
248 |
void HWMapContainer::setMap(const QString & map) |
|
249 |
{ |
|
1333
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
250 |
if(map == "+rnd+") |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
251 |
{ |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
252 |
changeImage(); |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
253 |
return; |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
254 |
} |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
255 |
|
331 | 256 |
int id = chooseMap->findText(map); |
1333
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
257 |
if(id > 0) { |
331 | 258 |
chooseMap->setCurrentIndex(id); |
259 |
loadMap(id); |
|
1333
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
260 |
if (pMap) |
1365 | 261 |
{ |
1333
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
262 |
disconnect(pMap, 0, this, SLOT(setImage(const QImage))); |
1365 | 263 |
pMap = 0; |
264 |
} |
|
331 | 265 |
} |
320 | 266 |
} |
267 |
||
268 |
void HWMapContainer::setTheme(const QString & theme) |
|
269 |
{ |
|
1215 | 270 |
QList<QListWidgetItem *> items = lwThemes->findItems(theme, Qt::MatchExactly); |
271 |
if(items.size()) |
|
272 |
lwThemes->setCurrentItem(items.at(0)); |
|
320 | 273 |
} |
274 |
||
275 |
void HWMapContainer::setRandomSeed() |
|
276 |
{ |
|
277 |
m_seed = QUuid::createUuid().toString(); |
|
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
325
diff
changeset
|
278 |
emit seedChanged(m_seed); |
320 | 279 |
changeImage(); |
280 |
} |
|
1318 | 281 |
|
282 |
void HWMapContainer::setRandomTheme() |
|
283 |
{ |
|
284 |
if(!Themes->size()) return; |
|
285 |
quint32 themeNum = rand() % Themes->size(); |
|
286 |
lwThemes->setCurrentRow(themeNum); |
|
287 |
} |
|
1797 | 288 |
|
289 |
void HWMapContainer::setTemplateFilter(int filter) |
|
290 |
{ |
|
291 |
templateFilter = filter; |
|
292 |
} |