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