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