author | unc0rr |
Fri, 24 Oct 2008 13:00:53 +0000 | |
changeset 1405 | ee4b28a1861d |
parent 1404 | 2b6b6809c2e4 |
child 1409 | d1cbe4a57ebf |
permissions | -rw-r--r-- |
184 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
1236 | 3 |
* Copyright (c) 2006-2008 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> |
1252 | 35 |
#include <QTabWidget> |
1377 | 36 |
#include <QTextBrowser> |
1399 | 37 |
#include <QTableWidget> |
184 | 38 |
|
39 |
#include "pages.h" |
|
40 |
#include "sdlkeys.h" |
|
41 |
#include "hwconsts.h" |
|
42 |
#include "gamecfgwidget.h" |
|
43 |
#include "teamselect.h" |
|
44 |
#include "gamecfgwidget.h" |
|
45 |
#include "SquareLabel.h" |
|
46 |
#include "mapContainer.h" |
|
187 | 47 |
#include "about.h" |
297 | 48 |
#include "fpsedit.h" |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
49 |
#include "netserverslist.h" |
412 | 50 |
#include "netudpwidget.h" |
461 | 51 |
#include "chatwidget.h" |
579 | 52 |
#include "playrecordpage.h" |
612
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
603
diff
changeset
|
53 |
#include "selectWeapon.h" |
1192 | 54 |
#include "igbox.h" |
1238
914bd2a9a249
Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents:
1236
diff
changeset
|
55 |
#include "hats.h" |
184 | 56 |
|
684 | 57 |
PageMain::PageMain(QWidget* parent) : |
58 |
AbstractPage(parent) |
|
184 | 59 |
{ |
60 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
1148 | 61 |
//pageLayout->setColumnStretch(0, 1); |
62 |
//pageLayout->setColumnStretch(1, 2); |
|
63 |
//pageLayout->setColumnStretch(2, 1); |
|
184 | 64 |
|
1199 | 65 |
//QPushButton* btnLogo = addButton(":/res/HedgewarsTitle.png", pageLayout, 0, 0, 1, 4, true); |
66 |
//pageLayout->setAlignment(btnLogo, Qt::AlignHCenter); |
|
1148 | 67 |
pageLayout->setRowStretch(0, 1); |
1150 | 68 |
pageLayout->setRowStretch(1, 1); |
69 |
pageLayout->setRowStretch(2, 0); |
|
70 |
pageLayout->setRowStretch(3, 1); |
|
1199 | 71 |
pageLayout->setRowStretch(4, 1); |
184 | 72 |
|
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1151
diff
changeset
|
73 |
BtnSinglePlayer = addButton(":/res/LocalPlay.png", pageLayout, 2, 0, 1, 2, true); |
1150 | 74 |
pageLayout->setAlignment(BtnSinglePlayer, Qt::AlignHCenter); |
184 | 75 |
|
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1151
diff
changeset
|
76 |
BtnNet = addButton(":/res/NetworkPlay.png", pageLayout, 2, 2, 1, 2, true); |
1150 | 77 |
pageLayout->setAlignment(BtnNet, Qt::AlignHCenter); |
579 | 78 |
|
1199 | 79 |
BtnSetup = addButton(":/res/Settings.png", pageLayout, 4, 3, true); |
184 | 80 |
|
1199 | 81 |
//BtnInfo = addButton(":/res/About.png", pageLayout, 3, 1, 1, 2, true); |
82 |
BtnInfo = addButton(":/res/HedgewarsTitle.png", pageLayout, 0, 0, 1, 4, true); |
|
1212 | 83 |
BtnInfo->setStyleSheet("border: transparent;background: transparent;"); |
1150 | 84 |
pageLayout->setAlignment(BtnInfo, Qt::AlignHCenter); |
1199 | 85 |
//pageLayout->setAlignment(BtnInfo, Qt::AlignHCenter); |
184 | 86 |
|
1199 | 87 |
BtnExit = addButton(":/res/Exit.png", pageLayout, 4, 0, 1, 1, true); |
184 | 88 |
} |
89 |
||
788
00720357601f
- Get rid of PageSimpleGame, now pressing 'quick game' just starts round
unc0rr
parents:
730
diff
changeset
|
90 |
PageEditTeam::PageEditTeam(QWidget* parent) : |
692 | 91 |
AbstractPage(parent) |
184 | 92 |
{ |
93 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
1252 | 94 |
QTabWidget * tbw = new QTabWidget(this); |
1389 | 95 |
QWidget * page1 = new QWidget(this); |
96 |
QWidget * page2 = new QWidget(this); |
|
1252 | 97 |
tbw->addTab(page1, tr("General")); |
98 |
tbw->addTab(page2, tr("Advanced")); |
|
99 |
pageLayout->addWidget(tbw, 0, 0, 1, 3); |
|
100 |
BtnTeamDiscard = addButton(":/res/Exit.png", pageLayout, 1, 0, true); |
|
101 |
BtnTeamSave = addButton(":/res/Save.png", pageLayout, 1, 2, true);; |
|
184 | 102 |
|
1252 | 103 |
QHBoxLayout * page1Layout = new QHBoxLayout(page1); |
104 |
page1Layout->setAlignment(Qt::AlignTop); |
|
105 |
QGridLayout * page2Layout = new QGridLayout(page2); |
|
106 |
||
107 |
// ====== Page 1 ====== |
|
108 |
QVBoxLayout * vbox1 = new QVBoxLayout(); |
|
109 |
QVBoxLayout * vbox2 = new QVBoxLayout(); |
|
110 |
QVBoxLayout * vbox3 = new QVBoxLayout(); |
|
111 |
page1Layout->addLayout(vbox1); |
|
112 |
page1Layout->addLayout(vbox2); |
|
113 |
page1Layout->addLayout(vbox3); |
|
114 |
||
588 | 115 |
GBoxHedgehogs = new QGroupBox(this); |
184 | 116 |
GBoxHedgehogs->setTitle(QGroupBox::tr("Team Members")); |
117 |
GBoxHedgehogs->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
118 |
QGridLayout * GBHLayout = new QGridLayout(GBoxHedgehogs); |
|
1238
914bd2a9a249
Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents:
1236
diff
changeset
|
119 |
|
914bd2a9a249
Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents:
1236
diff
changeset
|
120 |
HatsModel * hatsModel = new HatsModel(GBoxHedgehogs); |
184 | 121 |
for(int i = 0; i < 8; i++) |
122 |
{ |
|
123 |
HHNameEdit[i] = new QLineEdit(GBoxHedgehogs); |
|
1216
df1b19976e28
Allow team and hh name length be up to 64 letters length
unc0rr
parents:
1212
diff
changeset
|
124 |
HHNameEdit[i]->setMaxLength(64); |
1238
914bd2a9a249
Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents:
1236
diff
changeset
|
125 |
HHNameEdit[i]->setMinimumWidth(120); |
914bd2a9a249
Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents:
1236
diff
changeset
|
126 |
GBHLayout->addWidget(HHNameEdit[i], i, 0); |
914bd2a9a249
Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents:
1236
diff
changeset
|
127 |
|
914bd2a9a249
Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents:
1236
diff
changeset
|
128 |
HHHats[i] = new QComboBox(GBoxHedgehogs); |
914bd2a9a249
Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents:
1236
diff
changeset
|
129 |
HHHats[i]->setModel(hatsModel); |
1282 | 130 |
HHHats[i]->setIconSize(QSize(32, 37)); |
131 |
//HHHats[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents); |
|
1239 | 132 |
//HHHats[i]->setModelColumn(1); |
1240 | 133 |
//HHHats[i]->setMinimumWidth(132); |
1238
914bd2a9a249
Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents:
1236
diff
changeset
|
134 |
GBHLayout->addWidget(HHHats[i], i, 1); |
184 | 135 |
} |
1252 | 136 |
vbox1->addWidget(GBoxHedgehogs); |
137 |
||
138 |
||
1288
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
139 |
GBoxTeam = new QGroupBox(this); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
140 |
GBoxTeam->setTitle(QGroupBox::tr("Team")); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
141 |
GBoxTeam->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
142 |
QVBoxLayout * GBTLayout = new QVBoxLayout(GBoxTeam); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
143 |
TeamNameEdit = new QLineEdit(GBoxTeam); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
144 |
TeamNameEdit->setMaxLength(64); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
145 |
GBTLayout->addWidget(TeamNameEdit); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
146 |
vbox2->addWidget(GBoxTeam); |
1252 | 147 |
|
1290 | 148 |
CBTeamLvl = new QComboBox(GBoxTeam); |
1287 | 149 |
CBTeamLvl->setIconSize(QSize(32, 32)); |
150 |
CBTeamLvl->addItem(QIcon(":/res/botlevels/0.png"), QComboBox::tr("Human")); |
|
151 |
for(int i = 5; i > 0; i--) |
|
152 |
CBTeamLvl->addItem( |
|
153 |
QIcon(QString(":/res/botlevels/%1.png").arg(6 - i)), |
|
154 |
QString("%1 %2").arg(QComboBox::tr("Level")).arg(i) |
|
155 |
); |
|
1288
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
156 |
GBTLayout->addWidget(CBTeamLvl); |
1287 | 157 |
|
1290 | 158 |
CBGrave = new QComboBox(GBoxTeam); |
1288
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
159 |
CBGrave->setMaxCount(65535); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
160 |
CBGrave->setIconSize(QSize(32, 32)); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
161 |
GBTLayout->addWidget(CBGrave); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
162 |
|
1252 | 163 |
GBoxFort = new QGroupBox(this); |
164 |
GBoxFort->setTitle(QGroupBox::tr("Fort")); |
|
165 |
QGridLayout * GBFLayout = new QGridLayout(GBoxFort); |
|
166 |
CBFort = new QComboBox(GBoxFort); |
|
167 |
CBFort->setMaxCount(65535); |
|
168 |
GBFLayout->addWidget(CBFort, 0, 0); |
|
169 |
FortPreview = new SquareLabel(GBoxFort); |
|
170 |
FortPreview->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
171 |
FortPreview->setPixmap(QPixmap()); |
|
172 |
GBFLayout->addWidget(FortPreview, 1, 0); |
|
173 |
vbox3->addWidget(GBoxFort); |
|
174 |
||
175 |
QDir tmpdir; |
|
176 |
tmpdir.cd(datadir->absolutePath()); |
|
177 |
tmpdir.cd("Forts"); |
|
178 |
tmpdir.setFilter(QDir::Files); |
|
179 |
||
1287 | 180 |
connect(CBFort, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(CBFort_activated(const QString &))); |
1252 | 181 |
CBFort->addItems(tmpdir.entryList(QStringList("*L.png")).replaceInStrings(QRegExp("^(.*)L\\.png"), "\\1")); |
1287 | 182 |
|
1252 | 183 |
tmpdir.cd("../Graphics/Graves"); |
184 |
QStringList list = tmpdir.entryList(QStringList("*.png")); |
|
185 |
for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
|
186 |
{ |
|
1287 | 187 |
QPixmap pix(datadir->absolutePath() + "/Graphics/Graves/" + *it); |
188 |
QIcon icon(pix.copy(0, 0, 32, 32)); |
|
189 |
CBGrave->addItem(icon, (*it).replace(QRegExp("^(.*)\\.png"), "\\1")); |
|
1252 | 190 |
} |
191 |
||
192 |
vbox1->addStretch(); |
|
193 |
vbox2->addStretch(); |
|
194 |
// vbox3->addStretch(); |
|
195 |
||
196 |
// ====== Page 2 ====== |
|
588 | 197 |
GBoxBinds = new QGroupBox(this); |
184 | 198 |
GBoxBinds->setTitle(QGroupBox::tr("Key binds")); |
199 |
QGridLayout * GBBLayout = new QGridLayout(GBoxBinds); |
|
200 |
BindsBox = new QToolBox(GBoxBinds); |
|
201 |
BindsBox->setLineWidth(0); |
|
202 |
GBBLayout->addWidget(BindsBox); |
|
1389 | 203 |
page_A = new QWidget(this); |
184 | 204 |
BindsBox->addItem(page_A, QToolBox::tr("Actions")); |
1389 | 205 |
page_W = new QWidget(this); |
184 | 206 |
BindsBox->addItem(page_W, QToolBox::tr("Weapons")); |
1389 | 207 |
page_WP = new QWidget(this); |
184 | 208 |
BindsBox->addItem(page_WP, QToolBox::tr("Weapon properties")); |
1389 | 209 |
page_O = new QWidget(this); |
184 | 210 |
BindsBox->addItem(page_O, QToolBox::tr("Other")); |
1252 | 211 |
page2Layout->addWidget(GBoxBinds, 0, 0); |
184 | 212 |
|
213 |
QStringList binds; |
|
214 |
for(int i = 0; strlen(sdlkeys[i][1]) > 0; i++) |
|
215 |
{ |
|
216 |
binds << sdlkeys[i][1]; |
|
217 |
} |
|
218 |
||
219 |
quint16 widind = 0, i = 0; |
|
220 |
while (i < BINDS_NUMBER) { |
|
221 |
quint16 num = 0; |
|
1389 | 222 |
QWidget * curW = BindsBox->widget(widind); |
223 |
QGridLayout * pagelayout = new QGridLayout(curW); |
|
184 | 224 |
do { |
1389 | 225 |
LBind[i] = new QLabel(curW); |
184 | 226 |
LBind[i]->setText(QApplication::translate("binds", cbinds[i].name)); |
227 |
LBind[i]->setAlignment(Qt::AlignRight); |
|
228 |
pagelayout->addWidget(LBind[i], num, 0); |
|
1389 | 229 |
CBBind[i] = new QComboBox(curW); |
184 | 230 |
CBBind[i]->addItems(binds); |
231 |
pagelayout->addWidget(CBBind[i], num, 1); |
|
232 |
num++; |
|
233 |
} while (!cbinds[i++].chwidget); |
|
1389 | 234 |
pagelayout->addWidget(new QWidget(curW), num, 0, 1, 2); |
184 | 235 |
widind++; |
236 |
} |
|
237 |
} |
|
238 |
||
239 |
void PageEditTeam::CBFort_activated(const QString & fortname) |
|
240 |
{ |
|
241 |
QPixmap pix(datadir->absolutePath() + "/Forts/" + fortname + "L.png"); |
|
242 |
FortPreview->setPixmap(pix); |
|
243 |
} |
|
244 |
||
1287 | 245 |
PageMultiplayer::PageMultiplayer(QWidget* parent) : |
692 | 246 |
AbstractPage(parent) |
184 | 247 |
{ |
248 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
249 |
||
1218 | 250 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 2, 0, true); |
187 | 251 |
|
184 | 252 |
gameCFG = new GameCFGWidget(this); |
253 |
pageLayout->addWidget(gameCFG, 0, 0, 1, 2); |
|
696 | 254 |
|
1218 | 255 |
pageLayout->setRowStretch(1, 1); |
256 |
||
184 | 257 |
teamsSelect = new TeamSelWidget(this); |
1218 | 258 |
pageLayout->addWidget(teamsSelect, 0, 2, 2, 2); |
184 | 259 |
|
1218 | 260 |
BtnStartMPGame = addButton(tr("Start"), pageLayout, 2, 3); |
184 | 261 |
} |
262 |
||
1249
b6670a6ea2d0
Remove 25pix margin on every page, so exit button is almost in the same place on all pages
unc0rr
parents:
1240
diff
changeset
|
263 |
PageOptions::PageOptions(QWidget* parent) : |
692 | 264 |
AbstractPage(parent) |
184 | 265 |
{ |
266 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
427 | 267 |
pageLayout->setColumnStretch(0, 100); |
268 |
pageLayout->setColumnStretch(1, 100); |
|
269 |
pageLayout->setColumnStretch(2, 100); |
|
270 |
pageLayout->setRowStretch(0, 0); |
|
271 |
pageLayout->setRowStretch(1, 0); |
|
719 | 272 |
pageLayout->setRowStretch(2, 0); |
273 |
pageLayout->setRowStretch(3, 100); |
|
274 |
pageLayout->setRowStretch(4, 0); |
|
427 | 275 |
|
1198 | 276 |
|
277 |
QGroupBox * gbTwoBoxes = new QGroupBox(this); |
|
278 |
pageLayout->addWidget(gbTwoBoxes, 0, 0, 1, 3); |
|
279 |
QHBoxLayout * gbTBLayout = new QHBoxLayout(gbTwoBoxes); |
|
280 |
{ |
|
281 |
teamsBox = new IconedGroupBox(this); |
|
282 |
teamsBox->setIcon(QIcon(":/res/teamicon.png")); |
|
283 |
teamsBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
284 |
teamsBox->setTitle(QGroupBox::tr("Teams")); |
|
285 |
||
286 |
QGridLayout * GBTlayout = new QGridLayout(teamsBox); |
|
287 |
||
288 |
BtnNewTeam = addButton(tr("New team"), GBTlayout, 1, 0); |
|
289 |
||
290 |
CBTeamName = new QComboBox(teamsBox); |
|
291 |
GBTlayout->addWidget(CBTeamName, 0, 0, 1, 2); |
|
184 | 292 |
|
1198 | 293 |
BtnEditTeam = addButton(tr("Edit team"), GBTlayout, 1, 1); |
1199 | 294 |
|
295 |
labelNN = new QLabel(teamsBox); |
|
296 |
labelNN->setText(QLabel::tr("Net nick")); |
|
297 |
GBTlayout->addWidget(labelNN, 2, 0, 1, 2); |
|
298 |
||
299 |
editNetNick = new QLineEdit(teamsBox); |
|
300 |
editNetNick->setMaxLength(20); |
|
301 |
editNetNick->setText(QLineEdit::tr("unnamed")); |
|
302 |
GBTlayout->addWidget(editNetNick, 3, 0, 1, 2); |
|
303 |
||
1198 | 304 |
gbTBLayout->addWidget(teamsBox); |
305 |
} |
|
184 | 306 |
|
1198 | 307 |
{ |
308 |
IconedGroupBox* groupWeapons = new IconedGroupBox(this); |
|
1199 | 309 |
groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
1198 | 310 |
groupWeapons->setIcon(QIcon(":/res/weaponsicon.png")); |
1199 | 311 |
//groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
1198 | 312 |
groupWeapons->setTitle(QGroupBox::tr("Weapons")); |
313 |
QGridLayout * WeaponsLayout = new QGridLayout(groupWeapons); |
|
184 | 314 |
|
1198 | 315 |
WeaponsButt = addButton(tr("Weapons set"), WeaponsLayout, 1, 0); |
316 |
WeaponsName = new QComboBox(this); |
|
317 |
WeaponsLayout->addWidget(WeaponsName, 0, 0, 1, 2); |
|
318 |
WeaponEdit = addButton(tr("Edit"), WeaponsLayout, 1, 1); |
|
319 |
gbTBLayout->addWidget(groupWeapons); |
|
320 |
} |
|
184 | 321 |
|
1193 | 322 |
AGGroupBox = new IconedGroupBox(this); |
323 |
AGGroupBox->setIcon(QIcon(":/res/graphicsicon.png")); |
|
184 | 324 |
AGGroupBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
325 |
AGGroupBox->setTitle(QGroupBox::tr("Audio/Graphic options")); |
|
693 | 326 |
pageLayout->addWidget(AGGroupBox, 2, 1); |
184 | 327 |
|
427 | 328 |
QVBoxLayout * GBAlayout = new QVBoxLayout(AGGroupBox); |
436 | 329 |
QHBoxLayout * GBAreslayout = new QHBoxLayout(0); |
427 | 330 |
QLabel * resolution = new QLabel(AGGroupBox); |
331 |
resolution->setText(QLabel::tr("Resolution")); |
|
332 |
GBAreslayout->addWidget(resolution); |
|
333 |
||
184 | 334 |
CBResolution = new QComboBox(AGGroupBox); |
427 | 335 |
GBAreslayout->addWidget(CBResolution); |
336 |
GBAlayout->addLayout(GBAreslayout); |
|
337 |
||
436 | 338 |
QHBoxLayout * GBAfpslayout = new QHBoxLayout(0); |
427 | 339 |
QLabel * maxfps = new QLabel(AGGroupBox); |
340 |
maxfps->setText(QLabel::tr("FPS limit")); |
|
341 |
GBAfpslayout->addWidget(maxfps); |
|
342 |
GBAlayout->addLayout(GBAfpslayout); |
|
184 | 343 |
|
344 |
CBFullscreen = new QCheckBox(AGGroupBox); |
|
345 |
CBFullscreen->setText(QCheckBox::tr("Fullscreen")); |
|
427 | 346 |
GBAlayout->addWidget(CBFullscreen); |
184 | 347 |
|
1162 | 348 |
CBFrontendFullscreen = new QCheckBox(AGGroupBox); |
349 |
CBFrontendFullscreen->setText(QCheckBox::tr("Frontend fullscreen")); |
|
350 |
GBAlayout->addWidget(CBFrontendFullscreen); |
|
351 |
||
1157 | 352 |
CBEnableSound = new QCheckBox(AGGroupBox); |
184 | 353 |
CBEnableSound->setText(QCheckBox::tr("Enable sound")); |
427 | 354 |
GBAlayout->addWidget(CBEnableSound); |
184 | 355 |
|
1157 | 356 |
CBEnableMusic = new QCheckBox(AGGroupBox); |
1129 | 357 |
CBEnableMusic->setText(QCheckBox::tr("Enable music")); |
358 |
GBAlayout->addWidget(CBEnableMusic); |
|
359 |
||
297 | 360 |
CBShowFPS = new QCheckBox(AGGroupBox); |
361 |
CBShowFPS->setText(QCheckBox::tr("Show FPS")); |
|
427 | 362 |
GBAlayout->addWidget(CBShowFPS); |
297 | 363 |
|
529 | 364 |
CBAltDamage = new QCheckBox(AGGroupBox); |
365 |
CBAltDamage->setText(QCheckBox::tr("Alternative damage show")); |
|
366 |
GBAlayout->addWidget(CBAltDamage); |
|
367 |
||
297 | 368 |
fpsedit = new FPSEdit(AGGroupBox); |
427 | 369 |
GBAfpslayout->addWidget(fpsedit); |
184 | 370 |
|
1157 | 371 |
BtnSaveOptions = addButton(":/res/Save.png", pageLayout, 4, 2, true); |
184 | 372 |
|
1153 | 373 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 4, 0, true); |
184 | 374 |
} |
375 |
||
1153 | 376 |
PageNet::PageNet(QWidget* parent) : AbstractPage(parent) |
184 | 377 |
{ |
378 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
379 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
380 |
pageLayout->setColumnStretch(0, 1); |
|
381 |
pageLayout->setColumnStretch(1, 1); |
|
617 | 382 |
pageLayout->setColumnStretch(2, 1); |
421 | 383 |
|
384 |
BtnNetSvrStart = new QPushButton(this); |
|
385 |
BtnNetSvrStart->setFont(*font14); |
|
386 |
BtnNetSvrStart->setText(QPushButton::tr("Start server")); |
|
1395 | 387 |
pageLayout->addWidget(BtnNetSvrStart, 4, 2); |
388 |
||
389 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 4, 0, true); |
|
184 | 390 |
|
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
391 |
ConnGroupBox = new QGroupBox(this); |
421 | 392 |
ConnGroupBox->setTitle(QGroupBox::tr("Net game")); |
393 |
pageLayout->addWidget(ConnGroupBox, 2, 0, 1, 3); |
|
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
394 |
GBClayout = new QGridLayout(ConnGroupBox); |
646 | 395 |
GBClayout->setColumnStretch(0, 1); |
421 | 396 |
GBClayout->setColumnStretch(1, 1); |
397 |
GBClayout->setColumnStretch(2, 1); |
|
184 | 398 |
|
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
399 |
BtnNetConnect = new QPushButton(ConnGroupBox); |
184 | 400 |
BtnNetConnect->setFont(*font14); |
401 |
BtnNetConnect->setText(QPushButton::tr("Connect")); |
|
646 | 402 |
GBClayout->addWidget(BtnNetConnect, 2, 2); |
416 | 403 |
|
665 | 404 |
tvServersList = new QTableView(ConnGroupBox); |
671
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
405 |
tvServersList->setSelectionBehavior(QAbstractItemView::SelectRows); |
665 | 406 |
GBClayout->addWidget(tvServersList, 1, 0, 1, 3); |
421 | 407 |
|
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
408 |
BtnUpdateSList = new QPushButton(ConnGroupBox); |
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
409 |
BtnUpdateSList->setFont(*font14); |
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
410 |
BtnUpdateSList->setText(QPushButton::tr("Update")); |
646 | 411 |
GBClayout->addWidget(BtnUpdateSList, 2, 0); |
314 | 412 |
|
653
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
413 |
BtnSpecifyServer = new QPushButton(ConnGroupBox); |
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
414 |
BtnSpecifyServer->setFont(*font14); |
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
415 |
BtnSpecifyServer->setText(QPushButton::tr("Specify")); |
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
416 |
GBClayout->addWidget(BtnSpecifyServer, 2, 1); |
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
417 |
|
1395 | 418 |
BtnOfficialServer = new QPushButton(ConnGroupBox); |
419 |
BtnOfficialServer->setFont(*font14); |
|
420 |
BtnOfficialServer->setText(QPushButton::tr("Join official server")); |
|
421 |
GBClayout->addWidget(BtnOfficialServer, 3, 0, 1, 3); |
|
636 | 422 |
|
668 | 423 |
connect(BtnNetConnect, SIGNAL(clicked()), this, SLOT(slotConnect())); |
184 | 424 |
} |
425 |
||
646 | 426 |
void PageNet::updateServersList() |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
427 |
{ |
1310 | 428 |
tvServersList->setModel(new HWNetUdpModel(tvServersList)); |
659 | 429 |
|
673 | 430 |
tvServersList->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); |
431 |
||
665 | 432 |
static_cast<HWNetServersModel *>(tvServersList->model())->updateList(); |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
433 |
|
665 | 434 |
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
|
435 |
connect(tvServersList, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotConnect())); |
646 | 436 |
} |
437 |
||
438 |
void PageNet::slotConnect() |
|
439 |
{ |
|
671
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
440 |
HWNetServersModel * model = static_cast<HWNetServersModel *>(tvServersList->model()); |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
441 |
QModelIndex mi = tvServersList->currentIndex(); |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
442 |
if(!mi.isValid()) |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
443 |
{ |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
444 |
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
|
445 |
return; |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
446 |
} |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
447 |
QString host = model->index(mi.row(), 1).data().toString(); |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
448 |
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
|
449 |
|
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
|
450 |
emit connectClicked(host, port); |
646 | 451 |
} |
452 |
||
1153 | 453 |
PageNetServer::PageNetServer(QWidget* parent) : AbstractPage(parent) |
646 | 454 |
{ |
455 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
456 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
457 |
pageLayout->setColumnStretch(0, 1); |
|
458 |
pageLayout->setColumnStretch(1, 1); |
|
459 |
pageLayout->setColumnStretch(2, 1); |
|
460 |
||
675 | 461 |
pageLayout->setRowStretch(0, 1); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
462 |
pageLayout->setRowStretch(1, 0); |
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
463 |
|
1153 | 464 |
BtnBack =addButton(":/res/Exit.png", pageLayout, 1, 0, true); |
646 | 465 |
|
466 |
BtnStart = new QPushButton(this); |
|
467 |
BtnStart->setFont(*font14); |
|
468 |
BtnStart->setText(QPushButton::tr("Start")); |
|
675 | 469 |
pageLayout->addWidget(BtnStart, 1, 2); |
470 |
||
471 |
QWidget * wg = new QWidget(this); |
|
472 |
pageLayout->addWidget(wg, 0, 0, 1, 3); |
|
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
473 |
|
675 | 474 |
QGridLayout * wgLayout = new QGridLayout(wg); |
475 |
wgLayout->setColumnStretch(0, 1); |
|
476 |
wgLayout->setColumnStretch(1, 3); |
|
477 |
wgLayout->setColumnStretch(2, 1); |
|
478 |
||
479 |
wgLayout->setRowStretch(0, 0); |
|
480 |
wgLayout->setRowStretch(1, 1); |
|
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
481 |
|
675 | 482 |
QGroupBox * gb = new QGroupBox(wg); |
483 |
wgLayout->addWidget(gb, 0, 1); |
|
484 |
||
485 |
QGridLayout * gbLayout = new QGridLayout(gb); |
|
486 |
||
487 |
labelSD = new QLabel(gb); |
|
488 |
labelSD->setText(QLabel::tr("Server name:")); |
|
489 |
gbLayout->addWidget(labelSD, 0, 0); |
|
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
490 |
|
675 | 491 |
leServerDescr = new QLineEdit(gb); |
492 |
gbLayout->addWidget(leServerDescr, 0, 1); |
|
493 |
||
494 |
labelPort = new QLabel(gb); |
|
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
495 |
labelPort->setText(QLabel::tr("Server port:")); |
675 | 496 |
gbLayout->addWidget(labelPort, 1, 0); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
497 |
|
675 | 498 |
sbPort = new QSpinBox(gb); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
499 |
sbPort->setMinimum(0); |
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
500 |
sbPort->setMaximum(65535); |
675 | 501 |
gbLayout->addWidget(sbPort, 1, 1); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
502 |
|
675 | 503 |
BtnDefault = new QPushButton(gb); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
504 |
BtnDefault->setText(QPushButton::tr("default")); |
675 | 505 |
gbLayout->addWidget(BtnDefault, 1, 2); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
506 |
|
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
507 |
connect(BtnDefault, SIGNAL(clicked()), this, SLOT(setDefaultPort())); |
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
508 |
} |
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
509 |
|
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
510 |
void PageNetServer::setDefaultPort() |
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 |
sbPort->setValue(46631); |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
513 |
} |
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
514 |
|
1153 | 515 |
PageNetGame::PageNetGame(QWidget* parent) : AbstractPage(parent) |
184 | 516 |
{ |
517 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
518 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
452 | 519 |
pageLayout->setSizeConstraint(QLayout::SetMinimumSize); |
461 | 520 |
//pageLayout->setSpacing(1); |
463 | 521 |
pageLayout->setColumnStretch(0, 50); |
522 |
pageLayout->setColumnStretch(1, 50); |
|
322 | 523 |
|
461 | 524 |
// chatwidget |
525 |
pChatWidget = new HWChatWidget(this); |
|
526 |
pageLayout->addWidget(pChatWidget, 1, 0); |
|
464 | 527 |
pageLayout->setRowStretch(1, 100); |
453 | 528 |
|
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
323
diff
changeset
|
529 |
pGameCFG = new GameCFGWidget(this); |
322 | 530 |
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
|
531 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
323
diff
changeset
|
532 |
pNetTeamsWidget = new TeamSelWidget(this); |
373 | 533 |
pNetTeamsWidget->setAcceptOuter(true); |
461 | 534 |
pageLayout->addWidget(pNetTeamsWidget, 0, 1, 2, 1); |
184 | 535 |
|
1153 | 536 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 2, 0, true); |
184 | 537 |
|
646 | 538 |
BtnGo = new QPushButton(this); |
184 | 539 |
BtnGo->setFont(*font14); |
1404 | 540 |
BtnGo->setText(QPushButton::tr("Ready")); |
461 | 541 |
pageLayout->addWidget(BtnGo, 2, 1); |
184 | 542 |
} |
187 | 543 |
|
1153 | 544 |
PageInfo::PageInfo(QWidget* parent) : AbstractPage(parent) |
187 | 545 |
{ |
546 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
547 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
548 |
pageLayout->setColumnStretch(0, 1); |
|
549 |
pageLayout->setColumnStretch(1, 1); |
|
550 |
pageLayout->setColumnStretch(2, 1); |
|
551 |
||
1153 | 552 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true); |
187 | 553 |
|
554 |
about = new About(this); |
|
555 |
pageLayout->addWidget(about, 0, 0, 1, 3); |
|
556 |
} |
|
306 | 557 |
|
1153 | 558 |
PageGameStats::PageGameStats(QWidget* parent) : AbstractPage(parent) |
306 | 559 |
{ |
560 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
561 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
562 |
pageLayout->setColumnStretch(0, 1); |
|
563 |
pageLayout->setColumnStretch(1, 1); |
|
564 |
pageLayout->setColumnStretch(2, 1); |
|
565 |
||
1153 | 566 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true); |
306 | 567 |
|
307 | 568 |
labelGameStats = new QLabel(this); |
569 |
labelGameStats->setTextFormat(Qt::RichText); |
|
570 |
pageLayout->addWidget(labelGameStats, 0, 0, 1, 3); |
|
306 | 571 |
} |
586 | 572 |
|
1150 | 573 |
PageSinglePlayer::PageSinglePlayer(QWidget* parent) : AbstractPage(parent) |
586 | 574 |
{ |
575 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
576 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
1252 | 577 |
// pageLayout->setColumnStretch(0, 1); |
578 |
// pageLayout->setColumnStretch(1, 2); |
|
579 |
// pageLayout->setColumnStretch(2, 1); |
|
588 | 580 |
pageLayout->setRowStretch(0, 1); |
1150 | 581 |
pageLayout->setRowStretch(6, 1); |
586 | 582 |
|
1150 | 583 |
BtnSimpleGamePage = addButton(tr("Simple Game"), pageLayout, 1, 1); |
584 |
BtnTrainPage = addButton(tr("Training"), pageLayout, 2, 1); |
|
585 |
BtnMultiplayer = addButton(tr("Multiplayer"), pageLayout, 3, 1); |
|
586 |
BtnLoad = addButton(tr("Saved games"), pageLayout, 4, 1); |
|
587 |
BtnDemos = addButton(tr("Demos"), pageLayout, 5, 1); |
|
586 | 588 |
|
1153 | 589 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 7, 0, true); |
586 | 590 |
} |
591 |
||
1153 | 592 |
PageTraining::PageTraining(QWidget* parent) : AbstractPage(parent) |
587 | 593 |
{ |
594 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
595 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
596 |
pageLayout->setColumnStretch(0, 1); |
|
597 |
pageLayout->setColumnStretch(1, 2); |
|
598 |
pageLayout->setColumnStretch(2, 1); |
|
599 |
||
600 |
BtnStartTrain = new QPushButton(this); |
|
601 |
BtnStartTrain->setFont(*font14); |
|
602 |
BtnStartTrain->setText(QPushButton::tr("Go!")); |
|
603 |
pageLayout->addWidget(BtnStartTrain, 1, 2); |
|
604 |
||
1153 | 605 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true); |
587 | 606 |
} |
607 |
||
923
b3d097097b54
Use default ammostore string size for weapons number instead of predefined const
unc0rr
parents:
788
diff
changeset
|
608 |
PageSelectWeapon::PageSelectWeapon(QWidget* parent) : |
684 | 609 |
AbstractPage(parent) |
600 | 610 |
{ |
611 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
923
b3d097097b54
Use default ammostore string size for weapons number instead of predefined const
unc0rr
parents:
788
diff
changeset
|
612 |
|
1168 | 613 |
pWeapons = new SelWeaponWidget(cDefaultAmmoStore->size() - 10, this); |
718 | 614 |
pageLayout->addWidget(pWeapons, 0, 0, 1, 4); |
600 | 615 |
|
1168 | 616 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true); |
730 | 617 |
BtnDefault = addButton(tr("Default"), pageLayout, 1, 1); |
618 |
BtnDelete = addButton(tr("Delete"), pageLayout, 1, 2); |
|
1168 | 619 |
BtnSave = addButton(":/res/Save.png", pageLayout, 1, 3, true); |
600 | 620 |
} |
621 |
||
1249
b6670a6ea2d0
Remove 25pix margin on every page, so exit button is almost in the same place on all pages
unc0rr
parents:
1240
diff
changeset
|
622 |
PageInGame::PageInGame(QWidget* parent) : |
686 | 623 |
AbstractPage(parent) |
624 |
{ |
|
625 |
QLabel * label = new QLabel(this); |
|
626 |
label->setText("In game..."); |
|
627 |
} |
|
1311 | 628 |
|
629 |
PageRoomsList::PageRoomsList(QWidget* parent) : |
|
630 |
AbstractPage(parent) |
|
631 |
{ |
|
1312 | 632 |
QGridLayout * pageLayout = new QGridLayout(this); |
1314 | 633 |
|
634 |
roomName = new QLineEdit(this); |
|
1334
b58afaadf7ae
Send team removal message to others in room when client disconnects
unc0rr
parents:
1315
diff
changeset
|
635 |
roomName->setMaxLength(60); |
1314 | 636 |
pageLayout->addWidget(roomName, 0, 0); |
1399 | 637 |
|
638 |
roomsList = new QTableWidget(this); |
|
639 |
roomsList->setColumnCount(3); |
|
640 |
roomsList->setSelectionBehavior(QAbstractItemView::SelectRows); |
|
641 |
roomsList->verticalHeader()->setVisible(false); |
|
642 |
roomsList->horizontalHeader()->setResizeMode(QHeaderView::Interactive); |
|
643 |
roomsList->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); |
|
644 |
||
1314 | 645 |
pageLayout->addWidget(roomsList, 1, 0, 3, 1); |
1377 | 646 |
serverMessage = new QTextBrowser(this); |
647 |
serverMessage->setOpenExternalLinks(true); |
|
648 |
pageLayout->addWidget(serverMessage, 4, 0, 1, 2); |
|
1312 | 649 |
|
1377 | 650 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 5, 0, true); |
1312 | 651 |
BtnCreate = addButton(tr("Create"), pageLayout, 0, 1); |
652 |
BtnJoin = addButton(tr("Join"), pageLayout, 1, 1); |
|
653 |
BtnRefresh = addButton(tr("Refresh"), pageLayout, 2, 1); |
|
1314 | 654 |
|
655 |
connect(BtnCreate, SIGNAL(clicked()), this, SLOT(onCreateClick())); |
|
656 |
connect(BtnJoin, SIGNAL(clicked()), this, SLOT(onJoinClick())); |
|
1315 | 657 |
connect(BtnRefresh, SIGNAL(clicked()), this, SLOT(onRefreshClick())); |
1314 | 658 |
connect(roomsList, SIGNAL(doubleClicked (const QModelIndex &)), this, SLOT(onJoinClick())); |
1311 | 659 |
} |
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1312
diff
changeset
|
660 |
|
1377 | 661 |
|
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1312
diff
changeset
|
662 |
void PageRoomsList::setRoomsList(const QStringList & list) |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1312
diff
changeset
|
663 |
{ |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1312
diff
changeset
|
664 |
roomsList->clear(); |
1399 | 665 |
roomsList->setHorizontalHeaderLabels( |
666 |
QStringList() << |
|
667 |
QTableWidget::tr("Room name") << |
|
668 |
QTableWidget::tr("Players number") << |
|
669 |
QTableWidget::tr("Round in progress") |
|
670 |
); |
|
671 |
||
672 |
if (list.size() % 3) |
|
673 |
return; |
|
674 |
||
675 |
roomsList->setRowCount(list.size() / 3); |
|
676 |
for(int i = 0; i < list.size(); i += 3) |
|
677 |
for(int t = 0; t < 3; t++) |
|
678 |
{ |
|
679 |
QTableWidgetItem * item = new QTableWidgetItem(list[i + t]); |
|
680 |
item->setFlags(Qt::ItemIsSelectable); |
|
1400 | 681 |
roomsList->setItem(i / 3, t, item); |
1399 | 682 |
} |
683 |
//roomsList->resizeColumnsToContents(); |
|
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1312
diff
changeset
|
684 |
} |
1314 | 685 |
|
686 |
void PageRoomsList::onCreateClick() |
|
687 |
{ |
|
688 |
if (roomName->text().size()) |
|
689 |
emit askForCreateRoom(roomName->text()); |
|
690 |
else |
|
691 |
QMessageBox::critical(this, |
|
692 |
tr("Error"), |
|
1315 | 693 |
tr("Please, enter room name"), |
1314 | 694 |
tr("OK")); |
695 |
} |
|
696 |
||
697 |
void PageRoomsList::onJoinClick() |
|
698 |
{ |
|
1399 | 699 |
QTableWidgetItem * curritem = roomsList->item(roomsList->currentRow(), 0); |
1314 | 700 |
if (!curritem) |
701 |
{ |
|
702 |
QMessageBox::critical(this, |
|
703 |
tr("Error"), |
|
704 |
tr("Please, select room from the list"), |
|
705 |
tr("OK")); |
|
706 |
return ; |
|
707 |
} |
|
708 |
emit askForJoinRoom(curritem->data(Qt::DisplayRole).toString()); |
|
709 |
} |
|
710 |
||
1315 | 711 |
void PageRoomsList::onRefreshClick() |
712 |
{ |
|
713 |
emit askForRoomList(); |
|
714 |
} |
|
715 |