23 #include <QSpinBox> |
23 #include <QSpinBox> |
24 #include <QLabel> |
24 #include <QLabel> |
25 #include <QMessageBox> |
25 #include <QMessageBox> |
26 #include <QTableView> |
26 #include <QTableView> |
27 #include <QPushButton> |
27 #include <QPushButton> |
|
28 #include <QDebug> |
|
29 #include <QList> |
28 |
30 |
29 #include "gamecfgwidget.h" |
31 #include "gamecfgwidget.h" |
30 #include "igbox.h" |
32 #include "igbox.h" |
31 #include "DataManager.h" |
33 #include "DataManager.h" |
32 #include "hwconsts.h" |
34 #include "hwconsts.h" |
33 #include "ammoSchemeModel.h" |
35 #include "ammoSchemeModel.h" |
34 #include "proto.h" |
36 #include "proto.h" |
35 #include "GameStyleModel.h" |
37 #include "GameStyleModel.h" |
|
38 #include "themeprompt.h" |
36 |
39 |
37 GameCFGWidget::GameCFGWidget(QWidget* parent) : |
40 GameCFGWidget::GameCFGWidget(QWidget* parent) : |
38 QGroupBox(parent) |
41 QGroupBox(parent) |
39 , mainLayout(this) |
42 , mainLayout(this) |
40 , seedRegexp("\\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\}") |
43 , seedRegexp("\\{[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}\\}") |
41 { |
44 { |
42 mainLayout.setMargin(0); |
45 mainLayout.setMargin(0); |
43 // mainLayout.setSizeConstraint(QLayout::SetMinimumSize); |
|
44 |
46 |
45 pMapContainer = new HWMapContainer(this); |
47 pMapContainer = new HWMapContainer(this); |
46 mainLayout.addWidget(pMapContainer, 0, 0); |
48 mainLayout.addWidget(pMapContainer, 0, 0, Qt::AlignHCenter | Qt::AlignTop); |
|
49 pMapContainer->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Fixed); |
|
50 pMapContainer->setFixedSize(460, 275); |
47 |
51 |
48 IconedGroupBox *GBoxOptions = new IconedGroupBox(this); |
52 IconedGroupBox *GBoxOptions = new IconedGroupBox(this); |
49 GBoxOptions->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); |
53 m_childWidgets << GBoxOptions; |
|
54 GBoxOptions->setFixedWidth(pMapContainer->width()); |
|
55 GBoxOptions->setSizePolicy(QSizePolicy::Fixed, QSizePolicy::Minimum); |
50 mainLayout.addWidget(GBoxOptions, 1, 0); |
56 mainLayout.addWidget(GBoxOptions, 1, 0); |
51 |
57 |
52 QGridLayout *GBoxOptionsLayout = new QGridLayout(GBoxOptions); |
58 QGridLayout *GBoxOptionsLayout = new QGridLayout(GBoxOptions); |
53 |
59 |
54 GBoxOptions->setTitle(tr("Game Options")); |
60 GBoxOptions->setTitle(tr("Game Options")); |
172 if (schemeData(17).toBool()) |
178 if (schemeData(17).toBool()) |
173 result |= 0x00040000; // disable land obj |
179 result |= 0x00040000; // disable land obj |
174 if (schemeData(18).toBool()) |
180 if (schemeData(18).toBool()) |
175 result |= 0x00080000; // ai survival |
181 result |= 0x00080000; // ai survival |
176 if (schemeData(19).toBool()) |
182 if (schemeData(19).toBool()) |
177 result |= 0x00100000; // infinite attacks |
183 result |= 0x00100000; // infinite attacks |
178 if (schemeData(20).toBool()) |
184 if (schemeData(20).toBool()) |
179 result |= 0x00200000; // reset weaps |
185 result |= 0x00200000; // reset weaps |
180 if (schemeData(21).toBool()) |
186 if (schemeData(21).toBool()) |
181 result |= 0x00400000; // per hog ammo |
187 result |= 0x00400000; // per hog ammo |
182 if (schemeData(22).toBool()) |
188 if (schemeData(22).toBool()) |
184 if (schemeData(23).toBool()) |
190 if (schemeData(23).toBool()) |
185 result |= 0x01000000; // more wind |
191 result |= 0x01000000; // more wind |
186 if (schemeData(24).toBool()) |
192 if (schemeData(24).toBool()) |
187 result |= 0x02000000; // tag team |
193 result |= 0x02000000; // tag team |
188 if (schemeData(25).toBool()) |
194 if (schemeData(25).toBool()) |
189 result |= 0x04000000; // bottom border |
195 result |= 0x04000000; // bottom |
190 |
196 |
191 return result; |
197 return result; |
192 } |
198 } |
193 |
199 |
194 quint32 GameCFGWidget::getInitHealth() const |
200 quint32 GameCFGWidget::getInitHealth() const |
233 bcfg << QString("e$ropepct %1").arg(schemeData(39).toInt()).toUtf8(); |
239 bcfg << QString("e$ropepct %1").arg(schemeData(39).toInt()).toUtf8(); |
234 bcfg << QString("e$getawaytime %1").arg(schemeData(40).toInt()).toUtf8(); |
240 bcfg << QString("e$getawaytime %1").arg(schemeData(40).toInt()).toUtf8(); |
235 bcfg << QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter()).toUtf8(); |
241 bcfg << QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter()).toUtf8(); |
236 bcfg << QString("e$mapgen %1").arg(mapgen).toUtf8(); |
242 bcfg << QString("e$mapgen %1").arg(mapgen).toUtf8(); |
237 |
243 |
|
244 |
|
245 |
238 switch (mapgen) |
246 switch (mapgen) |
239 { |
247 { |
240 case MAPGEN_MAZE: |
248 case MAPGEN_MAZE: |
241 bcfg << QString("e$maze_size %1").arg(pMapContainer->getMazeSize()).toUtf8(); |
249 bcfg << QString("e$maze_size %1").arg(pMapContainer->getMazeSize()).toUtf8(); |
242 break; |
250 break; |
269 void GameCFGWidget::setNetAmmo(const QString& name, const QString& ammo) |
277 void GameCFGWidget::setNetAmmo(const QString& name, const QString& ammo) |
270 { |
278 { |
271 bool illegal = ammo.size() != cDefaultAmmoStore->size(); |
279 bool illegal = ammo.size() != cDefaultAmmoStore->size(); |
272 if (illegal) |
280 if (illegal) |
273 { |
281 { |
274 QMessageBox illegalMsg(this); |
282 QMessageBox illegalMsg(parentWidget()); |
275 illegalMsg.setIcon(QMessageBox::Warning); |
283 illegalMsg.setIcon(QMessageBox::Warning); |
276 illegalMsg.setWindowTitle(QMessageBox::tr("Error")); |
284 illegalMsg.setWindowTitle(QMessageBox::tr("Error")); |
277 illegalMsg.setText(QMessageBox::tr("Cannot use the ammo '%1'!").arg(name)); |
285 illegalMsg.setText(QMessageBox::tr("Cannot use the ammo '%1'!").arg(name)); |
278 illegalMsg.setWindowModality(Qt::WindowModal); |
286 illegalMsg.setWindowModality(Qt::WindowModal); |
279 illegalMsg.exec(); |
287 illegalMsg.exec(); |
375 if (slValue.size() == 5) |
379 if (slValue.size() == 5) |
376 { |
380 { |
377 if (param == "FULLMAPCONFIG") |
381 if (param == "FULLMAPCONFIG") |
378 { |
382 { |
379 QString seed = slValue[3]; |
383 QString seed = slValue[3]; |
380 if (!seedRegexp.exactMatch(seed)) |
|
381 pMapContainer->seedEdit->setVisible(true); |
|
382 |
384 |
383 pMapContainer->setAllMapParameters( |
385 pMapContainer->setAllMapParameters( |
384 slValue[0], |
386 slValue[0], |
385 (MapGenerator)slValue[1].toUInt(), |
387 (MapGenerator)slValue[1].toUInt(), |
386 slValue[2].toUInt(), |
388 slValue[2].toUInt(), |
584 Scripts->setCurrentIndex(idx); |
586 Scripts->setCurrentIndex(idx); |
585 else |
587 else |
586 Scripts->setCurrentIndex(0); |
588 Scripts->setCurrentIndex(0); |
587 } |
589 } |
588 } |
590 } |
|
591 |
|
592 bool GameCFGWidget::isMaster() |
|
593 { |
|
594 return m_master; |
|
595 } |
|
596 |
|
597 void GameCFGWidget::setMaster(bool master) |
|
598 { |
|
599 if (master == m_master) return; |
|
600 m_master = master; |
|
601 |
|
602 pMapContainer->setMaster(master); |
|
603 |
|
604 foreach (QWidget *widget, m_childWidgets) |
|
605 widget->setEnabled(master); |
|
606 } |