author | unc0rr |
Sun, 27 Jul 2008 23:01:41 +0000 | |
changeset 1132 | b4c0698fbb6b |
parent 1129 | b74ffca22762 |
child 1148 | e44de3416af4 |
permissions | -rw-r--r-- |
184 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
486 | 3 |
* Copyright (c) 2006, 2007 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 <QGridLayout> |
|
20 |
#include <QPushButton> |
|
21 |
#include <QGroupBox> |
|
22 |
#include <QComboBox> |
|
311 | 23 |
#include <QCheckBox> |
184 | 24 |
#include <QLabel> |
25 |
#include <QToolBox> |
|
26 |
#include <QLineEdit> |
|
27 |
#include <QListWidget> |
|
28 |
#include <QApplication> |
|
231 | 29 |
#include <QSpinBox> |
452 | 30 |
#include <QTextEdit> |
636 | 31 |
#include <QRadioButton> |
665 | 32 |
#include <QTableView> |
671
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
33 |
#include <QMessageBox> |
673 | 34 |
#include <QHeaderView> |
184 | 35 |
|
36 |
#include "pages.h" |
|
37 |
#include "sdlkeys.h" |
|
38 |
#include "hwconsts.h" |
|
39 |
#include "gamecfgwidget.h" |
|
40 |
#include "teamselect.h" |
|
41 |
#include "gamecfgwidget.h" |
|
42 |
#include "SquareLabel.h" |
|
43 |
#include "mapContainer.h" |
|
187 | 44 |
#include "about.h" |
297 | 45 |
#include "fpsedit.h" |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
46 |
#include "netserverslist.h" |
412 | 47 |
#include "netudpwidget.h" |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
48 |
#include "netwwwwidget.h" |
461 | 49 |
#include "chatwidget.h" |
555 | 50 |
#include "SDLs.h" |
579 | 51 |
#include "playrecordpage.h" |
612
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
603
diff
changeset
|
52 |
#include "selectWeapon.h" |
184 | 53 |
|
684 | 54 |
PageMain::PageMain(QWidget* parent) : |
55 |
AbstractPage(parent) |
|
184 | 56 |
{ |
57 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
58 |
pageLayout->setMargin(25); |
|
59 |
pageLayout->setColumnStretch(0, 1); |
|
60 |
pageLayout->setColumnStretch(1, 2); |
|
61 |
pageLayout->setColumnStretch(2, 1); |
|
62 |
||
730 | 63 |
BtnSinglePlayer = addButton(tr("Single Player"), pageLayout, 0, 1); |
184 | 64 |
BtnSinglePlayer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
65 |
||
728 | 66 |
BtnMultiplayer = addButton(tr("Multiplayer"), pageLayout, 1, 1); |
184 | 67 |
BtnMultiplayer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
68 |
||
730 | 69 |
BtnNet = addButton(tr("Net game"), pageLayout, 2, 1); |
184 | 70 |
BtnNet->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
71 |
||
730 | 72 |
BtnLoad = addButton(tr("Saved games"), pageLayout, 3, 1); |
579 | 73 |
BtnLoad->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
74 |
||
730 | 75 |
BtnDemos = addButton(tr("Demos"), pageLayout, 4, 1); |
184 | 76 |
BtnDemos->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
77 |
||
730 | 78 |
BtnSetup = addButton(tr("Setup"), pageLayout, 5, 1); |
184 | 79 |
BtnSetup->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
80 |
||
730 | 81 |
BtnInfo = addButton(tr("About"), pageLayout, 6, 1); |
187 | 82 |
BtnInfo->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
83 |
||
730 | 84 |
BtnExit = addButton(tr("Exit"), pageLayout, 7, 1); |
184 | 85 |
BtnExit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
86 |
} |
|
87 |
||
788
00720357601f
- Get rid of PageSimpleGame, now pressing 'quick game' just starts round
unc0rr
parents:
730
diff
changeset
|
88 |
PageEditTeam::PageEditTeam(QWidget* parent) : |
692 | 89 |
AbstractPage(parent) |
184 | 90 |
{ |
91 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
310 | 92 |
pageLayout->setColumnStretch(0, 1); |
184 | 93 |
pageLayout->setColumnMinimumWidth(0, 150); |
94 |
pageLayout->setColumnStretch(1, 100); |
|
336 | 95 |
pageLayout->setColumnMinimumWidth(1, 210); |
451 | 96 |
pageLayout->setColumnStretch(2, 75); |
336 | 97 |
pageLayout->setColumnMinimumWidth(2, 110); |
451 | 98 |
pageLayout->setColumnStretch(3, 75); |
336 | 99 |
pageLayout->setColumnMinimumWidth(3, 110); |
184 | 100 |
|
101 |
GBoxTeam = new QGroupBox(this); |
|
102 |
GBoxTeam->setTitle(QGroupBox::tr("Team")); |
|
103 |
GBoxTeam->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
104 |
QGridLayout * GBTLayout = new QGridLayout(GBoxTeam); |
|
105 |
TeamNameEdit = new QLineEdit(GBoxTeam); |
|
106 |
TeamNameEdit->setMaxLength(15); |
|
231 | 107 |
GBTLayout->addWidget(TeamNameEdit, 0, 0, 1, 0); |
108 |
||
184 | 109 |
pageLayout->addWidget(GBoxTeam, 0, 0); |
110 |
||
588 | 111 |
GBoxHedgehogs = new QGroupBox(this); |
184 | 112 |
GBoxHedgehogs->setTitle(QGroupBox::tr("Team Members")); |
113 |
GBoxHedgehogs->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
114 |
QGridLayout * GBHLayout = new QGridLayout(GBoxHedgehogs); |
|
115 |
for(int i = 0; i < 8; i++) |
|
116 |
{ |
|
117 |
HHNameEdit[i] = new QLineEdit(GBoxHedgehogs); |
|
118 |
HHNameEdit[i]->setGeometry(QRect(10, 20 + i * 30, 141, 20)); |
|
119 |
HHNameEdit[i]->setMaxLength(15); |
|
120 |
GBHLayout->addWidget(HHNameEdit[i]); |
|
121 |
} |
|
122 |
pageLayout->addWidget(GBoxHedgehogs, 1, 0, 2, 1); |
|
123 |
||
730 | 124 |
BtnTeamDiscard = addButton(tr("Discard"), pageLayout, 4, 0); |
184 | 125 |
|
588 | 126 |
GBoxBinds = new QGroupBox(this); |
184 | 127 |
GBoxBinds->setTitle(QGroupBox::tr("Key binds")); |
128 |
QGridLayout * GBBLayout = new QGridLayout(GBoxBinds); |
|
129 |
BindsBox = new QToolBox(GBoxBinds); |
|
130 |
BindsBox->setLineWidth(0); |
|
131 |
GBBLayout->addWidget(BindsBox); |
|
132 |
page_A = new QWidget(); |
|
133 |
BindsBox->addItem(page_A, QToolBox::tr("Actions")); |
|
134 |
page_W = new QWidget(); |
|
135 |
BindsBox->addItem(page_W, QToolBox::tr("Weapons")); |
|
136 |
page_WP = new QWidget(); |
|
137 |
BindsBox->addItem(page_WP, QToolBox::tr("Weapon properties")); |
|
138 |
page_O = new QWidget(); |
|
139 |
BindsBox->addItem(page_O, QToolBox::tr("Other")); |
|
140 |
pageLayout->addWidget(GBoxBinds, 0, 1, 5, 1); |
|
141 |
||
142 |
QStringList binds; |
|
143 |
for(int i = 0; strlen(sdlkeys[i][1]) > 0; i++) |
|
144 |
{ |
|
145 |
binds << sdlkeys[i][1]; |
|
146 |
} |
|
147 |
||
148 |
quint16 widind = 0, i = 0; |
|
149 |
while (i < BINDS_NUMBER) { |
|
150 |
quint16 num = 0; |
|
151 |
QGridLayout * pagelayout = new QGridLayout(BindsBox->widget(widind)); |
|
152 |
do { |
|
153 |
LBind[i] = new QLabel(BindsBox->widget(widind)); |
|
154 |
LBind[i]->setText(QApplication::translate("binds", cbinds[i].name)); |
|
155 |
LBind[i]->setAlignment(Qt::AlignRight); |
|
156 |
pagelayout->addWidget(LBind[i], num, 0); |
|
157 |
CBBind[i] = new QComboBox(BindsBox->widget(widind)); |
|
158 |
CBBind[i]->addItems(binds); |
|
159 |
pagelayout->addWidget(CBBind[i], num, 1); |
|
160 |
num++; |
|
161 |
} while (!cbinds[i++].chwidget); |
|
162 |
pagelayout->addWidget(new QWidget(BindsBox->widget(widind)), num, 0, 1, 2); |
|
163 |
widind++; |
|
164 |
} |
|
165 |
||
588 | 166 |
GBoxGrave = new QGroupBox(this); |
184 | 167 |
GBoxGrave->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
168 |
GBoxGrave->setTitle(QGroupBox::tr("Grave")); |
|
169 |
QGridLayout * GBGLayout = new QGridLayout(GBoxGrave); |
|
170 |
CBGrave = new QComboBox(GBoxGrave); |
|
171 |
CBGrave->setMaxCount(65535); |
|
172 |
GBGLayout->addWidget(CBGrave, 0, 0, 1, 3); |
|
173 |
GravePreview = new QLabel(GBoxGrave); |
|
174 |
GravePreview->setScaledContents(false); |
|
336 | 175 |
pageLayout->addWidget(GBoxGrave, 0, 3, 2, 1); |
184 | 176 |
GBGLayout->addWidget(GravePreview, 1, 1); |
336 | 177 |
|
178 |
GBoxTeamLvl = new QGroupBox(this); |
|
179 |
GBoxTeamLvl->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
180 |
GBoxTeamLvl->setTitle(QGroupBox::tr("Team level")); |
|
181 |
QGridLayout * GBTLLayout = new QGridLayout(GBoxTeamLvl); |
|
182 |
CBTeamLvl = new QComboBox(GBoxTeamLvl); |
|
183 |
CBTeamLvl->addItem(QComboBox::tr("Human")); |
|
427 | 184 |
CBTeamLvl->addItem(QComboBox::tr("Level 5")); |
185 |
CBTeamLvl->addItem(QComboBox::tr("Level 4")); |
|
336 | 186 |
CBTeamLvl->addItem(QComboBox::tr("Level 3")); |
427 | 187 |
CBTeamLvl->addItem(QComboBox::tr("Level 2")); |
188 |
CBTeamLvl->addItem(QComboBox::tr("Level 1")); |
|
336 | 189 |
CBTeamLvl->setMaxCount(6); |
190 |
GBTLLayout->addWidget(CBTeamLvl, 0, 0, 1, 3); |
|
191 |
LevelPict = new QLabel(GBoxTeamLvl); |
|
192 |
LevelPict->setScaledContents(false); |
|
193 |
LevelPict->setFixedSize(32, 32); |
|
194 |
pageLayout->addWidget(GBoxTeamLvl, 0, 2, 2, 1); |
|
195 |
GBTLLayout->addWidget(LevelPict, 1, 1); |
|
184 | 196 |
|
197 |
GBoxFort = new QGroupBox(this); |
|
198 |
GBoxFort->setTitle(QGroupBox::tr("Fort")); |
|
199 |
QGridLayout * GBFLayout = new QGridLayout(GBoxFort); |
|
200 |
CBFort = new QComboBox(GBoxFort); |
|
201 |
CBFort->setMaxCount(65535); |
|
202 |
GBFLayout->addWidget(CBFort, 0, 0); |
|
588 | 203 |
FortPreview = new SquareLabel(GBoxFort); |
310 | 204 |
FortPreview->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
184 | 205 |
FortPreview->setPixmap(QPixmap()); |
206 |
GBFLayout->addWidget(FortPreview, 1, 0); |
|
336 | 207 |
pageLayout->addWidget(GBoxFort, 2, 2, 1, 2); |
184 | 208 |
|
730 | 209 |
BtnTeamSave = addButton(tr("Save"), pageLayout, 4, 2, 1, 2); |
184 | 210 |
|
211 |
QDir tmpdir; |
|
212 |
tmpdir.cd(datadir->absolutePath()); |
|
213 |
tmpdir.cd("Forts"); |
|
214 |
tmpdir.setFilter(QDir::Files); |
|
215 |
||
603 | 216 |
CBFort->addItems(tmpdir.entryList(QStringList("*L.png")).replaceInStrings(QRegExp("^(.*)L\\.png"), "\\1")); |
184 | 217 |
tmpdir.cd("../Graphics/Graves"); |
218 |
QStringList list = tmpdir.entryList(QStringList("*.png")); |
|
219 |
for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
|
220 |
{ |
|
603 | 221 |
CBGrave->addItem((*it).replace(QRegExp("^(.*)\\.png"), "\\1")); |
184 | 222 |
} |
223 |
||
224 |
connect(CBGrave, SIGNAL(activated(const QString &)), this, SLOT(CBGrave_activated(const QString &))); |
|
336 | 225 |
connect(CBTeamLvl, SIGNAL(activated(int)), this, SLOT(CBTeamLvl_activated(int))); |
184 | 226 |
connect(CBFort, SIGNAL(activated(const QString &)), this, SLOT(CBFort_activated(const QString &))); |
227 |
} |
|
228 |
||
229 |
void PageEditTeam::CBGrave_activated(const QString & gravename) |
|
230 |
{ |
|
231 |
QPixmap pix(datadir->absolutePath() + "/Graphics/Graves/" + gravename + ".png"); |
|
232 |
GravePreview->setPixmap(pix.copy(0, 0, 32, 32)); |
|
233 |
} |
|
234 |
||
235 |
void PageEditTeam::CBFort_activated(const QString & fortname) |
|
236 |
{ |
|
237 |
QPixmap pix(datadir->absolutePath() + "/Forts/" + fortname + "L.png"); |
|
238 |
FortPreview->setPixmap(pix); |
|
239 |
} |
|
240 |
||
336 | 241 |
void PageEditTeam::CBTeamLvl_activated(int id) |
242 |
{ |
|
243 |
QPixmap pix(QString(":/res/botlevels/%1.png").arg(id)); |
|
244 |
LevelPict->setPixmap(pix); |
|
245 |
} |
|
246 |
||
692 | 247 |
PageMultiplayer::PageMultiplayer(QWidget* parent) : |
248 |
AbstractPage(parent) |
|
184 | 249 |
{ |
250 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
251 |
||
730 | 252 |
BtnBack = addButton(tr("Back"), pageLayout, 1, 0); |
187 | 253 |
|
184 | 254 |
gameCFG = new GameCFGWidget(this); |
255 |
pageLayout->addWidget(gameCFG, 0, 0, 1, 2); |
|
696 | 256 |
|
184 | 257 |
teamsSelect = new TeamSelWidget(this); |
258 |
pageLayout->addWidget(teamsSelect, 0, 2, 1, 2); |
|
259 |
||
730 | 260 |
BtnStartMPGame = addButton(tr("Start"), pageLayout, 1, 3); |
184 | 261 |
} |
262 |
||
692 | 263 |
PageOptions::PageOptions(QWidget* parent) : |
264 |
AbstractPage(parent) |
|
184 | 265 |
{ |
266 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
427 | 267 |
pageLayout->setColumnStretch(0, 100); |
268 |
pageLayout->setColumnStretch(1, 100); |
|
269 |
pageLayout->setColumnStretch(2, 100); |
|
270 |
pageLayout->setRowStretch(0, 0); |
|
271 |
pageLayout->setRowStretch(1, 0); |
|
719 | 272 |
pageLayout->setRowStretch(2, 0); |
273 |
pageLayout->setRowStretch(3, 100); |
|
274 |
pageLayout->setRowStretch(4, 0); |
|
427 | 275 |
|
184 | 276 |
groupBox = new QGroupBox(this); |
277 |
groupBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
278 |
groupBox->setTitle(QGroupBox::tr("Teams")); |
|
279 |
pageLayout->addWidget(groupBox, 0, 0, 1, 3); |
|
280 |
||
281 |
QGridLayout * GBTlayout = new QGridLayout(groupBox); |
|
692 | 282 |
|
730 | 283 |
BtnNewTeam = addButton(tr("New team"), GBTlayout, 0, 0); |
184 | 284 |
|
285 |
CBTeamName = new QComboBox(groupBox); |
|
286 |
GBTlayout->addWidget(CBTeamName, 0, 1); |
|
287 |
||
730 | 288 |
BtnEditTeam = addButton(tr("Edit team"), GBTlayout, 0, 2); |
184 | 289 |
|
290 |
AGGroupBox = new QGroupBox(this); |
|
291 |
AGGroupBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
292 |
AGGroupBox->setTitle(QGroupBox::tr("Audio/Graphic options")); |
|
693 | 293 |
pageLayout->addWidget(AGGroupBox, 2, 1); |
184 | 294 |
|
427 | 295 |
QVBoxLayout * GBAlayout = new QVBoxLayout(AGGroupBox); |
436 | 296 |
QHBoxLayout * GBAreslayout = new QHBoxLayout(0); |
427 | 297 |
QLabel * resolution = new QLabel(AGGroupBox); |
298 |
resolution->setText(QLabel::tr("Resolution")); |
|
299 |
GBAreslayout->addWidget(resolution); |
|
300 |
||
184 | 301 |
CBResolution = new QComboBox(AGGroupBox); |
555 | 302 |
SDLInteraction sdli; |
303 |
CBResolution->addItems(sdli.getResolutions()); |
|
427 | 304 |
GBAreslayout->addWidget(CBResolution); |
305 |
GBAlayout->addLayout(GBAreslayout); |
|
306 |
||
436 | 307 |
QHBoxLayout * GBAfpslayout = new QHBoxLayout(0); |
427 | 308 |
QLabel * maxfps = new QLabel(AGGroupBox); |
309 |
maxfps->setText(QLabel::tr("FPS limit")); |
|
310 |
GBAfpslayout->addWidget(maxfps); |
|
311 |
GBAlayout->addLayout(GBAfpslayout); |
|
184 | 312 |
|
313 |
CBFullscreen = new QCheckBox(AGGroupBox); |
|
314 |
CBFullscreen->setText(QCheckBox::tr("Fullscreen")); |
|
427 | 315 |
GBAlayout->addWidget(CBFullscreen); |
184 | 316 |
|
317 |
CBEnableSound = new QCheckBox(AGGroupBox); |
|
318 |
CBEnableSound->setText(QCheckBox::tr("Enable sound")); |
|
427 | 319 |
GBAlayout->addWidget(CBEnableSound); |
184 | 320 |
|
1129 | 321 |
CBEnableMusic = new QCheckBox(AGGroupBox); |
322 |
CBEnableMusic->setText(QCheckBox::tr("Enable music")); |
|
323 |
GBAlayout->addWidget(CBEnableMusic); |
|
324 |
||
297 | 325 |
CBShowFPS = new QCheckBox(AGGroupBox); |
326 |
CBShowFPS->setText(QCheckBox::tr("Show FPS")); |
|
427 | 327 |
GBAlayout->addWidget(CBShowFPS); |
297 | 328 |
|
529 | 329 |
CBAltDamage = new QCheckBox(AGGroupBox); |
330 |
CBAltDamage->setText(QCheckBox::tr("Alternative damage show")); |
|
331 |
GBAlayout->addWidget(CBAltDamage); |
|
332 |
||
297 | 333 |
fpsedit = new FPSEdit(AGGroupBox); |
427 | 334 |
GBAfpslayout->addWidget(fpsedit); |
184 | 335 |
|
730 | 336 |
BtnSaveOptions = addButton(tr("Save"), pageLayout, 4, 2); |
184 | 337 |
|
730 | 338 |
BtnBack = addButton(tr("Back"), pageLayout, 4, 0); |
597
ec5f057ab268
kdevelop project add, initial weapons scheme button
displacer
parents:
588
diff
changeset
|
339 |
|
693 | 340 |
QGroupBox* groupWeapons = new QGroupBox(this); |
341 |
groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
342 |
groupWeapons->setTitle(QGroupBox::tr("Weapons")); |
|
343 |
pageLayout->addWidget(groupWeapons, 1, 0, 1, 3); |
|
344 |
QGridLayout * WeaponsLayout = new QGridLayout(groupWeapons); |
|
345 |
||
730 | 346 |
WeaponsButt = addButton(tr("Weapons set"), WeaponsLayout, 0, 0); |
693 | 347 |
WeaponsName = new QComboBox(this); |
348 |
WeaponsLayout->addWidget(WeaponsName, 0, 1); |
|
730 | 349 |
WeaponEdit = addButton(tr("Edit"), WeaponsLayout, 0, 2); |
597
ec5f057ab268
kdevelop project add, initial weapons scheme button
displacer
parents:
588
diff
changeset
|
350 |
|
647 | 351 |
NNGroupBox = new QGroupBox(this); |
352 |
NNGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); |
|
353 |
NNGroupBox->setTitle(QGroupBox::tr("Net options")); |
|
693 | 354 |
pageLayout->addWidget(NNGroupBox, 2, 2); |
647 | 355 |
|
356 |
QGridLayout * GBNlayout = new QGridLayout(NNGroupBox); |
|
357 |
labelNN = new QLabel(NNGroupBox); |
|
358 |
labelNN->setText(QLabel::tr("Net nick")); |
|
359 |
GBNlayout->addWidget(labelNN, 0, 0); |
|
360 |
||
361 |
editNetNick = new QLineEdit(NNGroupBox); |
|
362 |
editNetNick->setMaxLength(20); |
|
363 |
editNetNick->setText(QLineEdit::tr("unnamed")); |
|
364 |
GBNlayout->addWidget(editNetNick, 0, 1); |
|
184 | 365 |
} |
366 |
||
367 |
PageNet::PageNet(QWidget* parent) : QWidget(parent) |
|
368 |
{ |
|
369 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
370 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
371 |
pageLayout->setColumnStretch(0, 1); |
|
372 |
pageLayout->setColumnStretch(1, 1); |
|
617 | 373 |
pageLayout->setColumnStretch(2, 1); |
421 | 374 |
|
375 |
BtnNetSvrStart = new QPushButton(this); |
|
376 |
BtnNetSvrStart->setFont(*font14); |
|
377 |
BtnNetSvrStart->setText(QPushButton::tr("Start server")); |
|
617 | 378 |
pageLayout->addWidget(BtnNetSvrStart, 3, 2); |
184 | 379 |
|
636 | 380 |
QGroupBox * NetTypeGroupBox = new QGroupBox(this); |
381 |
NetTypeGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); |
|
668 | 382 |
NetTypeGroupBox->setTitle(QGroupBox::tr("Servers list")); |
636 | 383 |
pageLayout->addWidget(NetTypeGroupBox, 0, 1); |
384 |
||
385 |
QVBoxLayout * GBTlayout = new QVBoxLayout(NetTypeGroupBox); |
|
386 |
rbLocalGame = new QRadioButton(NetTypeGroupBox); |
|
668 | 387 |
rbLocalGame->setText(tr("Local")); |
636 | 388 |
rbLocalGame->setChecked(true); |
389 |
GBTlayout->addWidget(rbLocalGame); |
|
390 |
rbInternetGame = new QRadioButton(NetTypeGroupBox); |
|
668 | 391 |
rbInternetGame->setText(tr("Internet")); |
636 | 392 |
GBTlayout->addWidget(rbInternetGame); |
393 |
||
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
394 |
ConnGroupBox = new QGroupBox(this); |
421 | 395 |
ConnGroupBox->setTitle(QGroupBox::tr("Net game")); |
396 |
pageLayout->addWidget(ConnGroupBox, 2, 0, 1, 3); |
|
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
397 |
GBClayout = new QGridLayout(ConnGroupBox); |
646 | 398 |
GBClayout->setColumnStretch(0, 1); |
421 | 399 |
GBClayout->setColumnStretch(1, 1); |
400 |
GBClayout->setColumnStretch(2, 1); |
|
184 | 401 |
|
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
402 |
BtnNetConnect = new QPushButton(ConnGroupBox); |
184 | 403 |
BtnNetConnect->setFont(*font14); |
404 |
BtnNetConnect->setText(QPushButton::tr("Connect")); |
|
646 | 405 |
GBClayout->addWidget(BtnNetConnect, 2, 2); |
416 | 406 |
|
665 | 407 |
tvServersList = new QTableView(ConnGroupBox); |
671
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
408 |
tvServersList->setSelectionBehavior(QAbstractItemView::SelectRows); |
665 | 409 |
GBClayout->addWidget(tvServersList, 1, 0, 1, 3); |
421 | 410 |
|
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
411 |
BtnUpdateSList = new QPushButton(ConnGroupBox); |
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
412 |
BtnUpdateSList->setFont(*font14); |
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
413 |
BtnUpdateSList->setText(QPushButton::tr("Update")); |
646 | 414 |
GBClayout->addWidget(BtnUpdateSList, 2, 0); |
314 | 415 |
|
653
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
416 |
BtnSpecifyServer = new QPushButton(ConnGroupBox); |
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
417 |
BtnSpecifyServer->setFont(*font14); |
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
418 |
BtnSpecifyServer->setText(QPushButton::tr("Specify")); |
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
419 |
GBClayout->addWidget(BtnSpecifyServer, 2, 1); |
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
420 |
|
184 | 421 |
BtnBack = new QPushButton(this); |
422 |
BtnBack->setFont(*font14); |
|
423 |
BtnBack->setText(QPushButton::tr("Back")); |
|
412 | 424 |
pageLayout->addWidget(BtnBack, 3, 0); |
636 | 425 |
|
646 | 426 |
connect(rbLocalGame, SIGNAL(toggled(bool)), this, SLOT(updateServersList())); |
668 | 427 |
connect(BtnNetConnect, SIGNAL(clicked()), this, SLOT(slotConnect())); |
184 | 428 |
} |
429 |
||
646 | 430 |
void PageNet::updateServersList() |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
431 |
{ |
636 | 432 |
if (rbLocalGame->isChecked()) |
671
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
433 |
tvServersList->setModel(new HWNetUdpModel(tvServersList)); |
667 | 434 |
else |
671
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
435 |
tvServersList->setModel(new HWNetWwwModel(tvServersList)); |
659 | 436 |
|
673 | 437 |
tvServersList->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); |
438 |
||
665 | 439 |
static_cast<HWNetServersModel *>(tvServersList->model())->updateList(); |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
440 |
|
665 | 441 |
connect(BtnUpdateSList, SIGNAL(clicked()), static_cast<HWNetServersModel *>(tvServersList->model()), SLOT(updateList())); |
671
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
442 |
connect(tvServersList, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotConnect())); |
646 | 443 |
} |
444 |
||
445 |
void PageNet::slotConnect() |
|
446 |
{ |
|
671
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
447 |
HWNetServersModel * model = static_cast<HWNetServersModel *>(tvServersList->model()); |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
448 |
QModelIndex mi = tvServersList->currentIndex(); |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
449 |
if(!mi.isValid()) |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
450 |
{ |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
451 |
QMessageBox::information(this, tr("Error"), tr("Please, select server from the list above")); |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
452 |
return; |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
453 |
} |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
454 |
QString host = model->index(mi.row(), 1).data().toString(); |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
455 |
quint16 port = model->index(mi.row(), 2).data().toUInt(); |
672
08ed55ea1e2a
- Fix a bug when server fails to start, and then connecting to another server on the same host (strange, the fix won't work on my machine)
unc0rr
parents:
671
diff
changeset
|
456 |
|
08ed55ea1e2a
- Fix a bug when server fails to start, and then connecting to another server on the same host (strange, the fix won't work on my machine)
unc0rr
parents:
671
diff
changeset
|
457 |
emit connectClicked(host, port); |
646 | 458 |
} |
459 |
||
460 |
PageNetServer::PageNetServer(QWidget* parent) : QWidget(parent) |
|
461 |
{ |
|
462 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
463 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
464 |
pageLayout->setColumnStretch(0, 1); |
|
465 |
pageLayout->setColumnStretch(1, 1); |
|
466 |
pageLayout->setColumnStretch(2, 1); |
|
467 |
||
675 | 468 |
pageLayout->setRowStretch(0, 1); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
469 |
pageLayout->setRowStretch(1, 0); |
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
470 |
|
646 | 471 |
BtnBack = new QPushButton(this); |
472 |
BtnBack->setFont(*font14); |
|
473 |
BtnBack->setText(QPushButton::tr("Back")); |
|
675 | 474 |
pageLayout->addWidget(BtnBack, 1, 0); |
646 | 475 |
|
476 |
BtnStart = new QPushButton(this); |
|
477 |
BtnStart->setFont(*font14); |
|
478 |
BtnStart->setText(QPushButton::tr("Start")); |
|
675 | 479 |
pageLayout->addWidget(BtnStart, 1, 2); |
480 |
||
481 |
QWidget * wg = new QWidget(this); |
|
482 |
pageLayout->addWidget(wg, 0, 0, 1, 3); |
|
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
483 |
|
675 | 484 |
QGridLayout * wgLayout = new QGridLayout(wg); |
485 |
wgLayout->setColumnStretch(0, 1); |
|
486 |
wgLayout->setColumnStretch(1, 3); |
|
487 |
wgLayout->setColumnStretch(2, 1); |
|
488 |
||
489 |
wgLayout->setRowStretch(0, 0); |
|
490 |
wgLayout->setRowStretch(1, 1); |
|
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
491 |
|
675 | 492 |
QGroupBox * gb = new QGroupBox(wg); |
493 |
wgLayout->addWidget(gb, 0, 1); |
|
494 |
||
495 |
QGridLayout * gbLayout = new QGridLayout(gb); |
|
496 |
||
497 |
labelSD = new QLabel(gb); |
|
498 |
labelSD->setText(QLabel::tr("Server name:")); |
|
499 |
gbLayout->addWidget(labelSD, 0, 0); |
|
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
500 |
|
675 | 501 |
leServerDescr = new QLineEdit(gb); |
502 |
gbLayout->addWidget(leServerDescr, 0, 1); |
|
503 |
||
504 |
labelPort = new QLabel(gb); |
|
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
505 |
labelPort->setText(QLabel::tr("Server port:")); |
675 | 506 |
gbLayout->addWidget(labelPort, 1, 0); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
507 |
|
675 | 508 |
sbPort = new QSpinBox(gb); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
509 |
sbPort->setMinimum(0); |
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
510 |
sbPort->setMaximum(65535); |
675 | 511 |
gbLayout->addWidget(sbPort, 1, 1); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
512 |
|
675 | 513 |
BtnDefault = new QPushButton(gb); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
514 |
BtnDefault->setText(QPushButton::tr("default")); |
675 | 515 |
gbLayout->addWidget(BtnDefault, 1, 2); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
516 |
|
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
517 |
connect(BtnDefault, SIGNAL(clicked()), this, SLOT(setDefaultPort())); |
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
518 |
} |
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
519 |
|
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
520 |
void PageNetServer::setDefaultPort() |
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
521 |
{ |
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
522 |
sbPort->setValue(46631); |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
523 |
} |
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
524 |
|
184 | 525 |
PageNetGame::PageNetGame(QWidget* parent) : QWidget(parent) |
526 |
{ |
|
527 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
528 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
452 | 529 |
pageLayout->setSizeConstraint(QLayout::SetMinimumSize); |
461 | 530 |
//pageLayout->setSpacing(1); |
531 |
//pageLayout->setMargin(1); |
|
463 | 532 |
pageLayout->setColumnStretch(0, 50); |
533 |
pageLayout->setColumnStretch(1, 50); |
|
322 | 534 |
|
461 | 535 |
// chatwidget |
536 |
pChatWidget = new HWChatWidget(this); |
|
537 |
pageLayout->addWidget(pChatWidget, 1, 0); |
|
464 | 538 |
pageLayout->setRowStretch(1, 100); |
453 | 539 |
|
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
323
diff
changeset
|
540 |
pGameCFG = new GameCFGWidget(this); |
322 | 541 |
pageLayout->addWidget(pGameCFG, 0, 0); |
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
323
diff
changeset
|
542 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
323
diff
changeset
|
543 |
pNetTeamsWidget = new TeamSelWidget(this); |
373 | 544 |
pNetTeamsWidget->setAcceptOuter(true); |
461 | 545 |
pageLayout->addWidget(pNetTeamsWidget, 0, 1, 2, 1); |
184 | 546 |
|
547 |
BtnBack = new QPushButton(this); |
|
548 |
BtnBack->setFont(*font14); |
|
549 |
BtnBack->setText(QPushButton::tr("Back")); |
|
461 | 550 |
pageLayout->addWidget(BtnBack, 2, 0); |
184 | 551 |
|
646 | 552 |
BtnGo = new QPushButton(this); |
184 | 553 |
BtnGo->setFont(*font14); |
554 |
BtnGo->setText(QPushButton::tr("Go!")); |
|
492 | 555 |
BtnGo->setEnabled(false); |
461 | 556 |
pageLayout->addWidget(BtnGo, 2, 1); |
184 | 557 |
} |
187 | 558 |
|
559 |
PageInfo::PageInfo(QWidget* parent) : QWidget(parent) |
|
560 |
{ |
|
561 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
562 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
563 |
pageLayout->setColumnStretch(0, 1); |
|
564 |
pageLayout->setColumnStretch(1, 1); |
|
565 |
pageLayout->setColumnStretch(2, 1); |
|
566 |
||
567 |
BtnBack = new QPushButton(this); |
|
568 |
BtnBack->setFont(*font14); |
|
569 |
BtnBack->setText(QPushButton::tr("Back")); |
|
570 |
pageLayout->addWidget(BtnBack, 1, 0); |
|
571 |
||
572 |
about = new About(this); |
|
573 |
pageLayout->addWidget(about, 0, 0, 1, 3); |
|
574 |
} |
|
306 | 575 |
|
576 |
PageGameStats::PageGameStats(QWidget* parent) : QWidget(parent) |
|
577 |
{ |
|
578 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
579 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
580 |
pageLayout->setColumnStretch(0, 1); |
|
581 |
pageLayout->setColumnStretch(1, 1); |
|
582 |
pageLayout->setColumnStretch(2, 1); |
|
583 |
||
584 |
BtnBack = new QPushButton(this); |
|
585 |
BtnBack->setFont(*font14); |
|
586 |
BtnBack->setText(QPushButton::tr("Back")); |
|
587 |
pageLayout->addWidget(BtnBack, 1, 0); |
|
588 |
||
307 | 589 |
labelGameStats = new QLabel(this); |
590 |
labelGameStats->setTextFormat(Qt::RichText); |
|
591 |
pageLayout->addWidget(labelGameStats, 0, 0, 1, 3); |
|
306 | 592 |
} |
586 | 593 |
|
594 |
PageSinglePlayer::PageSinglePlayer(QWidget* parent) : QWidget(parent) |
|
595 |
{ |
|
596 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
597 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
598 |
pageLayout->setMargin(25); |
|
599 |
pageLayout->setColumnStretch(0, 1); |
|
600 |
pageLayout->setColumnStretch(1, 2); |
|
601 |
pageLayout->setColumnStretch(2, 1); |
|
588 | 602 |
pageLayout->setRowStretch(0, 1); |
603 |
pageLayout->setRowStretch(3, 1); |
|
586 | 604 |
|
605 |
BtnSimpleGamePage = new QPushButton(this); |
|
606 |
BtnSimpleGamePage->setFont(*font14); |
|
607 |
BtnSimpleGamePage->setText(QPushButton::tr("Simple Game")); |
|
588 | 608 |
pageLayout->addWidget(BtnSimpleGamePage, 1, 1); |
586 | 609 |
|
610 |
BtnTrainPage = new QPushButton(this); |
|
611 |
BtnTrainPage->setFont(*font14); |
|
612 |
BtnTrainPage->setText(QPushButton::tr("Training")); |
|
588 | 613 |
pageLayout->addWidget(BtnTrainPage, 2, 1); |
586 | 614 |
|
615 |
BtnBack = new QPushButton(this); |
|
616 |
BtnBack->setFont(*font14); |
|
617 |
BtnBack->setText(QPushButton::tr("Back")); |
|
588 | 618 |
pageLayout->addWidget(BtnBack, 4, 0); |
586 | 619 |
|
620 |
} |
|
621 |
||
587 | 622 |
PageTraining::PageTraining(QWidget* parent) : QWidget(parent) |
623 |
{ |
|
624 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
625 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
626 |
pageLayout->setMargin(25); |
|
627 |
pageLayout->setColumnStretch(0, 1); |
|
628 |
pageLayout->setColumnStretch(1, 2); |
|
629 |
pageLayout->setColumnStretch(2, 1); |
|
630 |
||
631 |
BtnStartTrain = new QPushButton(this); |
|
632 |
BtnStartTrain->setFont(*font14); |
|
633 |
BtnStartTrain->setText(QPushButton::tr("Go!")); |
|
634 |
pageLayout->addWidget(BtnStartTrain, 1, 2); |
|
635 |
||
636 |
BtnBack = new QPushButton(this); |
|
637 |
BtnBack->setFont(*font14); |
|
638 |
BtnBack->setText(QPushButton::tr("Back")); |
|
639 |
pageLayout->addWidget(BtnBack, 1, 0); |
|
640 |
} |
|
641 |
||
923
b3d097097b54
Use default ammostore string size for weapons number instead of predefined const
unc0rr
parents:
788
diff
changeset
|
642 |
PageSelectWeapon::PageSelectWeapon(QWidget* parent) : |
684 | 643 |
AbstractPage(parent) |
600 | 644 |
{ |
645 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
646 |
pageLayout->setMargin(25); |
|
923
b3d097097b54
Use default ammostore string size for weapons number instead of predefined const
unc0rr
parents:
788
diff
changeset
|
647 |
|
b3d097097b54
Use default ammostore string size for weapons number instead of predefined const
unc0rr
parents:
788
diff
changeset
|
648 |
pWeapons=new SelWeaponWidget(cDefaultAmmoStore->size() - 10, this); |
718 | 649 |
pageLayout->addWidget(pWeapons, 0, 0, 1, 4); |
600 | 650 |
|
730 | 651 |
BtnBack = addButton(tr("Back"), pageLayout, 1, 0); |
652 |
BtnDefault = addButton(tr("Default"), pageLayout, 1, 1); |
|
653 |
BtnDelete = addButton(tr("Delete"), pageLayout, 1, 2); |
|
654 |
BtnSave = addButton(tr("Save"), pageLayout, 1, 3); |
|
600 | 655 |
} |
656 |
||
686 | 657 |
PageInGame::PageInGame(QWidget* parent) : |
658 |
AbstractPage(parent) |
|
659 |
{ |
|
660 |
QLabel * label = new QLabel(this); |
|
661 |
label->setText("In game..."); |
|
662 |
} |