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