author | smxx |
Wed, 17 Mar 2010 10:55:12 +0000 | |
changeset 3009 | 8f4e6de8e4ef |
parent 3008 | e57cafce4227 |
child 3010 | 3aa3675d97eb |
permissions | -rw-r--r-- |
184 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
1878
b3b277d2b891
own md5 function, no qca2 dependancy (patch by nemo with Qt adaptation by me)
unc0rr
parents:
1877
diff
changeset
|
3 |
* Copyright (c) 2006, 2007, 2009 Andrey Korotaev <unC0Rr@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 <QResizeEvent> |
|
218 | 20 |
#include <QGroupBox> |
311 | 21 |
#include <QCheckBox> |
22 |
#include <QGridLayout> |
|
23 |
#include <QSpinBox> |
|
24 |
#include <QLabel> |
|
1517 | 25 |
#include <QMessageBox> |
1884 | 26 |
#include <QTableView> |
1885 | 27 |
#include <QPushButton> |
1217 | 28 |
|
184 | 29 |
#include "gamecfgwidget.h" |
1217 | 30 |
#include "igbox.h" |
1517 | 31 |
#include "hwconsts.h" |
1884 | 32 |
#include "ammoSchemeModel.h" |
184 | 33 |
|
349 | 34 |
GameCFGWidget::GameCFGWidget(QWidget* parent, bool externalControl) : |
1217 | 35 |
QGroupBox(parent), mainLayout(this) |
184 | 36 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
37 |
mainLayout.setMargin(0); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
38 |
// mainLayout.setSizeConstraint(QLayout::SetMinimumSize); |
218 | 39 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
40 |
pMapContainer = new HWMapContainer(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
41 |
mainLayout.addWidget(pMapContainer, 0, 0); |
218 | 42 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
43 |
IconedGroupBox *GBoxOptions = new IconedGroupBox(this); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
44 |
GBoxOptions->setSizePolicy(QSizePolicy::Minimum, QSizePolicy::Minimum); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
45 |
mainLayout.addWidget(GBoxOptions); |
218 | 46 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
47 |
QGridLayout *GBoxOptionsLayout = new QGridLayout(GBoxOptions); |
1884 | 48 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
49 |
GameSchemes = new QComboBox(GBoxOptions); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
50 |
GBoxOptionsLayout->addWidget(GameSchemes, 0, 1); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
51 |
connect(GameSchemes, SIGNAL(currentIndexChanged(int)), this, SLOT(schemeChanged(int))); |
1885 | 52 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
53 |
GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Game scheme"), GBoxOptions), 0, 0); |
1979 | 54 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
55 |
QPixmap pmEdit(":/res/edit.png"); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
56 |
|
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
57 |
QPushButton * goToSchemePage = new QPushButton(GBoxOptions); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
58 |
//goToSchemePage->setText(tr("Edit schemes")); |
2888 | 59 |
goToSchemePage->setToolTip(tr("Edit schemes")); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
60 |
goToSchemePage->setIconSize(pmEdit.size()); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
61 |
goToSchemePage->setIcon(pmEdit); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
62 |
goToSchemePage->setMaximumWidth(pmEdit.width() + 6); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
63 |
GBoxOptionsLayout->addWidget(goToSchemePage, 0, 2); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
64 |
connect(goToSchemePage, SIGNAL(clicked()), this, SIGNAL(goToSchemes())); |
2377 | 65 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
66 |
GBoxOptionsLayout->addWidget(new QLabel(QLabel::tr("Weapons"), GBoxOptions), 1, 0); |
311 | 67 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
68 |
WeaponsName = new QComboBox(GBoxOptions); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
69 |
GBoxOptionsLayout->addWidget(WeaponsName, 1, 1); |
2377 | 70 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
71 |
connect(WeaponsName, SIGNAL(currentIndexChanged(int)), this, SLOT(ammoChanged(int))); |
2377 | 72 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
73 |
QPushButton * goToWeaponPage = new QPushButton(GBoxOptions); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
74 |
//goToWeaponPage->setText(tr("Edit weapons")); |
2888 | 75 |
goToWeaponPage->setToolTip(tr("Edit weapons")); |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
76 |
goToWeaponPage->setIconSize(pmEdit.size()); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
77 |
goToWeaponPage->setIcon(pmEdit); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
78 |
goToWeaponPage->setMaximumWidth(pmEdit.width() + 6); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
79 |
GBoxOptionsLayout->addWidget(goToWeaponPage, 1, 2); |
2009 | 80 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
81 |
connect(goToWeaponPage, SIGNAL(clicked()), this, SLOT(jumpToWeapons())); |
486 | 82 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
83 |
connect(pMapContainer, SIGNAL(seedChanged(const QString &)), this, SLOT(seedChanged(const QString &))); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
84 |
connect(pMapContainer, SIGNAL(mapChanged(const QString &)), this, SLOT(mapChanged(const QString &))); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
85 |
connect(pMapContainer, SIGNAL(themeChanged(const QString &)), this, SLOT(themeChanged(const QString &))); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
86 |
connect(pMapContainer, SIGNAL(newTemplateFilter(int)), this, SLOT(templateFilterChanged(int))); |
184 | 87 |
} |
88 |
||
2009 | 89 |
void GameCFGWidget::jumpToWeapons() |
90 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
91 |
emit goToWeapons(WeaponsName->currentText()); |
2009 | 92 |
} |
93 |
||
1890 | 94 |
QVariant GameCFGWidget::schemeData(int column) const |
95 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
96 |
return GameSchemes->model()->data(GameSchemes->model()->index(GameSchemes->currentIndex(), column)); |
1890 | 97 |
} |
98 |
||
318 | 99 |
quint32 GameCFGWidget::getGameFlags() const |
184 | 100 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
101 |
quint32 result = 0; |
1427 | 102 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
103 |
if (schemeData(1).toBool()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
104 |
result |= 0x01; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
105 |
if (schemeData(2).toBool()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
106 |
result |= 0x10; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
107 |
if (schemeData(3).toBool()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
108 |
result |= 0x04; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
109 |
if (schemeData(4).toBool()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
110 |
result |= 0x08; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
111 |
if (schemeData(5).toBool()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
112 |
result |= 0x20; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
113 |
if (schemeData(6).toBool()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
114 |
result |= 0x40; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
115 |
if (schemeData(7).toBool()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
116 |
result |= 0x80; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
117 |
if (schemeData(8).toBool()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
118 |
result |= 0x100; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
119 |
if (schemeData(9).toBool()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
120 |
result |= 0x200; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
121 |
if (schemeData(10).toBool()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
122 |
result |= 0x400; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
123 |
if (schemeData(11).toBool()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
124 |
result |= 0x800; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
125 |
if (schemeData(12).toBool()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
126 |
result |= 0x2000; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
127 |
if (schemeData(13).toBool()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
128 |
result |= 0x4000; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
129 |
if (schemeData(14).toBool()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
130 |
result |= 0x8000; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
131 |
if (schemeData(15).toBool()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
132 |
result |= 0x10000; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
133 |
if (schemeData(16).toBool()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
134 |
result |= 0x20000; |
1427 | 135 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
136 |
return result; |
184 | 137 |
} |
138 |
||
312 | 139 |
quint32 GameCFGWidget::getInitHealth() const |
140 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
141 |
return schemeData(19).toInt(); |
312 | 142 |
} |
143 |
||
318 | 144 |
QStringList GameCFGWidget::getFullConfig() const |
145 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
146 |
QStringList sl; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
147 |
sl.append("eseed " + pMapContainer->getCurrentSeed()); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
148 |
sl.append(QString("e$gmflags %1").arg(getGameFlags())); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
149 |
sl.append(QString("e$damagepct %1").arg(schemeData(17).toInt())); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
150 |
sl.append(QString("e$turntime %1").arg(schemeData(18).toInt() * 1000)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
151 |
sl.append(QString("e$minestime %1").arg(schemeData(22).toInt() * 1000)); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
152 |
sl.append(QString("e$landadds %1").arg(schemeData(23).toInt())); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
153 |
sl.append(QString("e$sd_turns %1").arg(schemeData(20).toInt())); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
154 |
sl.append(QString("e$casefreq %1").arg(schemeData(21).toInt())); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
155 |
sl.append(QString("e$minedudpct %1").arg(schemeData(24).toInt())); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
156 |
sl.append(QString("e$explosives %1").arg(schemeData(25).toInt())); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
157 |
sl.append(QString("e$template_filter %1").arg(pMapContainer->getTemplateFilter())); |
1782
e7589e37a6d6
Options for bonus box probability tuning and number of turn until sudden death
unc0rr
parents:
1628
diff
changeset
|
158 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
159 |
QString currentMap = pMapContainer->getCurrentMap(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
160 |
if (currentMap.size() > 0) |
2999 | 161 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
162 |
sl.append("emap " + currentMap); |
3008 | 163 |
if(pMapContainer->getCurrentIsMission()) |
164 |
sl.append(QString("escript %1/Maps/%2/map.lua") |
|
2999 | 165 |
.arg(datadir->absolutePath()) |
166 |
.arg(currentMap)); |
|
167 |
} |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
168 |
sl.append("etheme " + pMapContainer->getCurrentTheme()); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
169 |
return sl; |
318 | 170 |
} |
320 | 171 |
|
703 | 172 |
void GameCFGWidget::setNetAmmo(const QString& name, const QString& ammo) |
697 | 173 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
174 |
bool illegal = ammo.size() != cDefaultAmmoStore->size(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
175 |
if (illegal) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
176 |
QMessageBox::critical(this, tr("Error"), tr("Illegal ammo scheme")); |
703 | 177 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
178 |
int pos = WeaponsName->findText(name); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
179 |
if ((pos == -1) || illegal) { // prevent from overriding schemes with bad ones |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
180 |
WeaponsName->addItem(name, ammo); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
181 |
WeaponsName->setCurrentIndex(WeaponsName->count() - 1); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
182 |
} else { |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
183 |
WeaponsName->setItemData(pos, ammo); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
184 |
WeaponsName->setCurrentIndex(pos); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
185 |
} |
1530 | 186 |
} |
1531 | 187 |
|
1875 | 188 |
void GameCFGWidget::fullNetConfig() |
189 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
190 |
ammoChanged(WeaponsName->currentIndex()); |
2377 | 191 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
192 |
seedChanged(pMapContainer->getCurrentSeed()); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
193 |
templateFilterChanged(pMapContainer->getTemplateFilter()); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
194 |
themeChanged(pMapContainer->getCurrentTheme()); |
1875 | 195 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
196 |
schemeChanged(GameSchemes->currentIndex()); |
1921 | 197 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
198 |
// map must be the last |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
199 |
QString map = pMapContainer->getCurrentMap(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
200 |
if (map.size()) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
201 |
mapChanged(map); |
1875 | 202 |
} |
203 |
||
1873
815a3ff1fe4b
Start refactoring some things. Frontend becomes temporarily unusable for network game
unc0rr
parents:
1802
diff
changeset
|
204 |
void GameCFGWidget::setParam(const QString & param, const QStringList & slValue) |
815a3ff1fe4b
Start refactoring some things. Frontend becomes temporarily unusable for network game
unc0rr
parents:
1802
diff
changeset
|
205 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
206 |
if (slValue.size() == 1) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
207 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
208 |
QString value = slValue[0]; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
209 |
if (param == "MAP") { |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
210 |
pMapContainer->setMap(value); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
211 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
212 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
213 |
if (param == "SEED") { |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
214 |
pMapContainer->setSeed(value); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
215 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
216 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
217 |
if (param == "THEME") { |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
218 |
pMapContainer->setTheme(value); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
219 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
220 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
221 |
if (param == "TEMPLATE") { |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
222 |
pMapContainer->setTemplateFilter(value.toUInt()); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
223 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
224 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
225 |
} |
1873
815a3ff1fe4b
Start refactoring some things. Frontend becomes temporarily unusable for network game
unc0rr
parents:
1802
diff
changeset
|
226 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
227 |
if (slValue.size() == 2) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
228 |
{ |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
229 |
if (param == "AMMO") { |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
230 |
setNetAmmo(slValue[0], slValue[1]); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
231 |
return; |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
232 |
} |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
233 |
} |
2377 | 234 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
235 |
qWarning("Got bad config param from net"); |
1873
815a3ff1fe4b
Start refactoring some things. Frontend becomes temporarily unusable for network game
unc0rr
parents:
1802
diff
changeset
|
236 |
} |
815a3ff1fe4b
Start refactoring some things. Frontend becomes temporarily unusable for network game
unc0rr
parents:
1802
diff
changeset
|
237 |
|
1874 | 238 |
void GameCFGWidget::ammoChanged(int index) |
239 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
240 |
if (index >= 0) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
241 |
emit paramChanged( |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
242 |
"AMMO", |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
243 |
QStringList() << WeaponsName->itemText(index) << WeaponsName->itemData(index).toString() |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
244 |
); |
1874 | 245 |
} |
246 |
||
247 |
void GameCFGWidget::mapChanged(const QString & value) |
|
248 |
{ |
|
3009 | 249 |
GameSchemes->setEnabled(pMapContainer->getCurrentIsMission()); |
250 |
WeaponsName->setEnabled(pMapContainer->getCurrentIsMission()); |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
251 |
emit paramChanged("MAP", QStringList(value)); |
1874 | 252 |
} |
253 |
||
1876 | 254 |
void GameCFGWidget::templateFilterChanged(int value) |
255 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
256 |
emit paramChanged("TEMPLATE", QStringList(QString::number(value))); |
1876 | 257 |
} |
258 |
||
1874 | 259 |
void GameCFGWidget::seedChanged(const QString & value) |
260 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
261 |
emit paramChanged("SEED", QStringList(value)); |
1874 | 262 |
} |
263 |
||
264 |
void GameCFGWidget::themeChanged(const QString & value) |
|
265 |
{ |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
266 |
emit paramChanged("THEME", QStringList(value)); |
1874 | 267 |
} |
1898
f0ab0c77946d
Send scheme data over net (but recieving part isn't implemented yet)
unc0rr
parents:
1895
diff
changeset
|
268 |
|
f0ab0c77946d
Send scheme data over net (but recieving part isn't implemented yet)
unc0rr
parents:
1895
diff
changeset
|
269 |
void GameCFGWidget::schemeChanged(int value) |
f0ab0c77946d
Send scheme data over net (but recieving part isn't implemented yet)
unc0rr
parents:
1895
diff
changeset
|
270 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
271 |
QStringList sl; |
1898
f0ab0c77946d
Send scheme data over net (but recieving part isn't implemented yet)
unc0rr
parents:
1895
diff
changeset
|
272 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
273 |
int size = GameSchemes->model()->columnCount(); |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
274 |
for(int i = 0; i < size; ++i) |
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
275 |
sl << schemeData(i).toString(); |
2377 | 276 |
|
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
277 |
emit paramChanged("SCHEME", sl); |
1898
f0ab0c77946d
Send scheme data over net (but recieving part isn't implemented yet)
unc0rr
parents:
1895
diff
changeset
|
278 |
} |
2080
6d29370dc0dd
This should resend scheme info to net server when scheme got edited (not tested)
unc0rr
parents:
2031
diff
changeset
|
279 |
|
6d29370dc0dd
This should resend scheme info to net server when scheme got edited (not tested)
unc0rr
parents:
2031
diff
changeset
|
280 |
void GameCFGWidget::resendSchemeData() |
6d29370dc0dd
This should resend scheme info to net server when scheme got edited (not tested)
unc0rr
parents:
2031
diff
changeset
|
281 |
{ |
2948
3f21a9dc93d0
Replace tabs with spaces using 'expand -t 4' command
unc0rr
parents:
2915
diff
changeset
|
282 |
schemeChanged(GameSchemes->currentIndex()); |
2080
6d29370dc0dd
This should resend scheme info to net server when scheme got edited (not tested)
unc0rr
parents:
2031
diff
changeset
|
283 |
} |