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