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