author | displacer |
Sun, 04 Feb 2007 21:30:23 +0000 | |
changeset 390 | dca6bd77d71d |
parent 383 | 09a8795105a4 |
child 407 | c7890ba9ed6e |
permissions | -rw-r--r-- |
184 | 1 |
/* |
2 |
* Hedgewars, a worms-like game |
|
3 |
* Copyright (c) 2005, 2006 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 <QtGui> |
|
20 |
#include <QStringList> |
|
21 |
#include <QProcess> |
|
22 |
#include <QDir> |
|
23 |
#include <QPixmap> |
|
24 |
#include <QRegExp> |
|
25 |
#include <QIcon> |
|
26 |
#include <QFile> |
|
27 |
#include <QTextStream> |
|
28 |
||
29 |
#include "hwform.h" |
|
30 |
#include "game.h" |
|
31 |
#include "team.h" |
|
32 |
#include "netclient.h" |
|
33 |
#include "teamselect.h" |
|
34 |
#include "gameuiconfig.h" |
|
35 |
#include "pages.h" |
|
36 |
#include "hwconsts.h" |
|
314 | 37 |
#include "newnetclient.h" |
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
328
diff
changeset
|
38 |
#include "gamecfgwidget.h" |
184 | 39 |
|
40 |
HWForm::HWForm(QWidget *parent) |
|
314 | 41 |
: QMainWindow(parent), pnetserver(0) |
184 | 42 |
{ |
43 |
ui.setupUi(this); |
|
44 |
||
301 | 45 |
config = new GameUIConfig(this, cfgdir->absolutePath() + "/hedgewars.ini"); |
184 | 46 |
|
245 | 47 |
UpdateTeamsLists(); |
184 | 48 |
|
49 |
connect(ui.pageMain->BtnSinglePlayer, SIGNAL(clicked()), this, SLOT(GoToSinglePlayer())); |
|
50 |
connect(ui.pageMain->BtnSetup, SIGNAL(clicked()), this, SLOT(GoToSetup())); |
|
51 |
connect(ui.pageMain->BtnMultiplayer, SIGNAL(clicked()), this, SLOT(GoToMultiplayer())); |
|
52 |
connect(ui.pageMain->BtnDemos, SIGNAL(clicked()), this, SLOT(GoToDemos())); |
|
53 |
connect(ui.pageMain->BtnNet, SIGNAL(clicked()), this, SLOT(GoToNet())); |
|
187 | 54 |
connect(ui.pageMain->BtnInfo, SIGNAL(clicked()), this, SLOT(GoToInfo())); |
184 | 55 |
connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(close())); |
56 |
||
289 | 57 |
connect(ui.pageLocalGame->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
184 | 58 |
connect(ui.pageLocalGame->BtnSimpleGame, SIGNAL(clicked()), this, SLOT(SimpleGame())); |
59 |
||
60 |
connect(ui.pageEditTeam->BtnTeamSave, SIGNAL(clicked()), this, SLOT(TeamSave())); |
|
61 |
connect(ui.pageEditTeam->BtnTeamDiscard, SIGNAL(clicked()), this, SLOT(TeamDiscard())); |
|
62 |
||
289 | 63 |
connect(ui.pageMultiplayer->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
184 | 64 |
connect(ui.pageMultiplayer->BtnStartMPGame, SIGNAL(clicked()), this, SLOT(StartMPGame())); |
65 |
||
289 | 66 |
connect(ui.pagePlayDemo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
184 | 67 |
connect(ui.pagePlayDemo->BtnPlayDemo, SIGNAL(clicked()), this, SLOT(PlayDemo())); |
247
07605d2a2024
- Fix infinite loop when selecting weapon with ammo menu
unc0rr
parents:
245
diff
changeset
|
68 |
connect(ui.pagePlayDemo->DemosList, SIGNAL(doubleClicked (const QModelIndex &)), this, SLOT(PlayDemo())); |
184 | 69 |
|
289 | 70 |
connect(ui.pageOptions->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
184 | 71 |
connect(ui.pageOptions->BtnNewTeam, SIGNAL(clicked()), this, SLOT(NewTeam())); |
72 |
connect(ui.pageOptions->BtnEditTeam, SIGNAL(clicked()), this, SLOT(EditTeam())); |
|
73 |
connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), config, SLOT(SaveOptions())); |
|
312 | 74 |
connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), this, SLOT(GoBack())); |
184 | 75 |
|
289 | 76 |
connect(ui.pageNet->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
184 | 77 |
connect(ui.pageNet->BtnNetConnect, SIGNAL(clicked()), this, SLOT(NetConnect())); |
314 | 78 |
connect(ui.pageNet->BtnNetSvrStart, SIGNAL(clicked()), this, SLOT(NetStartServer())); |
184 | 79 |
|
289 | 80 |
connect(ui.pageNetGame->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
184 | 81 |
connect(ui.pageNetGame->BtnGo, SIGNAL(clicked()), this, SLOT(NetStartGame())); |
82 |
||
83 |
connect(ui.pageNetChat->BtnDisconnect, SIGNAL(clicked()), this, SLOT(NetDisconnect())); |
|
84 |
connect(ui.pageNetChat->BtnJoin, SIGNAL(clicked()), this, SLOT(NetJoin())); |
|
85 |
connect(ui.pageNetChat->BtnCreate, SIGNAL(clicked()), this, SLOT(NetCreate())); |
|
86 |
||
289 | 87 |
connect(ui.pageInfo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
187 | 88 |
|
306 | 89 |
connect(ui.pageGameStats->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
90 |
||
311 | 91 |
connect(ui.pageMultiplayer->teamsSelect, SIGNAL(NewTeam()), this, SLOT(NewTeam())); |
92 |
||
290 | 93 |
GoToPage(ID_PAGE_MAIN); |
184 | 94 |
} |
95 |
||
245 | 96 |
void HWForm::UpdateTeamsLists() |
97 |
{ |
|
98 |
QStringList teamslist = config->GetTeamsList(); |
|
99 |
||
100 |
if(teamslist.empty()) { |
|
101 |
HWTeam defaultTeam("DefaultTeam"); |
|
102 |
defaultTeam.SaveToFile(); |
|
103 |
teamslist.push_back("DefaultTeam"); |
|
104 |
} |
|
105 |
||
106 |
ui.pageOptions->CBTeamName->clear(); |
|
107 |
ui.pageOptions->CBTeamName->addItems(teamslist); |
|
108 |
} |
|
109 |
||
184 | 110 |
void HWForm::GoToMain() |
111 |
{ |
|
289 | 112 |
GoToPage(ID_PAGE_MAIN); |
184 | 113 |
} |
114 |
||
115 |
void HWForm::GoToSinglePlayer() |
|
116 |
{ |
|
289 | 117 |
GoToPage(ID_PAGE_SINGLEPLAYER); |
184 | 118 |
} |
119 |
||
120 |
void HWForm::GoToSetup() |
|
121 |
{ |
|
289 | 122 |
GoToPage(ID_PAGE_SETUP); |
184 | 123 |
} |
124 |
||
187 | 125 |
void HWForm::GoToInfo() |
126 |
{ |
|
289 | 127 |
GoToPage(ID_PAGE_INFO); |
187 | 128 |
} |
129 |
||
184 | 130 |
void HWForm::GoToMultiplayer() |
131 |
{ |
|
290 | 132 |
GoToPage(ID_PAGE_MULTIPLAYER); |
184 | 133 |
} |
134 |
||
135 |
void HWForm::GoToDemos() |
|
136 |
{ |
|
137 |
QDir tmpdir; |
|
138 |
tmpdir.cd(cfgdir->absolutePath()); |
|
139 |
tmpdir.cd("Demos"); |
|
140 |
tmpdir.setFilter(QDir::Files); |
|
141 |
ui.pagePlayDemo->DemosList->clear(); |
|
271 | 142 |
ui.pagePlayDemo->DemosList->addItems(tmpdir.entryList(QStringList("*.hwd_" + cProtoVer)) |
143 |
.replaceInStrings(QRegExp("^(.*).hwd_" + cProtoVer), "\\1")); |
|
290 | 144 |
GoToPage(ID_PAGE_DEMOS); |
184 | 145 |
} |
146 |
||
147 |
void HWForm::GoToNet() |
|
148 |
{ |
|
289 | 149 |
GoToPage(ID_PAGE_NET); |
184 | 150 |
} |
151 |
||
152 |
void HWForm::GoToNetChat() |
|
153 |
{ |
|
289 | 154 |
GoToPage(ID_PAGE_NETCHAT); |
155 |
} |
|
156 |
||
311 | 157 |
void HWForm::OnPageShown(quint8 id) |
158 |
{ |
|
322 | 159 |
if (id == ID_PAGE_MULTIPLAYER || id == ID_PAGE_NETCFG) { |
311 | 160 |
QStringList tmNames=config->GetTeamsList(); |
322 | 161 |
TeamSelWidget* curTeamSelWidget; |
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
162 |
id == ID_PAGE_MULTIPLAYER ? curTeamSelWidget=ui.pageMultiplayer->teamsSelect : |
322 | 163 |
curTeamSelWidget=ui.pageNetGame->pNetTeamsWidget; |
311 | 164 |
QList<HWTeam> teamsList; |
165 |
for(QStringList::iterator it=tmNames.begin(); it!=tmNames.end(); it++) { |
|
166 |
HWTeam team(*it); |
|
167 |
team.LoadFromFile(); |
|
168 |
teamsList.push_back(team); |
|
169 |
} |
|
322 | 170 |
curTeamSelWidget->resetPlayingTeams(teamsList); |
311 | 171 |
} |
172 |
} |
|
173 |
||
289 | 174 |
void HWForm::GoToPage(quint8 id) |
175 |
{ |
|
176 |
PagesStack.push(ui.Pages->currentIndex()); |
|
311 | 177 |
OnPageShown(id); |
289 | 178 |
ui.Pages->setCurrentIndex(id); |
179 |
} |
|
180 |
||
181 |
void HWForm::GoBack() |
|
182 |
{ |
|
350 | 183 |
if (!PagesStack.isEmpty() && PagesStack.top() == ID_PAGE_NET) { |
383 | 184 |
if(hwnet || pnetserver) NetDisconnect(); |
350 | 185 |
} |
289 | 186 |
quint8 id = PagesStack.isEmpty() ? ID_PAGE_MAIN : PagesStack.pop(); |
311 | 187 |
OnPageShown(id); |
289 | 188 |
ui.Pages->setCurrentIndex(id); |
184 | 189 |
} |
190 |
||
191 |
void HWForm::NewTeam() |
|
192 |
{ |
|
245 | 193 |
editedTeam = new HWTeam("unnamed"); |
194 |
editedTeam->SetToPage(this); |
|
290 | 195 |
GoToPage(ID_PAGE_SETUP_TEAM); |
184 | 196 |
} |
197 |
||
198 |
void HWForm::EditTeam() |
|
199 |
{ |
|
245 | 200 |
editedTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText()); |
201 |
editedTeam->LoadFromFile(); |
|
202 |
editedTeam->SetToPage(this); |
|
290 | 203 |
GoToPage(ID_PAGE_SETUP_TEAM); |
184 | 204 |
} |
205 |
||
206 |
void HWForm::TeamSave() |
|
207 |
{ |
|
245 | 208 |
editedTeam->GetFromPage(this); |
209 |
editedTeam->SaveToFile(); |
|
210 |
delete editedTeam; |
|
211 |
UpdateTeamsLists(); |
|
290 | 212 |
GoBack(); |
184 | 213 |
} |
214 |
||
215 |
void HWForm::TeamDiscard() |
|
216 |
{ |
|
245 | 217 |
delete editedTeam; |
290 | 218 |
GoBack(); |
184 | 219 |
} |
220 |
||
221 |
void HWForm::SimpleGame() |
|
222 |
{ |
|
341 | 223 |
CreateGame(ui.pageLocalGame->gameCFG, 0); |
184 | 224 |
game->StartQuick(); |
225 |
} |
|
226 |
||
227 |
void HWForm::PlayDemo() |
|
228 |
{ |
|
229 |
QListWidgetItem * curritem = ui.pagePlayDemo->DemosList->currentItem(); |
|
230 |
if (!curritem) |
|
231 |
{ |
|
232 |
QMessageBox::critical(this, |
|
233 |
tr("Error"), |
|
234 |
tr("Please, select demo from the list above"), |
|
235 |
tr("OK")); |
|
236 |
return ; |
|
237 |
} |
|
341 | 238 |
CreateGame(0, 0); |
271 | 239 |
game->PlayDemo(cfgdir->absolutePath() + "/Demos/" + curritem->text() + ".hwd_" + cProtoVer); |
184 | 240 |
} |
241 |
||
314 | 242 |
void HWForm::_NetConnect(const QString & hostName, quint16 port, const QString & nick) |
184 | 243 |
{ |
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
244 |
hwnet = new HWNewNet(config, ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget); |
184 | 245 |
connect(hwnet, SIGNAL(AddGame(const QString &)), this, SLOT(AddGame(const QString &))); |
246 |
connect(hwnet, SIGNAL(EnteredGame()), this, SLOT(NetGameEnter())); |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
247 |
connect(hwnet, SIGNAL(AddNetTeam(const HWTeam&)), this, SLOT(AddNetTeam(const HWTeam&))); |
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
328
diff
changeset
|
248 |
|
352 | 249 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(hhogsNumChanged(const HWTeam&)), |
250 |
hwnet, SLOT(onHedgehogsNumChanged(const HWTeam&))); |
|
372 | 251 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamColorChanged(const HWTeam&)), |
252 |
hwnet, SLOT(onTeamColorChanged(const HWTeam&))); |
|
327 | 253 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamWillPlay(HWTeam)), hwnet, SLOT(AddTeam(HWTeam))); |
373 | 254 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(acceptRequested(HWTeam)), hwnet, SLOT(AddTeam(HWTeam))); |
347 | 255 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamNotPlaying(const HWTeam&)), hwnet, SLOT(RemoveTeam(const HWTeam&))); |
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
328
diff
changeset
|
256 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
328
diff
changeset
|
257 |
connect(ui.pageNetGame->pGameCFG, SIGNAL(seedChanged(const QString &)), hwnet, SLOT(onSeedChanged(const QString &))); |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
328
diff
changeset
|
258 |
connect(ui.pageNetGame->pGameCFG, SIGNAL(mapChanged(const QString &)), hwnet, SLOT(onMapChanged(const QString &))); |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
328
diff
changeset
|
259 |
connect(ui.pageNetGame->pGameCFG, SIGNAL(themeChanged(const QString &)), hwnet, SLOT(onThemeChanged(const QString &))); |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
328
diff
changeset
|
260 |
connect(ui.pageNetGame->pGameCFG, SIGNAL(initHealthChanged(quint32)), hwnet, SLOT(onInitHealthChanged(quint32))); |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
328
diff
changeset
|
261 |
connect(ui.pageNetGame->pGameCFG, SIGNAL(turnTimeChanged(quint32)), hwnet, SLOT(onTurnTimeChanged(quint32))); |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
328
diff
changeset
|
262 |
connect(ui.pageNetGame->pGameCFG, SIGNAL(fortsModeChanged(bool)), hwnet, SLOT(onFortsModeChanged(bool))); |
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
328
diff
changeset
|
263 |
|
383 | 264 |
connect(hwnet, SIGNAL(Disconnected()), this, SLOT(ForcedDisconnect())); |
330 | 265 |
connect(hwnet, SIGNAL(seedChanged(const QString &)), ui.pageNetGame->pGameCFG, SLOT(setSeed(const QString &))); |
266 |
connect(hwnet, SIGNAL(mapChanged(const QString &)), ui.pageNetGame->pGameCFG, SLOT(setMap(const QString &))); |
|
267 |
connect(hwnet, SIGNAL(themeChanged(const QString &)), ui.pageNetGame->pGameCFG, SLOT(setTheme(const QString &))); |
|
268 |
connect(hwnet, SIGNAL(initHealthChanged(quint32)), ui.pageNetGame->pGameCFG, SLOT(setInitHealth(quint32))); |
|
269 |
connect(hwnet, SIGNAL(turnTimeChanged(quint32)), ui.pageNetGame->pGameCFG, SLOT(setTurnTime(quint32))); |
|
270 |
connect(hwnet, SIGNAL(fortsModeChanged(bool)), ui.pageNetGame->pGameCFG, SLOT(setFortsMode(bool))); |
|
352 | 271 |
connect(hwnet, SIGNAL(hhnumChanged(const HWTeam&)), |
272 |
ui.pageNetGame->pNetTeamsWidget, SLOT(changeHHNum(const HWTeam&))); |
|
372 | 273 |
connect(hwnet, SIGNAL(teamColorChanged(const HWTeam&)), |
274 |
ui.pageNetGame->pNetTeamsWidget, SLOT(changeTeamColor(const HWTeam&))); |
|
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
328
diff
changeset
|
275 |
|
314 | 276 |
hwnet->Connect(hostName, port, nick); |
184 | 277 |
config->SaveOptions(); |
278 |
} |
|
279 |
||
314 | 280 |
void HWForm::NetConnect() |
281 |
{ |
|
282 |
_NetConnect(ui.pageNet->editIP->text(), 46631, ui.pageNet->editNetNick->text()); |
|
283 |
} |
|
284 |
||
285 |
void HWForm::NetStartServer() |
|
286 |
{ |
|
287 |
pnetserver = new HWNetServer; |
|
288 |
pnetserver->StartServer(); |
|
289 |
_NetConnect(pnetserver->getRunningHostName(), pnetserver->getRunningPort(), ui.pageNet->editNetNick->text()); |
|
290 |
} |
|
291 |
||
184 | 292 |
void HWForm::NetDisconnect() |
293 |
{ |
|
383 | 294 |
if(hwnet) { |
295 |
hwnet->Disconnect(); |
|
296 |
delete hwnet; |
|
297 |
hwnet=0; |
|
298 |
} |
|
314 | 299 |
if(pnetserver) { |
300 |
pnetserver->StopServer(); |
|
301 |
delete pnetserver; |
|
302 |
pnetserver=0; |
|
303 |
} |
|
184 | 304 |
} |
305 |
||
383 | 306 |
void HWForm::ForcedDisconnect() |
307 |
{ |
|
308 |
if(pnetserver) return; // we have server - let it care of all things |
|
309 |
if (hwnet) { |
|
310 |
hwnet->deleteLater(); |
|
311 |
hwnet=0; |
|
312 |
} |
|
313 |
GoBack(); |
|
314 |
} |
|
315 |
||
184 | 316 |
void HWForm::AddGame(const QString & chan) |
317 |
{ |
|
318 |
ui.pageNetChat->ChannelsList->addItem(chan); |
|
319 |
} |
|
320 |
||
321 |
void HWForm::NetGameEnter() |
|
322 |
{ |
|
290 | 323 |
GoToPage(ID_PAGE_NETCFG); |
184 | 324 |
} |
325 |
||
326 |
void HWForm::NetJoin() |
|
327 |
{ |
|
328 |
hwnet->JoinGame("#hw"); |
|
329 |
} |
|
330 |
||
331 |
void HWForm::NetCreate() |
|
332 |
{ |
|
333 |
hwnet->JoinGame("#hw"); |
|
334 |
} |
|
335 |
||
336 |
void HWForm::NetStartGame() |
|
337 |
{ |
|
338 |
hwnet->StartGame(); |
|
339 |
} |
|
340 |
||
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
341 |
void HWForm::AddNetTeam(const HWTeam& team) |
184 | 342 |
{ |
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
343 |
ui.pageNetGame->pNetTeamsWidget->addTeam(team); |
184 | 344 |
} |
345 |
||
346 |
void HWForm::StartMPGame() |
|
347 |
{ |
|
341 | 348 |
CreateGame(ui.pageMultiplayer->gameCFG, ui.pageMultiplayer->teamsSelect); |
306 | 349 |
|
184 | 350 |
game->StartLocal(); |
351 |
} |
|
306 | 352 |
|
353 |
void HWForm::GameStateChanged(GameState gameState) |
|
354 |
{ |
|
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
355 |
switch(gameState) { |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
356 |
case gsStarted: { |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
357 |
ui.pageGameStats->labelGameStats->setText(""); |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
358 |
break; |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
359 |
} |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
360 |
case gsFinished: { |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
361 |
GoToPage(ID_PAGE_GAMESTATS); |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
362 |
break; |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
363 |
} |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
364 |
default: ; |
307 | 365 |
} |
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
366 |
|
307 | 367 |
} |
368 |
||
369 |
void HWForm::AddStatText(const QString & msg) |
|
370 |
{ |
|
371 |
ui.pageGameStats->labelGameStats->setText( |
|
372 |
ui.pageGameStats->labelGameStats->text() + msg); |
|
306 | 373 |
} |
374 |
||
375 |
void HWForm::GameStats(char type, const QString & info) |
|
376 |
{ |
|
377 |
switch(type) { |
|
307 | 378 |
case 'r' : { |
379 |
AddStatText(QString("<h1 align=\"center\">%1</h1>").arg(info)); |
|
380 |
break; |
|
381 |
} |
|
382 |
case 'D' : { |
|
383 |
int i = info.indexOf(' '); |
|
384 |
QString message = QLabel::tr("<p>The best shot award was won by <b>%1</b> with <b>%2</b> pts.</p>") |
|
385 |
.arg(info.mid(i + 1), info.left(i)); |
|
386 |
AddStatText(message); |
|
387 |
break; |
|
388 |
} |
|
389 |
case 'K' : { |
|
390 |
QString message = QLabel::tr("<p>A total of <b>%1</b> Hedgehog(s) were killed during this round.</p>").arg(info); |
|
391 |
AddStatText(message); |
|
392 |
break; |
|
393 |
} |
|
306 | 394 |
} |
395 |
} |
|
396 |
||
341 | 397 |
void HWForm::CreateGame(GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget) |
306 | 398 |
{ |
341 | 399 |
game = new HWGame(config, gamecfg, pTeamSelWidget); |
306 | 400 |
connect(game, SIGNAL(GameStateChanged(GameState)), this, SLOT(GameStateChanged(GameState))); |
401 |
connect(game, SIGNAL(GameStats(char, const QString &)), this, SLOT(GameStats(char, const QString &))); |
|
402 |
} |