author | displacer |
Tue, 08 Jan 2008 20:32:17 +0000 | |
changeset 694 | 436045756181 |
parent 693 | 32a546d1eb3e |
child 696 | d6f32ed6edc8 |
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); |
|
276 |
teamsSelect = new TeamSelWidget(this); |
|
277 |
pageLayout->addWidget(teamsSelect, 0, 2, 1, 2); |
|
278 |
||
692 | 279 |
BtnStartMPGame = addButton("Start", pageLayout, 1, 3); |
184 | 280 |
} |
281 |
||
692 | 282 |
PageOptions::PageOptions(QWidget* parent) : |
283 |
AbstractPage(parent) |
|
184 | 284 |
{ |
285 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
427 | 286 |
pageLayout->setColumnStretch(0, 100); |
287 |
pageLayout->setColumnStretch(1, 100); |
|
288 |
pageLayout->setColumnStretch(2, 100); |
|
289 |
pageLayout->setRowStretch(0, 0); |
|
290 |
pageLayout->setRowStretch(1, 0); |
|
291 |
pageLayout->setRowStretch(2, 100); |
|
292 |
pageLayout->setRowStretch(3, 0); |
|
293 |
||
184 | 294 |
groupBox = new QGroupBox(this); |
295 |
groupBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
296 |
groupBox->setTitle(QGroupBox::tr("Teams")); |
|
297 |
pageLayout->addWidget(groupBox, 0, 0, 1, 3); |
|
298 |
||
299 |
QGridLayout * GBTlayout = new QGridLayout(groupBox); |
|
692 | 300 |
|
301 |
BtnNewTeam = addButton("New team", GBTlayout, 0, 0); |
|
184 | 302 |
|
303 |
CBTeamName = new QComboBox(groupBox); |
|
304 |
GBTlayout->addWidget(CBTeamName, 0, 1); |
|
305 |
||
692 | 306 |
BtnEditTeam = addButton("Edit team", GBTlayout, 0, 2); |
184 | 307 |
|
308 |
AGGroupBox = new QGroupBox(this); |
|
309 |
AGGroupBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
310 |
AGGroupBox->setTitle(QGroupBox::tr("Audio/Graphic options")); |
|
693 | 311 |
pageLayout->addWidget(AGGroupBox, 2, 1); |
184 | 312 |
|
427 | 313 |
QVBoxLayout * GBAlayout = new QVBoxLayout(AGGroupBox); |
436 | 314 |
QHBoxLayout * GBAreslayout = new QHBoxLayout(0); |
427 | 315 |
QLabel * resolution = new QLabel(AGGroupBox); |
316 |
resolution->setText(QLabel::tr("Resolution")); |
|
317 |
GBAreslayout->addWidget(resolution); |
|
318 |
||
184 | 319 |
CBResolution = new QComboBox(AGGroupBox); |
555 | 320 |
SDLInteraction sdli; |
321 |
CBResolution->addItems(sdli.getResolutions()); |
|
427 | 322 |
GBAreslayout->addWidget(CBResolution); |
323 |
GBAlayout->addLayout(GBAreslayout); |
|
324 |
||
436 | 325 |
QHBoxLayout * GBAfpslayout = new QHBoxLayout(0); |
427 | 326 |
QLabel * maxfps = new QLabel(AGGroupBox); |
327 |
maxfps->setText(QLabel::tr("FPS limit")); |
|
328 |
GBAfpslayout->addWidget(maxfps); |
|
329 |
GBAlayout->addLayout(GBAfpslayout); |
|
184 | 330 |
|
331 |
CBFullscreen = new QCheckBox(AGGroupBox); |
|
332 |
CBFullscreen->setText(QCheckBox::tr("Fullscreen")); |
|
427 | 333 |
GBAlayout->addWidget(CBFullscreen); |
184 | 334 |
|
335 |
CBEnableSound = new QCheckBox(AGGroupBox); |
|
336 |
CBEnableSound->setText(QCheckBox::tr("Enable sound")); |
|
427 | 337 |
GBAlayout->addWidget(CBEnableSound); |
184 | 338 |
|
297 | 339 |
CBShowFPS = new QCheckBox(AGGroupBox); |
340 |
CBShowFPS->setText(QCheckBox::tr("Show FPS")); |
|
427 | 341 |
GBAlayout->addWidget(CBShowFPS); |
297 | 342 |
|
529 | 343 |
CBAltDamage = new QCheckBox(AGGroupBox); |
344 |
CBAltDamage->setText(QCheckBox::tr("Alternative damage show")); |
|
345 |
GBAlayout->addWidget(CBAltDamage); |
|
346 |
||
297 | 347 |
fpsedit = new FPSEdit(AGGroupBox); |
427 | 348 |
GBAfpslayout->addWidget(fpsedit); |
184 | 349 |
|
692 | 350 |
BtnSaveOptions = addButton("Save", pageLayout, 4, 2); |
184 | 351 |
|
692 | 352 |
BtnBack = addButton("Back", pageLayout, 4, 0); |
597
ec5f057ab268
kdevelop project add, initial weapons scheme button
displacer
parents:
588
diff
changeset
|
353 |
|
693 | 354 |
QGroupBox* groupWeapons = new QGroupBox(this); |
355 |
groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
356 |
groupWeapons->setTitle(QGroupBox::tr("Weapons")); |
|
357 |
pageLayout->addWidget(groupWeapons, 1, 0, 1, 3); |
|
358 |
QGridLayout * WeaponsLayout = new QGridLayout(groupWeapons); |
|
359 |
||
360 |
WeaponsButt = addButton("Weapons scheme", WeaponsLayout, 0, 0); |
|
361 |
WeaponsName = new QComboBox(this); |
|
362 |
WeaponsLayout->addWidget(WeaponsName, 0, 1); |
|
363 |
WeaponEdit = addButton("Edit", WeaponsLayout, 0, 2); |
|
597
ec5f057ab268
kdevelop project add, initial weapons scheme button
displacer
parents:
588
diff
changeset
|
364 |
|
647 | 365 |
NNGroupBox = new QGroupBox(this); |
366 |
NNGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); |
|
367 |
NNGroupBox->setTitle(QGroupBox::tr("Net options")); |
|
693 | 368 |
pageLayout->addWidget(NNGroupBox, 2, 2); |
647 | 369 |
|
370 |
QGridLayout * GBNlayout = new QGridLayout(NNGroupBox); |
|
371 |
labelNN = new QLabel(NNGroupBox); |
|
372 |
labelNN->setText(QLabel::tr("Net nick")); |
|
373 |
GBNlayout->addWidget(labelNN, 0, 0); |
|
374 |
||
375 |
editNetNick = new QLineEdit(NNGroupBox); |
|
376 |
editNetNick->setMaxLength(20); |
|
377 |
editNetNick->setText(QLineEdit::tr("unnamed")); |
|
378 |
GBNlayout->addWidget(editNetNick, 0, 1); |
|
184 | 379 |
} |
380 |
||
381 |
PageNet::PageNet(QWidget* parent) : QWidget(parent) |
|
382 |
{ |
|
383 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
384 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
385 |
pageLayout->setColumnStretch(0, 1); |
|
386 |
pageLayout->setColumnStretch(1, 1); |
|
617 | 387 |
pageLayout->setColumnStretch(2, 1); |
421 | 388 |
|
389 |
BtnNetSvrStart = new QPushButton(this); |
|
390 |
BtnNetSvrStart->setFont(*font14); |
|
391 |
BtnNetSvrStart->setText(QPushButton::tr("Start server")); |
|
617 | 392 |
pageLayout->addWidget(BtnNetSvrStart, 3, 2); |
184 | 393 |
|
636 | 394 |
QGroupBox * NetTypeGroupBox = new QGroupBox(this); |
395 |
NetTypeGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); |
|
668 | 396 |
NetTypeGroupBox->setTitle(QGroupBox::tr("Servers list")); |
636 | 397 |
pageLayout->addWidget(NetTypeGroupBox, 0, 1); |
398 |
||
399 |
QVBoxLayout * GBTlayout = new QVBoxLayout(NetTypeGroupBox); |
|
400 |
rbLocalGame = new QRadioButton(NetTypeGroupBox); |
|
668 | 401 |
rbLocalGame->setText(tr("Local")); |
636 | 402 |
rbLocalGame->setChecked(true); |
403 |
GBTlayout->addWidget(rbLocalGame); |
|
404 |
rbInternetGame = new QRadioButton(NetTypeGroupBox); |
|
668 | 405 |
rbInternetGame->setText(tr("Internet")); |
636 | 406 |
GBTlayout->addWidget(rbInternetGame); |
407 |
||
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
408 |
ConnGroupBox = new QGroupBox(this); |
421 | 409 |
ConnGroupBox->setTitle(QGroupBox::tr("Net game")); |
410 |
pageLayout->addWidget(ConnGroupBox, 2, 0, 1, 3); |
|
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
411 |
GBClayout = new QGridLayout(ConnGroupBox); |
646 | 412 |
GBClayout->setColumnStretch(0, 1); |
421 | 413 |
GBClayout->setColumnStretch(1, 1); |
414 |
GBClayout->setColumnStretch(2, 1); |
|
184 | 415 |
|
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
416 |
BtnNetConnect = new QPushButton(ConnGroupBox); |
184 | 417 |
BtnNetConnect->setFont(*font14); |
418 |
BtnNetConnect->setText(QPushButton::tr("Connect")); |
|
646 | 419 |
GBClayout->addWidget(BtnNetConnect, 2, 2); |
416 | 420 |
|
665 | 421 |
tvServersList = new QTableView(ConnGroupBox); |
671
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
422 |
tvServersList->setSelectionBehavior(QAbstractItemView::SelectRows); |
665 | 423 |
GBClayout->addWidget(tvServersList, 1, 0, 1, 3); |
421 | 424 |
|
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
425 |
BtnUpdateSList = new QPushButton(ConnGroupBox); |
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
426 |
BtnUpdateSList->setFont(*font14); |
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
427 |
BtnUpdateSList->setText(QPushButton::tr("Update")); |
646 | 428 |
GBClayout->addWidget(BtnUpdateSList, 2, 0); |
314 | 429 |
|
653
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
430 |
BtnSpecifyServer = new QPushButton(ConnGroupBox); |
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
431 |
BtnSpecifyServer->setFont(*font14); |
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
432 |
BtnSpecifyServer->setText(QPushButton::tr("Specify")); |
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
433 |
GBClayout->addWidget(BtnSpecifyServer, 2, 1); |
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
434 |
|
184 | 435 |
BtnBack = new QPushButton(this); |
436 |
BtnBack->setFont(*font14); |
|
437 |
BtnBack->setText(QPushButton::tr("Back")); |
|
412 | 438 |
pageLayout->addWidget(BtnBack, 3, 0); |
636 | 439 |
|
646 | 440 |
connect(rbLocalGame, SIGNAL(toggled(bool)), this, SLOT(updateServersList())); |
668 | 441 |
connect(BtnNetConnect, SIGNAL(clicked()), this, SLOT(slotConnect())); |
184 | 442 |
} |
443 |
||
646 | 444 |
void PageNet::updateServersList() |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
445 |
{ |
636 | 446 |
if (rbLocalGame->isChecked()) |
671
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
447 |
tvServersList->setModel(new HWNetUdpModel(tvServersList)); |
667 | 448 |
else |
671
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
449 |
tvServersList->setModel(new HWNetWwwModel(tvServersList)); |
659 | 450 |
|
673 | 451 |
tvServersList->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); |
452 |
||
665 | 453 |
static_cast<HWNetServersModel *>(tvServersList->model())->updateList(); |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
454 |
|
665 | 455 |
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
|
456 |
connect(tvServersList, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotConnect())); |
646 | 457 |
} |
458 |
||
459 |
void PageNet::slotConnect() |
|
460 |
{ |
|
671
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
461 |
HWNetServersModel * model = static_cast<HWNetServersModel *>(tvServersList->model()); |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
462 |
QModelIndex mi = tvServersList->currentIndex(); |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
463 |
if(!mi.isValid()) |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
464 |
{ |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
465 |
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
|
466 |
return; |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
467 |
} |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
468 |
QString host = model->index(mi.row(), 1).data().toString(); |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
469 |
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
|
470 |
|
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
|
471 |
emit connectClicked(host, port); |
646 | 472 |
} |
473 |
||
474 |
PageNetServer::PageNetServer(QWidget* parent) : QWidget(parent) |
|
475 |
{ |
|
476 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
477 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
478 |
pageLayout->setColumnStretch(0, 1); |
|
479 |
pageLayout->setColumnStretch(1, 1); |
|
480 |
pageLayout->setColumnStretch(2, 1); |
|
481 |
||
675 | 482 |
pageLayout->setRowStretch(0, 1); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
483 |
pageLayout->setRowStretch(1, 0); |
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
484 |
|
646 | 485 |
BtnBack = new QPushButton(this); |
486 |
BtnBack->setFont(*font14); |
|
487 |
BtnBack->setText(QPushButton::tr("Back")); |
|
675 | 488 |
pageLayout->addWidget(BtnBack, 1, 0); |
646 | 489 |
|
490 |
BtnStart = new QPushButton(this); |
|
491 |
BtnStart->setFont(*font14); |
|
492 |
BtnStart->setText(QPushButton::tr("Start")); |
|
675 | 493 |
pageLayout->addWidget(BtnStart, 1, 2); |
494 |
||
495 |
QWidget * wg = new QWidget(this); |
|
496 |
pageLayout->addWidget(wg, 0, 0, 1, 3); |
|
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
497 |
|
675 | 498 |
QGridLayout * wgLayout = new QGridLayout(wg); |
499 |
wgLayout->setColumnStretch(0, 1); |
|
500 |
wgLayout->setColumnStretch(1, 3); |
|
501 |
wgLayout->setColumnStretch(2, 1); |
|
502 |
||
503 |
wgLayout->setRowStretch(0, 0); |
|
504 |
wgLayout->setRowStretch(1, 1); |
|
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
505 |
|
675 | 506 |
QGroupBox * gb = new QGroupBox(wg); |
507 |
wgLayout->addWidget(gb, 0, 1); |
|
508 |
||
509 |
QGridLayout * gbLayout = new QGridLayout(gb); |
|
510 |
||
511 |
labelSD = new QLabel(gb); |
|
512 |
labelSD->setText(QLabel::tr("Server name:")); |
|
513 |
gbLayout->addWidget(labelSD, 0, 0); |
|
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
514 |
|
675 | 515 |
leServerDescr = new QLineEdit(gb); |
516 |
gbLayout->addWidget(leServerDescr, 0, 1); |
|
517 |
||
518 |
labelPort = new QLabel(gb); |
|
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
519 |
labelPort->setText(QLabel::tr("Server port:")); |
675 | 520 |
gbLayout->addWidget(labelPort, 1, 0); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
521 |
|
675 | 522 |
sbPort = new QSpinBox(gb); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
523 |
sbPort->setMinimum(0); |
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
524 |
sbPort->setMaximum(65535); |
675 | 525 |
gbLayout->addWidget(sbPort, 1, 1); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
526 |
|
675 | 527 |
BtnDefault = new QPushButton(gb); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
528 |
BtnDefault->setText(QPushButton::tr("default")); |
675 | 529 |
gbLayout->addWidget(BtnDefault, 1, 2); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
530 |
|
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
531 |
connect(BtnDefault, SIGNAL(clicked()), this, SLOT(setDefaultPort())); |
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 |
|
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
534 |
void PageNetServer::setDefaultPort() |
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 |
sbPort->setValue(46631); |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
537 |
} |
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
538 |
|
184 | 539 |
PageNetGame::PageNetGame(QWidget* parent) : QWidget(parent) |
540 |
{ |
|
541 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
542 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
452 | 543 |
pageLayout->setSizeConstraint(QLayout::SetMinimumSize); |
461 | 544 |
//pageLayout->setSpacing(1); |
545 |
//pageLayout->setMargin(1); |
|
463 | 546 |
pageLayout->setColumnStretch(0, 50); |
547 |
pageLayout->setColumnStretch(1, 50); |
|
322 | 548 |
|
461 | 549 |
// chatwidget |
550 |
pChatWidget = new HWChatWidget(this); |
|
551 |
pageLayout->addWidget(pChatWidget, 1, 0); |
|
464 | 552 |
pageLayout->setRowStretch(1, 100); |
453 | 553 |
|
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
323
diff
changeset
|
554 |
pGameCFG = new GameCFGWidget(this); |
322 | 555 |
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
|
556 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
323
diff
changeset
|
557 |
pNetTeamsWidget = new TeamSelWidget(this); |
373 | 558 |
pNetTeamsWidget->setAcceptOuter(true); |
461 | 559 |
pageLayout->addWidget(pNetTeamsWidget, 0, 1, 2, 1); |
184 | 560 |
|
561 |
BtnBack = new QPushButton(this); |
|
562 |
BtnBack->setFont(*font14); |
|
563 |
BtnBack->setText(QPushButton::tr("Back")); |
|
461 | 564 |
pageLayout->addWidget(BtnBack, 2, 0); |
184 | 565 |
|
646 | 566 |
BtnGo = new QPushButton(this); |
184 | 567 |
BtnGo->setFont(*font14); |
568 |
BtnGo->setText(QPushButton::tr("Go!")); |
|
492 | 569 |
BtnGo->setEnabled(false); |
461 | 570 |
pageLayout->addWidget(BtnGo, 2, 1); |
184 | 571 |
} |
187 | 572 |
|
573 |
PageInfo::PageInfo(QWidget* parent) : QWidget(parent) |
|
574 |
{ |
|
575 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
576 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
577 |
pageLayout->setColumnStretch(0, 1); |
|
578 |
pageLayout->setColumnStretch(1, 1); |
|
579 |
pageLayout->setColumnStretch(2, 1); |
|
580 |
||
581 |
BtnBack = new QPushButton(this); |
|
582 |
BtnBack->setFont(*font14); |
|
583 |
BtnBack->setText(QPushButton::tr("Back")); |
|
584 |
pageLayout->addWidget(BtnBack, 1, 0); |
|
585 |
||
586 |
about = new About(this); |
|
587 |
pageLayout->addWidget(about, 0, 0, 1, 3); |
|
588 |
} |
|
306 | 589 |
|
590 |
PageGameStats::PageGameStats(QWidget* parent) : QWidget(parent) |
|
591 |
{ |
|
592 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
593 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
594 |
pageLayout->setColumnStretch(0, 1); |
|
595 |
pageLayout->setColumnStretch(1, 1); |
|
596 |
pageLayout->setColumnStretch(2, 1); |
|
597 |
||
598 |
BtnBack = new QPushButton(this); |
|
599 |
BtnBack->setFont(*font14); |
|
600 |
BtnBack->setText(QPushButton::tr("Back")); |
|
601 |
pageLayout->addWidget(BtnBack, 1, 0); |
|
602 |
||
307 | 603 |
labelGameStats = new QLabel(this); |
604 |
labelGameStats->setTextFormat(Qt::RichText); |
|
605 |
pageLayout->addWidget(labelGameStats, 0, 0, 1, 3); |
|
306 | 606 |
} |
586 | 607 |
|
608 |
PageSinglePlayer::PageSinglePlayer(QWidget* parent) : QWidget(parent) |
|
609 |
{ |
|
610 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
611 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
612 |
pageLayout->setMargin(25); |
|
613 |
pageLayout->setColumnStretch(0, 1); |
|
614 |
pageLayout->setColumnStretch(1, 2); |
|
615 |
pageLayout->setColumnStretch(2, 1); |
|
588 | 616 |
pageLayout->setRowStretch(0, 1); |
617 |
pageLayout->setRowStretch(3, 1); |
|
586 | 618 |
|
619 |
BtnSimpleGamePage = new QPushButton(this); |
|
620 |
BtnSimpleGamePage->setFont(*font14); |
|
621 |
BtnSimpleGamePage->setText(QPushButton::tr("Simple Game")); |
|
588 | 622 |
pageLayout->addWidget(BtnSimpleGamePage, 1, 1); |
586 | 623 |
|
624 |
BtnTrainPage = new QPushButton(this); |
|
625 |
BtnTrainPage->setFont(*font14); |
|
626 |
BtnTrainPage->setText(QPushButton::tr("Training")); |
|
588 | 627 |
pageLayout->addWidget(BtnTrainPage, 2, 1); |
586 | 628 |
|
629 |
BtnBack = new QPushButton(this); |
|
630 |
BtnBack->setFont(*font14); |
|
631 |
BtnBack->setText(QPushButton::tr("Back")); |
|
588 | 632 |
pageLayout->addWidget(BtnBack, 4, 0); |
586 | 633 |
|
634 |
} |
|
635 |
||
587 | 636 |
PageTraining::PageTraining(QWidget* parent) : QWidget(parent) |
637 |
{ |
|
638 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
639 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
640 |
pageLayout->setMargin(25); |
|
641 |
pageLayout->setColumnStretch(0, 1); |
|
642 |
pageLayout->setColumnStretch(1, 2); |
|
643 |
pageLayout->setColumnStretch(2, 1); |
|
644 |
||
645 |
BtnStartTrain = new QPushButton(this); |
|
646 |
BtnStartTrain->setFont(*font14); |
|
647 |
BtnStartTrain->setText(QPushButton::tr("Go!")); |
|
648 |
pageLayout->addWidget(BtnStartTrain, 1, 2); |
|
649 |
||
650 |
BtnBack = new QPushButton(this); |
|
651 |
BtnBack->setFont(*font14); |
|
652 |
BtnBack->setText(QPushButton::tr("Back")); |
|
653 |
pageLayout->addWidget(BtnBack, 1, 0); |
|
654 |
} |
|
655 |
||
684 | 656 |
PageSelectWeapon::PageSelectWeapon(QWidget* parent) : |
657 |
AbstractPage(parent) |
|
600 | 658 |
{ |
659 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
660 |
pageLayout->setMargin(25); |
|
612
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
603
diff
changeset
|
661 |
|
683 | 662 |
pWeapons=new SelWeaponWidget(20, this); |
663 |
pageLayout->addWidget(pWeapons, 0, 0, 1, 3); |
|
600 | 664 |
|
684 | 665 |
BtnBack = addButton("Back", pageLayout, 1, 0); |
666 |
BtnDefault = addButton("Default", pageLayout, 1, 1); |
|
667 |
BtnSave = addButton("Save", pageLayout, 1, 2); |
|
600 | 668 |
} |
669 |
||
686 | 670 |
PageInGame::PageInGame(QWidget* parent) : |
671 |
AbstractPage(parent) |
|
672 |
{ |
|
673 |
QLabel * label = new QLabel(this); |
|
674 |
label->setText("In game..."); |
|
675 |
} |