author | unc0rr |
Sat, 14 Feb 2009 16:24:20 +0000 | |
changeset 1790 | c84223511ca8 |
parent 1366 | eba12c22f8ca |
child 1797 | fedd8649fdd9 |
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; |
|
44 |
||
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
45 |
mainLayout.setContentsMargins(QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin), |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
46 |
1, |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
47 |
QApplication::style()->pixelMetric(QStyle::PM_LayoutRightMargin), |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
48 |
QApplication::style()->pixelMetric(QStyle::PM_LayoutBottomMargin)); |
1790 | 49 |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
50 |
imageButt = new QPushButton(this); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
51 |
imageButt->setObjectName("imageButt"); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
52 |
imageButt->setFixedSize(256 + 6, 128 + 6); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
53 |
imageButt->setFlat(true); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
54 |
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
|
55 |
mainLayout.addWidget(imageButt, 0, 0, 1, 2); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
56 |
connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomSeed())); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
57 |
connect(imageButt, SIGNAL(clicked()), this, SLOT(setRandomTheme())); |
249 | 58 |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
59 |
chooseMap = new QComboBox(this); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
60 |
chooseMap->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
61 |
chooseMap->addItem(QComboBox::tr("generated map...")); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
62 |
for (int i = 0; i < mapList->size(); ++i) { |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
63 |
QString map = (*mapList)[i]; |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
64 |
QFile mapCfgFile( |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
65 |
QString("%1/Maps/%2/map.cfg") |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
66 |
.arg(datadir->absolutePath()) |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
67 |
.arg(map)); |
1790 | 68 |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
69 |
if (mapCfgFile.open(QFile::ReadOnly)) { |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
70 |
QString theme; |
1790 | 71 |
quint32 limit = 0; |
72 |
QList<QVariant> mapInfo; |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
73 |
QTextStream input(&mapCfgFile); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
74 |
input >> theme; |
1790 | 75 |
input >> limit; |
76 |
mapInfo.push_back(theme); |
|
77 |
if (limit) |
|
78 |
mapInfo.push_back(limit); |
|
79 |
else |
|
80 |
mapInfo.push_back(18); |
|
81 |
chooseMap->addItem(map, mapInfo); |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
82 |
mapCfgFile.close(); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
83 |
} |
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 |
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
|
87 |
mainLayout.addWidget(chooseMap, 1, 1); |
249 | 88 |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
89 |
QLabel * lblMap = new QLabel(tr("Map"), this); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
90 |
mainLayout.addWidget(lblMap, 1, 0); |
1209 | 91 |
|
92 |
gbThemes = new IconedGroupBox(this); |
|
1248 | 93 |
gbThemes->setTitleTextPadding(60); |
1209 | 94 |
gbThemes->setTitle(tr("Themes")); |
1248 | 95 |
|
96 |
//gbThemes->setStyleSheet("padding: 0px"); // doesn't work - stylesheet is set with icon |
|
1209 | 97 |
mainLayout.addWidget(gbThemes, 0, 2, 2, 1); |
1210 | 98 |
|
1209 | 99 |
QVBoxLayout * gbTLayout = new QVBoxLayout(gbThemes); |
1228 | 100 |
gbTLayout->setContentsMargins(0, 0, 0 ,0); |
101 |
gbTLayout->setSpacing(0); |
|
1209 | 102 |
lwThemes = new QListWidget(this); |
1210 | 103 |
lwThemes->setMinimumHeight(30); |
1248 | 104 |
lwThemes->setFixedWidth(120); |
1211 | 105 |
for (int i = 0; i < Themes->size(); ++i) { |
106 |
QListWidgetItem * lwi = new QListWidgetItem(); |
|
107 |
lwi->setText(Themes->at(i)); |
|
108 |
lwi->setTextAlignment(Qt::AlignHCenter); |
|
109 |
lwThemes->addItem(lwi); |
|
110 |
} |
|
1215 | 111 |
connect(lwThemes, SIGNAL(currentRowChanged(int)), this, SLOT(themeSelected(int))); |
1210 | 112 |
|
1209 | 113 |
gbTLayout->addWidget(lwThemes); |
114 |
lwThemes->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum); |
|
115 |
||
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
116 |
mainLayout.setSizeConstraint(QLayout::SetFixedSize);//SetMinimumSize |
1215 | 117 |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
118 |
setRandomSeed(); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
119 |
setRandomTheme(); |
184 | 120 |
} |
121 |
||
122 |
void HWMapContainer::setImage(const QImage newImage) |
|
123 |
{ |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
124 |
QPixmap px(256, 128); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
125 |
QPixmap pxres(256, 128); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
126 |
QPainter p(&pxres); |
184 | 127 |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
128 |
px.fill(Qt::yellow); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
129 |
QBitmap bm = QBitmap::fromImage(newImage); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
130 |
px.setMask(bm); |
184 | 131 |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
132 |
QLinearGradient linearGrad(QPoint(128, 0), QPoint(128, 128)); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
133 |
linearGrad.setColorAt(1, QColor(0, 0, 192)); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
134 |
linearGrad.setColorAt(0, QColor(66, 115, 225)); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
135 |
p.fillRect(QRect(0, 0, 256, 128), linearGrad); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
136 |
p.drawPixmap(QPoint(0, 0), px); |
184 | 137 |
|
1790 | 138 |
addInfoToPreview(pxres); |
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
139 |
chooseMap->setCurrentIndex(0); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
140 |
pMap = 0; |
249 | 141 |
} |
142 |
||
1790 | 143 |
void HWMapContainer::setHHLimit(int newHHLimit) |
144 |
{ |
|
145 |
hhLimit = newHHLimit; |
|
146 |
} |
|
147 |
||
249 | 148 |
void HWMapContainer::mapChanged(int index) |
149 |
{ |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
150 |
if(!index) { |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
151 |
changeImage(); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
152 |
gbThemes->show(); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
153 |
emit mapChanged("+rnd+"); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
154 |
emit themeChanged(chooseMap->itemData(0).toString()); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
155 |
} else |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
156 |
{ |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
157 |
loadMap(index); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
158 |
gbThemes->hide(); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
159 |
emit mapChanged(chooseMap->currentText()); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
160 |
} |
331 | 161 |
} |
162 |
||
163 |
void HWMapContainer::loadMap(int index) |
|
164 |
{ |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
165 |
QPixmap mapImage; |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
166 |
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
|
167 |
changeImage(); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
168 |
chooseMap->setCurrentIndex(0); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
169 |
return; |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
170 |
} |
1790 | 171 |
|
172 |
hhLimit = chooseMap->itemData(index).toList()[1].toInt(); |
|
173 |
addInfoToPreview(mapImage); |
|
174 |
} |
|
175 |
||
176 |
// Should this add text to identify map size? |
|
177 |
void HWMapContainer::addInfoToPreview(QPixmap image) |
|
178 |
{ |
|
179 |
QPixmap finalImage = QPixmap(image.size()); |
|
180 |
finalImage.fill(QColor(0, 0, 0, 0)); |
|
181 |
||
182 |
QPainter p(&finalImage); |
|
183 |
p.drawPixmap(image.rect(), image); |
|
184 |
//p.setPen(QColor(0xf4,0x9e,0xe9)); |
|
185 |
p.setPen(QColor(0xff,0xcc,0x00)); |
|
186 |
p.setBrush(QColor(0, 0, 0)); |
|
187 |
p.drawRect(image.rect().width() - hhSmall.rect().width() - 28, 3, 40, 20); |
|
188 |
p.setFont(QFont("MS Shell Dlg", 10)); |
|
189 |
p.drawText(image.rect().width() - hhSmall.rect().width() - 14 - (hhLimit > 9 ? 10 : 0), 18, QString::number(hhLimit)); |
|
190 |
p.drawPixmap(image.rect().width() - hhSmall.rect().width() - 5, 5, hhSmall.rect().width(), hhSmall.rect().height(), hhSmall); |
|
191 |
||
192 |
imageButt->setIcon(finalImage); |
|
193 |
imageButt->setIconSize(image.size()); |
|
184 | 194 |
} |
195 |
||
196 |
void HWMapContainer::changeImage() |
|
197 |
{ |
|
1214 | 198 |
pMap = new HWMap(); |
199 |
connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage))); |
|
1790 | 200 |
connect(pMap, SIGNAL(HHLimitReceived(int)), this, SLOT(setHHLimit(int))); |
1214 | 201 |
pMap->getImage(m_seed.toStdString()); |
184 | 202 |
} |
203 |
||
1215 | 204 |
void HWMapContainer::themeSelected(int currentRow) |
205 |
{ |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
206 |
QString theme = Themes->at(currentRow); |
1790 | 207 |
QList<QVariant> mapInfo; |
208 |
mapInfo.push_back(theme); |
|
209 |
mapInfo.push_back(18); |
|
210 |
chooseMap->setItemData(0, mapInfo); |
|
1224 | 211 |
gbThemes->setIcon(QIcon(QString("%1/Themes/%2/icon.png").arg(datadir->absolutePath()).arg(theme))); |
1215 | 212 |
emit themeChanged(theme); |
213 |
} |
|
214 |
||
184 | 215 |
QString HWMapContainer::getCurrentSeed() const |
216 |
{ |
|
217 |
return m_seed; |
|
218 |
} |
|
219 |
||
249 | 220 |
QString HWMapContainer::getCurrentMap() const |
221 |
{ |
|
320 | 222 |
if(!chooseMap->currentIndex()) return QString(); |
249 | 223 |
return chooseMap->currentText(); |
224 |
} |
|
225 |
||
226 |
QString HWMapContainer::getCurrentTheme() const |
|
227 |
{ |
|
1790 | 228 |
return chooseMap->itemData(chooseMap->currentIndex()).toList()[0].toString(); |
229 |
} |
|
230 |
||
231 |
int HWMapContainer::getCurrentHHLimit() const |
|
232 |
{ |
|
233 |
return hhLimit; |
|
249 | 234 |
} |
235 |
||
184 | 236 |
void HWMapContainer::resizeEvent ( QResizeEvent * event ) |
237 |
{ |
|
238 |
//imageButt->setIconSize(imageButt->size()); |
|
239 |
} |
|
320 | 240 |
|
241 |
void HWMapContainer::setSeed(const QString & seed) |
|
242 |
{ |
|
243 |
m_seed = seed; |
|
244 |
changeImage(); |
|
245 |
} |
|
246 |
||
247 |
void HWMapContainer::setMap(const QString & map) |
|
248 |
{ |
|
1333
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
249 |
if(map == "+rnd+") |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
250 |
{ |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
251 |
changeImage(); |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
252 |
return; |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
253 |
} |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
254 |
|
331 | 255 |
int id = chooseMap->findText(map); |
1333
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
256 |
if(id > 0) { |
331 | 257 |
chooseMap->setCurrentIndex(id); |
258 |
loadMap(id); |
|
1333
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
259 |
if (pMap) |
1365 | 260 |
{ |
1333
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
261 |
disconnect(pMap, 0, this, SLOT(setImage(const QImage))); |
1365 | 262 |
pMap = 0; |
263 |
} |
|
331 | 264 |
} |
320 | 265 |
} |
266 |
||
267 |
void HWMapContainer::setTheme(const QString & theme) |
|
268 |
{ |
|
1215 | 269 |
QList<QListWidgetItem *> items = lwThemes->findItems(theme, Qt::MatchExactly); |
270 |
if(items.size()) |
|
271 |
lwThemes->setCurrentItem(items.at(0)); |
|
320 | 272 |
} |
273 |
||
274 |
void HWMapContainer::setRandomSeed() |
|
275 |
{ |
|
276 |
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
|
277 |
emit seedChanged(m_seed); |
320 | 278 |
changeImage(); |
279 |
} |
|
1318 | 280 |
|
281 |
void HWMapContainer::setRandomTheme() |
|
282 |
{ |
|
283 |
if(!Themes->size()) return; |
|
284 |
quint32 themeNum = rand() % Themes->size(); |
|
285 |
lwThemes->setCurrentRow(themeNum); |
|
286 |
} |