1 /* |
|
2 * Hedgewars, a free turn based strategy game |
|
3 * Copyright (c) 2006-2011 Andrey Korotaev <unC0Rr@gmail.com> |
|
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> |
|
23 #include <QCheckBox> |
|
24 #include <QLabel> |
|
25 #include <QToolBox> |
|
26 #include <QLineEdit> |
|
27 #include <QListWidget> |
|
28 #include <QApplication> |
|
29 #include <QSpinBox> |
|
30 #include <QTextEdit> |
|
31 #include <QRadioButton> |
|
32 #include <QTableView> |
|
33 #include <QMessageBox> |
|
34 #include <QHeaderView> |
|
35 #include <QTabWidget> |
|
36 #include <QTextBrowser> |
|
37 #include <QTableWidget> |
|
38 #include <QAction> |
|
39 #include <QMenu> |
|
40 #include <QDataWidgetMapper> |
|
41 #include <QTime> |
|
42 #include <QSlider> |
|
43 #include <QFileDialog> |
|
44 |
|
45 #include "ammoSchemeModel.h" |
|
46 #include "pages.h" |
|
47 #include "sdlkeys.h" |
|
48 #include "hwconsts.h" |
|
49 #include "gamecfgwidget.h" |
|
50 #include "teamselect.h" |
|
51 #include "gamecfgwidget.h" |
|
52 #include "SquareLabel.h" |
|
53 #include "mapContainer.h" |
|
54 #include "about.h" |
|
55 #include "fpsedit.h" |
|
56 #include "netserverslist.h" |
|
57 #include "netudpwidget.h" |
|
58 #include "chatwidget.h" |
|
59 #include "playrecordpage.h" |
|
60 #include "selectWeapon.h" |
|
61 #include "igbox.h" |
|
62 #include "hats.h" |
|
63 #include "misc.h" |
|
64 #include "togglebutton.h" |
|
65 #include "hwform.h" |
|
66 #include "SDLs.h" |
|
67 #include "drawmapwidget.h" |
|
68 |
|
69 PageMain::PageMain(QWidget* parent) : |
|
70 AbstractPage(parent) |
|
71 { |
|
72 if(frontendEffects) setAttribute(Qt::WA_NoSystemBackground, true); |
|
73 QGridLayout * pageLayout = new QGridLayout(this); |
|
74 //pageLayout->setColumnStretch(0, 1); |
|
75 //pageLayout->setColumnStretch(1, 2); |
|
76 //pageLayout->setColumnStretch(2, 1); |
|
77 |
|
78 //QPushButton* btnLogo = addButton(":/res/HedgewarsTitle.png", pageLayout, 0, 0, 1, 4, true); |
|
79 //pageLayout->setAlignment(btnLogo, Qt::AlignHCenter); |
|
80 pageLayout->setRowStretch(0, 1); |
|
81 pageLayout->setRowStretch(1, 1); |
|
82 pageLayout->setRowStretch(2, 0); |
|
83 pageLayout->setRowStretch(3, 1); |
|
84 pageLayout->setRowStretch(4, 1); |
|
85 |
|
86 BtnSinglePlayer = addButton(":/res/LocalPlay.png", pageLayout, 2, 0, 1, 2, true); |
|
87 BtnSinglePlayer->setToolTip(tr("Local Game (Play a game on a single computer)")); |
|
88 pageLayout->setAlignment(BtnSinglePlayer, Qt::AlignHCenter); |
|
89 |
|
90 BtnNet = addButton(":/res/NetworkPlay.png", pageLayout, 2, 2, 1, 2, true); |
|
91 BtnNet->setToolTip(tr("Network Game (Play a game across a network)")); |
|
92 pageLayout->setAlignment(BtnNet, Qt::AlignHCenter); |
|
93 |
|
94 mainNote = new QLabel(this); |
|
95 mainNote->setAlignment(Qt::AlignHCenter | Qt::AlignVCenter); |
|
96 mainNote->setWordWrap(true); |
|
97 mainNote->setOpenExternalLinks(true); |
|
98 |
|
99 if(!isDevBuild) |
|
100 { |
|
101 QStringList Tips; |
|
102 Tips << tr("Simply pick the same color as a friend to play together as a team. Each of you will still control his or her own hedgehogs but they'll win or lose together.", "Tips"); |
|
103 Tips << tr("Some weapons might do only low damage but they can be a lot more devastating in the right situation. Try to use the Desert Eagle to knock multiple hedgehogs into the water.", "Tips"); |
|
104 Tips << tr("If you're unsure what to do and don't want to waste ammo, skip one round. But don't let too much time pass as there will be Sudden Death!", "Tips"); |
|
105 Tips << tr("Want to save ropes? Release the rope in mid air and then shoot again. As long as you don't touch the ground you'll reuse your rope without wasting ammo!", "Tips"); |
|
106 Tips << tr("If you'd like to keep others from using your preferred nickname on the official server, register an account at http://www.hedgewars.org/.", "Tips"); |
|
107 Tips << tr("You're bored of default gameplay? Try one of the missions - they'll offer different gameplay depending on the one you picked.", "Tips"); |
|
108 Tips << tr("By default the game will always record the last game played as a demo. Select 'Local Game' and pick the 'Demos' button on the lower right corner to play or manage them.", "Tips"); |
|
109 Tips << tr("Hedgewars is Open Source and Freeware we create in our spare time. If you've got problems, ask on our forums but please don't expect 24/7 support!", "Tips"); |
|
110 Tips << tr("Hedgewars is Open Source and Freeware we create in our spare time. If you like it, help us with a small donation or contribute your own work!", "Tips"); |
|
111 Tips << tr("Hedgewars is Open Source and Freeware we create in our spare time. Share it with your family and friends as you like!", "Tips"); |
|
112 Tips << tr("Hedgewars is Open Source and Freeware we create in our spare time. If someone sold you the game, you should try get a refund!", "Tips"); |
|
113 Tips << tr("From time to time there will be official tournaments. Upcoming events will be announced at http://www.hedgewars.org/ some days in advance.", "Tips"); |
|
114 Tips << tr("Hedgewars is available in many languages. If the translation in your language seems to be missing or outdated, feel free to contact us!", "Tips"); |
|
115 Tips << tr("Hedgewars can be run on lots of different operating systems including Microsoft Windows, Mac OS X and Linux.", "Tips"); |
|
116 Tips << tr("Always remember you're able to set up your own games in local and network/online play. You're not restricted to the 'Simple Game' option.", "Tips"); |
|
117 Tips << tr("Connect one or more gamepads before starting the game to be able to assign their controls to your teams.", "Tips"); |
|
118 Tips << tr("Create an account on %1 to keep others from using your most favourite nickname while playing on the official server.", "Tips").arg("<a href=\"http://www.hedgewars.org/\">http://www.hedgewars.org/</a>"); |
|
119 Tips << tr("While playing you should give yourself a short break at least once an hour.", "Tips"); |
|
120 Tips << tr("If your graphics card isn't able to provide hardware accelerated OpenGL, try to enable the low quality mode to improve performance.", "Tips"); |
|
121 Tips << tr("If your graphics card isn't able to provide hardware accelerated OpenGL, try to update the associated drivers.", "Tips"); |
|
122 Tips << tr("We're open to suggestions and constructive feedback. If you don't like something or got a great idea, let us know!", "Tips"); |
|
123 Tips << tr("Especially while playing online be polite and always remember there might be some minors playing with or against you as well!", "Tips"); |
|
124 Tips << tr("Special game modes such as 'Vampirism' or 'Karma' allow you to develop completely new tactics. Try them in a custom game!", "Tips"); |
|
125 Tips << tr("The Windows version of Hedgewars supports Xfire. Make sure to add Hedgewars to its game list so your friends can see you playing.", "Tips"); |
|
126 Tips << tr("You should never install Hedgewars on computers you don't own (school, university, work, etc.). Please ask the responsible person instead!", "Tips"); |
|
127 Tips << tr("Hedgewars can be perfect for short games during breaks. Just ensure you don't add too many hedgehogs or use an huge map. Reducing time and health might help as well.", "Tips"); |
|
128 Tips << tr("No hedgehogs were harmed in making this game.", "Tips"); |
|
129 Tips << tr("There are three different jumps available. Tap [high jump] twice to do a very high/backwards jump.", "Tips"); |
|
130 Tips << tr("Afraid of falling off a cliff? Hold down [precise] to turn [left] or [right] without actually moving.", "Tips"); |
|
131 Tips << tr("Some weapons require special strategies or just lots of training, so don't give up on a particular tool if you miss an enemy once.", "Tips"); |
|
132 Tips << tr("Most weapons won't work once they touch the water. The Homing Bee as well as the Cake are exceptions to this.", "Tips"); |
|
133 Tips << tr("The Old Limbuger only causes a small explosion. However the wind affected smelly cloud can poison lots of hogs at once.", "Tips"); |
|
134 Tips << tr("The Piano Strike is the most damaging air strike. You'll lose the hedgehog performing it, so there's a huge downside as well.", "Tips"); |
|
135 Tips << tr("The Homing Bee can be tricky to use. Its turn radius depends on it's velocity, so try to not use full power.", "Tips"); |
|
136 Tips << tr("Sticky Mines are a perfect tool to create small chain reactions knocking enemy hedgehogs into dire situations ... or water.", "Tips"); |
|
137 Tips << tr("The Hammer is most effective when used on bridges or girders. Hit hogs will just break through the ground.", "Tips"); |
|
138 Tips << tr("If you're stuck behind an enemy hedgehog, use the Hammer to free yourself without getting damaged by an explosion.", "Tips"); |
|
139 Tips << tr("The Cake's maximum walking distance depends on the ground it has to pass. Use [attack] to detonate it early.", "Tips"); |
|
140 Tips << tr("The Flame Thrower is a weapon but it can be used for tunnel digging as well.", "Tips"); |
|
141 Tips << tr("Use the Molotov or Flame Thrower to temporary keep hedgehogs from passing terrain such as tunnels or platforms.", "Tips"); |
|
142 Tips << tr("Want to know who's behind the game? Click on the Hedgewars logo in the main menu to see the credits.", "Tips"); |
|
143 Tips << tr("Like Hedgewars? Become a fan on %1 or follow us on %2!", "Tips").arg("<a href=\"http://www.facebook.com/Hedgewars\">Facebook</a>").arg("<a href=\"http://twitter.com/hedgewars\">Twitter</a>"); |
|
144 Tips << tr("Feel free to draw your own graves, hats, flags or even maps and themes! But note that you'll have to share them somewhere to use them online.", "Tips"); |
|
145 Tips << tr("Really want to wear a specific hat? Donate to us and receive an exclusive hat of your choice!", "Tips"); |
|
146 // The following tip will require links to app store entries first. |
|
147 //Tips << tr("Want to play Hedgewars any time? Grab the Mobile version for %1 and %2.", "Tips").arg("").arg(""); |
|
148 Tips << tr("Keep your video card drivers up to date to avoid issues playing the game.", "Tips"); |
|
149 //Tips << tr("", "Tips"); |
|
150 #ifndef __APPLE__ |
|
151 Tips << tr("You're able to associate Hedgewars related files (savegames and demo recordings) with the game to launch them right from your favorite file or internet browser.", "Tips"); |
|
152 #endif |
|
153 #ifdef _WIN32 |
|
154 Tips << tr("You can find your Hedgewars configuration files under \"My Documents\\Hedgewars\". Create backups or take the files with you, but don't edit them by hand.", "Tips"); |
|
155 #elif defined __APPLE__ |
|
156 Tips << tr("You can find your Hedgewars configuration files under \"Library/Application Support/Hedgewars\" in your home directory. Create backups or take the files with you, but don't edit them by hand.", "Tips"); |
|
157 #else |
|
158 Tips << tr("You can find your Hedgewars configuration files under \".hedgewars\" in your home directory. Create backups or take the files with you, but don't edit them by hand.", "Tips"); |
|
159 #endif |
|
160 mainNote->setText(QLabel::tr("Tip: ") + Tips[QTime(0, 0, 0).secsTo(QTime::currentTime()) % Tips.length()]); |
|
161 } |
|
162 else |
|
163 mainNote->setText(QLabel::tr("This development build is 'work in progress' and may not be compatible with other versions of the game. Some features might be broken or incomplete. Use at your own risk!")); |
|
164 |
|
165 pageLayout->addWidget(mainNote, 4, 1, 1, 2); |
|
166 |
|
167 BtnSetup = addButton(":/res/Settings.png", pageLayout, 4, 3, true); |
|
168 |
|
169 //BtnInfo = addButton(":/res/About.png", pageLayout, 3, 1, 1, 2, true); |
|
170 BtnInfo = addButton(":/res/HedgewarsTitle.png", pageLayout, 0, 0, 1, 4, true); |
|
171 BtnInfo->setStyleSheet("border: transparent;background: transparent;"); |
|
172 pageLayout->setAlignment(BtnInfo, Qt::AlignHCenter); |
|
173 //pageLayout->setAlignment(BtnInfo, Qt::AlignHCenter); |
|
174 |
|
175 BtnExit = addButton(":/res/Exit.png", pageLayout, 4, 0, 1, 1, true); |
|
176 BtnExit->setFixedHeight(BtnSetup->height()); |
|
177 BtnExit->setStyleSheet("QPushButton{margin-top: 2px;}"); |
|
178 } |
|
179 |
|
180 PageEditTeam::PageEditTeam(QWidget* parent, SDLInteraction * sdli) : |
|
181 AbstractPage(parent) |
|
182 { |
|
183 mySdli = sdli; |
|
184 QGridLayout * pageLayout = new QGridLayout(this); |
|
185 QTabWidget * tbw = new QTabWidget(this); |
|
186 QWidget * page1 = new QWidget(this); |
|
187 QWidget * page2 = new QWidget(this); |
|
188 tbw->addTab(page1, tr("General")); |
|
189 tbw->addTab(page2, tr("Advanced")); |
|
190 pageLayout->addWidget(tbw, 0, 0, 1, 3); |
|
191 BtnTeamDiscard = addButton(":/res/Exit.png", pageLayout, 1, 0, true); |
|
192 BtnTeamSave = addButton(":/res/Save.png", pageLayout, 1, 2, true);; |
|
193 BtnTeamSave->setStyleSheet("QPushButton{margin: 12px 0px 12px 0px;}"); |
|
194 BtnTeamDiscard->setFixedHeight(BtnTeamSave->height()); |
|
195 BtnTeamDiscard->setStyleSheet("QPushButton{margin-top: 31px;}"); |
|
196 |
|
197 QHBoxLayout * page1Layout = new QHBoxLayout(page1); |
|
198 page1Layout->setAlignment(Qt::AlignTop); |
|
199 QGridLayout * page2Layout = new QGridLayout(page2); |
|
200 |
|
201 // ====== Page 1 ====== |
|
202 QVBoxLayout * vbox1 = new QVBoxLayout(); |
|
203 QVBoxLayout * vbox2 = new QVBoxLayout(); |
|
204 page1Layout->addLayout(vbox1); |
|
205 page1Layout->addLayout(vbox2); |
|
206 |
|
207 GBoxHedgehogs = new QGroupBox(this); |
|
208 GBoxHedgehogs->setTitle(QGroupBox::tr("Team Members")); |
|
209 GBoxHedgehogs->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
210 QGridLayout * GBHLayout = new QGridLayout(GBoxHedgehogs); |
|
211 |
|
212 signalMapper = new QSignalMapper(this); |
|
213 |
|
214 HatsModel * hatsModel = new HatsModel(GBoxHedgehogs); |
|
215 for(int i = 0; i < 8; i++) |
|
216 { |
|
217 HHHats[i] = new QComboBox(GBoxHedgehogs); |
|
218 HHHats[i]->setModel(hatsModel); |
|
219 HHHats[i]->setIconSize(QSize(32, 37)); |
|
220 //HHHats[i]->setSizeAdjustPolicy(QComboBox::AdjustToContents); |
|
221 //HHHats[i]->setModelColumn(1); |
|
222 //HHHats[i]->setMinimumWidth(132); |
|
223 GBHLayout->addWidget(HHHats[i], i, 0); |
|
224 |
|
225 HHNameEdit[i] = new QLineEdit(GBoxHedgehogs); |
|
226 HHNameEdit[i]->setMaxLength(64); |
|
227 HHNameEdit[i]->setMinimumWidth(120); |
|
228 GBHLayout->addWidget(HHNameEdit[i], i, 1); |
|
229 |
|
230 randButton[i] = addButton(":/res/dice.png", GBHLayout, i, 3, true); |
|
231 |
|
232 connect(randButton[i], SIGNAL(clicked()), signalMapper, SLOT(map())); |
|
233 signalMapper->setMapping(randButton[i], i); |
|
234 |
|
235 } |
|
236 |
|
237 randTeamButton = addButton(QPushButton::tr("Random Team"), GBHLayout, 9, false); |
|
238 |
|
239 vbox1->addWidget(GBoxHedgehogs); |
|
240 |
|
241 |
|
242 GBoxTeam = new QGroupBox(this); |
|
243 GBoxTeam->setTitle(QGroupBox::tr("Team Settings")); |
|
244 GBoxTeam->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
245 QGridLayout * GBTLayout = new QGridLayout(GBoxTeam); |
|
246 QLabel * tmpLabel = new QLabel(GBoxTeam); |
|
247 tmpLabel->setText(QLabel::tr("Name")); |
|
248 GBTLayout->addWidget(tmpLabel, 0, 0); |
|
249 tmpLabel = new QLabel(GBoxTeam); |
|
250 tmpLabel->setText(QLabel::tr("Type")); |
|
251 GBTLayout->addWidget(tmpLabel, 1, 0); |
|
252 tmpLabel = new QLabel(GBoxTeam); |
|
253 tmpLabel->setText(QLabel::tr("Grave")); |
|
254 GBTLayout->addWidget(tmpLabel, 2, 0); |
|
255 tmpLabel = new QLabel(GBoxTeam); |
|
256 tmpLabel->setText(QLabel::tr("Flag")); |
|
257 GBTLayout->addWidget(tmpLabel, 3, 0); |
|
258 tmpLabel = new QLabel(GBoxTeam); |
|
259 tmpLabel->setText(QLabel::tr("Voice")); |
|
260 GBTLayout->addWidget(tmpLabel, 4, 0); |
|
261 |
|
262 |
|
263 TeamNameEdit = new QLineEdit(GBoxTeam); |
|
264 TeamNameEdit->setMaxLength(64); |
|
265 GBTLayout->addWidget(TeamNameEdit, 0, 1); |
|
266 vbox2->addWidget(GBoxTeam); |
|
267 |
|
268 CBTeamLvl = new QComboBox(GBoxTeam); |
|
269 CBTeamLvl->setIconSize(QSize(48, 48)); |
|
270 CBTeamLvl->addItem(QIcon(":/res/botlevels/0.png"), QComboBox::tr("Human")); |
|
271 for(int i = 5; i > 0; i--) |
|
272 CBTeamLvl->addItem( |
|
273 QIcon(QString(":/res/botlevels/%1.png").arg(6 - i)), |
|
274 QString("%1 %2").arg(QComboBox::tr("Level")).arg(i) |
|
275 ); |
|
276 GBTLayout->addWidget(CBTeamLvl, 1, 1); |
|
277 |
|
278 CBGrave = new QComboBox(GBoxTeam); |
|
279 CBGrave->setMaxCount(65535); |
|
280 CBGrave->setIconSize(QSize(32, 32)); |
|
281 GBTLayout->addWidget(CBGrave, 2, 1); |
|
282 |
|
283 CBFlag = new QComboBox(GBoxTeam); |
|
284 CBFlag->setMaxCount(65535); |
|
285 CBFlag->setIconSize(QSize(22, 15)); |
|
286 GBTLayout->addWidget(CBFlag, 3, 1); |
|
287 |
|
288 { |
|
289 QHBoxLayout * hbox = new QHBoxLayout(); |
|
290 CBVoicepack = new QComboBox(GBoxTeam); |
|
291 { |
|
292 QDir tmpdir; |
|
293 tmpdir.cd(datadir->absolutePath()); |
|
294 tmpdir.cd("Sounds/voices"); |
|
295 QStringList list = tmpdir.entryList(QDir::AllDirs | QDir::NoDotAndDotDot, QDir::Name); |
|
296 CBVoicepack->addItems(list); |
|
297 } |
|
298 hbox->addWidget(CBVoicepack, 100); |
|
299 BtnTestSound = addButton(":/res/PlaySound.png", hbox, 1, true); |
|
300 hbox->setStretchFactor(BtnTestSound, 1); |
|
301 connect(BtnTestSound, SIGNAL(clicked()), this, SLOT(testSound())); |
|
302 GBTLayout->addLayout(hbox, 4, 1); |
|
303 } |
|
304 |
|
305 GBoxFort = new QGroupBox(this); |
|
306 GBoxFort->setTitle(QGroupBox::tr("Fort")); |
|
307 QGridLayout * GBFLayout = new QGridLayout(GBoxFort); |
|
308 CBFort = new QComboBox(GBoxFort); |
|
309 CBFort->setMaxCount(65535); |
|
310 GBFLayout->addWidget(CBFort, 0, 0); |
|
311 FortPreview = new SquareLabel(GBoxFort); |
|
312 FortPreview->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
313 FortPreview->setMinimumSize(128, 128); |
|
314 FortPreview->setPixmap(QPixmap()); |
|
315 // perhaps due to handling its own paintevents, SquareLabel doesn't play nice with the stars |
|
316 //FortPreview->setAttribute(Qt::WA_PaintOnScreen, true); |
|
317 GBFLayout->addWidget(FortPreview, 1, 0); |
|
318 vbox2->addWidget(GBoxFort); |
|
319 |
|
320 QDir tmpdir; |
|
321 tmpdir.cd(datadir->absolutePath()); |
|
322 tmpdir.cd("Forts"); |
|
323 tmpdir.setFilter(QDir::Files); |
|
324 |
|
325 connect(CBFort, SIGNAL(currentIndexChanged(const QString &)), this, SLOT(CBFort_activated(const QString &))); |
|
326 CBFort->addItems(tmpdir.entryList(QStringList("*L.png")).replaceInStrings(QRegExp("^(.*)L\\.png"), "\\1")); |
|
327 |
|
328 tmpdir.cd("../Graphics/Graves"); |
|
329 QStringList list = tmpdir.entryList(QStringList("*.png")); |
|
330 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
|
331 { |
|
332 QPixmap pix(datadir->absolutePath() + "/Graphics/Graves/" + *it); |
|
333 QIcon icon(pix.copy(0, 0, 32, 32)); |
|
334 CBGrave->addItem(icon, (*it).replace(QRegExp("^(.*)\\.png"), "\\1")); |
|
335 } |
|
336 |
|
337 tmpdir.cd(datadir->absolutePath()); |
|
338 tmpdir.cd("Graphics/Flags"); |
|
339 list = tmpdir.entryList(QStringList("*.png")); |
|
340 |
|
341 // add the default flag |
|
342 CBFlag->addItem(QIcon(QPixmap(datadir->absolutePath() + "/Graphics/Flags/hedgewars.png").copy(0, 0, 22, 15)), "Hedgewars", "hedgewars"); |
|
343 |
|
344 CBFlag->insertSeparator(CBFlag->count()); |
|
345 // add all country flags |
|
346 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
|
347 { |
|
348 QPixmap pix(datadir->absolutePath() + "/Graphics/Flags/" + *it); |
|
349 QIcon icon(pix.copy(0, 0, 22, 15)); |
|
350 if(it->compare("cpu.png") && it->compare("hedgewars.png") && (it->indexOf("cm_") == -1)) // skip cpu and hedgewars flags as well as all community flags |
|
351 { |
|
352 QString flag = (*it).replace(QRegExp("^(.*)\\.png"), "\\1"); |
|
353 CBFlag->addItem(icon, QString(flag).replace("_", " "), flag); |
|
354 } |
|
355 } |
|
356 CBFlag->insertSeparator(CBFlag->count()); |
|
357 // add all community flags |
|
358 for (QStringList::Iterator it = list.begin(); it != list.end(); ++it ) |
|
359 { |
|
360 QPixmap pix(datadir->absolutePath() + "/Graphics/Flags/" + *it); |
|
361 QIcon icon(pix.copy(0, 0, 22, 15)); |
|
362 if(it->indexOf("cm_") > -1) // skip non community flags this time |
|
363 { |
|
364 QString flag = (*it).replace(QRegExp("^(.*)\\.png"), "\\1"); |
|
365 CBFlag->addItem(icon, QString(flag).replace("cm_", QComboBox::tr("Community") + ": "), flag); |
|
366 } |
|
367 } |
|
368 |
|
369 vbox1->addStretch(); |
|
370 vbox2->addStretch(); |
|
371 |
|
372 // ====== Page 2 ====== |
|
373 GBoxBinds = new QGroupBox(this); |
|
374 GBoxBinds->setTitle(QGroupBox::tr("Key binds")); |
|
375 QGridLayout * GBBLayout = new QGridLayout(GBoxBinds); |
|
376 BindsBox = new QToolBox(GBoxBinds); |
|
377 BindsBox->setLineWidth(0); |
|
378 GBBLayout->addWidget(BindsBox); |
|
379 page2Layout->addWidget(GBoxBinds, 0, 0); |
|
380 |
|
381 quint16 i = 0; |
|
382 quint16 num = 0; |
|
383 QWidget * curW = NULL; |
|
384 QGridLayout * pagelayout = NULL; |
|
385 QLabel* l = NULL; |
|
386 while (i < BINDS_NUMBER) { |
|
387 if(cbinds[i].category != NULL) |
|
388 { |
|
389 if(curW != NULL) |
|
390 { |
|
391 l = new QLabel(curW); |
|
392 l->setText(""); |
|
393 pagelayout->addWidget(l, num++, 0, 1, 2); |
|
394 } |
|
395 curW = new QWidget(this); |
|
396 BindsBox->addItem(curW, QApplication::translate("binds (categories)", cbinds[i].category)); |
|
397 pagelayout = new QGridLayout(curW); |
|
398 num = 0; |
|
399 } |
|
400 if(cbinds[i].description != NULL) |
|
401 { |
|
402 l = new QLabel(curW); |
|
403 l->setText((num > 0 ? QString("\n") : QString("")) + QApplication::translate("binds (descriptions)", cbinds[i].description)); |
|
404 pagelayout->addWidget(l, num++, 0, 1, 2); |
|
405 } |
|
406 |
|
407 l = new QLabel(curW); |
|
408 l->setText(QApplication::translate("binds", cbinds[i].name)); |
|
409 l->setAlignment(Qt::AlignRight); |
|
410 pagelayout->addWidget(l, num, 0); |
|
411 CBBind[i] = new QComboBox(curW); |
|
412 for(int j = 0; sdlkeys[j][1][0] != '\0'; j++) |
|
413 CBBind[i]->addItem(QApplication::translate("binds (keys)", sdlkeys[j][1]).contains(": ") ? QApplication::translate("binds (keys)", sdlkeys[j][1]) : QApplication::translate("binds (keys)", "Keyboard") + QString(": ") + QApplication::translate("binds (keys)", sdlkeys[j][1]), sdlkeys[j][0]); |
|
414 pagelayout->addWidget(CBBind[i++], num++, 1); |
|
415 } |
|
416 } |
|
417 |
|
418 void PageEditTeam::CBFort_activated(const QString & fortname) |
|
419 { |
|
420 QPixmap pix(datadir->absolutePath() + "/Forts/" + fortname + "L.png"); |
|
421 FortPreview->setPixmap(pix); |
|
422 } |
|
423 |
|
424 void PageEditTeam::testSound() |
|
425 { |
|
426 Mix_Chunk *sound; |
|
427 QDir tmpdir; |
|
428 mySdli->SDLMusicInit(); |
|
429 |
|
430 tmpdir.cd(datadir->absolutePath()); |
|
431 tmpdir.cd("Sounds/voices"); |
|
432 tmpdir.cd(CBVoicepack->currentText()); |
|
433 QStringList list = tmpdir.entryList(QStringList() << "Illgetyou.ogg" << "Incoming.ogg" << "Stupid.ogg" << "Coward.ogg" << "Firstblood.ogg", QDir::Files); |
|
434 if (list.size()) { |
|
435 sound = Mix_LoadWAV(QString(tmpdir.absolutePath() + "/" + list[rand() % list.size()]).toLocal8Bit().constData()); |
|
436 Mix_PlayChannel(-1, sound, 0); |
|
437 } |
|
438 } |
|
439 |
|
440 PageMultiplayer::PageMultiplayer(QWidget* parent) : |
|
441 AbstractPage(parent) |
|
442 { |
|
443 QGridLayout * pageLayout = new QGridLayout(this); |
|
444 |
|
445 BtnBack = addButton(":/res/Exit.png", pageLayout, 3, 0, true); |
|
446 |
|
447 gameCFG = new GameCFGWidget(this); |
|
448 pageLayout->addWidget(gameCFG, 0, 0, 1, 2); |
|
449 |
|
450 QPushButton * btnSetup = new QPushButton(this); |
|
451 btnSetup->setText(QPushButton::tr("Setup")); |
|
452 connect(btnSetup, SIGNAL(clicked()), this, SIGNAL(SetupClicked())); |
|
453 pageLayout->addWidget(btnSetup, 1, 0, 1, 2); |
|
454 |
|
455 pageLayout->setRowStretch(2, 1); |
|
456 |
|
457 teamsSelect = new TeamSelWidget(this); |
|
458 pageLayout->addWidget(teamsSelect, 0, 2, 3, 2); |
|
459 |
|
460 BtnStartMPGame = addButton(tr("Start"), pageLayout, 3, 3); |
|
461 } |
|
462 |
|
463 PageOptions::PageOptions(QWidget* parent) : |
|
464 AbstractPage(parent) |
|
465 { |
|
466 QGridLayout * pageLayout = new QGridLayout(this); |
|
467 pageLayout->setColumnStretch(0, 100); |
|
468 pageLayout->setColumnStretch(1, 100); |
|
469 pageLayout->setColumnStretch(2, 100); |
|
470 pageLayout->setRowStretch(0, 0); |
|
471 //pageLayout->setRowStretch(1, 100); |
|
472 pageLayout->setRowStretch(2, 0); |
|
473 pageLayout->setContentsMargins(7, 7, 7, 0); |
|
474 pageLayout->setSpacing(0); |
|
475 |
|
476 |
|
477 QGroupBox * gbTwoBoxes = new QGroupBox(this); |
|
478 pageLayout->addWidget(gbTwoBoxes, 0, 0, 1, 3); |
|
479 QGridLayout * gbTBLayout = new QGridLayout(gbTwoBoxes); |
|
480 gbTBLayout->setMargin(0); |
|
481 gbTBLayout->setSpacing(0); |
|
482 gbTBLayout->setAlignment(Qt::AlignTop | Qt::AlignLeft); |
|
483 |
|
484 QPixmap pmNew(":/res/new.png"); |
|
485 QPixmap pmEdit(":/res/edit.png"); |
|
486 QPixmap pmDelete(":/res/delete.png"); |
|
487 |
|
488 { |
|
489 teamsBox = new IconedGroupBox(this); |
|
490 //teamsBox->setContentTopPadding(0); |
|
491 //teamsBox->setAttribute(Qt::WA_PaintOnScreen, true); |
|
492 teamsBox->setIcon(QIcon(":/res/teamicon.png")); |
|
493 teamsBox->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
494 teamsBox->setTitle(QGroupBox::tr("Teams")); |
|
495 |
|
496 QGridLayout * GBTlayout = new QGridLayout(teamsBox); |
|
497 |
|
498 CBTeamName = new QComboBox(teamsBox); |
|
499 GBTlayout->addWidget(CBTeamName, 0, 0); |
|
500 |
|
501 BtnNewTeam = new QPushButton(teamsBox); |
|
502 BtnNewTeam->setToolTip(tr("New team")); |
|
503 BtnNewTeam->setIconSize(pmNew.size()); |
|
504 BtnNewTeam->setIcon(pmNew); |
|
505 BtnNewTeam->setMaximumWidth(pmNew.width() + 6); |
|
506 GBTlayout->addWidget(BtnNewTeam, 0, 1); |
|
507 |
|
508 BtnEditTeam = new QPushButton(teamsBox); |
|
509 BtnEditTeam->setToolTip(tr("Edit team")); |
|
510 BtnEditTeam->setIconSize(pmEdit.size()); |
|
511 BtnEditTeam->setIcon(pmEdit); |
|
512 BtnEditTeam->setMaximumWidth(pmEdit.width() + 6); |
|
513 GBTlayout->addWidget(BtnEditTeam, 0, 2); |
|
514 |
|
515 BtnDeleteTeam = new QPushButton(teamsBox); |
|
516 BtnDeleteTeam->setToolTip(tr("Delete team")); |
|
517 BtnDeleteTeam->setIconSize(pmDelete.size()); |
|
518 BtnDeleteTeam->setIcon(pmDelete); |
|
519 BtnDeleteTeam->setMaximumWidth(pmDelete.width() + 6); |
|
520 GBTlayout->addWidget(BtnDeleteTeam, 0, 3); |
|
521 |
|
522 LblNoEditTeam = new QLabel(teamsBox); |
|
523 LblNoEditTeam->setText(tr("You can't edit teams from team selection. Go back to main menu to add, edit or delete teams.")); |
|
524 LblNoEditTeam->setWordWrap(true); |
|
525 LblNoEditTeam->setVisible(false); |
|
526 GBTlayout->addWidget(LblNoEditTeam, 0, 0); |
|
527 |
|
528 gbTBLayout->addWidget(teamsBox, 0, 0); |
|
529 } |
|
530 |
|
531 { |
|
532 IconedGroupBox* groupWeapons = new IconedGroupBox(this); |
|
533 |
|
534 //groupWeapons->setContentTopPadding(0); |
|
535 //groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
536 groupWeapons->setIcon(QIcon(":/res/weaponsicon.png")); |
|
537 groupWeapons->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
538 groupWeapons->setTitle(QGroupBox::tr("Schemes and Weapons")); |
|
539 QGridLayout * WeaponsLayout = new QGridLayout(groupWeapons); |
|
540 |
|
541 QLabel* SchemeLabel = new QLabel(groupWeapons); |
|
542 SchemeLabel->setText(QLabel::tr("Game scheme")); |
|
543 WeaponsLayout->addWidget(SchemeLabel, 1, 0); |
|
544 |
|
545 SchemesName = new QComboBox(groupWeapons); |
|
546 WeaponsLayout->addWidget(SchemesName, 1, 1); |
|
547 |
|
548 SchemeNew = new QPushButton(groupWeapons); |
|
549 SchemeNew->setToolTip(tr("New scheme")); |
|
550 SchemeNew->setIconSize(pmNew.size()); |
|
551 SchemeNew->setIcon(pmNew); |
|
552 SchemeNew->setMaximumWidth(pmNew.width() + 6); |
|
553 WeaponsLayout->addWidget(SchemeNew, 1, 2); |
|
554 |
|
555 SchemeEdit = new QPushButton(groupWeapons); |
|
556 SchemeEdit->setToolTip(tr("Edit scheme")); |
|
557 SchemeEdit->setIconSize(pmEdit.size()); |
|
558 SchemeEdit->setIcon(pmEdit); |
|
559 SchemeEdit->setMaximumWidth(pmEdit.width() + 6); |
|
560 WeaponsLayout->addWidget(SchemeEdit, 1, 3); |
|
561 |
|
562 SchemeDelete = new QPushButton(groupWeapons); |
|
563 SchemeDelete->setToolTip(tr("Delete scheme")); |
|
564 SchemeDelete->setIconSize(pmDelete.size()); |
|
565 SchemeDelete->setIcon(pmDelete); |
|
566 SchemeDelete->setMaximumWidth(pmDelete.width() + 6); |
|
567 WeaponsLayout->addWidget(SchemeDelete, 1, 4); |
|
568 |
|
569 QLabel* WeaponLabel = new QLabel(groupWeapons); |
|
570 WeaponLabel->setText(QLabel::tr("Weapons")); |
|
571 WeaponsLayout->addWidget(WeaponLabel, 2, 0); |
|
572 |
|
573 WeaponsName = new QComboBox(groupWeapons); |
|
574 WeaponsLayout->addWidget(WeaponsName, 2, 1); |
|
575 |
|
576 WeaponNew = new QPushButton(groupWeapons); |
|
577 WeaponNew->setToolTip(tr("New weapon set")); |
|
578 WeaponNew->setIconSize(pmNew.size()); |
|
579 WeaponNew->setIcon(pmNew); |
|
580 WeaponNew->setMaximumWidth(pmNew.width() + 6); |
|
581 WeaponsLayout->addWidget(WeaponNew, 2, 2); |
|
582 |
|
583 WeaponEdit = new QPushButton(groupWeapons); |
|
584 WeaponEdit->setToolTip(tr("Edit weapon set")); |
|
585 WeaponEdit->setIconSize(pmEdit.size()); |
|
586 WeaponEdit->setIcon(pmEdit); |
|
587 WeaponEdit->setMaximumWidth(pmEdit.width() + 6); |
|
588 WeaponsLayout->addWidget(WeaponEdit, 2, 3); |
|
589 |
|
590 WeaponDelete = new QPushButton(groupWeapons); |
|
591 WeaponDelete->setToolTip(tr("Delete weapon set")); |
|
592 WeaponDelete->setIconSize(pmDelete.size()); |
|
593 WeaponDelete->setIcon(pmDelete); |
|
594 WeaponDelete->setMaximumWidth(pmDelete.width() + 6); |
|
595 WeaponsLayout->addWidget(WeaponDelete, 2, 4); |
|
596 |
|
597 WeaponTooltip = new QCheckBox(this); |
|
598 WeaponTooltip->setText(QCheckBox::tr("Show ammo menu tooltips")); |
|
599 WeaponsLayout->addWidget(WeaponTooltip, 3, 0, 1, 4); |
|
600 |
|
601 gbTBLayout->addWidget(groupWeapons, 1, 0); |
|
602 } |
|
603 |
|
604 { |
|
605 IconedGroupBox* groupMisc = new IconedGroupBox(this); |
|
606 //groupMisc->setContentTopPadding(0); |
|
607 groupMisc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Expanding); |
|
608 groupMisc->setIcon(QIcon(":/res/miscicon.png")); |
|
609 //groupMisc->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
610 groupMisc->setTitle(QGroupBox::tr("Misc")); |
|
611 QGridLayout * MiscLayout = new QGridLayout(groupMisc); |
|
612 |
|
613 labelNN = new QLabel(groupMisc); |
|
614 labelNN->setText(QLabel::tr("Net nick")); |
|
615 MiscLayout->addWidget(labelNN, 0, 0); |
|
616 |
|
617 editNetNick = new QLineEdit(groupMisc); |
|
618 editNetNick->setMaxLength(20); |
|
619 editNetNick->setText(QLineEdit::tr("unnamed")); |
|
620 connect(editNetNick, SIGNAL(editingFinished()), this, SLOT(trimNetNick())); |
|
621 MiscLayout->addWidget(editNetNick, 0, 1); |
|
622 |
|
623 QLabel *labelLanguage = new QLabel(groupMisc); |
|
624 labelLanguage->setText(QLabel::tr("Locale") + " *"); |
|
625 MiscLayout->addWidget(labelLanguage, 1, 0); |
|
626 |
|
627 CBLanguage = new QComboBox(groupMisc); |
|
628 QDir tmpdir; |
|
629 tmpdir.cd(datadir->absolutePath()); |
|
630 tmpdir.cd("Locale"); |
|
631 tmpdir.setFilter(QDir::Files); |
|
632 QStringList locs = tmpdir.entryList(QStringList("hedgewars_*.qm")); |
|
633 CBLanguage->addItem(QComboBox::tr("(System default)"), QString("")); |
|
634 for(int i = 0; i < locs.count(); i++) |
|
635 { |
|
636 QLocale loc(locs[i].replace(QRegExp("hedgewars_(.*)\\.qm"), "\\1")); |
|
637 CBLanguage->addItem(QLocale::languageToString(loc.language()) + " (" + QLocale::countryToString(loc.country()) + ")", loc.name()); |
|
638 } |
|
639 |
|
640 MiscLayout->addWidget(CBLanguage, 1, 1); |
|
641 |
|
642 CBAltDamage = new QCheckBox(groupMisc); |
|
643 CBAltDamage->setText(QCheckBox::tr("Alternative damage show")); |
|
644 MiscLayout->addWidget(CBAltDamage, 2, 0, 1, 2); |
|
645 |
|
646 CBNameWithDate = new QCheckBox(groupMisc); |
|
647 CBNameWithDate->setText(QCheckBox::tr("Append date and time to record file name")); |
|
648 MiscLayout->addWidget(CBNameWithDate, 3, 0, 1, 2); |
|
649 |
|
650 #ifdef SPARKLE_ENABLED |
|
651 CBAutoUpdate = new QCheckBox(groupMisc); |
|
652 CBAutoUpdate->setText(QCheckBox::tr("Check for updates at startup")); |
|
653 MiscLayout->addWidget(CBAutoUpdate, 4, 0, 1, 2); |
|
654 #endif |
|
655 #ifndef __APPLE__ |
|
656 BtnAssociateFiles = new QPushButton(groupMisc); |
|
657 BtnAssociateFiles->setText(QPushButton::tr("Associate file extensions")); |
|
658 BtnAssociateFiles->setEnabled(!custom_data && !custom_config); |
|
659 MiscLayout->addWidget(BtnAssociateFiles, 4, 0, 1, 2); |
|
660 #endif |
|
661 gbTBLayout->addWidget(groupMisc, 2, 0); |
|
662 } |
|
663 |
|
664 { |
|
665 AGGroupBox = new IconedGroupBox(this); |
|
666 //AGGroupBox->setContentTopPadding(0); |
|
667 AGGroupBox->setIcon(QIcon(":/res/graphicsicon.png")); |
|
668 //AGGroupBox->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); |
|
669 AGGroupBox->setTitle(QGroupBox::tr("Audio/Graphic options")); |
|
670 |
|
671 QVBoxLayout * GBAlayout = new QVBoxLayout(AGGroupBox); |
|
672 QHBoxLayout * GBAreslayout = new QHBoxLayout(0); |
|
673 QHBoxLayout * GBAstereolayout = new QHBoxLayout(0); |
|
674 QHBoxLayout * GBAqualayout = new QHBoxLayout(0); |
|
675 |
|
676 CBFrontendFullscreen = new QCheckBox(AGGroupBox); |
|
677 CBFrontendFullscreen->setText(QCheckBox::tr("Frontend fullscreen")); |
|
678 GBAlayout->addWidget(CBFrontendFullscreen); |
|
679 |
|
680 CBFrontendEffects = new QCheckBox(AGGroupBox); |
|
681 CBFrontendEffects->setText(QCheckBox::tr("Frontend effects") + " *"); |
|
682 GBAlayout->addWidget(CBFrontendEffects); |
|
683 |
|
684 CBEnableFrontendSound = new QCheckBox(AGGroupBox); |
|
685 CBEnableFrontendSound->setText(QCheckBox::tr("Enable frontend sounds")); |
|
686 GBAlayout->addWidget(CBEnableFrontendSound); |
|
687 |
|
688 CBEnableFrontendMusic = new QCheckBox(AGGroupBox); |
|
689 CBEnableFrontendMusic->setText(QCheckBox::tr("Enable frontend music")); |
|
690 GBAlayout->addWidget(CBEnableFrontendMusic); |
|
691 |
|
692 QFrame * hr = new QFrame(AGGroupBox); |
|
693 hr->setFrameStyle(QFrame::HLine); |
|
694 hr->setLineWidth(3); |
|
695 hr->setFixedHeight(10); |
|
696 GBAlayout->addWidget(hr); |
|
697 |
|
698 QLabel * resolution = new QLabel(AGGroupBox); |
|
699 resolution->setText(QLabel::tr("Resolution")); |
|
700 GBAreslayout->addWidget(resolution); |
|
701 |
|
702 CBResolution = new QComboBox(AGGroupBox); |
|
703 GBAreslayout->addWidget(CBResolution); |
|
704 GBAlayout->addLayout(GBAreslayout); |
|
705 |
|
706 CBFullscreen = new QCheckBox(AGGroupBox); |
|
707 CBFullscreen->setText(QCheckBox::tr("Fullscreen")); |
|
708 GBAlayout->addWidget(CBFullscreen); |
|
709 connect(CBFullscreen, SIGNAL(stateChanged(int)), this, SLOT(setFullscreen(void))); |
|
710 |
|
711 QLabel * quality = new QLabel(AGGroupBox); |
|
712 quality->setText(QLabel::tr("Quality")); |
|
713 quality->setSizePolicy(QSizePolicy::Expanding, QSizePolicy::Fixed); |
|
714 GBAqualayout->addWidget(quality); |
|
715 |
|
716 SLQuality = new QSlider(Qt::Horizontal, AGGroupBox); |
|
717 SLQuality->setTickPosition(QSlider::TicksBelow); |
|
718 SLQuality->setMaximum(5); |
|
719 SLQuality->setMinimum(0); |
|
720 SLQuality->setFixedWidth(150); |
|
721 GBAqualayout->addWidget(SLQuality); |
|
722 GBAlayout->addLayout(GBAqualayout); |
|
723 QLabel * stereo = new QLabel(AGGroupBox); |
|
724 stereo->setText(QLabel::tr("Stereo rendering")); |
|
725 GBAstereolayout->addWidget(stereo); |
|
726 |
|
727 CBStereoMode = new QComboBox(AGGroupBox); |
|
728 CBStereoMode->addItem(QComboBox::tr("Disabled")); |
|
729 CBStereoMode->addItem(QComboBox::tr("Red/Cyan")); |
|
730 CBStereoMode->addItem(QComboBox::tr("Cyan/Red")); |
|
731 CBStereoMode->addItem(QComboBox::tr("Red/Blue")); |
|
732 CBStereoMode->addItem(QComboBox::tr("Blue/Red")); |
|
733 CBStereoMode->addItem(QComboBox::tr("Red/Green")); |
|
734 CBStereoMode->addItem(QComboBox::tr("Green/Red")); |
|
735 CBStereoMode->addItem(QComboBox::tr("Side-by-side")); |
|
736 CBStereoMode->addItem(QComboBox::tr("Top-Bottom")); |
|
737 CBStereoMode->addItem(QComboBox::tr("Wiggle")); |
|
738 connect(CBStereoMode, SIGNAL(currentIndexChanged(int)), this, SLOT(forceFullscreen(int))); |
|
739 |
|
740 GBAstereolayout->addWidget(CBStereoMode); |
|
741 GBAlayout->addLayout(GBAstereolayout); |
|
742 |
|
743 hr = new QFrame(AGGroupBox); |
|
744 hr->setFrameStyle(QFrame::HLine); |
|
745 hr->setLineWidth(3); |
|
746 hr->setFixedHeight(10); |
|
747 GBAlayout->addWidget(hr); |
|
748 |
|
749 QHBoxLayout * GBAvollayout = new QHBoxLayout(0); |
|
750 QLabel * vol = new QLabel(AGGroupBox); |
|
751 vol->setText(QLabel::tr("Initial sound volume")); |
|
752 GBAvollayout->addWidget(vol); |
|
753 GBAlayout->addLayout(GBAvollayout); |
|
754 volumeBox = new QSpinBox(AGGroupBox); |
|
755 volumeBox->setRange(0, 100); |
|
756 volumeBox->setSingleStep(5); |
|
757 GBAvollayout->addWidget(volumeBox); |
|
758 |
|
759 CBEnableSound = new QCheckBox(AGGroupBox); |
|
760 CBEnableSound->setText(QCheckBox::tr("Enable sound")); |
|
761 GBAlayout->addWidget(CBEnableSound); |
|
762 |
|
763 CBEnableMusic = new QCheckBox(AGGroupBox); |
|
764 CBEnableMusic->setText(QCheckBox::tr("Enable music")); |
|
765 GBAlayout->addWidget(CBEnableMusic); |
|
766 |
|
767 hr = new QFrame(AGGroupBox); |
|
768 hr->setFrameStyle(QFrame::HLine); |
|
769 hr->setLineWidth(3); |
|
770 hr->setFixedHeight(10); |
|
771 GBAlayout->addWidget(hr); |
|
772 |
|
773 QHBoxLayout * GBAfpslayout = new QHBoxLayout(0); |
|
774 QLabel * maxfps = new QLabel(AGGroupBox); |
|
775 maxfps->setText(QLabel::tr("FPS limit")); |
|
776 GBAfpslayout->addWidget(maxfps); |
|
777 GBAlayout->addLayout(GBAfpslayout); |
|
778 fpsedit = new FPSEdit(AGGroupBox); |
|
779 GBAfpslayout->addWidget(fpsedit); |
|
780 |
|
781 CBShowFPS = new QCheckBox(AGGroupBox); |
|
782 CBShowFPS->setText(QCheckBox::tr("Show FPS")); |
|
783 GBAlayout->addWidget(CBShowFPS); |
|
784 |
|
785 hr = new QFrame(AGGroupBox); |
|
786 hr->setFrameStyle(QFrame::HLine); |
|
787 hr->setLineWidth(3); |
|
788 hr->setFixedHeight(10); |
|
789 GBAlayout->addWidget(hr); |
|
790 |
|
791 QLabel *restartNote = new QLabel(this); |
|
792 restartNote->setText(QString("* ") + QLabel::tr("Restart game to apply")); |
|
793 restartNote->setSizePolicy(QSizePolicy::MinimumExpanding, QSizePolicy::Fixed); |
|
794 GBAlayout->addWidget(restartNote); |
|
795 |
|
796 gbTBLayout->addWidget(AGGroupBox, 0, 1, 3, 1); |
|
797 } |
|
798 |
|
799 BtnSaveOptions = addButton(":/res/Save.png", pageLayout, 2, 2, true); |
|
800 BtnSaveOptions->setStyleSheet("QPushButton{margin: 12px 0px 12px 0px;}"); |
|
801 |
|
802 BtnBack = addButton(":/res/Exit.png", pageLayout, 2, 0, true); |
|
803 BtnBack->setFixedHeight(BtnSaveOptions->height()); |
|
804 BtnBack->setFixedWidth(BtnBack->width()+2); |
|
805 BtnBack->setStyleSheet("QPushButton{margin: 22px 0 9px 2px;}"); |
|
806 } |
|
807 |
|
808 void PageOptions::forceFullscreen(int index) |
|
809 { |
|
810 if (index != 0) { |
|
811 previousFullscreenValue = this->CBFullscreen->isChecked(); |
|
812 this->CBFullscreen->setChecked(true); |
|
813 this->CBFullscreen->setEnabled(false); |
|
814 previousQuality = this->SLQuality->value(); |
|
815 this->SLQuality->setValue(this->SLQuality->maximum()); |
|
816 this->SLQuality->setEnabled(false); |
|
817 } else { |
|
818 this->CBFullscreen->setChecked(previousFullscreenValue); |
|
819 this->CBFullscreen->setEnabled(true); |
|
820 this->SLQuality->setValue(previousQuality); |
|
821 this->SLQuality->setEnabled(true); |
|
822 } |
|
823 } |
|
824 |
|
825 void PageOptions::setFullscreen(void) |
|
826 { |
|
827 int tmp = this->CBResolution->currentIndex(); |
|
828 if (this->CBFullscreen->isChecked()) |
|
829 this->CBResolution->setCurrentIndex(0); |
|
830 else |
|
831 this->CBResolution->setCurrentIndex(previousResolutionIndex); |
|
832 previousResolutionIndex = tmp; |
|
833 this->CBResolution->setEnabled(!this->CBFullscreen->isChecked()); |
|
834 } |
|
835 |
|
836 void PageOptions::trimNetNick() |
|
837 { |
|
838 editNetNick->setText(editNetNick->text().trimmed()); |
|
839 } |
|
840 |
|
841 PageNet::PageNet(QWidget* parent) : AbstractPage(parent) |
|
842 { |
|
843 QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
844 QGridLayout * pageLayout = new QGridLayout(this); |
|
845 pageLayout->setColumnStretch(0, 1); |
|
846 pageLayout->setColumnStretch(1, 1); |
|
847 pageLayout->setColumnStretch(2, 1); |
|
848 |
|
849 BtnNetSvrStart = new QPushButton(this); |
|
850 BtnNetSvrStart->setFont(*font14); |
|
851 BtnNetSvrStart->setText(QPushButton::tr("Start server")); |
|
852 BtnNetSvrStart->setVisible(haveServer); |
|
853 pageLayout->addWidget(BtnNetSvrStart, 4, 2); |
|
854 |
|
855 BtnBack = addButton(":/res/Exit.png", pageLayout, 4, 0, true); |
|
856 |
|
857 ConnGroupBox = new QGroupBox(this); |
|
858 ConnGroupBox->setTitle(QGroupBox::tr("Net game")); |
|
859 pageLayout->addWidget(ConnGroupBox, 2, 0, 1, 3); |
|
860 GBClayout = new QGridLayout(ConnGroupBox); |
|
861 GBClayout->setColumnStretch(0, 1); |
|
862 GBClayout->setColumnStretch(1, 1); |
|
863 GBClayout->setColumnStretch(2, 1); |
|
864 |
|
865 BtnNetConnect = new QPushButton(ConnGroupBox); |
|
866 BtnNetConnect->setFont(*font14); |
|
867 BtnNetConnect->setText(QPushButton::tr("Connect")); |
|
868 GBClayout->addWidget(BtnNetConnect, 2, 2); |
|
869 |
|
870 tvServersList = new QTableView(ConnGroupBox); |
|
871 tvServersList->setSelectionBehavior(QAbstractItemView::SelectRows); |
|
872 GBClayout->addWidget(tvServersList, 1, 0, 1, 3); |
|
873 |
|
874 BtnUpdateSList = new QPushButton(ConnGroupBox); |
|
875 BtnUpdateSList->setFont(*font14); |
|
876 BtnUpdateSList->setText(QPushButton::tr("Update")); |
|
877 GBClayout->addWidget(BtnUpdateSList, 2, 0); |
|
878 |
|
879 BtnSpecifyServer = new QPushButton(ConnGroupBox); |
|
880 BtnSpecifyServer->setFont(*font14); |
|
881 BtnSpecifyServer->setText(QPushButton::tr("Specify")); |
|
882 GBClayout->addWidget(BtnSpecifyServer, 2, 1); |
|
883 |
|
884 connect(BtnNetConnect, SIGNAL(clicked()), this, SLOT(slotConnect())); |
|
885 } |
|
886 |
|
887 void PageNet::updateServersList() |
|
888 { |
|
889 tvServersList->setModel(new HWNetUdpModel(tvServersList)); |
|
890 |
|
891 tvServersList->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); |
|
892 |
|
893 static_cast<HWNetServersModel *>(tvServersList->model())->updateList(); |
|
894 |
|
895 connect(BtnUpdateSList, SIGNAL(clicked()), static_cast<HWNetServersModel *>(tvServersList->model()), SLOT(updateList())); |
|
896 connect(tvServersList, SIGNAL(doubleClicked(const QModelIndex &)), this, SLOT(slotConnect())); |
|
897 } |
|
898 |
|
899 void PageNet::slotConnect() |
|
900 { |
|
901 HWNetServersModel * model = static_cast<HWNetServersModel *>(tvServersList->model()); |
|
902 QModelIndex mi = tvServersList->currentIndex(); |
|
903 if(!mi.isValid()) |
|
904 { |
|
905 QMessageBox::information(this, tr("Error"), tr("Please select server from the list above")); |
|
906 return; |
|
907 } |
|
908 QString host = model->index(mi.row(), 1).data().toString(); |
|
909 quint16 port = model->index(mi.row(), 2).data().toUInt(); |
|
910 |
|
911 emit connectClicked(host, port); |
|
912 } |
|
913 |
|
914 PageNetServer::PageNetServer(QWidget* parent) : AbstractPage(parent) |
|
915 { |
|
916 QFont * font14 = new QFont("MS Shell Dlg", 14); |
|
917 QGridLayout * pageLayout = new QGridLayout(this); |
|
918 pageLayout->setColumnStretch(0, 1); |
|
919 pageLayout->setColumnStretch(1, 1); |
|
920 pageLayout->setColumnStretch(2, 1); |
|
921 |
|
922 pageLayout->setRowStretch(0, 1); |
|
923 pageLayout->setRowStretch(1, 0); |
|
924 |
|
925 BtnBack =addButton(":/res/Exit.png", pageLayout, 1, 0, true); |
|
926 |
|
927 BtnStart = new QPushButton(this); |
|
928 BtnStart->setFont(*font14); |
|
929 BtnStart->setText(QPushButton::tr("Start")); |
|
930 pageLayout->addWidget(BtnStart, 1, 2); |
|
931 |
|
932 QWidget * wg = new QWidget(this); |
|
933 pageLayout->addWidget(wg, 0, 0, 1, 3); |
|
934 |
|
935 QGridLayout * wgLayout = new QGridLayout(wg); |
|
936 wgLayout->setColumnStretch(0, 1); |
|
937 wgLayout->setColumnStretch(1, 3); |
|
938 wgLayout->setColumnStretch(2, 1); |
|
939 |
|
940 wgLayout->setRowStretch(0, 0); |
|
941 wgLayout->setRowStretch(1, 1); |
|
942 |
|
943 QGroupBox * gb = new QGroupBox(wg); |
|
944 wgLayout->addWidget(gb, 0, 1); |
|
945 |
|
946 QGridLayout * gbLayout = new QGridLayout(gb); |
|
947 |
|
948 labelSD = new QLabel(gb); |
|
949 labelSD->setText(QLabel::tr("Server name:")); |
|
950 gbLayout->addWidget(labelSD, 0, 0); |
|
951 |
|
952 leServerDescr = new QLineEdit(gb); |
|
953 gbLayout->addWidget(leServerDescr, 0, 1); |
|
954 |
|
955 labelPort = new QLabel(gb); |
|
956 labelPort->setText(QLabel::tr("Server port:")); |
|
957 gbLayout->addWidget(labelPort, 1, 0); |
|
958 |
|
959 sbPort = new QSpinBox(gb); |
|
960 sbPort->setMinimum(0); |
|
961 sbPort->setMaximum(65535); |
|
962 gbLayout->addWidget(sbPort, 1, 1); |
|
963 |
|
964 BtnDefault = new QPushButton(gb); |
|
965 BtnDefault->setText(QPushButton::tr("default")); |
|
966 gbLayout->addWidget(BtnDefault, 1, 2); |
|
967 |
|
968 connect(BtnDefault, SIGNAL(clicked()), this, SLOT(setDefaultPort())); |
|
969 } |
|
970 |
|
971 void PageNetServer::setDefaultPort() |
|
972 { |
|
973 sbPort->setValue(46631); |
|
974 } |
|
975 |
|
976 PageNetGame::PageNetGame(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli) : AbstractPage(parent) |
|
977 { |
|
978 QGridLayout * pageLayout = new QGridLayout(this); |
|
979 pageLayout->setSizeConstraint(QLayout::SetMinimumSize); |
|
980 //pageLayout->setSpacing(1); |
|
981 pageLayout->setColumnStretch(0, 50); |
|
982 pageLayout->setColumnStretch(1, 50); |
|
983 |
|
984 // chatwidget |
|
985 pChatWidget = new HWChatWidget(this, gameSettings, sdli, true); |
|
986 pChatWidget->setShowReady(true); // show status bulbs by default |
|
987 pChatWidget->setShowFollow(false); // don't show follow in nicks' context menus |
|
988 pageLayout->addWidget(pChatWidget, 2, 0, 1, 2); |
|
989 pageLayout->setRowStretch(1, 100); |
|
990 |
|
991 pGameCFG = new GameCFGWidget(this); |
|
992 pageLayout->addWidget(pGameCFG, 0, 0); |
|
993 |
|
994 QPushButton * btnSetup = new QPushButton(this); |
|
995 btnSetup->setText(QPushButton::tr("Setup")); |
|
996 connect(btnSetup, SIGNAL(clicked()), this, SIGNAL(SetupClicked())); |
|
997 pageLayout->addWidget(btnSetup, 1, 0); |
|
998 |
|
999 pNetTeamsWidget = new TeamSelWidget(this); |
|
1000 pNetTeamsWidget->setAcceptOuter(true); |
|
1001 pageLayout->addWidget(pNetTeamsWidget, 0, 1, 2, 1); |
|
1002 |
|
1003 |
|
1004 QHBoxLayout * bottomLayout = new QHBoxLayout; |
|
1005 pageLayout->addLayout(bottomLayout, 4, 0, 1, 2); |
|
1006 |
|
1007 BtnBack = addButton(":/res/Exit.png", bottomLayout, 0, true); |
|
1008 |
|
1009 BtnGo = new QPushButton(this); |
|
1010 BtnGo->setToolTip(QPushButton::tr("Ready")); |
|
1011 BtnGo->setIcon(QIcon(":/res/lightbulb_off.png")); |
|
1012 BtnGo->setIconSize(QSize(25, 34)); |
|
1013 BtnGo->setMinimumWidth(50); |
|
1014 BtnGo->setMinimumHeight(50); |
|
1015 bottomLayout->addWidget(BtnGo, 4); |
|
1016 |
|
1017 |
|
1018 BtnMaster = addButton(tr("Control"), bottomLayout, 2); |
|
1019 QMenu * menu = new QMenu(BtnMaster); |
|
1020 restrictJoins = new QAction(QAction::tr("Restrict Joins"), menu); |
|
1021 restrictJoins->setCheckable(true); |
|
1022 restrictTeamAdds = new QAction(QAction::tr("Restrict Team Additions"), menu); |
|
1023 restrictTeamAdds->setCheckable(true); |
|
1024 //menu->addAction(startGame); |
|
1025 menu->addAction(restrictJoins); |
|
1026 menu->addAction(restrictTeamAdds); |
|
1027 |
|
1028 BtnMaster->setMenu(menu); |
|
1029 |
|
1030 BtnStart = addButton(QAction::tr("Start"), bottomLayout, 3); |
|
1031 |
|
1032 bottomLayout->insertStretch(1, 100); |
|
1033 } |
|
1034 |
|
1035 void PageNetGame::setReadyStatus(bool isReady) |
|
1036 { |
|
1037 if(isReady) |
|
1038 BtnGo->setIcon(QIcon(":/res/lightbulb_on.png")); |
|
1039 else |
|
1040 BtnGo->setIcon(QIcon(":/res/lightbulb_off.png")); |
|
1041 } |
|
1042 |
|
1043 void PageNetGame::setMasterMode(bool isMaster) |
|
1044 { |
|
1045 BtnMaster->setVisible(isMaster); |
|
1046 BtnStart->setVisible(isMaster); |
|
1047 } |
|
1048 |
|
1049 PageInfo::PageInfo(QWidget* parent) : AbstractPage(parent) |
|
1050 { |
|
1051 QGridLayout * pageLayout = new QGridLayout(this); |
|
1052 pageLayout->setColumnStretch(0, 1); |
|
1053 pageLayout->setColumnStretch(1, 1); |
|
1054 pageLayout->setColumnStretch(2, 1); |
|
1055 |
|
1056 BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, true); |
|
1057 |
|
1058 about = new About(this); |
|
1059 pageLayout->addWidget(about, 0, 0, 1, 3); |
|
1060 } |
|
1061 |
|
1062 PageSinglePlayer::PageSinglePlayer(QWidget* parent) : AbstractPage(parent) |
|
1063 { |
|
1064 QVBoxLayout * vLayout = new QVBoxLayout(this); |
|
1065 QHBoxLayout * topLine = new QHBoxLayout(); |
|
1066 QHBoxLayout * middleLine = new QHBoxLayout(); |
|
1067 QHBoxLayout * bottomLine = new QHBoxLayout(); |
|
1068 vLayout->addStretch(); |
|
1069 vLayout->addLayout(topLine); |
|
1070 vLayout->addSpacing(30); |
|
1071 vLayout->addLayout(middleLine); |
|
1072 vLayout->addStretch(); |
|
1073 vLayout->addLayout(bottomLine); |
|
1074 |
|
1075 topLine->addStretch(); |
|
1076 BtnSimpleGamePage = addButton(":/res/SimpleGame.png", topLine, 0, true); |
|
1077 BtnSimpleGamePage->setToolTip(tr("Simple Game (a quick game against the computer, settings are chosen for you)")); |
|
1078 topLine->addSpacing(60); |
|
1079 BtnMultiplayer = addButton(":/res/Multiplayer.png", topLine, 1, true); |
|
1080 BtnMultiplayer->setToolTip(tr("Multiplayer (play a hotseat game against your friends, or AI teams)")); |
|
1081 topLine->addStretch(); |
|
1082 |
|
1083 |
|
1084 BtnCampaignPage = addButton(":/res/Campaign.png", middleLine, 0, true); |
|
1085 BtnCampaignPage->setToolTip(tr("Campaign Mode (...). IN DEVELOPMENT")); |
|
1086 //BtnCampaignPage->setVisible(false); |
|
1087 |
|
1088 BtnTrainPage = addButton(":/res/Trainings.png", middleLine, 1, true); |
|
1089 BtnTrainPage->setToolTip(tr("Training Mode (Practice your skills in a range of training missions). IN DEVELOPMENT")); |
|
1090 |
|
1091 BtnBack = addButton(":/res/Exit.png", bottomLine, 0, true); |
|
1092 bottomLine->addStretch(); |
|
1093 |
|
1094 BtnDemos = addButton(":/res/Record.png", bottomLine, 1, true); |
|
1095 BtnDemos->setToolTip(tr("Demos (Watch recorded demos)")); |
|
1096 BtnLoad = addButton(":/res/Save.png", bottomLine, 2, true); |
|
1097 BtnLoad->setStyleSheet("QPushButton{margin: 12px 0px 12px 0px;}"); |
|
1098 BtnLoad->setToolTip(tr("Load (Load a previously saved game)")); |
|
1099 BtnBack->setFixedHeight(BtnLoad->height()); |
|
1100 BtnBack->setStyleSheet("QPushButton{margin-top: 31px;}"); |
|
1101 } |
|
1102 |
|
1103 PageTraining::PageTraining(QWidget* parent) : AbstractPage(parent) |
|
1104 { |
|
1105 QGridLayout * pageLayout = new QGridLayout(this); |
|
1106 pageLayout->setColumnStretch(0, 1); |
|
1107 pageLayout->setColumnStretch(1, 2); |
|
1108 pageLayout->setColumnStretch(2, 1); |
|
1109 pageLayout->setRowStretch(0, 1); |
|
1110 pageLayout->setRowStretch(2, 1); |
|
1111 |
|
1112 CBSelect = new QComboBox(this); |
|
1113 |
|
1114 QDir tmpdir; |
|
1115 tmpdir.cd(datadir->absolutePath()); |
|
1116 tmpdir.cd("Missions/Training"); |
|
1117 tmpdir.setFilter(QDir::Files); |
|
1118 CBSelect->addItems(tmpdir.entryList(QStringList("*.lua")).replaceInStrings(QRegExp("^(.*)\\.lua"), "\\1")); |
|
1119 for(int i = 0; i < CBSelect->count(); i++) |
|
1120 { |
|
1121 CBSelect->setItemData(i, CBSelect->itemText(i)); |
|
1122 CBSelect->setItemText(i, CBSelect->itemText(i).replace("_", " ")); |
|
1123 } |
|
1124 |
|
1125 pageLayout->addWidget(CBSelect, 1, 1); |
|
1126 |
|
1127 BtnStartTrain = new QPushButton(this); |
|
1128 BtnStartTrain->setFont(*font14); |
|
1129 BtnStartTrain->setText(QPushButton::tr("Go!")); |
|
1130 pageLayout->addWidget(BtnStartTrain, 1, 2); |
|
1131 |
|
1132 BtnBack = addButton(":/res/Exit.png", pageLayout, 3, 0, true); |
|
1133 } |
|
1134 |
|
1135 PageCampaign::PageCampaign(QWidget* parent) : AbstractPage(parent) |
|
1136 { |
|
1137 QGridLayout * pageLayout = new QGridLayout(this); |
|
1138 pageLayout->setColumnStretch(0, 1); |
|
1139 pageLayout->setColumnStretch(1, 2); |
|
1140 pageLayout->setColumnStretch(2, 1); |
|
1141 pageLayout->setRowStretch(0, 1); |
|
1142 pageLayout->setRowStretch(3, 1); |
|
1143 |
|
1144 CBSelect = new QComboBox(this); |
|
1145 CBTeam = new QComboBox(this); |
|
1146 |
|
1147 pageLayout->addWidget(CBTeam, 1, 1); |
|
1148 pageLayout->addWidget(CBSelect, 2, 1); |
|
1149 |
|
1150 BtnStartCampaign = new QPushButton(this); |
|
1151 BtnStartCampaign->setFont(*font14); |
|
1152 BtnStartCampaign->setText(QPushButton::tr("Go!")); |
|
1153 pageLayout->addWidget(BtnStartCampaign, 2, 2); |
|
1154 |
|
1155 BtnBack = addButton(":/res/Exit.png", pageLayout, 4, 0, true); |
|
1156 } |
|
1157 |
|
1158 PageSelectWeapon::PageSelectWeapon(QWidget* parent) : |
|
1159 AbstractPage(parent) |
|
1160 { |
|
1161 QGridLayout * pageLayout = new QGridLayout(this); |
|
1162 |
|
1163 pWeapons = new SelWeaponWidget(cAmmoNumber, this); |
|
1164 pageLayout->addWidget(pWeapons, 0, 0, 1, 5); |
|
1165 |
|
1166 BtnBack = addButton(":/res/Exit.png", pageLayout, 1, 0, 2, 1, true); |
|
1167 BtnDefault = addButton(tr("Default"), pageLayout, 1, 3); |
|
1168 BtnNew = addButton(tr("New"), pageLayout, 1, 2); |
|
1169 BtnCopy = addButton(tr("Copy"), pageLayout, 2, 2); |
|
1170 BtnDelete = addButton(tr("Delete"), pageLayout, 2, 3); |
|
1171 BtnSave = addButton(":/res/Save.png", pageLayout, 1, 4, 2, 1, true); |
|
1172 BtnSave->setStyleSheet("QPushButton{margin: 24px 0px 0px 0px;}"); |
|
1173 BtnBack->setFixedHeight(BtnSave->height()); |
|
1174 BtnBack->setStyleSheet("QPushButton{margin-top: 31px;}"); |
|
1175 |
|
1176 selectWeaponSet = new QComboBox(this); |
|
1177 pageLayout->addWidget(selectWeaponSet, 1, 1, 2, 1); |
|
1178 |
|
1179 connect(BtnDefault, SIGNAL(clicked()), pWeapons, SLOT(setDefault())); |
|
1180 connect(BtnSave, SIGNAL(clicked()), pWeapons, SLOT(save())); |
|
1181 connect(BtnNew, SIGNAL(clicked()), pWeapons, SLOT(newWeaponsName())); |
|
1182 connect(BtnCopy, SIGNAL(clicked()), pWeapons, SLOT(copy())); |
|
1183 connect(selectWeaponSet, SIGNAL(currentIndexChanged(const QString&)), pWeapons, SLOT(setWeaponsName(const QString&))); |
|
1184 } |
|
1185 |
|
1186 PageInGame::PageInGame(QWidget* parent) : |
|
1187 AbstractPage(parent) |
|
1188 { |
|
1189 QLabel * label = new QLabel(this); |
|
1190 label->setText("In game..."); |
|
1191 } |
|
1192 |
|
1193 PageRoomsList::PageRoomsList(QWidget* parent, QSettings * gameSettings, SDLInteraction * sdli) : |
|
1194 AbstractPage(parent) |
|
1195 { |
|
1196 QGridLayout * pageLayout = new QGridLayout(this); |
|
1197 |
|
1198 QHBoxLayout * newRoomLayout = new QHBoxLayout(); |
|
1199 QLabel * roomNameLabel = new QLabel(this); |
|
1200 roomNameLabel->setText(tr("Room Name:")); |
|
1201 roomName = new QLineEdit(this); |
|
1202 roomName->setMaxLength(60); |
|
1203 newRoomLayout->addWidget(roomNameLabel); |
|
1204 newRoomLayout->addWidget(roomName); |
|
1205 pageLayout->addLayout(newRoomLayout, 0, 0); |
|
1206 |
|
1207 roomsList = new QTableWidget(this); |
|
1208 roomsList->setSelectionBehavior(QAbstractItemView::SelectRows); |
|
1209 roomsList->verticalHeader()->setVisible(false); |
|
1210 roomsList->horizontalHeader()->setResizeMode(QHeaderView::Interactive); |
|
1211 roomsList->setAlternatingRowColors(true); |
|
1212 roomsList->setShowGrid(false); |
|
1213 roomsList->setSelectionMode(QAbstractItemView::SingleSelection); |
|
1214 pageLayout->addWidget(roomsList, 1, 0, 3, 1); |
|
1215 pageLayout->setRowStretch(2, 100); |
|
1216 |
|
1217 QHBoxLayout * filterLayout = new QHBoxLayout(); |
|
1218 |
|
1219 QLabel * stateLabel = new QLabel(this); |
|
1220 stateLabel->setText(tr("State:")); |
|
1221 CBState = new QComboBox(this); |
|
1222 CBState->addItem(QComboBox::tr("Any")); |
|
1223 CBState->addItem(QComboBox::tr("In lobby")); |
|
1224 CBState->addItem(QComboBox::tr("In progress")); |
|
1225 filterLayout->addWidget(stateLabel); |
|
1226 filterLayout->addWidget(CBState); |
|
1227 filterLayout->addSpacing(30); |
|
1228 |
|
1229 QLabel * ruleLabel = new QLabel(this); |
|
1230 ruleLabel->setText(tr("Rules:")); |
|
1231 CBRules = new QComboBox(this); |
|
1232 CBRules->addItem(QComboBox::tr("Any")); |
|
1233 // not the most elegant solution but it works |
|
1234 ammoSchemeModel = new AmmoSchemeModel(this, NULL); |
|
1235 for (int i = 0; i < ammoSchemeModel->predefSchemesNames.count(); i++) |
|
1236 CBRules->addItem(ammoSchemeModel->predefSchemesNames.at(i).toAscii().constData()); |
|
1237 filterLayout->addWidget(ruleLabel); |
|
1238 filterLayout->addWidget(CBRules); |
|
1239 filterLayout->addSpacing(30); |
|
1240 |
|
1241 QLabel * weaponLabel = new QLabel(this); |
|
1242 weaponLabel->setText(tr("Weapons:")); |
|
1243 CBWeapons = new QComboBox(this); |
|
1244 CBWeapons->addItem(QComboBox::tr("Any")); |
|
1245 for (int i = 0; i < cDefaultAmmos.count(); i++) { |
|
1246 QPair<QString,QString> ammo = cDefaultAmmos.at(i); |
|
1247 CBWeapons->addItem(ammo.first.toAscii().constData()); |
|
1248 } |
|
1249 filterLayout->addWidget(weaponLabel); |
|
1250 filterLayout->addWidget(CBWeapons); |
|
1251 filterLayout->addSpacing(30); |
|
1252 |
|
1253 QLabel * searchLabel = new QLabel(this); |
|
1254 searchLabel->setText(tr("Search:")); |
|
1255 searchText = new QLineEdit(this); |
|
1256 searchText->setMaxLength(60); |
|
1257 filterLayout->addWidget(searchLabel); |
|
1258 filterLayout->addWidget(searchText); |
|
1259 |
|
1260 pageLayout->addLayout(filterLayout, 4, 0); |
|
1261 |
|
1262 chatWidget = new HWChatWidget(this, gameSettings, sdli, false); |
|
1263 pageLayout->addWidget(chatWidget, 5, 0, 1, 2); |
|
1264 pageLayout->setRowStretch(5, 350); |
|
1265 |
|
1266 BtnCreate = addButton(tr("Create"), pageLayout, 0, 1); |
|
1267 BtnJoin = addButton(tr("Join"), pageLayout, 1, 1); |
|
1268 BtnRefresh = addButton(tr("Refresh"), pageLayout, 3, 1); |
|
1269 BtnClear = addButton(tr("Clear"), pageLayout, 4, 1); |
|
1270 |
|
1271 BtnBack = addButton(":/res/Exit.png", pageLayout, 6, 0, true); |
|
1272 BtnAdmin = addButton(tr("Admin features"), pageLayout, 6, 1); |
|
1273 |
|
1274 connect(BtnCreate, SIGNAL(clicked()), this, SLOT(onCreateClick())); |
|
1275 connect(BtnJoin, SIGNAL(clicked()), this, SLOT(onJoinClick())); |
|
1276 connect(BtnRefresh, SIGNAL(clicked()), this, SLOT(onRefreshClick())); |
|
1277 connect(BtnClear, SIGNAL(clicked()), this, SLOT(onClearClick())); |
|
1278 connect(roomsList, SIGNAL(doubleClicked (const QModelIndex &)), this, SLOT(onJoinClick())); |
|
1279 connect(CBState, SIGNAL(currentIndexChanged (int)), this, SLOT(onRefreshClick())); |
|
1280 connect(CBRules, SIGNAL(currentIndexChanged (int)), this, SLOT(onRefreshClick())); |
|
1281 connect(CBWeapons, SIGNAL(currentIndexChanged (int)), this, SLOT(onRefreshClick())); |
|
1282 connect(searchText, SIGNAL(textChanged (const QString &)), this, SLOT(onRefreshClick())); |
|
1283 connect(this, SIGNAL(askJoinConfirmation (const QString &)), this, SLOT(onJoinConfirmation(const QString &)), Qt::QueuedConnection); |
|
1284 |
|
1285 gameInLobby = false; |
|
1286 } |
|
1287 |
|
1288 void PageRoomsList::setAdmin(bool flag) |
|
1289 { |
|
1290 BtnAdmin->setVisible(flag); |
|
1291 } |
|
1292 |
|
1293 void PageRoomsList::setRoomsList(const QStringList & list) |
|
1294 { |
|
1295 QBrush red(QColor(255, 0, 0)); |
|
1296 QBrush orange(QColor(127, 127, 0)); |
|
1297 QBrush yellow(QColor(255, 255, 0)); |
|
1298 QBrush green(QColor(0, 255, 0)); |
|
1299 |
|
1300 listFromServer = list; |
|
1301 |
|
1302 QString selection = ""; |
|
1303 |
|
1304 if(QTableWidgetItem *item = roomsList->item(roomsList->currentRow(), 0)) |
|
1305 selection = item->text(); |
|
1306 |
|
1307 roomsList->clear(); |
|
1308 roomsList->setColumnCount(7); |
|
1309 roomsList->setHorizontalHeaderLabels( |
|
1310 QStringList() << |
|
1311 QTableWidget::tr("Room Name") << |
|
1312 QTableWidget::tr("C") << |
|
1313 QTableWidget::tr("T") << |
|
1314 QTableWidget::tr("Owner") << |
|
1315 QTableWidget::tr("Map") << |
|
1316 QTableWidget::tr("Rules") << |
|
1317 QTableWidget::tr("Weapons") |
|
1318 ); |
|
1319 |
|
1320 // set minimum sizes |
|
1321 // roomsList->horizontalHeader()->resizeSection(0, 200); |
|
1322 // roomsList->horizontalHeader()->resizeSection(1, 50); |
|
1323 // roomsList->horizontalHeader()->resizeSection(2, 50); |
|
1324 // roomsList->horizontalHeader()->resizeSection(3, 100); |
|
1325 // roomsList->horizontalHeader()->resizeSection(4, 100); |
|
1326 // roomsList->horizontalHeader()->resizeSection(5, 100); |
|
1327 // roomsList->horizontalHeader()->resizeSection(6, 100); |
|
1328 |
|
1329 // set resize modes |
|
1330 // roomsList->horizontalHeader()->setResizeMode(QHeaderView::Interactive); |
|
1331 |
|
1332 bool gameCanBeJoined = true; |
|
1333 |
|
1334 if (list.size() % 8) |
|
1335 return; |
|
1336 |
|
1337 roomsList->setRowCount(list.size() / 8); |
|
1338 for(int i = 0, r = 0; i < list.size(); i += 8, r++) |
|
1339 { |
|
1340 // if we are joining a game |
|
1341 // TODO: Should NOT be done here |
|
1342 if (gameInLobby) { |
|
1343 if (gameInLobbyName == list[i + 1]) { |
|
1344 gameCanBeJoined = list[i].compare("True"); |
|
1345 } |
|
1346 } |
|
1347 |
|
1348 // check filter settings |
|
1349 #define NO_FILTER_MATCH roomsList->setRowCount(roomsList->rowCount() - 1); --r; continue |
|
1350 |
|
1351 if (list[i].compare("True") && CBState->currentIndex() == 2) { NO_FILTER_MATCH; } |
|
1352 if (list[i].compare("False") && CBState->currentIndex() == 1) { NO_FILTER_MATCH; } |
|
1353 if (CBRules->currentIndex() != 0 && list[i + 6].compare(CBRules->currentText())) { NO_FILTER_MATCH; } |
|
1354 if (CBWeapons->currentIndex() != 0 && list[i + 7].compare(CBWeapons->currentText())) { NO_FILTER_MATCH; } |
|
1355 bool found = list[i + 1].contains(searchText->text(), Qt::CaseInsensitive); |
|
1356 if (!found) { |
|
1357 for (int a = 4; a <= 7; ++a) { |
|
1358 QString compString = list[i + a]; |
|
1359 if (a == 5 && compString == "+rnd+") { |
|
1360 compString = "Random Map"; |
|
1361 } else if (a == 5 && compString == "+maze+") { |
|
1362 compString = "Random Maze"; |
|
1363 } else if (a == 5 && compString == "+drawn+") { |
|
1364 compString = "Drawn Map"; |
|
1365 } |
|
1366 if (compString.contains(searchText->text(), Qt::CaseInsensitive)) { |
|
1367 found = true; |
|
1368 break; |
|
1369 } |
|
1370 } |
|
1371 } |
|
1372 if (!searchText->text().isEmpty() && !found) { NO_FILTER_MATCH; } |
|
1373 |
|
1374 QTableWidgetItem * item; |
|
1375 item = new QTableWidgetItem(list[i + 1]); // room name |
|
1376 item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); |
|
1377 |
|
1378 // pick appropriate room icon and tooltip (game in progress yes/no; later maybe locked rooms etc.) |
|
1379 if(list[i].compare("True")) |
|
1380 { |
|
1381 item->setIcon(QIcon(":/res/iconTime.png"));// game is in lobby |
|
1382 item->setToolTip(tr("This game is in lobby.\nYou may join and start playing once the game starts.")); |
|
1383 } |
|
1384 else |
|
1385 { |
|
1386 item->setIcon(QIcon(":/res/iconDamage.png"));// game has started |
|
1387 item->setToolTip(tr("This game is in progress.\nYou may join and spectate now but you'll have to wait for the game to end to start playing.")); |
|
1388 } |
|
1389 |
|
1390 roomsList->setItem(r, 0, item); |
|
1391 |
|
1392 item = new QTableWidgetItem(list[i + 2]); // number of clients |
|
1393 item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); |
|
1394 item->setTextAlignment(Qt::AlignCenter); |
|
1395 item->setToolTip(tr("There are %1 clients connected to this room.", "", list[i + 2].toInt()).arg(list[i + 2])); |
|
1396 roomsList->setItem(r, 1, item); |
|
1397 |
|
1398 item = new QTableWidgetItem(list[i + 3]); // number of teams |
|
1399 item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); |
|
1400 item->setTextAlignment(Qt::AlignCenter); |
|
1401 item->setToolTip(tr("There are %1 teams participating in this room.", "", list[i + 3].toInt()).arg(list[i + 3])); |
|
1402 //Should we highlight "full" games? Might get misinterpreted |
|
1403 //if(list[i + 3].toInt() >= cMaxTeams) |
|
1404 // item->setForeground(red); |
|
1405 roomsList->setItem(r, 2, item); |
|
1406 |
|
1407 item = new QTableWidgetItem(list[i + 4].left(15)); // name of host |
|
1408 item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); |
|
1409 item->setToolTip(tr("%1 is the host. He may adjust settings and start the game.").arg(list[i + 4])); |
|
1410 roomsList->setItem(r, 3, item); |
|
1411 |
|
1412 if(list[i + 5] == "+rnd+") |
|
1413 { |
|
1414 item = new QTableWidgetItem(tr("Random Map")); // selected map (is randomized) |
|
1415 // FIXME - need real icons. Disabling until then |
|
1416 // item->setIcon(QIcon(":/res/mapRandom.png")); |
|
1417 } |
|
1418 else if (list[i+5] == "+maze+") |
|
1419 { |
|
1420 item = new QTableWidgetItem(tr("Random Maze")); |
|
1421 // FIXME - need real icons. Disabling until then |
|
1422 // item->setIcon(QIcon(":/res/mapMaze.png")); |
|
1423 } |
|
1424 else |
|
1425 { |
|
1426 item = new QTableWidgetItem(list[i + 5]); // selected map |
|
1427 |
|
1428 // check to see if we've got this map |
|
1429 // not perfect but a start |
|
1430 if(!mapList->contains(list[i + 5])) |
|
1431 { |
|
1432 item->setForeground(red); |
|
1433 item->setIcon(QIcon(":/res/mapMissing.png")); |
|
1434 } |
|
1435 else |
|
1436 { |
|
1437 // todo: mission icon? |
|
1438 // FIXME - need real icons. Disabling until then |
|
1439 // item->setIcon(QIcon(":/res/mapCustom.png")); |
|
1440 } |
|
1441 } |
|
1442 |
|
1443 item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); |
|
1444 item->setToolTip(tr("Games may be played on precreated or randomized maps.")); |
|
1445 roomsList->setItem(r, 4, item); |
|
1446 |
|
1447 item = new QTableWidgetItem(list[i + 6].left(24)); // selected game scheme |
|
1448 item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); |
|
1449 item->setToolTip(tr("The Game Scheme defines general options and preferences like Round Time, Sudden Death or Vampirism.")); |
|
1450 roomsList->setItem(r, 5, item); |
|
1451 |
|
1452 item = new QTableWidgetItem(list[i + 7].left(24)); // selected weapon scheme |
|
1453 item->setFlags(Qt::ItemIsEnabled | Qt::ItemIsSelectable); |
|
1454 item->setToolTip(tr("The Weapon Scheme defines available weapons and their ammunition count.")); |
|
1455 roomsList->setItem(r, 6, item); |
|
1456 |
|
1457 if(!list[i + 1].compare(selection) && !selection.isEmpty()) |
|
1458 roomsList->selectionModel()->setCurrentIndex(roomsList->model()->index(r, 0), QItemSelectionModel::SelectCurrent | QItemSelectionModel::Rows); |
|
1459 } |
|
1460 |
|
1461 roomsList->horizontalHeader()->setResizeMode(0, QHeaderView::Stretch); |
|
1462 roomsList->horizontalHeader()->setResizeMode(1, QHeaderView::ResizeToContents); |
|
1463 roomsList->horizontalHeader()->setResizeMode(2, QHeaderView::ResizeToContents); |
|
1464 roomsList->horizontalHeader()->setResizeMode(3, QHeaderView::ResizeToContents); |
|
1465 roomsList->horizontalHeader()->setResizeMode(4, QHeaderView::ResizeToContents); |
|
1466 roomsList->horizontalHeader()->setResizeMode(5, QHeaderView::ResizeToContents); |
|
1467 roomsList->horizontalHeader()->setResizeMode(6, QHeaderView::ResizeToContents); |
|
1468 |
|
1469 // TODO: Should NOT be done here |
|
1470 if (gameInLobby) { |
|
1471 gameInLobby = false; |
|
1472 if (gameCanBeJoined) { |
|
1473 emit askForJoinRoom(gameInLobbyName); |
|
1474 } else { |
|
1475 emit askJoinConfirmation(gameInLobbyName); |
|
1476 } |
|
1477 } |
|
1478 |
|
1479 // roomsList->resizeColumnsToContents(); |
|
1480 } |
|
1481 |
|
1482 void PageRoomsList::onCreateClick() |
|
1483 { |
|
1484 if (roomName->text().size()) |
|
1485 emit askForCreateRoom(roomName->text()); |
|
1486 else |
|
1487 QMessageBox::critical(this, |
|
1488 tr("Error"), |
|
1489 tr("Please enter room name"), |
|
1490 tr("OK")); |
|
1491 } |
|
1492 |
|
1493 void PageRoomsList::onJoinClick() |
|
1494 { |
|
1495 QTableWidgetItem * curritem = roomsList->item(roomsList->currentRow(), 0); |
|
1496 if (!curritem) |
|
1497 { |
|
1498 QMessageBox::critical(this, |
|
1499 tr("Error"), |
|
1500 tr("Please select room from the list"), |
|
1501 tr("OK")); |
|
1502 return; |
|
1503 } |
|
1504 |
|
1505 for (int i = 0; i < listFromServer.size(); i += 8) { |
|
1506 if (listFromServer[i + 1] == curritem->data(Qt::DisplayRole).toString()) { |
|
1507 gameInLobby = listFromServer[i].compare("True"); |
|
1508 break; |
|
1509 } |
|
1510 } |
|
1511 |
|
1512 if (gameInLobby) { |
|
1513 gameInLobbyName = curritem->data(Qt::DisplayRole).toString(); |
|
1514 emit askForRoomList(); |
|
1515 } else { |
|
1516 emit askForJoinRoom(curritem->data(Qt::DisplayRole).toString()); |
|
1517 } |
|
1518 } |
|
1519 |
|
1520 void PageRoomsList::onRefreshClick() |
|
1521 { |
|
1522 emit askForRoomList(); |
|
1523 } |
|
1524 |
|
1525 void PageRoomsList::onClearClick() |
|
1526 { |
|
1527 CBState->setCurrentIndex(0); |
|
1528 CBRules->setCurrentIndex(0); |
|
1529 CBWeapons->setCurrentIndex(0); |
|
1530 searchText->clear(); |
|
1531 } |
|
1532 |
|
1533 void PageRoomsList::onJoinConfirmation(const QString & room) |
|
1534 { |
|
1535 if (QMessageBox::warning(this, |
|
1536 tr("Warning"), |
|
1537 tr("The game you are trying to join has started.\nDo you still want to join the room?"), |
|
1538 QMessageBox::Yes | QMessageBox::No) == QMessageBox::Yes) |
|
1539 { |
|
1540 emit askForJoinRoom(room); |
|
1541 } |
|
1542 } |
|
1543 |
|
1544 PageConnecting::PageConnecting(QWidget* parent) : |
|
1545 AbstractPage(parent) |
|
1546 { |
|
1547 QGridLayout * pageLayout = new QGridLayout(this); |
|
1548 |
|
1549 QLabel * lblConnecting = new QLabel(this); |
|
1550 lblConnecting->setText(tr("Connecting...")); |
|
1551 pageLayout->addWidget(lblConnecting); |
|
1552 } |
|
1553 |
|
1554 PageScheme::PageScheme(QWidget* parent) : |
|
1555 AbstractPage(parent) |
|
1556 { |
|
1557 QGridLayout * pageLayout = new QGridLayout(this); |
|
1558 QGroupBox * gb = new QGroupBox(this); |
|
1559 |
|
1560 QGridLayout * gl = new QGridLayout(); |
|
1561 gb->setLayout(gl); |
|
1562 QSizePolicy sp; |
|
1563 sp.setVerticalPolicy(QSizePolicy::MinimumExpanding); |
|
1564 sp.setHorizontalPolicy(QSizePolicy::Expanding); |
|
1565 |
|
1566 pageLayout->addWidget(gb, 1,0,13,5); |
|
1567 |
|
1568 gbGameModes = new QGroupBox(QGroupBox::tr("Game Modifiers"), gb); |
|
1569 gbBasicSettings = new QGroupBox(QGroupBox::tr("Basic Settings"), gb); |
|
1570 |
|
1571 gbGameModes->setStyleSheet(".QGroupBox {" |
|
1572 "background-color: #130f2c; background-image:url();" |
|
1573 "}"); |
|
1574 gbBasicSettings->setStyleSheet(".QGroupBox {" |
|
1575 "background-color: #130f2c; background-image:url();" |
|
1576 "}"); |
|
1577 |
|
1578 gbGameModes->setSizePolicy(sp); |
|
1579 gbBasicSettings->setSizePolicy(sp); |
|
1580 gl->addWidget(gbGameModes,0,0,1,3,Qt::AlignTop); |
|
1581 gl->addWidget(gbBasicSettings,0,3,1,3,Qt::AlignTop); |
|
1582 |
|
1583 QGridLayout * glGMLayout = new QGridLayout(gbGameModes); |
|
1584 QGridLayout * glBSLayout = new QGridLayout(gbBasicSettings); |
|
1585 gbGameModes->setLayout(glGMLayout); |
|
1586 gbBasicSettings->setLayout(glBSLayout); |
|
1587 // Left |
|
1588 |
|
1589 TBW_mode_Forts = new ToggleButtonWidget(gbGameModes, ":/res/btnForts.png"); |
|
1590 TBW_mode_Forts->setToolTip("<b>" + ToggleButtonWidget::tr("Fort Mode") + "</b>:<br />" + tr("Defend your fort and destroy the opponents, two team colours max!")); |
|
1591 glGMLayout->addWidget(TBW_mode_Forts,0,0,1,1); |
|
1592 |
|
1593 TBW_teamsDivide = new ToggleButtonWidget(gbGameModes, ":/res/btnTeamsDivide.png"); |
|
1594 TBW_teamsDivide->setToolTip("<b>" + ToggleButtonWidget::tr("Divide Teams") + "</b>:<br />" + tr("Teams will start on opposite sides of the terrain, two team colours max!")); |
|
1595 glGMLayout->addWidget(TBW_teamsDivide,0,1,1,1); |
|
1596 |
|
1597 TBW_solid = new ToggleButtonWidget(gbGameModes, ":/res/btnSolid.png"); |
|
1598 TBW_solid->setToolTip("<b>" + ToggleButtonWidget::tr("Solid Land") + "</b>:<br />" + tr("Land can not be destroyed!")); |
|
1599 glGMLayout->addWidget(TBW_solid,0,2,1,1); |
|
1600 |
|
1601 TBW_border = new ToggleButtonWidget(gbGameModes, ":/res/btnBorder.png"); |
|
1602 TBW_border->setToolTip("<b>" + ToggleButtonWidget::tr("Add Border") + "</b>:<br />" + tr("Add an indestructable border around the terrain")); |
|
1603 glGMLayout->addWidget(TBW_border,0,3,1,1); |
|
1604 |
|
1605 TBW_lowGravity = new ToggleButtonWidget(gbGameModes, ":/res/btnLowGravity.png"); |
|
1606 TBW_lowGravity->setToolTip("<b>" + ToggleButtonWidget::tr("Low Gravity") + "</b>:<br />" + tr("Lower gravity")); |
|
1607 glGMLayout->addWidget(TBW_lowGravity,0,4,1,1); |
|
1608 |
|
1609 TBW_laserSight = new ToggleButtonWidget(gbGameModes, ":/res/btnLaserSight.png"); |
|
1610 TBW_laserSight->setToolTip("<b>" + ToggleButtonWidget::tr("Laser Sight") + "</b>:<br />" + tr("Assisted aiming with laser sight")); |
|
1611 glGMLayout->addWidget(TBW_laserSight,1,0,1,1); |
|
1612 |
|
1613 TBW_invulnerable = new ToggleButtonWidget(gbGameModes, ":/res/btnInvulnerable.png"); |
|
1614 TBW_invulnerable->setToolTip("<b>" + ToggleButtonWidget::tr("Invulnerable") + "</b>:<br />" + tr("All hogs have a personal forcefield")); |
|
1615 glGMLayout->addWidget(TBW_invulnerable,1,1,1,1); |
|
1616 |
|
1617 TBW_resethealth = new ToggleButtonWidget(gbGameModes, ":/res/btnResetHealth.png"); |
|
1618 TBW_resethealth->setToolTip("<b>" + ToggleButtonWidget::tr("Reset Health") + "</b>:<br />" + tr("All (living) hedgehogs are fully restored at the end of turn")); |
|
1619 glGMLayout->addWidget(TBW_resethealth,1,2,1,1); |
|
1620 |
|
1621 TBW_vampiric = new ToggleButtonWidget(gbGameModes, ":/res/btnVampiric.png"); |
|
1622 TBW_vampiric->setToolTip("<b>" + ToggleButtonWidget::tr("Vampirism") + "</b>:<br />" + tr("Gain 80% of the damage you do back in health")); |
|
1623 glGMLayout->addWidget(TBW_vampiric,1,3,1,1); |
|
1624 |
|
1625 TBW_karma = new ToggleButtonWidget(gbGameModes, ":/res/btnKarma.png"); |
|
1626 TBW_karma->setToolTip("<b>" + ToggleButtonWidget::tr("Karma") + "</b>:<br />" + tr("Share your opponents pain, share their damage")); |
|
1627 glGMLayout->addWidget(TBW_karma,1,4,1,1); |
|
1628 |
|
1629 TBW_artillery = new ToggleButtonWidget(gbGameModes, ":/res/btnArtillery.png"); |
|
1630 TBW_artillery->setToolTip("<b>" + ToggleButtonWidget::tr("Artillery") + "</b>:<br />" + tr("Your hogs are unable to move, put your artillery skills to the test")); |
|
1631 glGMLayout->addWidget(TBW_artillery,2,0,1,1); |
|
1632 |
|
1633 TBW_randomorder = new ToggleButtonWidget(gbGameModes, ":/res/btnRandomOrder.png"); |
|
1634 TBW_randomorder->setToolTip("<b>" + ToggleButtonWidget::tr("Random Order") + "</b>:<br />" + tr("Order of play is random instead of in room order.")); |
|
1635 glGMLayout->addWidget(TBW_randomorder,2,1,1,1); |
|
1636 |
|
1637 TBW_king = new ToggleButtonWidget(gbGameModes, ":/res/btnKing.png"); |
|
1638 TBW_king->setToolTip("<b>" + ToggleButtonWidget::tr("King") + "</b>:<br />" + tr("Play with a King. If he dies, your side dies.")); |
|
1639 glGMLayout->addWidget(TBW_king,2,2,1,1); |
|
1640 |
|
1641 TBW_placehog = new ToggleButtonWidget(gbGameModes, ":/res/btnPlaceHog.png"); |
|
1642 TBW_placehog->setToolTip("<b>" + ToggleButtonWidget::tr("Place Hedgehogs") + "</b>:<br />" + tr("Take turns placing your hedgehogs before the start of play.")); |
|
1643 glGMLayout->addWidget(TBW_placehog,2,3,1,1); |
|
1644 |
|
1645 TBW_sharedammo = new ToggleButtonWidget(gbGameModes, ":/res/btnSharedAmmo.png"); |
|
1646 TBW_sharedammo->setToolTip("<b>" + ToggleButtonWidget::tr("Clan Shares Ammo") + "</b>:<br />" + tr("Ammo is shared between all teams that share a colour.")); |
|
1647 glGMLayout->addWidget(TBW_sharedammo,2,4,1,1); |
|
1648 |
|
1649 TBW_disablegirders = new ToggleButtonWidget(gbGameModes, ":/res/btnDisableGirders.png"); |
|
1650 TBW_disablegirders->setToolTip("<b>" + ToggleButtonWidget::tr("Disable Girders") + "</b>:<br />" + tr("Disable girders when generating random maps.")); |
|
1651 glGMLayout->addWidget(TBW_disablegirders,3,0,1,1); |
|
1652 |
|
1653 TBW_disablelandobjects = new ToggleButtonWidget(gbGameModes, ":/res/btnDisableLandObjects.png"); |
|
1654 TBW_disablelandobjects->setToolTip("<b>" + ToggleButtonWidget::tr("Disable Land Objects") + "</b>:<br />" + tr("Disable land objects when generating random maps.")); |
|
1655 glGMLayout->addWidget(TBW_disablelandobjects,3,1,1,1); |
|
1656 |
|
1657 TBW_aisurvival = new ToggleButtonWidget(gbGameModes, ":/res/btnAISurvival.png"); |
|
1658 TBW_aisurvival->setToolTip("<b>" + ToggleButtonWidget::tr("AI Survival Mode") + "</b>:<br />" + tr("AI respawns on death.")); |
|
1659 glGMLayout->addWidget(TBW_aisurvival,3,2,1,1); |
|
1660 |
|
1661 TBW_infattack = new ToggleButtonWidget(gbGameModes, ":/res/btnInfAttack.png"); |
|
1662 TBW_infattack->setToolTip("<b>" + ToggleButtonWidget::tr("Unlimited Attacks") + "</b>:<br />" + tr("Attacking does not end your turn.")); |
|
1663 glGMLayout->addWidget(TBW_infattack,3,3,1,1); |
|
1664 |
|
1665 TBW_resetweps = new ToggleButtonWidget(gbGameModes, ":/res/btnResetWeps.png"); |
|
1666 TBW_resetweps->setToolTip("<b>" + ToggleButtonWidget::tr("Reset Weapons") + "</b>:<br />" + tr("Weapons are reset to starting values each turn.")); |
|
1667 glGMLayout->addWidget(TBW_resetweps,3,4,1,1); |
|
1668 |
|
1669 TBW_perhogammo = new ToggleButtonWidget(gbGameModes, ":/res/btnPerHogAmmo.png"); |
|
1670 TBW_perhogammo->setToolTip("<b>" + ToggleButtonWidget::tr("Per Hedgehog Ammo") + "</b>:<br />" + tr("Each hedgehog has its own ammo. It does not share with the team.")); |
|
1671 glGMLayout->addWidget(TBW_perhogammo,4,0,1,1); |
|
1672 |
|
1673 TBW_nowind = new ToggleButtonWidget(gbGameModes, ":/res/btnNoWind.png"); |
|
1674 TBW_nowind->setToolTip("<b>" + ToggleButtonWidget::tr("Disable Wind") + "</b>:<br />" + tr("You will not have to worry about wind anymore.")); |
|
1675 glGMLayout->addWidget(TBW_nowind,4,1,1,1); |
|
1676 |
|
1677 TBW_morewind = new ToggleButtonWidget(gbGameModes, ":/res/btnMoreWind.png"); |
|
1678 TBW_morewind->setToolTip("<b>" + ToggleButtonWidget::tr("More Wind") + "</b>:<br />" + tr("Wind will affect almost everything.")); |
|
1679 glGMLayout->addWidget(TBW_morewind,4,2,1,1); |
|
1680 |
|
1681 TBW_tagteam = new ToggleButtonWidget(gbGameModes, ":/res/btnTagTeam.png"); |
|
1682 TBW_tagteam->setToolTip("<b>" + ToggleButtonWidget::tr("Tag Team") + "</b>:<br />" + tr("Teams in each clan takes successive turns but have to share turn time.")); |
|
1683 glGMLayout->addWidget(TBW_tagteam,4,3,1,1); |
|
1684 |
|
1685 // Right |
|
1686 QLabel * l; |
|
1687 |
|
1688 l = new QLabel(gbBasicSettings); |
|
1689 l->setText(QLabel::tr("Damage Modifier")); |
|
1690 l->setWordWrap(true); |
|
1691 glBSLayout->addWidget(l,0,0,1,1); |
|
1692 l = new QLabel(gbBasicSettings); |
|
1693 l->setFixedSize(32,32); |
|
1694 l->setPixmap(QPixmap(":/res/iconDamage.png")); |
|
1695 glBSLayout->addWidget(l,0,1,1,1); |
|
1696 SB_DamageModifier = new QSpinBox(gbBasicSettings); |
|
1697 SB_DamageModifier->setRange(10, 300); |
|
1698 SB_DamageModifier->setValue(100); |
|
1699 SB_DamageModifier->setSingleStep(25); |
|
1700 glBSLayout->addWidget(SB_DamageModifier,0,2,1,1); |
|
1701 |
|
1702 l = new QLabel(gbBasicSettings); |
|
1703 l->setText(QLabel::tr("Turn Time")); |
|
1704 l->setWordWrap(true); |
|
1705 glBSLayout->addWidget(l,1,0,1,1); |
|
1706 l = new QLabel(gbBasicSettings); |
|
1707 l->setFixedSize(32,32); |
|
1708 l->setPixmap(QPixmap(":/res/iconTime.png")); |
|
1709 glBSLayout->addWidget(l,1,1,1,1); |
|
1710 SB_TurnTime = new QSpinBox(gbBasicSettings); |
|
1711 SB_TurnTime->setRange(1, 9999); |
|
1712 SB_TurnTime->setValue(45); |
|
1713 SB_TurnTime->setSingleStep(15); |
|
1714 glBSLayout->addWidget(SB_TurnTime,1,2,1,1); |
|
1715 |
|
1716 l = new QLabel(gbBasicSettings); |
|
1717 l->setText(QLabel::tr("Initial Health")); |
|
1718 l->setWordWrap(true); |
|
1719 glBSLayout->addWidget(l,2,0,1,1); |
|
1720 l = new QLabel(gbBasicSettings); |
|
1721 l->setFixedSize(32,32); |
|
1722 l->setPixmap(QPixmap(":/res/iconHealth.png")); |
|
1723 glBSLayout->addWidget(l,2,1,1,1); |
|
1724 SB_InitHealth = new QSpinBox(gbBasicSettings); |
|
1725 SB_InitHealth->setRange(50, 200); |
|
1726 SB_InitHealth->setValue(100); |
|
1727 SB_InitHealth->setSingleStep(25); |
|
1728 glBSLayout->addWidget(SB_InitHealth,2,2,1,1); |
|
1729 |
|
1730 l = new QLabel(gbBasicSettings); |
|
1731 l->setText(QLabel::tr("Sudden Death Timeout")); |
|
1732 l->setWordWrap(true); |
|
1733 glBSLayout->addWidget(l,3,0,1,1); |
|
1734 l = new QLabel(gbBasicSettings); |
|
1735 l->setFixedSize(32,32); |
|
1736 l->setPixmap(QPixmap(":/res/iconSuddenDeath.png")); |
|
1737 glBSLayout->addWidget(l,3,1,1,1); |
|
1738 SB_SuddenDeath = new QSpinBox(gbBasicSettings); |
|
1739 SB_SuddenDeath->setRange(0, 50); |
|
1740 SB_SuddenDeath->setValue(15); |
|
1741 SB_SuddenDeath->setSingleStep(3); |
|
1742 glBSLayout->addWidget(SB_SuddenDeath,3,2,1,1); |
|
1743 |
|
1744 l = new QLabel(gbBasicSettings); |
|
1745 l->setText(QLabel::tr("Sudden Death Water Rise")); |
|
1746 l->setWordWrap(true); |
|
1747 glBSLayout->addWidget(l,4,0,1,1); |
|
1748 l = new QLabel(gbBasicSettings); |
|
1749 l->setFixedSize(32,32); |
|
1750 l->setPixmap(QPixmap(":/res/iconSuddenDeath.png")); // TODO: icon |
|
1751 glBSLayout->addWidget(l,4,1,1,1); |
|
1752 SB_WaterRise = new QSpinBox(gbBasicSettings); |
|
1753 SB_WaterRise->setRange(0, 100); |
|
1754 SB_WaterRise->setValue(47); |
|
1755 SB_WaterRise->setSingleStep(5); |
|
1756 glBSLayout->addWidget(SB_WaterRise,4,2,1,1); |
|
1757 |
|
1758 l = new QLabel(gbBasicSettings); |
|
1759 l->setText(QLabel::tr("Sudden Death Health Decrease")); |
|
1760 l->setWordWrap(true); |
|
1761 glBSLayout->addWidget(l,5,0,1,1); |
|
1762 l = new QLabel(gbBasicSettings); |
|
1763 l->setFixedSize(32,32); |
|
1764 l->setPixmap(QPixmap(":/res/iconSuddenDeath.png")); // TODO: icon |
|
1765 glBSLayout->addWidget(l,5,1,1,1); |
|
1766 SB_HealthDecrease = new QSpinBox(gbBasicSettings); |
|
1767 SB_HealthDecrease->setRange(0, 100); |
|
1768 SB_HealthDecrease->setValue(5); |
|
1769 SB_HealthDecrease->setSingleStep(1); |
|
1770 glBSLayout->addWidget(SB_HealthDecrease,5,2,1,1); |
|
1771 |
|
1772 l = new QLabel(gbBasicSettings); |
|
1773 l->setText(QLabel::tr("% Rope Length")); |
|
1774 l->setWordWrap(true); |
|
1775 glBSLayout->addWidget(l,6,0,1,1); |
|
1776 l = new QLabel(gbBasicSettings); |
|
1777 l->setFixedSize(32,32); |
|
1778 l->setPixmap(QPixmap(":/res/iconRope.png")); |
|
1779 glBSLayout->addWidget(l,6,1,1,1); |
|
1780 SB_RopeModifier = new QSpinBox(gbBasicSettings); |
|
1781 SB_RopeModifier->setRange(25, 999); |
|
1782 SB_RopeModifier->setValue(100); |
|
1783 SB_RopeModifier->setSingleStep(25); |
|
1784 glBSLayout->addWidget(SB_RopeModifier,6,2,1,1); |
|
1785 |
|
1786 l = new QLabel(gbBasicSettings); |
|
1787 l->setText(QLabel::tr("Crate Drops")); |
|
1788 l->setWordWrap(true); |
|
1789 glBSLayout->addWidget(l,7,0,1,1); |
|
1790 l = new QLabel(gbBasicSettings); |
|
1791 l->setFixedSize(32,32); |
|
1792 l->setPixmap(QPixmap(":/res/iconBox.png")); |
|
1793 glBSLayout->addWidget(l,7,1,1,1); |
|
1794 SB_CaseProb = new FreqSpinBox(gbBasicSettings); |
|
1795 SB_CaseProb->setRange(0, 9); |
|
1796 SB_CaseProb->setValue(5); |
|
1797 glBSLayout->addWidget(SB_CaseProb,7,2,1,1); |
|
1798 |
|
1799 l = new QLabel(gbBasicSettings); |
|
1800 l->setText(QLabel::tr("% Health Crates")); |
|
1801 l->setWordWrap(true); |
|
1802 glBSLayout->addWidget(l,8,0,1,1); |
|
1803 l = new QLabel(gbBasicSettings); |
|
1804 l->setFixedSize(32,32); |
|
1805 l->setPixmap(QPixmap(":/res/iconHealth.png")); // TODO: icon |
|
1806 glBSLayout->addWidget(l,8,1,1,1); |
|
1807 SB_HealthCrates = new QSpinBox(gbBasicSettings); |
|
1808 SB_HealthCrates->setRange(0, 100); |
|
1809 SB_HealthCrates->setValue(35); |
|
1810 SB_HealthCrates->setSingleStep(5); |
|
1811 glBSLayout->addWidget(SB_HealthCrates,8,2,1,1); |
|
1812 |
|
1813 l = new QLabel(gbBasicSettings); |
|
1814 l->setText(QLabel::tr("Health in Crates")); |
|
1815 l->setWordWrap(true); |
|
1816 glBSLayout->addWidget(l,9,0,1,1); |
|
1817 l = new QLabel(gbBasicSettings); |
|
1818 l->setFixedSize(32,32); |
|
1819 l->setPixmap(QPixmap(":/res/iconHealth.png")); // TODO: icon |
|
1820 glBSLayout->addWidget(l,9,1,1,1); |
|
1821 SB_CrateHealth = new QSpinBox(gbBasicSettings); |
|
1822 SB_CrateHealth->setRange(0, 200); |
|
1823 SB_CrateHealth->setValue(25); |
|
1824 SB_CrateHealth->setSingleStep(5); |
|
1825 glBSLayout->addWidget(SB_CrateHealth,9,2,1,1); |
|
1826 |
|
1827 l = new QLabel(gbBasicSettings); |
|
1828 l->setText(QLabel::tr("Mines Time")); |
|
1829 l->setWordWrap(true); |
|
1830 glBSLayout->addWidget(l,10,0,1,1); |
|
1831 l = new QLabel(gbBasicSettings); |
|
1832 l->setFixedSize(32,32); |
|
1833 l->setPixmap(QPixmap(":/res/iconTime.png")); // TODO: icon |
|
1834 glBSLayout->addWidget(l,10,1,1,1); |
|
1835 SB_MinesTime = new QSpinBox(gbBasicSettings); |
|
1836 SB_MinesTime->setRange(-1, 5); |
|
1837 SB_MinesTime->setValue(3); |
|
1838 SB_MinesTime->setSingleStep(1); |
|
1839 SB_MinesTime->setSpecialValueText(tr("Random")); |
|
1840 SB_MinesTime->setSuffix(" "+ tr("Seconds")); |
|
1841 glBSLayout->addWidget(SB_MinesTime,10,2,1,1); |
|
1842 |
|
1843 l = new QLabel(gbBasicSettings); |
|
1844 l->setText(QLabel::tr("Mines")); |
|
1845 l->setWordWrap(true); |
|
1846 glBSLayout->addWidget(l,11,0,1,1); |
|
1847 l = new QLabel(gbBasicSettings); |
|
1848 l->setFixedSize(32,32); |
|
1849 l->setPixmap(QPixmap(":/res/iconMine.png")); // TODO: icon |
|
1850 glBSLayout->addWidget(l,11,1,1,1); |
|
1851 SB_Mines = new QSpinBox(gbBasicSettings); |
|
1852 SB_Mines->setRange(0, 80); |
|
1853 SB_Mines->setValue(0); |
|
1854 SB_Mines->setSingleStep(5); |
|
1855 glBSLayout->addWidget(SB_Mines,11,2,1,1); |
|
1856 |
|
1857 l = new QLabel(gbBasicSettings); |
|
1858 l->setText(QLabel::tr("% Dud Mines")); |
|
1859 l->setWordWrap(true); |
|
1860 glBSLayout->addWidget(l,12,0,1,1); |
|
1861 l = new QLabel(gbBasicSettings); |
|
1862 l->setFixedSize(32,32); |
|
1863 l->setPixmap(QPixmap(":/res/iconDud.png")); |
|
1864 glBSLayout->addWidget(l,12,1,1,1); |
|
1865 SB_MineDuds = new QSpinBox(gbBasicSettings); |
|
1866 SB_MineDuds->setRange(0, 100); |
|
1867 SB_MineDuds->setValue(0); |
|
1868 SB_MineDuds->setSingleStep(5); |
|
1869 glBSLayout->addWidget(SB_MineDuds,12,2,1,1); |
|
1870 |
|
1871 l = new QLabel(gbBasicSettings); |
|
1872 l->setText(QLabel::tr("Explosives")); |
|
1873 l->setWordWrap(true); |
|
1874 glBSLayout->addWidget(l,13,0,1,1); |
|
1875 l = new QLabel(gbBasicSettings); |
|
1876 l->setFixedSize(32,32); |
|
1877 l->setPixmap(QPixmap(":/res/iconDamage.png")); |
|
1878 glBSLayout->addWidget(l,13,1,1,1); |
|
1879 SB_Explosives = new QSpinBox(gbBasicSettings); |
|
1880 SB_Explosives->setRange(0, 40); |
|
1881 SB_Explosives->setValue(0); |
|
1882 SB_Explosives->setSingleStep(1); |
|
1883 glBSLayout->addWidget(SB_Explosives,13,2,1,1); |
|
1884 |
|
1885 l = new QLabel(gbBasicSettings); |
|
1886 l->setText(QLabel::tr("% Get Away Time")); |
|
1887 l->setWordWrap(true); |
|
1888 glBSLayout->addWidget(l,14,0,1,1); |
|
1889 l = new QLabel(gbBasicSettings); |
|
1890 l->setFixedSize(32,32); |
|
1891 l->setPixmap(QPixmap(":/res/iconTime.png")); |
|
1892 glBSLayout->addWidget(l,14,1,1,1); |
|
1893 SB_GetAwayTime = new QSpinBox(gbBasicSettings); |
|
1894 SB_GetAwayTime->setRange(0, 999); |
|
1895 SB_GetAwayTime->setValue(100); |
|
1896 SB_GetAwayTime->setSingleStep(25); |
|
1897 glBSLayout->addWidget(SB_GetAwayTime,14,2,1,1); |
|
1898 |
|
1899 l = new QLabel(gbBasicSettings); |
|
1900 l->setText(QLabel::tr("Scheme Name:")); |
|
1901 |
|
1902 LE_name = new QLineEdit(this); |
|
1903 |
|
1904 gl->addWidget(LE_name,15,1,1,5); |
|
1905 gl->addWidget(l,15,0,1,1); |
|
1906 |
|
1907 mapper = new QDataWidgetMapper(this); |
|
1908 |
|
1909 BtnBack = addButton(":/res/Exit.png", pageLayout, 16, 0, true); |
|
1910 BtnCopy = addButton(tr("Copy"), pageLayout, 16, 2); |
|
1911 BtnNew = addButton(tr("New"), pageLayout, 16, 3); |
|
1912 BtnDelete = addButton(tr("Delete"), pageLayout, 16, 4); |
|
1913 |
|
1914 selectScheme = new QComboBox(this); |
|
1915 pageLayout->addWidget(selectScheme, 16, 1); |
|
1916 |
|
1917 connect(BtnCopy, SIGNAL(clicked()), this, SLOT(copyRow())); |
|
1918 connect(BtnNew, SIGNAL(clicked()), this, SLOT(newRow())); |
|
1919 connect(BtnDelete, SIGNAL(clicked()), this, SLOT(deleteRow())); |
|
1920 connect(selectScheme, SIGNAL(currentIndexChanged(int)), mapper, SLOT(setCurrentIndex(int))); |
|
1921 connect(selectScheme, SIGNAL(currentIndexChanged(int)), this, SLOT(schemeSelected(int))); |
|
1922 } |
|
1923 |
|
1924 void PageScheme::setModel(QAbstractItemModel * model) |
|
1925 { |
|
1926 mapper->setModel(model); |
|
1927 selectScheme->setModel(model); |
|
1928 |
|
1929 mapper->addMapping(LE_name, 0); |
|
1930 mapper->addMapping(TBW_mode_Forts, 1); |
|
1931 mapper->addMapping(TBW_teamsDivide, 2); |
|
1932 mapper->addMapping(TBW_solid, 3); |
|
1933 mapper->addMapping(TBW_border, 4); |
|
1934 mapper->addMapping(TBW_lowGravity, 5); |
|
1935 mapper->addMapping(TBW_laserSight, 6); |
|
1936 mapper->addMapping(TBW_invulnerable, 7); |
|
1937 mapper->addMapping(TBW_resethealth, 8); |
|
1938 mapper->addMapping(TBW_vampiric, 9); |
|
1939 mapper->addMapping(TBW_karma, 10); |
|
1940 mapper->addMapping(TBW_artillery, 11); |
|
1941 mapper->addMapping(TBW_randomorder, 12); |
|
1942 mapper->addMapping(TBW_king, 13); |
|
1943 mapper->addMapping(TBW_placehog, 14); |
|
1944 mapper->addMapping(TBW_sharedammo, 15); |
|
1945 mapper->addMapping(TBW_disablegirders, 16); |
|
1946 mapper->addMapping(TBW_disablelandobjects, 17); |
|
1947 mapper->addMapping(TBW_aisurvival, 18); |
|
1948 mapper->addMapping(TBW_infattack, 19); |
|
1949 mapper->addMapping(TBW_resetweps, 20); |
|
1950 mapper->addMapping(TBW_perhogammo, 21); |
|
1951 mapper->addMapping(TBW_nowind, 22); |
|
1952 mapper->addMapping(TBW_morewind, 23); |
|
1953 mapper->addMapping(TBW_tagteam, 24); |
|
1954 mapper->addMapping(SB_DamageModifier, 25); |
|
1955 mapper->addMapping(SB_TurnTime, 26); |
|
1956 mapper->addMapping(SB_InitHealth, 27); |
|
1957 mapper->addMapping(SB_SuddenDeath, 28); |
|
1958 mapper->addMapping(SB_CaseProb, 29); |
|
1959 mapper->addMapping(SB_MinesTime, 30); |
|
1960 mapper->addMapping(SB_Mines, 31); |
|
1961 mapper->addMapping(SB_MineDuds, 32); |
|
1962 mapper->addMapping(SB_Explosives, 33); |
|
1963 mapper->addMapping(SB_HealthCrates, 34); |
|
1964 mapper->addMapping(SB_CrateHealth, 35); |
|
1965 mapper->addMapping(SB_WaterRise, 36); |
|
1966 mapper->addMapping(SB_HealthDecrease, 37); |
|
1967 mapper->addMapping(SB_RopeModifier, 38); |
|
1968 mapper->addMapping(SB_GetAwayTime, 39); |
|
1969 |
|
1970 mapper->toFirst(); |
|
1971 } |
|
1972 |
|
1973 void PageScheme::newRow() |
|
1974 { |
|
1975 QAbstractItemModel * model = mapper->model(); |
|
1976 model->insertRow(-1); |
|
1977 selectScheme->setCurrentIndex(model->rowCount() - 1); |
|
1978 } |
|
1979 |
|
1980 void PageScheme::copyRow() |
|
1981 { |
|
1982 QAbstractItemModel * model = mapper->model(); |
|
1983 model->insertRow(selectScheme->currentIndex()); |
|
1984 selectScheme->setCurrentIndex(model->rowCount() - 1); |
|
1985 } |
|
1986 |
|
1987 void PageScheme::deleteRow() |
|
1988 { |
|
1989 QMessageBox reallyDelete(QMessageBox::Question, QMessageBox::tr("Schemes"), QMessageBox::tr("Really delete this game scheme?"), QMessageBox::Ok | QMessageBox::Cancel); |
|
1990 |
|
1991 if (reallyDelete.exec() == QMessageBox::Ok) { |
|
1992 QAbstractItemModel * model = mapper->model(); |
|
1993 model->removeRow(selectScheme->currentIndex()); |
|
1994 } |
|
1995 } |
|
1996 |
|
1997 void PageScheme::schemeSelected(int n) |
|
1998 { |
|
1999 int c = ((AmmoSchemeModel*)mapper->model())->numberOfDefaultSchemes; |
|
2000 gbGameModes->setEnabled(n >= c); |
|
2001 gbBasicSettings->setEnabled(n >= c); |
|
2002 LE_name->setEnabled(n >= c); |
|
2003 } |
|
2004 |
|
2005 ///////////////////////////////////////////////// |
|
2006 |
|
2007 PageAdmin::PageAdmin(QWidget* parent) : |
|
2008 AbstractPage(parent) |
|
2009 { |
|
2010 QGridLayout * pageLayout = new QGridLayout(this); |
|
2011 |
|
2012 // 0 |
|
2013 pbAsk = addButton(tr("Fetch data"), pageLayout, 0, 0, 1, 3); |
|
2014 connect(pbAsk, SIGNAL(clicked()), this, SIGNAL(askServerVars())); |
|
2015 |
|
2016 // 1 |
|
2017 QLabel * lblSMN = new QLabel(this); |
|
2018 lblSMN->setText(tr("Server message for latest version:")); |
|
2019 pageLayout->addWidget(lblSMN, 1, 0); |
|
2020 |
|
2021 leServerMessageNew = new QLineEdit(this); |
|
2022 pageLayout->addWidget(leServerMessageNew, 1, 1); |
|
2023 |
|
2024 // 2 |
|
2025 QLabel * lblSMO = new QLabel(this); |
|
2026 lblSMO->setText(tr("Server message for previous versions:")); |
|
2027 pageLayout->addWidget(lblSMO, 2, 0); |
|
2028 |
|
2029 leServerMessageOld = new QLineEdit(this); |
|
2030 pageLayout->addWidget(leServerMessageOld, 2, 1); |
|
2031 |
|
2032 // 3 |
|
2033 QLabel * lblP = new QLabel(this); |
|
2034 lblP->setText(tr("Latest version protocol number:")); |
|
2035 pageLayout->addWidget(lblP, 3, 0); |
|
2036 |
|
2037 sbProtocol = new QSpinBox(this); |
|
2038 pageLayout->addWidget(sbProtocol, 3, 1); |
|
2039 |
|
2040 // 4 |
|
2041 QLabel * lblPreview = new QLabel(this); |
|
2042 lblPreview->setText(tr("MOTD preview:")); |
|
2043 pageLayout->addWidget(lblPreview, 4, 0); |
|
2044 |
|
2045 tb = new QTextBrowser(this); |
|
2046 tb->setOpenExternalLinks(true); |
|
2047 tb->document()->setDefaultStyleSheet(HWChatWidget::STYLE); |
|
2048 pageLayout->addWidget(tb, 4, 1, 1, 2); |
|
2049 connect(leServerMessageNew, SIGNAL(textEdited(const QString &)), tb, SLOT(setHtml(const QString &))); |
|
2050 connect(leServerMessageOld, SIGNAL(textEdited(const QString &)), tb, SLOT(setHtml(const QString &))); |
|
2051 |
|
2052 // 5 |
|
2053 pbClearAccountsCache = addButton(tr("Clear Accounts Cache"), pageLayout, 5, 0); |
|
2054 |
|
2055 // 6 |
|
2056 pbSetSM = addButton(tr("Set data"), pageLayout, 6, 0, 1, 3); |
|
2057 |
|
2058 // 7 |
|
2059 BtnBack = addButton(":/res/Exit.png", pageLayout, 7, 0, true); |
|
2060 |
|
2061 connect(pbSetSM, SIGNAL(clicked()), this, SLOT(smChanged())); |
|
2062 } |
|
2063 |
|
2064 void PageAdmin::smChanged() |
|
2065 { |
|
2066 emit setServerMessageNew(leServerMessageNew->text()); |
|
2067 emit setServerMessageOld(leServerMessageOld->text()); |
|
2068 emit setProtocol(sbProtocol->value()); |
|
2069 } |
|
2070 |
|
2071 void PageAdmin::serverMessageNew(const QString & str) |
|
2072 { |
|
2073 leServerMessageNew->setText(str); |
|
2074 } |
|
2075 |
|
2076 void PageAdmin::serverMessageOld(const QString & str) |
|
2077 { |
|
2078 leServerMessageOld->setText(str); |
|
2079 } |
|
2080 void PageAdmin::protocol(int proto) |
|
2081 { |
|
2082 sbProtocol->setValue(proto); |
|
2083 } |
|
2084 |
|
2085 ///////////////////////////////////////////////// |
|
2086 |
|
2087 PageNetType::PageNetType(QWidget* parent) : AbstractPage(parent) |
|
2088 { |
|
2089 QGridLayout * pageLayout = new QGridLayout(this); |
|
2090 pageLayout->setRowStretch(0, 10); |
|
2091 pageLayout->setRowStretch(3, 10); |
|
2092 |
|
2093 pageLayout->setColumnStretch(1, 10); |
|
2094 pageLayout->setColumnStretch(2, 20); |
|
2095 pageLayout->setColumnStretch(3, 10); |
|
2096 |
|
2097 BtnLAN = addButton(tr("LAN game"), pageLayout, 1, 2); |
|
2098 BtnOfficialServer = addButton(tr("Official server"), pageLayout, 2, 2); |
|
2099 |
|
2100 // hack: temporary deactivated - requires server modifications that aren't backward compatible (yet) |
|
2101 //BtnOfficialServer->setEnabled(false); |
|
2102 |
|
2103 BtnBack = addButton(":/res/Exit.png", pageLayout, 4, 0, true); |
|
2104 } |
|
2105 |
|
2106 ///////////////////////////////////////////////// |
|
2107 |
|
2108 PageDrawMap::PageDrawMap(QWidget* parent) : AbstractPage(parent) |
|
2109 { |
|
2110 QGridLayout * pageLayout = new QGridLayout(this); |
|
2111 |
|
2112 QPushButton * pbUndo = addButton(tr("Undo"), pageLayout, 0, 0); |
|
2113 QPushButton * pbClear = addButton(tr("Clear"), pageLayout, 1, 0); |
|
2114 QPushButton * pbLoad = addButton(tr("Load"), pageLayout, 2, 0); |
|
2115 QPushButton * pbSave = addButton(tr("Save"), pageLayout, 3, 0); |
|
2116 |
|
2117 BtnBack = addButton(":/res/Exit.png", pageLayout, 5, 0, true); |
|
2118 |
|
2119 drawMapWidget = new DrawMapWidget(this); |
|
2120 pageLayout->addWidget(drawMapWidget, 0, 1, 5, 1); |
|
2121 |
|
2122 connect(pbUndo, SIGNAL(clicked()), drawMapWidget, SLOT(undo())); |
|
2123 connect(pbClear, SIGNAL(clicked()), drawMapWidget, SLOT(clear())); |
|
2124 connect(pbLoad, SIGNAL(clicked()), this, SLOT(load())); |
|
2125 connect(pbSave, SIGNAL(clicked()), this, SLOT(save())); |
|
2126 } |
|
2127 |
|
2128 void PageDrawMap::load() |
|
2129 { |
|
2130 QString fileName = QFileDialog::getOpenFileName(this, tr("Load drawn map"), ".", tr("Drawn Maps (*.hwmap);;All files (*.*)")); |
|
2131 |
|
2132 if(!fileName.isEmpty()) |
|
2133 drawMapWidget->load(fileName); |
|
2134 } |
|
2135 |
|
2136 void PageDrawMap::save() |
|
2137 { |
|
2138 QString fileName = QFileDialog::getSaveFileName(this, tr("Save drawn map"), ".", tr("Drawn Maps (*.hwmap);;All files (*.*)")); |
|
2139 |
|
2140 if(!fileName.isEmpty()) |
|
2141 drawMapWidget->save(fileName); |
|
2142 } |
|