author | unc0rr |
Sun, 15 Mar 2009 14:36:14 +0000 | |
changeset 1893 | 85c61bc5e160 |
parent 1891 | 47e832a88cbd |
child 1894 | ba54441631da |
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> |
1409
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1404
diff
changeset
|
38 |
#include <QAction> |
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1404
diff
changeset
|
39 |
#include <QMenu> |
1701
ad7a7fd14d36
Now voicepack checking button should work (but it doesn't for me)
unc0rr
parents:
1684
diff
changeset
|
40 |
#include <QSound> |
1885 | 41 |
#include <QDataWidgetMapper> |
42 |
||
184 | 43 |
|
44 |
#include "pages.h" |
|
45 |
#include "sdlkeys.h" |
|
46 |
#include "hwconsts.h" |
|
47 |
#include "gamecfgwidget.h" |
|
48 |
#include "teamselect.h" |
|
49 |
#include "gamecfgwidget.h" |
|
50 |
#include "SquareLabel.h" |
|
51 |
#include "mapContainer.h" |
|
187 | 52 |
#include "about.h" |
297 | 53 |
#include "fpsedit.h" |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
54 |
#include "netserverslist.h" |
412 | 55 |
#include "netudpwidget.h" |
461 | 56 |
#include "chatwidget.h" |
579 | 57 |
#include "playrecordpage.h" |
612
333d095319de
abstract class for items container (hedgehogs num, bullets, etc.)
displacer
parents:
603
diff
changeset
|
58 |
#include "selectWeapon.h" |
1192 | 59 |
#include "igbox.h" |
1238
914bd2a9a249
Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents:
1236
diff
changeset
|
60 |
#include "hats.h" |
1885 | 61 |
#include "misc.h" |
184 | 62 |
|
684 | 63 |
PageMain::PageMain(QWidget* parent) : |
64 |
AbstractPage(parent) |
|
184 | 65 |
{ |
66 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
1148 | 67 |
//pageLayout->setColumnStretch(0, 1); |
68 |
//pageLayout->setColumnStretch(1, 2); |
|
69 |
//pageLayout->setColumnStretch(2, 1); |
|
184 | 70 |
|
1199 | 71 |
//QPushButton* btnLogo = addButton(":/res/HedgewarsTitle.png", pageLayout, 0, 0, 1, 4, true); |
72 |
//pageLayout->setAlignment(btnLogo, Qt::AlignHCenter); |
|
1148 | 73 |
pageLayout->setRowStretch(0, 1); |
1150 | 74 |
pageLayout->setRowStretch(1, 1); |
75 |
pageLayout->setRowStretch(2, 0); |
|
76 |
pageLayout->setRowStretch(3, 1); |
|
1199 | 77 |
pageLayout->setRowStretch(4, 1); |
184 | 78 |
|
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1151
diff
changeset
|
79 |
BtnSinglePlayer = addButton(":/res/LocalPlay.png", pageLayout, 2, 0, 1, 2, true); |
1450 | 80 |
BtnSinglePlayer->setToolTip(tr("Local Game (Play a game on a single computer)")); |
1150 | 81 |
pageLayout->setAlignment(BtnSinglePlayer, Qt::AlignHCenter); |
184 | 82 |
|
1152
c72b939c00df
Make buttons border have different colors when mouse is over or it is pressed
unc0rr
parents:
1151
diff
changeset
|
83 |
BtnNet = addButton(":/res/NetworkPlay.png", pageLayout, 2, 2, 1, 2, true); |
1450 | 84 |
BtnNet->setToolTip(tr("Network Game (Play a game across a network)")); |
1150 | 85 |
pageLayout->setAlignment(BtnNet, Qt::AlignHCenter); |
579 | 86 |
|
1199 | 87 |
BtnSetup = addButton(":/res/Settings.png", pageLayout, 4, 3, true); |
184 | 88 |
|
1199 | 89 |
//BtnInfo = addButton(":/res/About.png", pageLayout, 3, 1, 1, 2, true); |
90 |
BtnInfo = addButton(":/res/HedgewarsTitle.png", pageLayout, 0, 0, 1, 4, true); |
|
1212 | 91 |
BtnInfo->setStyleSheet("border: transparent;background: transparent;"); |
1150 | 92 |
pageLayout->setAlignment(BtnInfo, Qt::AlignHCenter); |
1199 | 93 |
//pageLayout->setAlignment(BtnInfo, Qt::AlignHCenter); |
184 | 94 |
|
1199 | 95 |
BtnExit = addButton(":/res/Exit.png", pageLayout, 4, 0, 1, 1, true); |
184 | 96 |
} |
97 |
||
788
00720357601f
- Get rid of PageSimpleGame, now pressing 'quick game' just starts round
unc0rr
parents:
730
diff
changeset
|
98 |
PageEditTeam::PageEditTeam(QWidget* parent) : |
692 | 99 |
AbstractPage(parent) |
184 | 100 |
{ |
101 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
1252 | 102 |
QTabWidget * tbw = new QTabWidget(this); |
1389 | 103 |
QWidget * page1 = new QWidget(this); |
104 |
QWidget * page2 = new QWidget(this); |
|
1252 | 105 |
tbw->addTab(page1, tr("General")); |
106 |
tbw->addTab(page2, tr("Advanced")); |
|
107 |
pageLayout->addWidget(tbw, 0, 0, 1, 3); |
|
108 |
BtnTeamDiscard = addButton(":/res/Exit.png", pageLayout, 1, 0, true); |
|
109 |
BtnTeamSave = addButton(":/res/Save.png", pageLayout, 1, 2, true);; |
|
1443 | 110 |
BtnTeamSave->setStyleSheet("QPushButton{margin: 12px 0px 12px 0px;}"); |
111 |
||
1252 | 112 |
QHBoxLayout * page1Layout = new QHBoxLayout(page1); |
113 |
page1Layout->setAlignment(Qt::AlignTop); |
|
114 |
QGridLayout * page2Layout = new QGridLayout(page2); |
|
115 |
||
116 |
// ====== Page 1 ====== |
|
117 |
QVBoxLayout * vbox1 = new QVBoxLayout(); |
|
118 |
QVBoxLayout * vbox2 = new QVBoxLayout(); |
|
119 |
QVBoxLayout * vbox3 = new QVBoxLayout(); |
|
120 |
page1Layout->addLayout(vbox1); |
|
121 |
page1Layout->addLayout(vbox2); |
|
122 |
page1Layout->addLayout(vbox3); |
|
123 |
||
588 | 124 |
GBoxHedgehogs = new QGroupBox(this); |
184 | 125 |
GBoxHedgehogs->setTitle(QGroupBox::tr("Team Members")); |
126 |
GBoxHedgehogs->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
127 |
QGridLayout * GBHLayout = new QGridLayout(GBoxHedgehogs); |
|
1840 | 128 |
|
129 |
signalMapper = new QSignalMapper(this); |
|
1238
914bd2a9a249
Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents:
1236
diff
changeset
|
130 |
|
914bd2a9a249
Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents:
1236
diff
changeset
|
131 |
HatsModel * hatsModel = new HatsModel(GBoxHedgehogs); |
184 | 132 |
for(int i = 0; i < 8; i++) |
133 |
{ |
|
1238
914bd2a9a249
Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents:
1236
diff
changeset
|
134 |
HHHats[i] = new QComboBox(GBoxHedgehogs); |
914bd2a9a249
Add hat selection control to team editing page (it's empty combobox yet)
unc0rr
parents:
1236
diff
changeset
|
135 |
HHHats[i]->setModel(hatsModel); |
1282 | 136 |
HHHats[i]->setIconSize(QSize(32, 37)); |
137 |
//HHHats[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents); |
|
1239 | 138 |
//HHHats[i]->setModelColumn(1); |
1240 | 139 |
//HHHats[i]->setMinimumWidth(132); |
1840 | 140 |
GBHLayout->addWidget(HHHats[i], i, 0); |
141 |
||
142 |
HHNameEdit[i] = new QLineEdit(GBoxHedgehogs); |
|
143 |
HHNameEdit[i]->setMaxLength(64); |
|
144 |
HHNameEdit[i]->setMinimumWidth(120); |
|
145 |
GBHLayout->addWidget(HHNameEdit[i], i, 1); |
|
146 |
||
147 |
randButton[i] = addButton(":/res/dice.png", GBHLayout, i, 3, true); |
|
148 |
||
149 |
connect(randButton[i], SIGNAL(clicked()), signalMapper, SLOT(map())); |
|
150 |
signalMapper->setMapping(randButton[i], i); |
|
151 |
||
184 | 152 |
} |
1840 | 153 |
|
154 |
randTeamButton = addButton("Random Team", GBHLayout, 9, false); |
|
155 |
||
1252 | 156 |
vbox1->addWidget(GBoxHedgehogs); |
157 |
||
158 |
||
1288
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
159 |
GBoxTeam = new QGroupBox(this); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
160 |
GBoxTeam->setTitle(QGroupBox::tr("Team")); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
161 |
GBoxTeam->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
162 |
QVBoxLayout * GBTLayout = new QVBoxLayout(GBoxTeam); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
163 |
TeamNameEdit = new QLineEdit(GBoxTeam); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
164 |
TeamNameEdit->setMaxLength(64); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
165 |
GBTLayout->addWidget(TeamNameEdit); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
166 |
vbox2->addWidget(GBoxTeam); |
1252 | 167 |
|
1290 | 168 |
CBTeamLvl = new QComboBox(GBoxTeam); |
1440 | 169 |
CBTeamLvl->setIconSize(QSize(48, 48)); |
1287 | 170 |
CBTeamLvl->addItem(QIcon(":/res/botlevels/0.png"), QComboBox::tr("Human")); |
171 |
for(int i = 5; i > 0; i--) |
|
172 |
CBTeamLvl->addItem( |
|
173 |
QIcon(QString(":/res/botlevels/%1.png").arg(6 - i)), |
|
174 |
QString("%1 %2").arg(QComboBox::tr("Level")).arg(i) |
|
175 |
); |
|
1288
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
176 |
GBTLayout->addWidget(CBTeamLvl); |
1287 | 177 |
|
1290 | 178 |
CBGrave = new QComboBox(GBoxTeam); |
1288
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
179 |
CBGrave->setMaxCount(65535); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
180 |
CBGrave->setIconSize(QSize(32, 32)); |
cea4a8f52f5a
Reorganize team edit page a little (save a lot of space)
unc0rr
parents:
1287
diff
changeset
|
181 |
GBTLayout->addWidget(CBGrave); |
1684 | 182 |
|
1659 | 183 |
{ |
1684 | 184 |
QHBoxLayout * hbox = new QHBoxLayout(); |
185 |
CBVoicepack = new QComboBox(GBoxTeam); |
|
186 |
{ |
|
187 |
QDir tmpdir; |
|
188 |
tmpdir.cd(datadir->absolutePath()); |
|
189 |
tmpdir.cd("Sounds/voices"); |
|
190 |
QStringList list = tmpdir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name); |
|
191 |
CBVoicepack->addItems(list); |
|
192 |
} |
|
193 |
hbox->addWidget(CBVoicepack, 100); |
|
1718 | 194 |
BtnTestSound = addButton(":/res/PlaySound.png", hbox, 1, true); |
1684 | 195 |
hbox->setStretchFactor(BtnTestSound, 1); |
196 |
connect(BtnTestSound, SIGNAL(clicked()), this, SLOT(testSound())); |
|
197 |
GBTLayout->addLayout(hbox); |
|
1659 | 198 |
} |
199 |
||
1252 | 200 |
GBoxFort = new QGroupBox(this); |
201 |
GBoxFort->setTitle(QGroupBox::tr("Fort")); |
|
202 |
QGridLayout * GBFLayout = new QGridLayout(GBoxFort); |
|
203 |
CBFort = new QComboBox(GBoxFort); |
|
204 |
CBFort->setMaxCount(65535); |
|
205 |
GBFLayout->addWidget(CBFort, 0, 0); |
|
206 |
FortPreview = new SquareLabel(GBoxFort); |
|
207 |
FortPreview->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
208 |
FortPreview->setPixmap(QPixmap()); |
|
209 |
GBFLayout->addWidget(FortPreview, 1, 0); |
|
210 |
vbox3->addWidget(GBoxFort); |
|
211 |
||
212 |
QDir tmpdir; |
|
213 |
tmpdir.cd(datadir->absolutePath()); |
|
214 |
tmpdir.cd("Forts"); |
|
215 |
tmpdir.setFilter(QDir::Files); |
|
216 |
||
1287 | 217 |
connect(CBFort, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(CBFort_activated(const QString &))); |
1252 | 218 |
CBFort->addItems(tmpdir.entryList(QStringList("*L.png")).replaceInStrings(QRegExp("^(.*)L\\.png"), "\\1")); |
1287 | 219 |
|
1252 | 220 |
tmpdir.cd("../Graphics/Graves"); |
221 |
QStringList list = tmpdir.entryList(QStringList("*.png")); |
|
222 |
for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
|
223 |
{ |
|
1287 | 224 |
QPixmap pix(datadir->absolutePath() + "/Graphics/Graves/" + *it); |
225 |
QIcon icon(pix.copy(0, 0, 32, 32)); |
|
226 |
CBGrave->addItem(icon, (*it).replace(QRegExp("^(.*)\\.png"), "\\1")); |
|
1252 | 227 |
} |
228 |
||
229 |
vbox1->addStretch(); |
|
230 |
vbox2->addStretch(); |
|
231 |
// vbox3->addStretch(); |
|
232 |
||
233 |
// ====== Page 2 ====== |
|
588 | 234 |
GBoxBinds = new QGroupBox(this); |
184 | 235 |
GBoxBinds->setTitle(QGroupBox::tr("Key binds")); |
236 |
QGridLayout * GBBLayout = new QGridLayout(GBoxBinds); |
|
237 |
BindsBox = new QToolBox(GBoxBinds); |
|
238 |
BindsBox->setLineWidth(0); |
|
239 |
GBBLayout->addWidget(BindsBox); |
|
1389 | 240 |
page_A = new QWidget(this); |
184 | 241 |
BindsBox->addItem(page_A, QToolBox::tr("Actions")); |
1389 | 242 |
page_W = new QWidget(this); |
184 | 243 |
BindsBox->addItem(page_W, QToolBox::tr("Weapons")); |
1389 | 244 |
page_WP = new QWidget(this); |
184 | 245 |
BindsBox->addItem(page_WP, QToolBox::tr("Weapon properties")); |
1389 | 246 |
page_O = new QWidget(this); |
184 | 247 |
BindsBox->addItem(page_O, QToolBox::tr("Other")); |
1252 | 248 |
page2Layout->addWidget(GBoxBinds, 0, 0); |
184 | 249 |
|
250 |
QStringList binds; |
|
251 |
for(int i = 0; strlen(sdlkeys[i][1]) > 0; i++) |
|
252 |
{ |
|
253 |
binds << sdlkeys[i][1]; |
|
254 |
} |
|
255 |
||
256 |
quint16 widind = 0, i = 0; |
|
257 |
while (i < BINDS_NUMBER) { |
|
258 |
quint16 num = 0; |
|
1389 | 259 |
QWidget * curW = BindsBox->widget(widind); |
260 |
QGridLayout * pagelayout = new QGridLayout(curW); |
|
184 | 261 |
do { |
1389 | 262 |
LBind[i] = new QLabel(curW); |
184 | 263 |
LBind[i]->setText(QApplication::translate("binds", cbinds[i].name)); |
264 |
LBind[i]->setAlignment(Qt::AlignRight); |
|
265 |
pagelayout->addWidget(LBind[i], num, 0); |
|
1389 | 266 |
CBBind[i] = new QComboBox(curW); |
184 | 267 |
CBBind[i]->addItems(binds); |
268 |
pagelayout->addWidget(CBBind[i], num, 1); |
|
269 |
num++; |
|
270 |
} while (!cbinds[i++].chwidget); |
|
1389 | 271 |
pagelayout->addWidget(new QWidget(curW), num, 0, 1, 2); |
184 | 272 |
widind++; |
273 |
} |
|
274 |
} |
|
275 |
||
276 |
void PageEditTeam::CBFort_activated(const QString & fortname) |
|
277 |
{ |
|
278 |
QPixmap pix(datadir->absolutePath() + "/Forts/" + fortname + "L.png"); |
|
279 |
FortPreview->setPixmap(pix); |
|
280 |
} |
|
281 |
||
1684 | 282 |
void PageEditTeam::testSound() |
283 |
{ |
|
284 |
QDir tmpdir; |
|
285 |
tmpdir.cd(datadir->absolutePath()); |
|
286 |
tmpdir.cd("Sounds/voices"); |
|
287 |
tmpdir.cd(CBVoicepack->currentText()); |
|
1701
ad7a7fd14d36
Now voicepack checking button should work (but it doesn't for me)
unc0rr
parents:
1684
diff
changeset
|
288 |
QStringList list = tmpdir.entryList(QStringList() << "*.wav", QDir::Files); |
1684 | 289 |
if (list.size()) |
1701
ad7a7fd14d36
Now voicepack checking button should work (but it doesn't for me)
unc0rr
parents:
1684
diff
changeset
|
290 |
QSound::play(tmpdir.absolutePath() + "/" + list[rand() % list.size()]); |
1684 | 291 |
} |
292 |
||
1287 | 293 |
PageMultiplayer::PageMultiplayer(QWidget* parent) : |
692 | 294 |
AbstractPage(parent) |
184 | 295 |
{ |
296 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
297 |
||
1218 | 298 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 2, 0, true); |
187 | 299 |
|
184 | 300 |
gameCFG = new GameCFGWidget(this); |
301 |
pageLayout->addWidget(gameCFG, 0, 0, 1, 2); |
|
696 | 302 |
|
1218 | 303 |
pageLayout->setRowStretch(1, 1); |
304 |
||
184 | 305 |
teamsSelect = new TeamSelWidget(this); |
1218 | 306 |
pageLayout->addWidget(teamsSelect, 0, 2, 2, 2); |
184 | 307 |
|
1218 | 308 |
BtnStartMPGame = addButton(tr("Start"), pageLayout, 2, 3); |
184 | 309 |
} |
310 |
||
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
|
311 |
PageOptions::PageOptions(QWidget* parent) : |
692 | 312 |
AbstractPage(parent) |
184 | 313 |
{ |
314 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
427 | 315 |
pageLayout->setColumnStretch(0, 100); |
316 |
pageLayout->setColumnStretch(1, 100); |
|
317 |
pageLayout->setColumnStretch(2, 100); |
|
318 |
pageLayout->setRowStretch(0, 0); |
|
1644 | 319 |
pageLayout->setRowStretch(1, 100); |
719 | 320 |
pageLayout->setRowStretch(2, 0); |
1644 | 321 |
pageLayout->setContentsMargins(7, 7, 7, 0); |
322 |
pageLayout->setSpacing(0); |
|
427 | 323 |
|
1198 | 324 |
|
325 |
QGroupBox * gbTwoBoxes = new QGroupBox(this); |
|
326 |
pageLayout->addWidget(gbTwoBoxes, 0, 0, 1, 3); |
|
1644 | 327 |
QGridLayout * gbTBLayout = new QGridLayout(gbTwoBoxes); |
328 |
gbTBLayout->setMargin(0); |
|
329 |
gbTBLayout->setSpacing(0); |
|
1198 | 330 |
{ |
331 |
teamsBox = new IconedGroupBox(this); |
|
332 |
teamsBox->setIcon(QIcon(":/res/teamicon.png")); |
|
333 |
teamsBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
334 |
teamsBox->setTitle(QGroupBox::tr("Teams")); |
|
335 |
||
1644 | 336 |
QVBoxLayout * GBTlayout = new QVBoxLayout(teamsBox); |
1198 | 337 |
|
338 |
CBTeamName = new QComboBox(teamsBox); |
|
1644 | 339 |
GBTlayout->addWidget(CBTeamName); |
184 | 340 |
|
1644 | 341 |
QHBoxLayout * layout1 = new QHBoxLayout; |
342 |
GBTlayout->addLayout(layout1); |
|
343 |
BtnNewTeam = addButton(tr("New team"), layout1, 0); |
|
344 |
BtnEditTeam = addButton(tr("Edit team"), layout1, 1); |
|
345 |
layout1->setStretchFactor(BtnNewTeam, 100); |
|
346 |
layout1->setStretchFactor(BtnEditTeam, 100); |
|
347 |
||
348 |
QHBoxLayout * layout2 = new QHBoxLayout; |
|
349 |
GBTlayout->addLayout(layout2); |
|
1199 | 350 |
|
351 |
labelNN = new QLabel(teamsBox); |
|
352 |
labelNN->setText(QLabel::tr("Net nick")); |
|
1644 | 353 |
layout2->addWidget(labelNN); |
1199 | 354 |
|
355 |
editNetNick = new QLineEdit(teamsBox); |
|
356 |
editNetNick->setMaxLength(20); |
|
357 |
editNetNick->setText(QLineEdit::tr("unnamed")); |
|
1644 | 358 |
layout2->addWidget(editNetNick); |
1199 | 359 |
|
1644 | 360 |
gbTBLayout->addWidget(teamsBox, 0, 0); |
1198 | 361 |
} |
184 | 362 |
|
1198 | 363 |
{ |
364 |
IconedGroupBox* groupWeapons = new IconedGroupBox(this); |
|
1810 | 365 |
groupWeapons->setContentTopPadding(0); |
1199 | 366 |
groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
1198 | 367 |
groupWeapons->setIcon(QIcon(":/res/weaponsicon.png")); |
1199 | 368 |
//groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
1198 | 369 |
groupWeapons->setTitle(QGroupBox::tr("Weapons")); |
370 |
QGridLayout * WeaponsLayout = new QGridLayout(groupWeapons); |
|
184 | 371 |
|
1198 | 372 |
WeaponsButt = addButton(tr("Weapons set"), WeaponsLayout, 1, 0); |
373 |
WeaponsName = new QComboBox(this); |
|
374 |
WeaponsLayout->addWidget(WeaponsName, 0, 0, 1, 2); |
|
375 |
WeaponEdit = addButton(tr("Edit"), WeaponsLayout, 1, 1); |
|
1644 | 376 |
gbTBLayout->addWidget(groupWeapons, 1, 0); |
1198 | 377 |
} |
184 | 378 |
|
1644 | 379 |
{ |
380 |
AGGroupBox = new IconedGroupBox(this); |
|
381 |
AGGroupBox->setIcon(QIcon(":/res/graphicsicon.png")); |
|
382 |
AGGroupBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
383 |
AGGroupBox->setTitle(QGroupBox::tr("Audio/Graphic options")); |
|
184 | 384 |
|
1644 | 385 |
QVBoxLayout * GBAlayout = new QVBoxLayout(AGGroupBox); |
386 |
QHBoxLayout * GBAreslayout = new QHBoxLayout(0); |
|
387 |
QLabel * resolution = new QLabel(AGGroupBox); |
|
388 |
resolution->setText(QLabel::tr("Resolution")); |
|
389 |
GBAreslayout->addWidget(resolution); |
|
427 | 390 |
|
1644 | 391 |
CBResolution = new QComboBox(AGGroupBox); |
392 |
GBAreslayout->addWidget(CBResolution); |
|
393 |
GBAlayout->addLayout(GBAreslayout); |
|
427 | 394 |
|
1644 | 395 |
QHBoxLayout * GBAfpslayout = new QHBoxLayout(0); |
396 |
QLabel * maxfps = new QLabel(AGGroupBox); |
|
397 |
maxfps->setText(QLabel::tr("FPS limit")); |
|
398 |
GBAfpslayout->addWidget(maxfps); |
|
399 |
GBAlayout->addLayout(GBAfpslayout); |
|
184 | 400 |
|
1812 | 401 |
CBReduceQuality = new QCheckBox(AGGroupBox); |
402 |
CBReduceQuality->setText(QCheckBox::tr("Reduce Quality")); |
|
403 |
GBAlayout->addWidget(CBReduceQuality); |
|
404 |
||
1644 | 405 |
CBFullscreen = new QCheckBox(AGGroupBox); |
406 |
CBFullscreen->setText(QCheckBox::tr("Fullscreen")); |
|
407 |
GBAlayout->addWidget(CBFullscreen); |
|
184 | 408 |
|
1644 | 409 |
CBFrontendFullscreen = new QCheckBox(AGGroupBox); |
410 |
CBFrontendFullscreen->setText(QCheckBox::tr("Frontend fullscreen")); |
|
411 |
GBAlayout->addWidget(CBFrontendFullscreen); |
|
1162 | 412 |
|
1644 | 413 |
CBEnableSound = new QCheckBox(AGGroupBox); |
414 |
CBEnableSound->setText(QCheckBox::tr("Enable sound")); |
|
415 |
GBAlayout->addWidget(CBEnableSound); |
|
184 | 416 |
|
1644 | 417 |
CBEnableMusic = new QCheckBox(AGGroupBox); |
418 |
CBEnableMusic->setText(QCheckBox::tr("Enable music")); |
|
419 |
GBAlayout->addWidget(CBEnableMusic); |
|
1129 | 420 |
|
1777 | 421 |
QHBoxLayout * GBAvollayout = new QHBoxLayout(0); |
422 |
QLabel * vol = new QLabel(AGGroupBox); |
|
423 |
vol->setText(QLabel::tr("Initial sound volume")); |
|
424 |
GBAvollayout->addWidget(vol); |
|
425 |
GBAlayout->addLayout(GBAvollayout); |
|
426 |
volumeBox = new QSpinBox(AGGroupBox); |
|
427 |
volumeBox->setRange(0, 100); |
|
428 |
volumeBox->setSingleStep(5); |
|
429 |
GBAvollayout->addWidget(volumeBox); |
|
430 |
||
431 |
||
1644 | 432 |
CBShowFPS = new QCheckBox(AGGroupBox); |
433 |
CBShowFPS->setText(QCheckBox::tr("Show FPS")); |
|
434 |
GBAlayout->addWidget(CBShowFPS); |
|
297 | 435 |
|
1644 | 436 |
CBAltDamage = new QCheckBox(AGGroupBox); |
437 |
CBAltDamage->setText(QCheckBox::tr("Alternative damage show")); |
|
438 |
GBAlayout->addWidget(CBAltDamage); |
|
529 | 439 |
|
1644 | 440 |
CBNameWithDate = new QCheckBox(AGGroupBox); |
441 |
CBNameWithDate->setText(QCheckBox::tr("Append date and time to record file name")); |
|
442 |
GBAlayout->addWidget(CBNameWithDate); |
|
1487
b4cc59a6d50a
Add an option to name records with current date and time
unc0rr
parents:
1457
diff
changeset
|
443 |
|
1644 | 444 |
fpsedit = new FPSEdit(AGGroupBox); |
445 |
GBAfpslayout->addWidget(fpsedit); |
|
446 |
gbTBLayout->addWidget(AGGroupBox, 0, 1, 2, 1); |
|
447 |
} |
|
184 | 448 |
|
1644 | 449 |
BtnSaveOptions = addButton(":/res/Save.png", pageLayout, 2, 2, true); |
1443 | 450 |
BtnSaveOptions->setStyleSheet("QPushButton{margin: 12px 0px 12px 0px;}"); |
184 | 451 |
|
1644 | 452 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 2, 0, true); |
184 | 453 |
} |
454 |
||
1153 | 455 |
PageNet::PageNet(QWidget* parent) : AbstractPage(parent) |
184 | 456 |
{ |
457 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
458 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
459 |
pageLayout->setColumnStretch(0, 1); |
|
460 |
pageLayout->setColumnStretch(1, 1); |
|
617 | 461 |
pageLayout->setColumnStretch(2, 1); |
421 | 462 |
|
463 |
BtnNetSvrStart = new QPushButton(this); |
|
464 |
BtnNetSvrStart->setFont(*font14); |
|
465 |
BtnNetSvrStart->setText(QPushButton::tr("Start server")); |
|
1415
6fbfee0e113a
Allow build without net game server: introduce -DWITH_SERVER configuration parameter
unc0rr
parents:
1409
diff
changeset
|
466 |
BtnNetSvrStart->setVisible(haveServer); |
1395 | 467 |
pageLayout->addWidget(BtnNetSvrStart, 4, 2); |
468 |
||
469 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 4, 0, true); |
|
184 | 470 |
|
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
471 |
ConnGroupBox = new QGroupBox(this); |
421 | 472 |
ConnGroupBox->setTitle(QGroupBox::tr("Net game")); |
473 |
pageLayout->addWidget(ConnGroupBox, 2, 0, 1, 3); |
|
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
474 |
GBClayout = new QGridLayout(ConnGroupBox); |
646 | 475 |
GBClayout->setColumnStretch(0, 1); |
421 | 476 |
GBClayout->setColumnStretch(1, 1); |
477 |
GBClayout->setColumnStretch(2, 1); |
|
184 | 478 |
|
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
479 |
BtnNetConnect = new QPushButton(ConnGroupBox); |
184 | 480 |
BtnNetConnect->setFont(*font14); |
481 |
BtnNetConnect->setText(QPushButton::tr("Connect")); |
|
646 | 482 |
GBClayout->addWidget(BtnNetConnect, 2, 2); |
416 | 483 |
|
665 | 484 |
tvServersList = new QTableView(ConnGroupBox); |
671
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
485 |
tvServersList->setSelectionBehavior(QAbstractItemView::SelectRows); |
665 | 486 |
GBClayout->addWidget(tvServersList, 1, 0, 1, 3); |
421 | 487 |
|
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
488 |
BtnUpdateSList = new QPushButton(ConnGroupBox); |
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
489 |
BtnUpdateSList->setFont(*font14); |
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
490 |
BtnUpdateSList->setText(QPushButton::tr("Update")); |
646 | 491 |
GBClayout->addWidget(BtnUpdateSList, 2, 0); |
314 | 492 |
|
653
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
493 |
BtnSpecifyServer = new QPushButton(ConnGroupBox); |
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
494 |
BtnSpecifyServer->setFont(*font14); |
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
495 |
BtnSpecifyServer->setText(QPushButton::tr("Specify")); |
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
496 |
GBClayout->addWidget(BtnSpecifyServer, 2, 1); |
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
497 |
|
1395 | 498 |
BtnOfficialServer = new QPushButton(ConnGroupBox); |
499 |
BtnOfficialServer->setFont(*font14); |
|
500 |
BtnOfficialServer->setText(QPushButton::tr("Join official server")); |
|
501 |
GBClayout->addWidget(BtnOfficialServer, 3, 0, 1, 3); |
|
636 | 502 |
|
668 | 503 |
connect(BtnNetConnect, SIGNAL(clicked()), this, SLOT(slotConnect())); |
184 | 504 |
} |
505 |
||
646 | 506 |
void PageNet::updateServersList() |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
507 |
{ |
1310 | 508 |
tvServersList->setModel(new HWNetUdpModel(tvServersList)); |
659 | 509 |
|
673 | 510 |
tvServersList->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); |
511 |
||
665 | 512 |
static_cast<HWNetServersModel *>(tvServersList->model())->updateList(); |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
513 |
|
665 | 514 |
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
|
515 |
connect(tvServersList, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotConnect())); |
646 | 516 |
} |
517 |
||
518 |
void PageNet::slotConnect() |
|
519 |
{ |
|
671
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
520 |
HWNetServersModel * model = static_cast<HWNetServersModel *>(tvServersList->model()); |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
521 |
QModelIndex mi = tvServersList->currentIndex(); |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
522 |
if(!mi.isValid()) |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
523 |
{ |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
524 |
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
|
525 |
return; |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
526 |
} |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
527 |
QString host = model->index(mi.row(), 1).data().toString(); |
a8970859f50e
Actually pass host and port values to NetConnect method
unc0rr
parents:
668
diff
changeset
|
528 |
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
|
529 |
|
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
|
530 |
emit connectClicked(host, port); |
646 | 531 |
} |
532 |
||
1153 | 533 |
PageNetServer::PageNetServer(QWidget* parent) : AbstractPage(parent) |
646 | 534 |
{ |
535 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
536 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
537 |
pageLayout->setColumnStretch(0, 1); |
|
538 |
pageLayout->setColumnStretch(1, 1); |
|
539 |
pageLayout->setColumnStretch(2, 1); |
|
540 |
||
675 | 541 |
pageLayout->setRowStretch(0, 1); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
542 |
pageLayout->setRowStretch(1, 0); |
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
543 |
|
1153 | 544 |
BtnBack =addButton(":/res/Exit.png", pageLayout, 1, 0, true); |
646 | 545 |
|
546 |
BtnStart = new QPushButton(this); |
|
547 |
BtnStart->setFont(*font14); |
|
548 |
BtnStart->setText(QPushButton::tr("Start")); |
|
675 | 549 |
pageLayout->addWidget(BtnStart, 1, 2); |
550 |
||
551 |
QWidget * wg = new QWidget(this); |
|
552 |
pageLayout->addWidget(wg, 0, 0, 1, 3); |
|
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
553 |
|
675 | 554 |
QGridLayout * wgLayout = new QGridLayout(wg); |
555 |
wgLayout->setColumnStretch(0, 1); |
|
556 |
wgLayout->setColumnStretch(1, 3); |
|
557 |
wgLayout->setColumnStretch(2, 1); |
|
558 |
||
559 |
wgLayout->setRowStretch(0, 0); |
|
560 |
wgLayout->setRowStretch(1, 1); |
|
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
561 |
|
675 | 562 |
QGroupBox * gb = new QGroupBox(wg); |
563 |
wgLayout->addWidget(gb, 0, 1); |
|
564 |
||
565 |
QGridLayout * gbLayout = new QGridLayout(gb); |
|
566 |
||
567 |
labelSD = new QLabel(gb); |
|
568 |
labelSD->setText(QLabel::tr("Server name:")); |
|
569 |
gbLayout->addWidget(labelSD, 0, 0); |
|
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
570 |
|
675 | 571 |
leServerDescr = new QLineEdit(gb); |
572 |
gbLayout->addWidget(leServerDescr, 0, 1); |
|
573 |
||
574 |
labelPort = new QLabel(gb); |
|
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
575 |
labelPort->setText(QLabel::tr("Server port:")); |
675 | 576 |
gbLayout->addWidget(labelPort, 1, 0); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
577 |
|
675 | 578 |
sbPort = new QSpinBox(gb); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
579 |
sbPort->setMinimum(0); |
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
580 |
sbPort->setMaximum(65535); |
675 | 581 |
gbLayout->addWidget(sbPort, 1, 1); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
582 |
|
675 | 583 |
BtnDefault = new QPushButton(gb); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
584 |
BtnDefault->setText(QPushButton::tr("default")); |
675 | 585 |
gbLayout->addWidget(BtnDefault, 1, 2); |
657
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
586 |
|
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
587 |
connect(BtnDefault, SIGNAL(clicked()), this, SLOT(setDefaultPort())); |
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
588 |
} |
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
589 |
|
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
590 |
void PageNetServer::setDefaultPort() |
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
591 |
{ |
b34fc518a48a
Basic concept for net server options page (subject to change)
unc0rr
parents:
653
diff
changeset
|
592 |
sbPort->setValue(46631); |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
593 |
} |
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
617
diff
changeset
|
594 |
|
1153 | 595 |
PageNetGame::PageNetGame(QWidget* parent) : AbstractPage(parent) |
184 | 596 |
{ |
597 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
598 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
452 | 599 |
pageLayout->setSizeConstraint(QLayout::SetMinimumSize); |
461 | 600 |
//pageLayout->setSpacing(1); |
463 | 601 |
pageLayout->setColumnStretch(0, 50); |
602 |
pageLayout->setColumnStretch(1, 50); |
|
322 | 603 |
|
461 | 604 |
// chatwidget |
605 |
pChatWidget = new HWChatWidget(this); |
|
1647 | 606 |
pageLayout->addWidget(pChatWidget, 1, 0, 1, 2); |
464 | 607 |
pageLayout->setRowStretch(1, 100); |
453 | 608 |
|
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
323
diff
changeset
|
609 |
pGameCFG = new GameCFGWidget(this); |
322 | 610 |
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
|
611 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
323
diff
changeset
|
612 |
pNetTeamsWidget = new TeamSelWidget(this); |
373 | 613 |
pNetTeamsWidget->setAcceptOuter(true); |
1647 | 614 |
pageLayout->addWidget(pNetTeamsWidget, 0, 1); |
184 | 615 |
|
1649 | 616 |
|
617 |
QHBoxLayout * bottomLayout = new QHBoxLayout; |
|
618 |
pageLayout->addLayout(bottomLayout, 3, 0, 1, 2); |
|
619 |
||
620 |
BtnBack = addButton(":/res/Exit.png", bottomLayout, 0, true); |
|
621 |
||
646 | 622 |
BtnGo = new QPushButton(this); |
184 | 623 |
BtnGo->setFont(*font14); |
1677 | 624 |
BtnGo->setToolTip(QPushButton::tr("Ready")); |
1648 | 625 |
BtnGo->setIcon(QIcon(":/res/lightbulb_off.png")); |
626 |
BtnGo->setIconSize(QSize(25, 34)); |
|
1649 | 627 |
BtnGo->setMinimumWidth(50); |
628 |
BtnGo->setMinimumHeight(50); |
|
629 |
bottomLayout->addWidget(BtnGo, 2); |
|
1409
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1404
diff
changeset
|
630 |
|
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1404
diff
changeset
|
631 |
|
1649 | 632 |
BtnMaster = addButton(tr("Control"), bottomLayout, 3); |
1409
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1404
diff
changeset
|
633 |
QMenu * menu = new QMenu(BtnMaster); |
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1404
diff
changeset
|
634 |
startGame = new QAction(QAction::tr("Start"), menu); |
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1404
diff
changeset
|
635 |
restrictJoins = new QAction(QAction::tr("Restrict Joins"), menu); |
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1404
diff
changeset
|
636 |
restrictJoins->setCheckable(true); |
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1404
diff
changeset
|
637 |
restrictTeamAdds = new QAction(QAction::tr("Restrict Team Additions"), menu); |
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1404
diff
changeset
|
638 |
restrictTeamAdds->setCheckable(true); |
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1404
diff
changeset
|
639 |
menu->addAction(startGame); |
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1404
diff
changeset
|
640 |
menu->addAction(restrictJoins); |
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1404
diff
changeset
|
641 |
menu->addAction(restrictTeamAdds); |
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1404
diff
changeset
|
642 |
|
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1404
diff
changeset
|
643 |
BtnMaster->setMenu(menu); |
1649 | 644 |
|
645 |
bottomLayout->insertStretch(1, 100); |
|
184 | 646 |
} |
187 | 647 |
|
1648 | 648 |
void PageNetGame::setReadyStatus(bool isReady) |
649 |
{ |
|
650 |
if(isReady) |
|
651 |
BtnGo->setIcon(QIcon(":/res/lightbulb_on.png")); |
|
652 |
else |
|
653 |
BtnGo->setIcon(QIcon(":/res/lightbulb_off.png")); |
|
654 |
} |
|
655 |
||
1649 | 656 |
void PageNetGame::setMasterMode(bool isMaster) |
657 |
{ |
|
658 |
BtnMaster->setVisible(isMaster); |
|
659 |
} |
|
660 |
||
1153 | 661 |
PageInfo::PageInfo(QWidget* parent) : AbstractPage(parent) |
187 | 662 |
{ |
663 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
664 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
665 |
pageLayout->setColumnStretch(0, 1); |
|
666 |
pageLayout->setColumnStretch(1, 1); |
|
667 |
pageLayout->setColumnStretch(2, 1); |
|
668 |
||
1153 | 669 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true); |
187 | 670 |
|
671 |
about = new About(this); |
|
672 |
pageLayout->addWidget(about, 0, 0, 1, 3); |
|
673 |
} |
|
306 | 674 |
|
1150 | 675 |
PageSinglePlayer::PageSinglePlayer(QWidget* parent) : AbstractPage(parent) |
586 | 676 |
{ |
677 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
1443 | 678 |
QVBoxLayout * vLayout = new QVBoxLayout(this); |
679 |
QHBoxLayout * topLine = new QHBoxLayout(); |
|
680 |
QHBoxLayout * middleLine = new QHBoxLayout(); |
|
681 |
QHBoxLayout * bottomLine = new QHBoxLayout(); |
|
1444 | 682 |
vLayout->addStretch(); |
1443 | 683 |
vLayout->addLayout(topLine); |
1457 | 684 |
vLayout->addSpacing(30); |
1443 | 685 |
vLayout->addLayout(middleLine); |
1444 | 686 |
vLayout->addStretch(); |
1443 | 687 |
vLayout->addLayout(bottomLine); |
586 | 688 |
|
1457 | 689 |
topLine->addStretch(); |
1443 | 690 |
BtnSimpleGamePage = addButton(":/res/SimpleGame.png", topLine, 0, true); |
1450 | 691 |
BtnSimpleGamePage->setToolTip(tr("Simple Game (a quick game against the computer, settings are chosen for you)")); |
1457 | 692 |
topLine->addSpacing(60); |
1443 | 693 |
BtnMultiplayer = addButton(":/res/Multiplayer.png", topLine, 1, true); |
1450 | 694 |
BtnMultiplayer->setToolTip(tr("Multiplayer (play a hotseat game against your friends, or AI teams)")); |
1457 | 695 |
topLine->addStretch(); |
696 |
||
697 |
||
1443 | 698 |
BtnTrainPage = addButton(":/res/Trainings.png", middleLine, 0, true); |
1450 | 699 |
BtnTrainPage->setToolTip(tr("Training Mode (Practice your skills in a range of training missions). IN DEVELOPMENT")); |
1443 | 700 |
|
701 |
BtnBack = addButton(":/res/Exit.png", bottomLine, 0, true); |
|
1444 | 702 |
bottomLine->addStretch(); |
703 |
||
1447 | 704 |
BtnDemos = addButton(":/res/Record.png", bottomLine, 1, true); |
1450 | 705 |
BtnDemos->setToolTip(tr("Demos (Watch recorded demos)")); |
1443 | 706 |
BtnLoad = addButton(":/res/Save.png", bottomLine, 2, true); |
707 |
BtnLoad->setStyleSheet("QPushButton{margin: 12px 0px 12px 0px;}"); |
|
1450 | 708 |
BtnLoad->setToolTip(tr("Load (Load a previously saved game)")); |
586 | 709 |
} |
710 |
||
1153 | 711 |
PageTraining::PageTraining(QWidget* parent) : AbstractPage(parent) |
587 | 712 |
{ |
713 |
QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
714 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
715 |
pageLayout->setColumnStretch(0, 1); |
|
716 |
pageLayout->setColumnStretch(1, 2); |
|
717 |
pageLayout->setColumnStretch(2, 1); |
|
718 |
||
719 |
BtnStartTrain = new QPushButton(this); |
|
720 |
BtnStartTrain->setFont(*font14); |
|
721 |
BtnStartTrain->setText(QPushButton::tr("Go!")); |
|
722 |
pageLayout->addWidget(BtnStartTrain, 1, 2); |
|
723 |
||
1153 | 724 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true); |
587 | 725 |
} |
726 |
||
923
b3d097097b54
Use default ammostore string size for weapons number instead of predefined const
unc0rr
parents:
788
diff
changeset
|
727 |
PageSelectWeapon::PageSelectWeapon(QWidget* parent) : |
684 | 728 |
AbstractPage(parent) |
600 | 729 |
{ |
730 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
923
b3d097097b54
Use default ammostore string size for weapons number instead of predefined const
unc0rr
parents:
788
diff
changeset
|
731 |
|
1576
a02353129a41
Check for deprecated ammo schemes at startup and delete them
unc0rr
parents:
1522
diff
changeset
|
732 |
pWeapons = new SelWeaponWidget(cDefaultAmmoStore->size(), this); |
718 | 733 |
pageLayout->addWidget(pWeapons, 0, 0, 1, 4); |
600 | 734 |
|
1168 | 735 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true); |
730 | 736 |
BtnDefault = addButton(tr("Default"), pageLayout, 1, 1); |
737 |
BtnDelete = addButton(tr("Delete"), pageLayout, 1, 2); |
|
1168 | 738 |
BtnSave = addButton(":/res/Save.png", pageLayout, 1, 3, true); |
1443 | 739 |
BtnSave->setStyleSheet("QPushButton{margin: 12px 0px 12px 0px;}"); |
600 | 740 |
} |
741 |
||
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
|
742 |
PageInGame::PageInGame(QWidget* parent) : |
686 | 743 |
AbstractPage(parent) |
744 |
{ |
|
745 |
QLabel * label = new QLabel(this); |
|
746 |
label->setText("In game..."); |
|
747 |
} |
|
1311 | 748 |
|
749 |
PageRoomsList::PageRoomsList(QWidget* parent) : |
|
750 |
AbstractPage(parent) |
|
751 |
{ |
|
1312 | 752 |
QGridLayout * pageLayout = new QGridLayout(this); |
1314 | 753 |
|
754 |
roomName = new QLineEdit(this); |
|
1334
b58afaadf7ae
Send team removal message to others in room when client disconnects
unc0rr
parents:
1315
diff
changeset
|
755 |
roomName->setMaxLength(60); |
1314 | 756 |
pageLayout->addWidget(roomName, 0, 0); |
1399 | 757 |
|
758 |
roomsList = new QTableWidget(this); |
|
759 |
roomsList->setColumnCount(3); |
|
760 |
roomsList->setSelectionBehavior(QAbstractItemView::SelectRows); |
|
761 |
roomsList->verticalHeader()->setVisible(false); |
|
762 |
roomsList->horizontalHeader()->setResizeMode(QHeaderView::Interactive); |
|
1522 | 763 |
pageLayout->addWidget(roomsList, 1, 0, 3, 1); |
1584
90f6a5abad17
Save much space for chat widget on lobby page by removing server message widget (now this messages goes to chat)
unc0rr
parents:
1576
diff
changeset
|
764 |
pageLayout->setRowStretch(2, 100); |
1399 | 765 |
|
1584
90f6a5abad17
Save much space for chat widget on lobby page by removing server message widget (now this messages goes to chat)
unc0rr
parents:
1576
diff
changeset
|
766 |
chatWidget = new HWChatWidget(this); |
90f6a5abad17
Save much space for chat widget on lobby page by removing server message widget (now this messages goes to chat)
unc0rr
parents:
1576
diff
changeset
|
767 |
pageLayout->addWidget(chatWidget, 4, 0, 1, 2); |
90f6a5abad17
Save much space for chat widget on lobby page by removing server message widget (now this messages goes to chat)
unc0rr
parents:
1576
diff
changeset
|
768 |
pageLayout->setRowStretch(4, 350); |
1522 | 769 |
|
1312 | 770 |
BtnCreate = addButton(tr("Create"), pageLayout, 0, 1); |
771 |
BtnJoin = addButton(tr("Join"), pageLayout, 1, 1); |
|
1522 | 772 |
BtnRefresh = addButton(tr("Refresh"), pageLayout, 3, 1); |
1856
e71dbf958c87
Enable admin button when have privilege. Button does nothing yet.
unc0rr
parents:
1840
diff
changeset
|
773 |
|
e71dbf958c87
Enable admin button when have privilege. Button does nothing yet.
unc0rr
parents:
1840
diff
changeset
|
774 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 5, 0, true); |
e71dbf958c87
Enable admin button when have privilege. Button does nothing yet.
unc0rr
parents:
1840
diff
changeset
|
775 |
BtnAdmin = addButton(tr("Admin features"), pageLayout, 5, 1); |
1314 | 776 |
|
777 |
connect(BtnCreate, SIGNAL(clicked()), this, SLOT(onCreateClick())); |
|
778 |
connect(BtnJoin, SIGNAL(clicked()), this, SLOT(onJoinClick())); |
|
1315 | 779 |
connect(BtnRefresh, SIGNAL(clicked()), this, SLOT(onRefreshClick())); |
1314 | 780 |
connect(roomsList, SIGNAL(doubleClicked (const QModelIndex &)), this, SLOT(onJoinClick())); |
1311 | 781 |
} |
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1312
diff
changeset
|
782 |
|
1856
e71dbf958c87
Enable admin button when have privilege. Button does nothing yet.
unc0rr
parents:
1840
diff
changeset
|
783 |
void PageRoomsList::setAdmin(bool flag) |
e71dbf958c87
Enable admin button when have privilege. Button does nothing yet.
unc0rr
parents:
1840
diff
changeset
|
784 |
{ |
e71dbf958c87
Enable admin button when have privilege. Button does nothing yet.
unc0rr
parents:
1840
diff
changeset
|
785 |
BtnAdmin->setVisible(flag); |
e71dbf958c87
Enable admin button when have privilege. Button does nothing yet.
unc0rr
parents:
1840
diff
changeset
|
786 |
} |
1377 | 787 |
|
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1312
diff
changeset
|
788 |
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
|
789 |
{ |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1312
diff
changeset
|
790 |
roomsList->clear(); |
1399 | 791 |
roomsList->setHorizontalHeaderLabels( |
792 |
QStringList() << |
|
793 |
QTableWidget::tr("Room name") << |
|
794 |
QTableWidget::tr("Players number") << |
|
795 |
QTableWidget::tr("Round in progress") |
|
796 |
); |
|
1893 | 797 |
|
798 |
roomsList->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); |
|
799 |
roomsList->horizontalHeader()->setResizeMode(1, QHeaderView::ResizeToContents); |
|
800 |
roomsList->horizontalHeader()->setResizeMode(2, QHeaderView::ResizeToContents); |
|
801 |
||
1399 | 802 |
|
803 |
if (list.size() % 3) |
|
804 |
return; |
|
805 |
||
806 |
roomsList->setRowCount(list.size() / 3); |
|
807 |
for(int i = 0; i < list.size(); i += 3) |
|
808 |
for(int t = 0; t < 3; t++) |
|
809 |
{ |
|
810 |
QTableWidgetItem * item = new QTableWidgetItem(list[i + t]); |
|
1891 | 811 |
item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); |
1400 | 812 |
roomsList->setItem(i / 3, t, item); |
1399 | 813 |
} |
814 |
//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
|
815 |
} |
1314 | 816 |
|
817 |
void PageRoomsList::onCreateClick() |
|
818 |
{ |
|
819 |
if (roomName->text().size()) |
|
820 |
emit askForCreateRoom(roomName->text()); |
|
821 |
else |
|
822 |
QMessageBox::critical(this, |
|
823 |
tr("Error"), |
|
1315 | 824 |
tr("Please, enter room name"), |
1314 | 825 |
tr("OK")); |
826 |
} |
|
827 |
||
828 |
void PageRoomsList::onJoinClick() |
|
829 |
{ |
|
1399 | 830 |
QTableWidgetItem * curritem = roomsList->item(roomsList->currentRow(), 0); |
1314 | 831 |
if (!curritem) |
832 |
{ |
|
833 |
QMessageBox::critical(this, |
|
834 |
tr("Error"), |
|
835 |
tr("Please, select room from the list"), |
|
836 |
tr("OK")); |
|
837 |
return ; |
|
838 |
} |
|
839 |
emit askForJoinRoom(curritem->data(Qt::DisplayRole).toString()); |
|
840 |
} |
|
841 |
||
1315 | 842 |
void PageRoomsList::onRefreshClick() |
843 |
{ |
|
844 |
emit askForRoomList(); |
|
845 |
} |
|
846 |
||
1800 | 847 |
|
848 |
PageConnecting::PageConnecting(QWidget* parent) : |
|
849 |
AbstractPage(parent) |
|
850 |
{ |
|
851 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
852 |
} |
|
1884 | 853 |
|
854 |
PageScheme::PageScheme(QWidget* parent) : |
|
855 |
AbstractPage(parent) |
|
856 |
{ |
|
857 |
QGridLayout * pageLayout = new QGridLayout(this); |
|
1885 | 858 |
|
859 |
CB_mode_Forts = new QCheckBox(this); |
|
860 |
CB_mode_Forts->setText(QCheckBox::tr("Forts mode")); |
|
861 |
pageLayout->addWidget(CB_mode_Forts, 0, 0, 1, 2); |
|
862 |
||
863 |
CB_teamsDivide = new QCheckBox(this); |
|
864 |
CB_teamsDivide->setText(QCheckBox::tr("Divide teams")); |
|
865 |
pageLayout->addWidget(CB_teamsDivide, 1, 0, 1, 2); |
|
866 |
||
867 |
CB_solid = new QCheckBox(this); |
|
868 |
CB_solid->setText(QCheckBox::tr("Solid land")); |
|
869 |
pageLayout->addWidget(CB_solid, 2, 0, 1, 2); |
|
870 |
||
871 |
CB_border = new QCheckBox(this); |
|
872 |
CB_border->setText(QCheckBox::tr("Add Border")); |
|
873 |
pageLayout->addWidget(CB_border, 3, 0, 1, 2); |
|
874 |
||
875 |
SB_TurnTime = new QSpinBox(this); |
|
876 |
SB_TurnTime->setRange(1, 99); |
|
877 |
SB_TurnTime->setValue(45); |
|
878 |
SB_TurnTime->setSingleStep(15); |
|
879 |
||
880 |
SB_InitHealth = new QSpinBox(this); |
|
881 |
SB_InitHealth->setRange(50, 200); |
|
882 |
SB_InitHealth->setValue(100); |
|
883 |
SB_InitHealth->setSingleStep(25); |
|
884 |
||
885 |
SB_SuddenDeath = new QSpinBox(this); |
|
886 |
SB_SuddenDeath->setRange(0, 50); |
|
887 |
SB_SuddenDeath->setValue(15); |
|
888 |
SB_SuddenDeath->setSingleStep(3); |
|
889 |
||
890 |
SB_CaseProb = new FreqSpinBox(this); |
|
891 |
SB_CaseProb->setRange(0, 9); |
|
892 |
SB_CaseProb->setValue(5); |
|
893 |
||
894 |
LE_name = new QLineEdit(this); |
|
895 |
||
896 |
pageLayout->addWidget(SB_TurnTime, 4, 1); |
|
897 |
pageLayout->addWidget(SB_InitHealth, 5, 1); |
|
898 |
pageLayout->addWidget(SB_SuddenDeath, 6, 1); |
|
899 |
pageLayout->addWidget(SB_CaseProb, 7, 1); |
|
900 |
pageLayout->addWidget(LE_name, 8, 1); |
|
901 |
||
902 |
mapper = new QDataWidgetMapper(this); |
|
1887 | 903 |
|
904 |
BtnBack = addButton(":/res/Exit.png", pageLayout, 10, 0, true); |
|
1889 | 905 |
BtnNew = addButton(tr("New"), pageLayout, 10, 1); |
906 |
BtnPrev = addButton(tr("Prev"), pageLayout, 10, 2); |
|
907 |
BtnNext = addButton(tr("Next"), pageLayout, 10, 3); |
|
908 |
BtnSave = addButton(":/res/Save.png", pageLayout, 10, 4, true); |
|
1887 | 909 |
|
910 |
connect(BtnSave, SIGNAL(clicked()), mapper, SLOT(toFirst())); |
|
1889 | 911 |
connect(BtnNew, SIGNAL(clicked()), this, SLOT(newRow())); |
912 |
connect(BtnPrev, SIGNAL(clicked()), mapper, SLOT(toPrevious())); |
|
913 |
connect(BtnNext, SIGNAL(clicked()), mapper, SLOT(toNext())); |
|
1887 | 914 |
} |
915 |
||
916 |
void PageScheme::setModel(QAbstractItemModel * model) |
|
917 |
{ |
|
918 |
mapper->setModel(model); |
|
919 |
||
1885 | 920 |
mapper->addMapping(LE_name, 0); |
921 |
mapper->addMapping(CB_mode_Forts, 1); |
|
922 |
mapper->addMapping(CB_teamsDivide, 2); |
|
923 |
mapper->addMapping(CB_solid, 3); |
|
924 |
mapper->addMapping(CB_border, 4); |
|
925 |
mapper->addMapping(SB_TurnTime, 5); |
|
926 |
mapper->addMapping(SB_InitHealth, 6); |
|
927 |
mapper->addMapping(SB_SuddenDeath, 7); |
|
928 |
mapper->addMapping(SB_CaseProb, 8); |
|
1887 | 929 |
|
930 |
mapper->toFirst(); |
|
1884 | 931 |
} |
1889 | 932 |
|
933 |
void PageScheme::newRow() |
|
934 |
{ |
|
935 |
QAbstractItemModel * model = mapper->model(); |
|
936 |
model->insertRow(model->rowCount()); |
|
937 |
mapper->toLast(); |
|
938 |
} |