author | unc0rr |
Wed, 18 Feb 2009 16:35:03 +0000 | |
changeset 1806 | 3c4f0886c123 |
parent 1802 | dd148e2506e2 |
child 1810 | 4059cafd1da7 |
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 |
|
1802 | 93 |
lblFilter = new QLabel(tr("Filter"), this); |
94 |
mainLayout.addWidget(lblFilter, 2, 0); |
|
95 |
||
96 |
CB_TemplateFilter = new QComboBox(this); |
|
97 |
CB_TemplateFilter->addItem(tr("All"), 0); |
|
98 |
CB_TemplateFilter->addItem(tr("Small"), 1); |
|
99 |
CB_TemplateFilter->addItem(tr("Medium"), 2); |
|
100 |
CB_TemplateFilter->addItem(tr("Large"), 3); |
|
101 |
CB_TemplateFilter->addItem(tr("Cavern"), 4); |
|
102 |
CB_TemplateFilter->addItem(tr("Wacky"), 5); |
|
103 |
mainLayout.addWidget(CB_TemplateFilter, 2, 1); |
|
104 |
||
105 |
connect(CB_TemplateFilter, SIGNAL(currentIndexChanged(int)), this, SLOT(templateFilterChanged(int))); |
|
106 |
||
1209 | 107 |
gbThemes = new IconedGroupBox(this); |
1248 | 108 |
gbThemes->setTitleTextPadding(60); |
1209 | 109 |
gbThemes->setTitle(tr("Themes")); |
1248 | 110 |
|
111 |
//gbThemes->setStyleSheet("padding: 0px"); // doesn't work - stylesheet is set with icon |
|
1802 | 112 |
mainLayout.addWidget(gbThemes, 0, 2, 3, 1); |
1210 | 113 |
|
1209 | 114 |
QVBoxLayout * gbTLayout = new QVBoxLayout(gbThemes); |
1228 | 115 |
gbTLayout->setContentsMargins(0, 0, 0 ,0); |
116 |
gbTLayout->setSpacing(0); |
|
1209 | 117 |
lwThemes = new QListWidget(this); |
1210 | 118 |
lwThemes->setMinimumHeight(30); |
1248 | 119 |
lwThemes->setFixedWidth(120); |
1211 | 120 |
for (int i = 0; i < Themes->size(); ++i) { |
121 |
QListWidgetItem * lwi = new QListWidgetItem(); |
|
122 |
lwi->setText(Themes->at(i)); |
|
123 |
lwi->setTextAlignment(Qt::AlignHCenter); |
|
124 |
lwThemes->addItem(lwi); |
|
125 |
} |
|
1215 | 126 |
connect(lwThemes, SIGNAL(currentRowChanged(int)), this, SLOT(themeSelected(int))); |
1802 | 127 |
|
128 |
// override default style to tighten up theme scroller |
|
129 |
lwThemes->setStyleSheet(QString( |
|
130 |
"QListWidget{" |
|
131 |
"border: solid;" |
|
132 |
"border-width: 0px;" |
|
133 |
"border-radius: 0px;" |
|
134 |
"border-color: transparent;" |
|
135 |
"background-color: #0d0544;" |
|
136 |
"color: #ffcc00;" |
|
137 |
"font: bold 14px;" |
|
138 |
"}" |
|
139 |
) |
|
140 |
); |
|
141 |
||
1209 | 142 |
gbTLayout->addWidget(lwThemes); |
143 |
lwThemes->setSizePolicy(QSizePolicy::Maximum, QSizePolicy::Minimum); |
|
144 |
||
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
145 |
mainLayout.setSizeConstraint(QLayout::SetFixedSize);//SetMinimumSize |
1215 | 146 |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
147 |
setRandomSeed(); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
148 |
setRandomTheme(); |
184 | 149 |
} |
150 |
||
151 |
void HWMapContainer::setImage(const QImage newImage) |
|
152 |
{ |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
153 |
QPixmap px(256, 128); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
154 |
QPixmap pxres(256, 128); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
155 |
QPainter p(&pxres); |
184 | 156 |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
157 |
px.fill(Qt::yellow); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
158 |
QBitmap bm = QBitmap::fromImage(newImage); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
159 |
px.setMask(bm); |
184 | 160 |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
161 |
QLinearGradient linearGrad(QPoint(128, 0), QPoint(128, 128)); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
162 |
linearGrad.setColorAt(1, QColor(0, 0, 192)); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
163 |
linearGrad.setColorAt(0, QColor(66, 115, 225)); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
164 |
p.fillRect(QRect(0, 0, 256, 128), linearGrad); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
165 |
p.drawPixmap(QPoint(0, 0), px); |
184 | 166 |
|
1790 | 167 |
addInfoToPreview(pxres); |
1366
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 |
pMap = 0; |
249 | 170 |
} |
171 |
||
1790 | 172 |
void HWMapContainer::setHHLimit(int newHHLimit) |
173 |
{ |
|
174 |
hhLimit = newHHLimit; |
|
175 |
} |
|
176 |
||
249 | 177 |
void HWMapContainer::mapChanged(int index) |
178 |
{ |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
179 |
if(!index) { |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
180 |
changeImage(); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
181 |
gbThemes->show(); |
1802 | 182 |
lblFilter->show(); |
183 |
CB_TemplateFilter->show(); |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
184 |
emit mapChanged("+rnd+"); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
185 |
emit themeChanged(chooseMap->itemData(0).toString()); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
186 |
} else |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
187 |
{ |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
188 |
loadMap(index); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
189 |
gbThemes->hide(); |
1802 | 190 |
lblFilter->hide(); |
191 |
CB_TemplateFilter->hide(); |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
192 |
emit mapChanged(chooseMap->currentText()); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
193 |
} |
331 | 194 |
} |
195 |
||
196 |
void HWMapContainer::loadMap(int index) |
|
197 |
{ |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
198 |
QPixmap mapImage; |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
199 |
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
|
200 |
changeImage(); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
201 |
chooseMap->setCurrentIndex(0); |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
202 |
return; |
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
203 |
} |
1790 | 204 |
|
205 |
hhLimit = chooseMap->itemData(index).toList()[1].toInt(); |
|
206 |
addInfoToPreview(mapImage); |
|
207 |
} |
|
208 |
||
209 |
// Should this add text to identify map size? |
|
210 |
void HWMapContainer::addInfoToPreview(QPixmap image) |
|
211 |
{ |
|
212 |
QPixmap finalImage = QPixmap(image.size()); |
|
213 |
finalImage.fill(QColor(0, 0, 0, 0)); |
|
214 |
||
215 |
QPainter p(&finalImage); |
|
216 |
p.drawPixmap(image.rect(), image); |
|
217 |
//p.setPen(QColor(0xf4,0x9e,0xe9)); |
|
218 |
p.setPen(QColor(0xff,0xcc,0x00)); |
|
219 |
p.setBrush(QColor(0, 0, 0)); |
|
220 |
p.drawRect(image.rect().width() - hhSmall.rect().width() - 28, 3, 40, 20); |
|
221 |
p.setFont(QFont("MS Shell Dlg", 10)); |
|
222 |
p.drawText(image.rect().width() - hhSmall.rect().width() - 14 - (hhLimit > 9 ? 10 : 0), 18, QString::number(hhLimit)); |
|
223 |
p.drawPixmap(image.rect().width() - hhSmall.rect().width() - 5, 5, hhSmall.rect().width(), hhSmall.rect().height(), hhSmall); |
|
224 |
||
225 |
imageButt->setIcon(finalImage); |
|
226 |
imageButt->setIconSize(image.size()); |
|
184 | 227 |
} |
228 |
||
229 |
void HWMapContainer::changeImage() |
|
230 |
{ |
|
1214 | 231 |
pMap = new HWMap(); |
232 |
connect(pMap, SIGNAL(ImageReceived(const QImage)), this, SLOT(setImage(const QImage))); |
|
1790 | 233 |
connect(pMap, SIGNAL(HHLimitReceived(int)), this, SLOT(setHHLimit(int))); |
1802 | 234 |
pMap->getImage(m_seed.toStdString(), getTemplateFilter()); |
184 | 235 |
} |
236 |
||
1215 | 237 |
void HWMapContainer::themeSelected(int currentRow) |
238 |
{ |
|
1366
eba12c22f8ca
Reorganize mapContainer widget. Fixes a bunch of bugs, improves widget.
unc0rr
parents:
1365
diff
changeset
|
239 |
QString theme = Themes->at(currentRow); |
1790 | 240 |
QList<QVariant> mapInfo; |
241 |
mapInfo.push_back(theme); |
|
242 |
mapInfo.push_back(18); |
|
243 |
chooseMap->setItemData(0, mapInfo); |
|
1224 | 244 |
gbThemes->setIcon(QIcon(QString("%1/Themes/%2/icon.png").arg(datadir->absolutePath()).arg(theme))); |
1215 | 245 |
emit themeChanged(theme); |
246 |
} |
|
247 |
||
184 | 248 |
QString HWMapContainer::getCurrentSeed() const |
249 |
{ |
|
250 |
return m_seed; |
|
251 |
} |
|
252 |
||
249 | 253 |
QString HWMapContainer::getCurrentMap() const |
254 |
{ |
|
320 | 255 |
if(!chooseMap->currentIndex()) return QString(); |
249 | 256 |
return chooseMap->currentText(); |
257 |
} |
|
258 |
||
259 |
QString HWMapContainer::getCurrentTheme() const |
|
260 |
{ |
|
1790 | 261 |
return chooseMap->itemData(chooseMap->currentIndex()).toList()[0].toString(); |
262 |
} |
|
263 |
||
264 |
int HWMapContainer::getCurrentHHLimit() const |
|
265 |
{ |
|
266 |
return hhLimit; |
|
249 | 267 |
} |
268 |
||
1802 | 269 |
quint32 HWMapContainer::getTemplateFilter() const |
270 |
{ |
|
271 |
return CB_TemplateFilter->itemData(CB_TemplateFilter->currentIndex()).toInt(); |
|
272 |
} |
|
273 |
||
184 | 274 |
void HWMapContainer::resizeEvent ( QResizeEvent * event ) |
275 |
{ |
|
276 |
//imageButt->setIconSize(imageButt->size()); |
|
277 |
} |
|
320 | 278 |
|
279 |
void HWMapContainer::setSeed(const QString & seed) |
|
280 |
{ |
|
281 |
m_seed = seed; |
|
282 |
changeImage(); |
|
283 |
} |
|
284 |
||
285 |
void HWMapContainer::setMap(const QString & map) |
|
286 |
{ |
|
1333
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
287 |
if(map == "+rnd+") |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
288 |
{ |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
289 |
changeImage(); |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
290 |
return; |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
291 |
} |
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
292 |
|
331 | 293 |
int id = chooseMap->findText(map); |
1333
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
294 |
if(id > 0) { |
331 | 295 |
chooseMap->setCurrentIndex(id); |
296 |
loadMap(id); |
|
1333
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
297 |
if (pMap) |
1365 | 298 |
{ |
1333
b0b0510eb82d
- Fix a bug with chosen map (new clinet gets wrong information)
unc0rr
parents:
1318
diff
changeset
|
299 |
disconnect(pMap, 0, this, SLOT(setImage(const QImage))); |
1365 | 300 |
pMap = 0; |
301 |
} |
|
331 | 302 |
} |
320 | 303 |
} |
304 |
||
305 |
void HWMapContainer::setTheme(const QString & theme) |
|
306 |
{ |
|
1215 | 307 |
QList<QListWidgetItem *> items = lwThemes->findItems(theme, Qt::MatchExactly); |
308 |
if(items.size()) |
|
309 |
lwThemes->setCurrentItem(items.at(0)); |
|
320 | 310 |
} |
311 |
||
312 |
void HWMapContainer::setRandomSeed() |
|
313 |
{ |
|
314 |
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
|
315 |
emit seedChanged(m_seed); |
320 | 316 |
changeImage(); |
317 |
} |
|
1318 | 318 |
|
319 |
void HWMapContainer::setRandomTheme() |
|
320 |
{ |
|
321 |
if(!Themes->size()) return; |
|
322 |
quint32 themeNum = rand() % Themes->size(); |
|
323 |
lwThemes->setCurrentRow(themeNum); |
|
324 |
} |
|
1797 | 325 |
|
326 |
void HWMapContainer::setTemplateFilter(int filter) |
|
327 |
{ |
|
1802 | 328 |
CB_TemplateFilter->setCurrentIndex(filter); |
1797 | 329 |
} |
1802 | 330 |
|
331 |
void HWMapContainer::templateFilterChanged(int filter) |
|
332 |
{ |
|
333 |
changeImage(); |
|
334 |
emit newTemplateFilter(filter); |
|
335 |
} |
|
336 |