87
|
1 |
/*
|
|
2 |
* Hedgewars, a worms-like game
|
|
3 |
* Copyright (c) 2006 Andrey Korotaev <unC0Rr@gmail.com>
|
|
4 |
*
|
|
5 |
* Distributed under the terms of the BSD-modified licence:
|
|
6 |
*
|
|
7 |
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
8 |
* of this software and associated documentation files (the "Software"), to deal
|
|
9 |
* with the Software without restriction, including without limitation the
|
|
10 |
* rights to use, copy, modify, merge, publish, distribute, sublicense, and/or
|
|
11 |
* sell copies of the Software, and to permit persons to whom the Software is
|
|
12 |
* furnished to do so, subject to the following conditions:
|
|
13 |
*
|
|
14 |
* 1. Redistributions of source code must retain the above copyright notice,
|
|
15 |
* this list of conditions and the following disclaimer.
|
|
16 |
* 2. Redistributions in binary form must reproduce the above copyright notice,
|
|
17 |
* this list of conditions and the following disclaimer in the documentation
|
|
18 |
* and/or other materials provided with the distribution.
|
|
19 |
* 3. The name of the author may not be used to endorse or promote products
|
|
20 |
* derived from this software without specific prior written permission.
|
|
21 |
*
|
|
22 |
* THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
|
23 |
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
|
|
24 |
* MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO
|
|
25 |
* EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
|
|
26 |
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
27 |
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
|
|
28 |
* OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
|
|
29 |
* WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
|
|
30 |
* OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
|
31 |
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
32 |
*/
|
|
33 |
|
|
34 |
#include <QGridLayout>
|
|
35 |
#include <QDir>
|
|
36 |
#include <QPushButton>
|
|
37 |
#include <QGroupBox>
|
|
38 |
#include <QComboBox>
|
|
39 |
#include <QLabel>
|
|
40 |
#include <QToolBox>
|
|
41 |
#include <QLineEdit>
|
|
42 |
#include <QListWidget>
|
88
|
43 |
#include <QApplication>
|
87
|
44 |
|
|
45 |
#include "pages.h"
|
|
46 |
#include "sdlkeys.h"
|
|
47 |
#include "hwconsts.h"
|
|
48 |
#include "gamecfgwidget.h"
|
|
49 |
#include "teamselect.h"
|
|
50 |
#include "gamecfgwidget.h"
|
|
51 |
|
|
52 |
PageMain::PageMain(QWidget* parent) : QWidget(parent)
|
|
53 |
{
|
|
54 |
QFont * font14 = new QFont("MS Shell Dlg", 14);
|
|
55 |
QGridLayout * pageLayout = new QGridLayout(this);
|
|
56 |
pageLayout->setMargin(25);
|
|
57 |
pageLayout->setColumnStretch(0, 1);
|
|
58 |
pageLayout->setColumnStretch(1, 2);
|
|
59 |
pageLayout->setColumnStretch(2, 1);
|
|
60 |
|
|
61 |
BtnSinglePlayer = new QPushButton(this);
|
|
62 |
BtnSinglePlayer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
63 |
BtnSinglePlayer->setFont(*font14);
|
|
64 |
BtnSinglePlayer->setText(QPushButton::tr("Single Player"));
|
|
65 |
pageLayout->addWidget(BtnSinglePlayer, 1, 1);
|
|
66 |
|
|
67 |
BtnMultiplayer = new QPushButton(this);
|
|
68 |
BtnMultiplayer->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
69 |
BtnMultiplayer->setFont(*font14);
|
|
70 |
BtnMultiplayer->setText(QPushButton::tr("Multiplayer"));
|
|
71 |
pageLayout->addWidget(BtnMultiplayer, 2, 1);
|
|
72 |
|
|
73 |
BtnNet = new QPushButton(this);
|
|
74 |
BtnNet->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
75 |
BtnNet->setFont(*font14);
|
|
76 |
BtnNet->setText(QPushButton::tr("Net game"));
|
|
77 |
pageLayout->addWidget(BtnNet, 3, 1);
|
|
78 |
|
|
79 |
BtnDemos = new QPushButton(this);
|
|
80 |
BtnDemos->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
81 |
BtnDemos->setFont(*font14);
|
|
82 |
BtnDemos->setText(QPushButton::tr("Demos"));
|
|
83 |
pageLayout->addWidget(BtnDemos, 4, 1);
|
|
84 |
|
|
85 |
BtnSetup = new QPushButton(this);
|
|
86 |
BtnSetup->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
87 |
BtnSetup->setFont(*font14);
|
|
88 |
BtnSetup->setText(QPushButton::tr("Setup"));
|
|
89 |
pageLayout->addWidget(BtnSetup, 5, 1);
|
|
90 |
|
|
91 |
BtnExit = new QPushButton(parent);
|
|
92 |
BtnExit->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding);
|
|
93 |
BtnExit->setFont(*font14);
|
|
94 |
BtnExit->setText(QPushButton::tr("Exit"));
|
|
95 |
pageLayout->addWidget(BtnExit, 6, 1);
|
|
96 |
}
|
|
97 |
|
|
98 |
PageLocalGame::PageLocalGame(QWidget* parent) : QWidget(parent)
|
|
99 |
{
|
|
100 |
QFont * font14 = new QFont("MS Shell Dlg", 14);
|
|
101 |
QGridLayout * pageLayout = new QGridLayout(this);
|
|
102 |
BtnBack = new QPushButton(this);
|
|
103 |
BtnBack->setFont(*font14);
|
|
104 |
BtnBack->setText(QPushButton::tr("Back"));
|
|
105 |
pageLayout->addWidget(BtnBack, 1, 0);
|
|
106 |
BtnSimpleGame = new QPushButton(this);
|
|
107 |
BtnSimpleGame->setFont(*font14);
|
|
108 |
BtnSimpleGame->setText(QPushButton::tr("Simple Game"));
|
|
109 |
pageLayout->addWidget(BtnSimpleGame, 1, 3);
|
|
110 |
gameCFG = new GameCFGWidget(this);
|
|
111 |
pageLayout->addWidget(gameCFG, 0, 0, 1, 2);
|
|
112 |
}
|
|
113 |
|
|
114 |
PageEditTeam::PageEditTeam(QWidget* parent) : QWidget(parent)
|
|
115 |
{
|
|
116 |
QFont * font14 = new QFont("MS Shell Dlg", 14);
|
|
117 |
GBoxHedgehogs = new QGroupBox(this);
|
|
118 |
GBoxHedgehogs->setGeometry(QRect(20, 70, 161, 261));
|
|
119 |
GBoxHedgehogs->setTitle(QGroupBox::tr("Team Members"));
|
|
120 |
GBoxTeam = new QGroupBox(this);
|
|
121 |
GBoxTeam->setGeometry(QRect(20, 10, 161, 51));
|
|
122 |
GBoxTeam->setTitle(QGroupBox::tr("Team"));
|
|
123 |
GBoxFort = new QGroupBox(this);
|
|
124 |
GBoxFort->setGeometry(QRect(420, 110, 181, 221));
|
|
125 |
GBoxFort->setTitle(QGroupBox::tr("Fort"));
|
|
126 |
CBFort = new QComboBox(GBoxFort);
|
|
127 |
CBFort->setGeometry(QRect(10, 20, 161, 21));
|
|
128 |
CBFort->setMaxCount(65535);
|
|
129 |
FortPreview = new QLabel(GBoxFort);
|
|
130 |
FortPreview->setGeometry(QRect(10, 50, 161, 161));
|
|
131 |
FortPreview->setPixmap(QPixmap());
|
|
132 |
FortPreview->setScaledContents(true);
|
|
133 |
GBoxGrave = new QGroupBox(this);
|
|
134 |
GBoxGrave->setGeometry(QRect(420, 10, 181, 91));
|
|
135 |
GBoxGrave->setTitle(QGroupBox::tr("Grave"));
|
|
136 |
CBGrave = new QComboBox(GBoxGrave);
|
|
137 |
CBGrave->setGeometry(QRect(10, 20, 161, 21));
|
|
138 |
CBGrave->setMaxCount(65535);
|
|
139 |
GravePreview = new QLabel(GBoxGrave);
|
|
140 |
GravePreview->setGeometry(QRect(80, 50, 32, 32));
|
|
141 |
GravePreview->setScaledContents(true);
|
|
142 |
GBoxBinds = new QGroupBox(this);
|
|
143 |
GBoxBinds->setGeometry(QRect(200, 10, 201, 431));
|
|
144 |
GBoxBinds->setTitle(QGroupBox::tr("Key binds"));
|
|
145 |
BindsBox = new QToolBox(GBoxBinds);
|
|
146 |
BindsBox->setGeometry(QRect(10, 20, 181, 401));
|
|
147 |
BindsBox->setLineWidth(0);
|
|
148 |
page_A = new QWidget();
|
|
149 |
page_A->setGeometry(QRect(0, 0, 96, 26));
|
|
150 |
BindsBox->addItem(page_A, QToolBox::tr("Actions"));
|
|
151 |
page_W = new QWidget();
|
|
152 |
BindsBox->addItem(page_W, QToolBox::tr("Weapons"));
|
|
153 |
page_WP = new QWidget();
|
|
154 |
BindsBox->addItem(page_WP, QToolBox::tr("Weapon properties"));
|
|
155 |
page_O = new QWidget();
|
|
156 |
page_O->setGeometry(QRect(0, 0, 96, 26));
|
|
157 |
BindsBox->addItem(page_O, QToolBox::tr("Other"));
|
|
158 |
BtnTeamDiscard = new QPushButton(this);
|
|
159 |
BtnTeamDiscard->setGeometry(QRect(440, 380, 161, 41));
|
|
160 |
BtnTeamDiscard->setFont(*font14);
|
|
161 |
BtnTeamDiscard->setText(QPushButton::tr("Discard"));
|
|
162 |
BtnTeamSave = new QPushButton(this);
|
|
163 |
BtnTeamSave->setGeometry(QRect(20, 380, 161, 41));
|
|
164 |
BtnTeamSave->setFont(*font14);
|
|
165 |
BtnTeamSave->setText(QPushButton::tr("Save"));
|
|
166 |
|
|
167 |
TeamNameEdit = new QLineEdit(GBoxTeam);
|
|
168 |
TeamNameEdit->setGeometry(QRect(10, 20, 141, 20));
|
|
169 |
TeamNameEdit->setMaxLength(15);
|
|
170 |
for(int i = 0; i < 8; i++)
|
|
171 |
{
|
|
172 |
HHNameEdit[i] = new QLineEdit(GBoxHedgehogs);
|
|
173 |
HHNameEdit[i]->setGeometry(QRect(10, 20 + i * 30, 141, 20));
|
|
174 |
HHNameEdit[i]->setMaxLength(15);
|
|
175 |
}
|
|
176 |
|
|
177 |
QStringList binds;
|
|
178 |
for(int i = 0; strlen(sdlkeys[i][1]) > 0; i++)
|
|
179 |
{
|
|
180 |
binds << sdlkeys[i][1];
|
|
181 |
}
|
|
182 |
|
|
183 |
quint16 widind = 0, top = 0;
|
|
184 |
for(quint8 i = 0; i < BINDS_NUMBER; i++)
|
|
185 |
{
|
|
186 |
LBind[i] = new QLabel(BindsBox->widget(widind));
|
|
187 |
LBind[i]->setGeometry(QRect(10, top + 3, 70, 20));
|
88
|
188 |
LBind[i]->setText(QApplication::translate("binds", cbinds[i].name));
|
87
|
189 |
LBind[i]->setAlignment(Qt::AlignRight);
|
|
190 |
CBBind[i] = new QComboBox(BindsBox->widget(widind));
|
|
191 |
CBBind[i]->setGeometry(QRect(90, top, 80, 20));
|
|
192 |
CBBind[i]->addItems(binds);
|
|
193 |
if (cbinds[i].chwidget)
|
|
194 |
{
|
|
195 |
top = 0;
|
|
196 |
widind++;
|
|
197 |
} else
|
|
198 |
{
|
|
199 |
top += 28;
|
|
200 |
}
|
|
201 |
}
|
|
202 |
|
|
203 |
QDir tmpdir;
|
|
204 |
tmpdir.cd(DATA_PATH);
|
|
205 |
tmpdir.cd("Forts");
|
|
206 |
tmpdir.setFilter(QDir::Files);
|
|
207 |
|
|
208 |
CBFort->addItems(tmpdir.entryList(QStringList("*L.png")).replaceInStrings(QRegExp("^(.*)L.png"), "\\1"));
|
|
209 |
tmpdir.cd("../Graphics/Graves");
|
|
210 |
QStringList list = tmpdir.entryList(QStringList("*.png"));
|
|
211 |
for (QStringList::Iterator it = list.begin(); it != list.end(); ++it )
|
|
212 |
{
|
|
213 |
CBGrave->addItem((*it).replace(QRegExp("^(.*).png"), "\\1"));
|
|
214 |
}
|
|
215 |
|
|
216 |
connect(CBGrave, SIGNAL(activated(const QString &)), this, SLOT(CBGrave_activated(const QString &)));
|
|
217 |
connect(CBFort, SIGNAL(activated(const QString &)), this, SLOT(CBFort_activated(const QString &)));
|
|
218 |
}
|
|
219 |
|
|
220 |
void PageEditTeam::CBGrave_activated(const QString & gravename)
|
|
221 |
{
|
|
222 |
QPixmap pix(QString(DATA_PATH) + "/Graphics/Graves/" + gravename + ".png");
|
|
223 |
GravePreview->setPixmap(pix.copy(0, 0, 32, 32));
|
|
224 |
}
|
|
225 |
|
|
226 |
void PageEditTeam::CBFort_activated(const QString & fortname)
|
|
227 |
{
|
|
228 |
QPixmap pix(QString(DATA_PATH) + "/Forts/" + fortname + "L.png");
|
|
229 |
FortPreview->setPixmap(pix);
|
|
230 |
}
|
|
231 |
|
|
232 |
PageMultiplayer::PageMultiplayer(QWidget* parent) : QWidget(parent)
|
|
233 |
{
|
|
234 |
QFont * font14 = new QFont("MS Shell Dlg", 14);
|
|
235 |
QGridLayout * pageLayout = new QGridLayout(this);
|
|
236 |
BtnBack = new QPushButton(this);
|
|
237 |
BtnBack->setFont(*font14);
|
|
238 |
BtnBack->setText(QPushButton::tr("Back"));
|
|
239 |
pageLayout->addWidget(BtnBack, 1, 0);
|
|
240 |
gameCFG = new GameCFGWidget(this);
|
|
241 |
pageLayout->addWidget(gameCFG, 0, 0, 1, 2);
|
|
242 |
teamsSelect = new TeamSelWidget(this);
|
|
243 |
pageLayout->addWidget(teamsSelect, 0, 2, 1, 2);
|
|
244 |
}
|
|
245 |
|
|
246 |
PagePlayDemo::PagePlayDemo(QWidget* parent) : QWidget(parent)
|
|
247 |
{
|
|
248 |
QFont * font14 = new QFont("MS Shell Dlg", 14);
|
|
249 |
QGridLayout * pageLayout = new QGridLayout(this);
|
|
250 |
pageLayout->setColumnStretch(0, 1);
|
|
251 |
pageLayout->setColumnStretch(1, 2);
|
|
252 |
pageLayout->setColumnStretch(2, 1);
|
|
253 |
|
|
254 |
BtnBack = new QPushButton(this);
|
|
255 |
BtnBack->setFont(*font14);
|
|
256 |
BtnBack->setText(QPushButton::tr("Back"));
|
|
257 |
pageLayout->addWidget(BtnBack, 1, 0);
|
|
258 |
|
|
259 |
BtnPlayDemo = new QPushButton(this);
|
|
260 |
BtnPlayDemo->setGeometry(QRect(240, 330, 161, 41));
|
|
261 |
BtnPlayDemo->setFont(*font14);
|
|
262 |
BtnPlayDemo->setText(QPushButton::tr("Play demo"));
|
|
263 |
pageLayout->addWidget(BtnPlayDemo, 1, 2);
|
|
264 |
|
|
265 |
DemosList = new QListWidget(this);
|
|
266 |
DemosList->setGeometry(QRect(170, 10, 311, 311));
|
|
267 |
pageLayout->addWidget(DemosList, 0, 1);
|
|
268 |
}
|
|
269 |
|
|
270 |
PageOptions::PageOptions(QWidget* parent) : QWidget(parent)
|
|
271 |
{
|
|
272 |
QFont * font14 = new QFont("MS Shell Dlg", 14);
|
|
273 |
groupBox = new QGroupBox(this);
|
|
274 |
groupBox->setGeometry(QRect(20, 10, 591, 71));
|
|
275 |
groupBox->setTitle(QGroupBox::tr("Teams"));
|
|
276 |
|
|
277 |
BtnNewTeam = new QPushButton(groupBox);
|
|
278 |
BtnNewTeam->setGeometry(QRect(10, 20, 160, 40));
|
|
279 |
BtnNewTeam->setFont(*font14);
|
|
280 |
BtnNewTeam->setText(QPushButton::tr("New team"));
|
|
281 |
|
|
282 |
BtnEditTeam = new QPushButton(groupBox);
|
|
283 |
BtnEditTeam->setGeometry(QRect(400, 20, 160, 40));
|
|
284 |
BtnEditTeam->setFont(*font14);
|
|
285 |
BtnEditTeam->setText(QPushButton::tr("Edit team"));
|
|
286 |
|
|
287 |
CBTeamName = new QComboBox(groupBox);
|
|
288 |
CBTeamName->setGeometry(QRect(200, 30, 171, 22));
|
|
289 |
CBResolution = new QComboBox(this);
|
|
290 |
CBResolution->addItem("640x480");
|
|
291 |
CBResolution->addItem("800x600");
|
|
292 |
CBResolution->addItem("1024x768");
|
|
293 |
CBResolution->addItem("1280x1024");
|
|
294 |
CBResolution->setGeometry(QRect(20, 120, 151, 22));
|
|
295 |
|
|
296 |
CBEnableSound = new QCheckBox(this);
|
|
297 |
CBEnableSound->setGeometry(QRect(20, 180, 101, 18));
|
|
298 |
CBEnableSound->setText(QCheckBox::tr("Enable sound"));
|
|
299 |
|
|
300 |
CBFullscreen = new QCheckBox(this);
|
|
301 |
CBFullscreen->setGeometry(QRect(20, 160, 101, 18));
|
|
302 |
CBFullscreen->setText(QCheckBox::tr("Fullscreen"));
|
|
303 |
|
|
304 |
label = new QLabel(this);
|
|
305 |
label->setGeometry(QRect(10, 233, 47, 13));
|
|
306 |
label->setText(QLabel::tr("Net nick"));
|
|
307 |
|
|
308 |
editNetNick = new QLineEdit(this);
|
|
309 |
editNetNick->setGeometry(QRect(60, 230, 113, 20));
|
|
310 |
editNetNick->setMaxLength(30);
|
|
311 |
editNetNick->setText(QLineEdit::tr("unnamed"));
|
|
312 |
|
|
313 |
BtnSaveOptions = new QPushButton(this);
|
|
314 |
BtnSaveOptions->setGeometry(QRect(20, 380, 161, 41));
|
|
315 |
BtnSaveOptions->setFont(*font14);
|
|
316 |
BtnSaveOptions->setText(QPushButton::tr("Save"));
|
|
317 |
|
|
318 |
BtnBack = new QPushButton(this);
|
|
319 |
BtnBack->setGeometry(QRect(440, 380, 161, 41));
|
|
320 |
BtnBack->setFont(*font14);
|
|
321 |
BtnBack->setText(QPushButton::tr("Back"));
|
|
322 |
}
|
|
323 |
|
|
324 |
PageNet::PageNet(QWidget* parent) : QWidget(parent)
|
|
325 |
{
|
|
326 |
QFont * font14 = new QFont("MS Shell Dlg", 14);
|
|
327 |
BtnNetConnect = new QPushButton(this);
|
|
328 |
BtnNetConnect->setGeometry(QRect(250, 140, 161, 41));
|
|
329 |
BtnNetConnect->setFont(*font14);
|
|
330 |
BtnNetConnect->setText(QPushButton::tr("Connect"));
|
|
331 |
BtnBack = new QPushButton(this);
|
|
332 |
BtnBack->setGeometry(QRect(250, 390, 161, 41));
|
|
333 |
BtnBack->setFont(*font14);
|
|
334 |
BtnBack->setText(QPushButton::tr("Back"));
|
|
335 |
}
|
|
336 |
|
|
337 |
PageNetChat::PageNetChat(QWidget* parent) : QWidget(parent)
|
|
338 |
{
|
|
339 |
QFont * font14 = new QFont("MS Shell Dlg", 14);
|
|
340 |
BtnDisconnect = new QPushButton(this);
|
|
341 |
BtnDisconnect->setGeometry(QRect(460, 390, 161, 41));
|
|
342 |
BtnDisconnect->setFont(*font14);
|
|
343 |
BtnDisconnect->setText(QPushButton::tr("Disconnect"));
|
|
344 |
ChannelsList = new QListWidget(this);
|
|
345 |
ChannelsList->setGeometry(QRect(20, 10, 201, 331));
|
|
346 |
BtnJoin = new QPushButton(this);
|
|
347 |
BtnJoin->setGeometry(QRect(460, 290, 161, 41));
|
|
348 |
BtnJoin->setFont(*font14);
|
|
349 |
BtnJoin->setText(QPushButton::tr("Join"));
|
|
350 |
BtnCreate = new QPushButton(this);
|
|
351 |
BtnCreate->setGeometry(QRect(460, 340, 161, 41));
|
|
352 |
BtnCreate->setFont(*font14);
|
|
353 |
BtnCreate->setText(QPushButton::tr("Create"));
|
|
354 |
}
|
|
355 |
|
|
356 |
|
|
357 |
PageNetGame::PageNetGame(QWidget* parent) : QWidget(parent)
|
|
358 |
{
|
|
359 |
QFont * font14 = new QFont("MS Shell Dlg", 14);
|
|
360 |
BtnBack = new QPushButton(this);
|
|
361 |
BtnBack->setGeometry(QRect(260, 390, 161, 41));
|
|
362 |
BtnBack->setFont(*font14);
|
|
363 |
BtnBack->setText(QPushButton::tr("Back"));
|
|
364 |
|
|
365 |
BtnAddTeam = new QPushButton(this);
|
|
366 |
BtnAddTeam->setGeometry(QRect(260, 290, 161, 41));
|
|
367 |
BtnAddTeam->setFont(*font14);
|
|
368 |
BtnAddTeam->setText(QPushButton::tr("Add Team"));
|
|
369 |
|
|
370 |
BtnGo = new QPushButton(this);
|
|
371 |
BtnGo->setGeometry(QRect(260, 340, 161, 41));
|
|
372 |
BtnGo->setFont(*font14);
|
|
373 |
BtnGo->setText(QPushButton::tr("Go!"));
|
|
374 |
|
|
375 |
listNetTeams = new QListWidget(this);
|
|
376 |
listNetTeams->setGeometry(QRect(270, 30, 120, 80));
|
|
377 |
}
|