author | displacer |
Thu, 20 Dec 2007 10:54:42 +0000 | |
changeset 683 | 57d624f71e65 |
parent 681 | 7a20c50988ec |
child 686 | 494b5880989a |
permissions | -rw-r--r-- |
184 | 1 |
/* |
2 |
* Hedgewars, a worms-like game |
|
486 | 3 |
* Copyright (c) 2005-2007 Andrey Korotaev <unC0Rr@gmail.com> |
184 | 4 |
* |
5 |
* This program is free software; you can redistribute it and/or modify |
|
6 |
* it under the terms of the GNU General Public License as published by |
|
7 |
* the Free Software Foundation; version 2 of the License |
|
8 |
* |
|
9 |
* This program is distributed in the hope that it will be useful, |
|
10 |
* but WITHOUT ANY WARRANTY; without even the implied warranty of |
|
11 |
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the |
|
12 |
* GNU General Public License for more details. |
|
13 |
* |
|
14 |
* You should have received a copy of the GNU General Public License |
|
15 |
* along with this program; if not, write to the Free Software |
|
16 |
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA |
|
17 |
*/ |
|
18 |
||
19 |
#include <QStringList> |
|
20 |
#include <QProcess> |
|
21 |
#include <QDir> |
|
22 |
#include <QPixmap> |
|
23 |
#include <QRegExp> |
|
24 |
#include <QIcon> |
|
25 |
#include <QFile> |
|
26 |
#include <QTextStream> |
|
407 | 27 |
#include <QMessageBox> |
502
bc178daca088
Fix build with CMake & gcc 4.1.2 on my system (treating #include <QtGui> as including directory)
unc0rr
parents:
496
diff
changeset
|
28 |
#include <QPushButton> |
bc178daca088
Fix build with CMake & gcc 4.1.2 on my system (treating #include <QtGui> as including directory)
unc0rr
parents:
496
diff
changeset
|
29 |
#include <QListWidget> |
bc178daca088
Fix build with CMake & gcc 4.1.2 on my system (treating #include <QtGui> as including directory)
unc0rr
parents:
496
diff
changeset
|
30 |
#include <QStackedLayout> |
bc178daca088
Fix build with CMake & gcc 4.1.2 on my system (treating #include <QtGui> as including directory)
unc0rr
parents:
496
diff
changeset
|
31 |
#include <QLineEdit> |
bc178daca088
Fix build with CMake & gcc 4.1.2 on my system (treating #include <QtGui> as including directory)
unc0rr
parents:
496
diff
changeset
|
32 |
#include <QLabel> |
636 | 33 |
#include <QRadioButton> |
654 | 34 |
#include <QSpinBox> |
674 | 35 |
#include <QCloseEvent> |
184 | 36 |
|
37 |
#include "hwform.h" |
|
38 |
#include "game.h" |
|
39 |
#include "team.h" |
|
40 |
#include "teamselect.h" |
|
681 | 41 |
#include "selectWeapon.h" |
184 | 42 |
#include "gameuiconfig.h" |
43 |
#include "pages.h" |
|
44 |
#include "hwconsts.h" |
|
314 | 45 |
#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
|
46 |
#include "gamecfgwidget.h" |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
625
diff
changeset
|
47 |
#include "netserverslist.h" |
634 | 48 |
#include "netudpserver.h" |
49 |
#include "netwwwserver.h" |
|
461 | 50 |
#include "chatwidget.h" |
579 | 51 |
#include "playrecordpage.h" |
653
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
52 |
#include "input_ip.h" |
184 | 53 |
|
54 |
HWForm::HWForm(QWidget *parent) |
|
637
8fa7ed5e13bd
Fix bad behavior when quickly click Connect button more than once
unc0rr
parents:
636
diff
changeset
|
55 |
: QMainWindow(parent), pnetserver(0), pRegisterServer(0), editedTeam(0), hwnet(0) |
184 | 56 |
{ |
57 |
ui.setupUi(this); |
|
301 | 58 |
config = new GameUIConfig(this, cfgdir->absolutePath() + "/hedgewars.ini"); |
184 | 59 |
|
245 | 60 |
UpdateTeamsLists(); |
184 | 61 |
|
62 |
connect(ui.pageMain->BtnSinglePlayer, SIGNAL(clicked()), this, SLOT(GoToSinglePlayer())); |
|
63 |
connect(ui.pageMain->BtnSetup, SIGNAL(clicked()), this, SLOT(GoToSetup())); |
|
64 |
connect(ui.pageMain->BtnMultiplayer, SIGNAL(clicked()), this, SLOT(GoToMultiplayer())); |
|
579 | 65 |
connect(ui.pageMain->BtnLoad, SIGNAL(clicked()), this, SLOT(GoToSaves())); |
184 | 66 |
connect(ui.pageMain->BtnDemos, SIGNAL(clicked()), this, SLOT(GoToDemos())); |
67 |
connect(ui.pageMain->BtnNet, SIGNAL(clicked()), this, SLOT(GoToNet())); |
|
187 | 68 |
connect(ui.pageMain->BtnInfo, SIGNAL(clicked()), this, SLOT(GoToInfo())); |
530 | 69 |
connect(ui.pageMain->BtnExit, SIGNAL(pressed()), this, SLOT(btnExitPressed())); |
70 |
connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(btnExitClicked())); |
|
184 | 71 |
|
585
7531ae5b146e
Rename PageLocalGame -> PageSimpleGame due to future changes
unc0rr
parents:
581
diff
changeset
|
72 |
connect(ui.pageSimpleGame->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
7531ae5b146e
Rename PageLocalGame -> PageSimpleGame due to future changes
unc0rr
parents:
581
diff
changeset
|
73 |
connect(ui.pageSimpleGame->BtnSimpleGame, SIGNAL(clicked()), this, SLOT(SimpleGame())); |
184 | 74 |
|
75 |
connect(ui.pageEditTeam->BtnTeamSave, SIGNAL(clicked()), this, SLOT(TeamSave())); |
|
76 |
connect(ui.pageEditTeam->BtnTeamDiscard, SIGNAL(clicked()), this, SLOT(TeamDiscard())); |
|
77 |
||
289 | 78 |
connect(ui.pageMultiplayer->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
184 | 79 |
connect(ui.pageMultiplayer->BtnStartMPGame, SIGNAL(clicked()), this, SLOT(StartMPGame())); |
493 | 80 |
connect(ui.pageMultiplayer->teamsSelect, SIGNAL(setEnabledGameStart(bool)), |
492 | 81 |
ui.pageMultiplayer->BtnStartMPGame, SLOT(setEnabled(bool))); |
586 | 82 |
connect(ui.pageMultiplayer->teamsSelect, SIGNAL(SetupClicked()), this, SLOT(IntermediateSetup())); |
184 | 83 |
|
289 | 84 |
connect(ui.pagePlayDemo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
184 | 85 |
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
|
86 |
connect(ui.pagePlayDemo->DemosList, SIGNAL(doubleClicked (const QModelIndex &)), this, SLOT(PlayDemo())); |
184 | 87 |
|
289 | 88 |
connect(ui.pageOptions->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
184 | 89 |
connect(ui.pageOptions->BtnNewTeam, SIGNAL(clicked()), this, SLOT(NewTeam())); |
90 |
connect(ui.pageOptions->BtnEditTeam, SIGNAL(clicked()), this, SLOT(EditTeam())); |
|
91 |
connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), config, SLOT(SaveOptions())); |
|
312 | 92 |
connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), this, SLOT(GoBack())); |
600 | 93 |
connect(ui.pageOptions->WeaponsButt, SIGNAL(clicked()), this, SLOT(GoToSelectWeapon())); |
184 | 94 |
|
289 | 95 |
connect(ui.pageNet->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
653
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
96 |
connect(ui.pageNet->BtnSpecifyServer, SIGNAL(clicked()), this, SLOT(NetConnect())); |
646 | 97 |
connect(ui.pageNet->BtnNetSvrStart, SIGNAL(clicked()), this, SLOT(GoToNetServer())); |
666 | 98 |
connect(ui.pageNet, SIGNAL(connectClicked(const QString &, quint16)), this, SLOT(NetConnectServer(const QString &, quint16))); |
646 | 99 |
|
100 |
connect(ui.pageNetServer->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
101 |
connect(ui.pageNetServer->BtnStart, SIGNAL(clicked()), this, SLOT(NetStartServer())); |
|
184 | 102 |
|
289 | 103 |
connect(ui.pageNetGame->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
184 | 104 |
connect(ui.pageNetGame->BtnGo, SIGNAL(clicked()), this, SLOT(NetStartGame())); |
493 | 105 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(setEnabledGameStart(bool)), |
492 | 106 |
ui.pageNetGame->BtnGo, SLOT(setEnabled(bool))); |
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
107 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(SetupClicked()), this, SLOT(IntermediateSetup())); |
184 | 108 |
|
289 | 109 |
connect(ui.pageInfo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
187 | 110 |
|
306 | 111 |
connect(ui.pageGameStats->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
112 |
||
586 | 113 |
connect(ui.pageSinglePlayer->BtnSimpleGamePage, SIGNAL(clicked()), this, SLOT(GoToSimpleGame())); |
587 | 114 |
connect(ui.pageSinglePlayer->BtnTrainPage, SIGNAL(clicked()), this, SLOT(GoToTraining())); |
586 | 115 |
connect(ui.pageSinglePlayer->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
311 | 116 |
|
587 | 117 |
connect(ui.pageTraining->BtnStartTrain, SIGNAL(clicked()), this, SLOT(StartTraining())); |
118 |
connect(ui.pageTraining->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
119 |
||
600 | 120 |
connect(ui.pageSelectWeapon->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
683 | 121 |
connect(ui.pageSelectWeapon->BtnDefault, SIGNAL(clicked()), ui.pageSelectWeapon->pWeapons, SLOT(setDefault())); |
122 |
connect(ui.pageSelectWeapon->BtnSave, SIGNAL(clicked()), ui.pageSelectWeapon->pWeapons, SLOT(save())); |
|
600 | 123 |
|
290 | 124 |
GoToPage(ID_PAGE_MAIN); |
184 | 125 |
} |
126 |
||
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
127 |
void HWForm::UpdateTeamsLists(const QStringList* editable_teams) |
245 | 128 |
{ |
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
129 |
QStringList teamslist; |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
130 |
if(editable_teams) { |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
131 |
teamslist=*editable_teams; |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
132 |
} else { |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
133 |
teamslist = config->GetTeamsList(); |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
134 |
} |
245 | 135 |
|
136 |
if(teamslist.empty()) { |
|
137 |
HWTeam defaultTeam("DefaultTeam"); |
|
138 |
defaultTeam.SaveToFile(); |
|
139 |
teamslist.push_back("DefaultTeam"); |
|
140 |
} |
|
141 |
||
142 |
ui.pageOptions->CBTeamName->clear(); |
|
143 |
ui.pageOptions->CBTeamName->addItems(teamslist); |
|
144 |
} |
|
145 |
||
184 | 146 |
void HWForm::GoToMain() |
147 |
{ |
|
289 | 148 |
GoToPage(ID_PAGE_MAIN); |
184 | 149 |
} |
150 |
||
151 |
void HWForm::GoToSinglePlayer() |
|
152 |
{ |
|
289 | 153 |
GoToPage(ID_PAGE_SINGLEPLAYER); |
184 | 154 |
} |
155 |
||
586 | 156 |
void HWForm::GoToSimpleGame() |
157 |
{ |
|
158 |
GoToPage(ID_PAGE_SIMPLEGAME); |
|
159 |
} |
|
160 |
||
587 | 161 |
void HWForm::GoToTraining() |
162 |
{ |
|
163 |
GoToPage(ID_PAGE_TRAINING); |
|
164 |
} |
|
165 |
||
184 | 166 |
void HWForm::GoToSetup() |
167 |
{ |
|
289 | 168 |
GoToPage(ID_PAGE_SETUP); |
184 | 169 |
} |
170 |
||
600 | 171 |
void HWForm::GoToSelectWeapon() |
172 |
{ |
|
173 |
GoToPage(ID_PAGE_SELECTWEAPON); |
|
174 |
} |
|
175 |
||
187 | 176 |
void HWForm::GoToInfo() |
177 |
{ |
|
289 | 178 |
GoToPage(ID_PAGE_INFO); |
187 | 179 |
} |
180 |
||
184 | 181 |
void HWForm::GoToMultiplayer() |
182 |
{ |
|
290 | 183 |
GoToPage(ID_PAGE_MULTIPLAYER); |
184 | 184 |
} |
185 |
||
579 | 186 |
void HWForm::GoToSaves() |
187 |
{ |
|
581 | 188 |
ui.pagePlayDemo->FillFromDir(PagePlayDemo::RT_Save); |
579 | 189 |
|
190 |
GoToPage(ID_PAGE_DEMOS); |
|
191 |
} |
|
192 |
||
184 | 193 |
void HWForm::GoToDemos() |
194 |
{ |
|
581 | 195 |
ui.pagePlayDemo->FillFromDir(PagePlayDemo::RT_Demo); |
579 | 196 |
|
290 | 197 |
GoToPage(ID_PAGE_DEMOS); |
184 | 198 |
} |
199 |
||
200 |
void HWForm::GoToNet() |
|
201 |
{ |
|
646 | 202 |
ui.pageNet->updateServersList(); |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
625
diff
changeset
|
203 |
|
289 | 204 |
GoToPage(ID_PAGE_NET); |
184 | 205 |
} |
206 |
||
646 | 207 |
void HWForm::GoToNetServer() |
208 |
{ |
|
209 |
GoToPage(ID_PAGE_NETSERVER); |
|
210 |
} |
|
211 |
||
496 | 212 |
void HWForm::OnPageShown(quint8 id, quint8 lastid) |
311 | 213 |
{ |
322 | 214 |
if (id == ID_PAGE_MULTIPLAYER || id == ID_PAGE_NETCFG) { |
311 | 215 |
QStringList tmNames=config->GetTeamsList(); |
322 | 216 |
TeamSelWidget* curTeamSelWidget; |
496 | 217 |
if(id == ID_PAGE_MULTIPLAYER) { |
218 |
curTeamSelWidget=ui.pageMultiplayer->teamsSelect; |
|
219 |
} else { |
|
322 | 220 |
curTeamSelWidget=ui.pageNetGame->pNetTeamsWidget; |
496 | 221 |
} |
311 | 222 |
QList<HWTeam> teamsList; |
223 |
for(QStringList::iterator it=tmNames.begin(); it!=tmNames.end(); it++) { |
|
224 |
HWTeam team(*it); |
|
225 |
team.LoadFromFile(); |
|
226 |
teamsList.push_back(team); |
|
227 |
} |
|
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
228 |
if(lastid==ID_PAGE_SETUP) { // _TEAM |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
229 |
if (editedTeam) { |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
230 |
curTeamSelWidget->addTeam(*editedTeam); |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
231 |
} |
496 | 232 |
} else { |
233 |
curTeamSelWidget->resetPlayingTeams(teamsList); |
|
234 |
} |
|
311 | 235 |
} |
236 |
} |
|
237 |
||
289 | 238 |
void HWForm::GoToPage(quint8 id) |
239 |
{ |
|
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
240 |
quint8 lastid=ui.Pages->currentIndex(); |
289 | 241 |
PagesStack.push(ui.Pages->currentIndex()); |
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
242 |
OnPageShown(id, lastid); |
289 | 243 |
ui.Pages->setCurrentIndex(id); |
244 |
} |
|
245 |
||
246 |
void HWForm::GoBack() |
|
247 |
{ |
|
350 | 248 |
if (!PagesStack.isEmpty() && PagesStack.top() == ID_PAGE_NET) { |
383 | 249 |
if(hwnet || pnetserver) NetDisconnect(); |
350 | 250 |
} |
289 | 251 |
quint8 id = PagesStack.isEmpty() ? ID_PAGE_MAIN : PagesStack.pop(); |
496 | 252 |
OnPageShown(id, ui.Pages->currentIndex()); |
289 | 253 |
ui.Pages->setCurrentIndex(id); |
184 | 254 |
} |
255 |
||
530 | 256 |
void HWForm::btnExitPressed() |
257 |
{ |
|
258 |
eggTimer.start(); |
|
259 |
} |
|
260 |
||
261 |
void HWForm::btnExitClicked() |
|
262 |
{ |
|
263 |
if (eggTimer.elapsed() < 3000) |
|
264 |
close(); |
|
265 |
else |
|
266 |
{ |
|
267 |
QPushButton * btn = findChild<QPushButton *>("imageButt"); |
|
268 |
if (btn) |
|
269 |
{ |
|
270 |
btn->setIcon(QIcon(":/res/bonus.png")); |
|
271 |
} |
|
272 |
} |
|
273 |
} |
|
274 |
||
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
275 |
void HWForm::IntermediateSetup() |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
276 |
{ |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
277 |
quint8 id=ui.Pages->currentIndex(); |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
278 |
TeamSelWidget* curTeamSelWidget; |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
279 |
if(id == ID_PAGE_MULTIPLAYER) { |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
280 |
curTeamSelWidget=ui.pageMultiplayer->teamsSelect; |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
281 |
} else { |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
282 |
curTeamSelWidget=ui.pageNetGame->pNetTeamsWidget; |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
283 |
} |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
284 |
QList<HWTeam> teams=curTeamSelWidget->getDontPlayingTeams(); |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
285 |
QStringList tmnames; |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
286 |
for(QList<HWTeam>::iterator it = teams.begin(); it != teams.end(); ++it) { |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
287 |
tmnames+=it->TeamName; |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
288 |
} |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
289 |
UpdateTeamsLists(&tmnames); // FIXME: still need more work if teamname is updated while configuring |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
290 |
|
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
291 |
GoToPage(ID_PAGE_SETUP); |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
292 |
} |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
293 |
|
184 | 294 |
void HWForm::NewTeam() |
295 |
{ |
|
245 | 296 |
editedTeam = new HWTeam("unnamed"); |
297 |
editedTeam->SetToPage(this); |
|
290 | 298 |
GoToPage(ID_PAGE_SETUP_TEAM); |
184 | 299 |
} |
300 |
||
301 |
void HWForm::EditTeam() |
|
302 |
{ |
|
245 | 303 |
editedTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText()); |
304 |
editedTeam->LoadFromFile(); |
|
305 |
editedTeam->SetToPage(this); |
|
290 | 306 |
GoToPage(ID_PAGE_SETUP_TEAM); |
184 | 307 |
} |
308 |
||
309 |
void HWForm::TeamSave() |
|
310 |
{ |
|
245 | 311 |
editedTeam->GetFromPage(this); |
312 |
editedTeam->SaveToFile(); |
|
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
313 |
delete editedTeam; |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
314 |
editedTeam=0; |
245 | 315 |
UpdateTeamsLists(); |
290 | 316 |
GoBack(); |
184 | 317 |
} |
318 |
||
319 |
void HWForm::TeamDiscard() |
|
320 |
{ |
|
245 | 321 |
delete editedTeam; |
496 | 322 |
editedTeam=0; |
290 | 323 |
GoBack(); |
184 | 324 |
} |
325 |
||
326 |
void HWForm::SimpleGame() |
|
327 |
{ |
|
585
7531ae5b146e
Rename PageLocalGame -> PageSimpleGame due to future changes
unc0rr
parents:
581
diff
changeset
|
328 |
CreateGame(ui.pageSimpleGame->gameCFG, 0); |
184 | 329 |
game->StartQuick(); |
330 |
} |
|
331 |
||
332 |
void HWForm::PlayDemo() |
|
333 |
{ |
|
334 |
QListWidgetItem * curritem = ui.pagePlayDemo->DemosList->currentItem(); |
|
335 |
if (!curritem) |
|
336 |
{ |
|
337 |
QMessageBox::critical(this, |
|
338 |
tr("Error"), |
|
581 | 339 |
tr("Please, select record from the list above"), |
184 | 340 |
tr("OK")); |
341 |
return ; |
|
342 |
} |
|
341 | 343 |
CreateGame(0, 0); |
580 | 344 |
game->PlayDemo(curritem->data(Qt::UserRole).toString()); |
184 | 345 |
} |
346 |
||
666 | 347 |
void HWForm::NetConnectServer(const QString & host, quint16 port) |
416 | 348 |
{ |
666 | 349 |
_NetConnect(host, port, ui.pageOptions->editNetNick->text()); |
416 | 350 |
} |
351 |
||
314 | 352 |
void HWForm::_NetConnect(const QString & hostName, quint16 port, const QString & nick) |
184 | 353 |
{ |
637
8fa7ed5e13bd
Fix bad behavior when quickly click Connect button more than once
unc0rr
parents:
636
diff
changeset
|
354 |
if(hwnet) { |
8fa7ed5e13bd
Fix bad behavior when quickly click Connect button more than once
unc0rr
parents:
636
diff
changeset
|
355 |
hwnet->Disconnect(); |
8fa7ed5e13bd
Fix bad behavior when quickly click Connect button more than once
unc0rr
parents:
636
diff
changeset
|
356 |
delete hwnet; |
8fa7ed5e13bd
Fix bad behavior when quickly click Connect button more than once
unc0rr
parents:
636
diff
changeset
|
357 |
hwnet=0; |
8fa7ed5e13bd
Fix bad behavior when quickly click Connect button more than once
unc0rr
parents:
636
diff
changeset
|
358 |
} |
465 | 359 |
ui.pageNetGame->pChatWidget->clear(); |
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
360 |
hwnet = new HWNewNet(config, ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget); |
637
8fa7ed5e13bd
Fix bad behavior when quickly click Connect button more than once
unc0rr
parents:
636
diff
changeset
|
361 |
|
660 | 362 |
connect(hwnet, SIGNAL(AskForRunGame()), this, SLOT(CreateNetGame())); |
184 | 363 |
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
|
364 |
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
|
365 |
|
471 | 366 |
connect(hwnet, SIGNAL(chatStringFromNet(const QStringList&)), |
461 | 367 |
ui.pageNetGame->pChatWidget, SLOT(onChatStringFromNet(const QStringList&))); |
368 |
connect(ui.pageNetGame->pChatWidget, SIGNAL(chatLine(const QString&)), |
|
369 |
hwnet, SLOT(chatLineToNet(const QString&))); |
|
471 | 370 |
connect(hwnet, SIGNAL(nickAdded(const QString&)), |
465 | 371 |
ui.pageNetGame->pChatWidget, SLOT(nickAdded(const QString&))); |
471 | 372 |
connect(hwnet, SIGNAL(nickRemoved(const QString&)), |
465 | 373 |
ui.pageNetGame->pChatWidget, SLOT(nickRemoved(const QString&))); |
461 | 374 |
|
352 | 375 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(hhogsNumChanged(const HWTeam&)), |
376 |
hwnet, SLOT(onHedgehogsNumChanged(const HWTeam&))); |
|
372 | 377 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamColorChanged(const HWTeam&)), |
378 |
hwnet, SLOT(onTeamColorChanged(const HWTeam&))); |
|
327 | 379 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamWillPlay(HWTeam)), hwnet, SLOT(AddTeam(HWTeam))); |
373 | 380 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(acceptRequested(HWTeam)), hwnet, SLOT(AddTeam(HWTeam))); |
347 | 381 |
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
|
382 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
328
diff
changeset
|
383 |
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
|
384 |
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
|
385 |
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
|
386 |
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
|
387 |
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
|
388 |
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
|
389 |
|
383 | 390 |
connect(hwnet, SIGNAL(Disconnected()), this, SLOT(ForcedDisconnect())); |
330 | 391 |
connect(hwnet, SIGNAL(seedChanged(const QString &)), ui.pageNetGame->pGameCFG, SLOT(setSeed(const QString &))); |
392 |
connect(hwnet, SIGNAL(mapChanged(const QString &)), ui.pageNetGame->pGameCFG, SLOT(setMap(const QString &))); |
|
393 |
connect(hwnet, SIGNAL(themeChanged(const QString &)), ui.pageNetGame->pGameCFG, SLOT(setTheme(const QString &))); |
|
394 |
connect(hwnet, SIGNAL(initHealthChanged(quint32)), ui.pageNetGame->pGameCFG, SLOT(setInitHealth(quint32))); |
|
395 |
connect(hwnet, SIGNAL(turnTimeChanged(quint32)), ui.pageNetGame->pGameCFG, SLOT(setTurnTime(quint32))); |
|
396 |
connect(hwnet, SIGNAL(fortsModeChanged(bool)), ui.pageNetGame->pGameCFG, SLOT(setFortsMode(bool))); |
|
425 | 397 |
connect(hwnet, SIGNAL(hhnumChanged(const HWTeam&)), |
352 | 398 |
ui.pageNetGame->pNetTeamsWidget, SLOT(changeHHNum(const HWTeam&))); |
425 | 399 |
connect(hwnet, SIGNAL(teamColorChanged(const HWTeam&)), |
372 | 400 |
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
|
401 |
|
314 | 402 |
hwnet->Connect(hostName, port, nick); |
184 | 403 |
} |
404 |
||
314 | 405 |
void HWForm::NetConnect() |
406 |
{ |
|
653
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
407 |
HWHostPortDialog * hpd = new HWHostPortDialog(this); |
654 | 408 |
hpd->leHost->setText(*netHost); |
409 |
hpd->sbPort->setValue(netPort); |
|
653
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
410 |
|
654 | 411 |
if (hpd->exec() == QDialog::Accepted) |
412 |
{ |
|
413 |
config->SaveOptions(); |
|
414 |
delete netHost; |
|
415 |
netHost = new QString(hpd->leHost->text()); |
|
416 |
netPort = hpd->sbPort->value(); |
|
417 |
_NetConnect(*netHost, netPort, ui.pageOptions->editNetNick->text()); |
|
418 |
} |
|
314 | 419 |
} |
420 |
||
421 |
void HWForm::NetStartServer() |
|
422 |
{ |
|
672
08ed55ea1e2a
- Fix a bug when server fails to start, and then connecting to another server on the same host (strange, the fix won't work on my machine)
unc0rr
parents:
668
diff
changeset
|
423 |
config->SaveOptions(); |
636 | 424 |
|
672
08ed55ea1e2a
- Fix a bug when server fails to start, and then connecting to another server on the same host (strange, the fix won't work on my machine)
unc0rr
parents:
668
diff
changeset
|
425 |
pnetserver = new HWNetServer; |
08ed55ea1e2a
- Fix a bug when server fails to start, and then connecting to another server on the same host (strange, the fix won't work on my machine)
unc0rr
parents:
668
diff
changeset
|
426 |
if(!pnetserver->StartServer(ui.pageNetServer->sbPort->value())) |
08ed55ea1e2a
- Fix a bug when server fails to start, and then connecting to another server on the same host (strange, the fix won't work on my machine)
unc0rr
parents:
668
diff
changeset
|
427 |
{ |
08ed55ea1e2a
- Fix a bug when server fails to start, and then connecting to another server on the same host (strange, the fix won't work on my machine)
unc0rr
parents:
668
diff
changeset
|
428 |
QMessageBox::critical(0, tr("Error"), |
08ed55ea1e2a
- Fix a bug when server fails to start, and then connecting to another server on the same host (strange, the fix won't work on my machine)
unc0rr
parents:
668
diff
changeset
|
429 |
tr("Unable to start the server")); |
08ed55ea1e2a
- Fix a bug when server fails to start, and then connecting to another server on the same host (strange, the fix won't work on my machine)
unc0rr
parents:
668
diff
changeset
|
430 |
delete pnetserver; |
08ed55ea1e2a
- Fix a bug when server fails to start, and then connecting to another server on the same host (strange, the fix won't work on my machine)
unc0rr
parents:
668
diff
changeset
|
431 |
pnetserver = 0; |
08ed55ea1e2a
- Fix a bug when server fails to start, and then connecting to another server on the same host (strange, the fix won't work on my machine)
unc0rr
parents:
668
diff
changeset
|
432 |
return; |
08ed55ea1e2a
- Fix a bug when server fails to start, and then connecting to another server on the same host (strange, the fix won't work on my machine)
unc0rr
parents:
668
diff
changeset
|
433 |
} |
08ed55ea1e2a
- Fix a bug when server fails to start, and then connecting to another server on the same host (strange, the fix won't work on my machine)
unc0rr
parents:
668
diff
changeset
|
434 |
|
08ed55ea1e2a
- Fix a bug when server fails to start, and then connecting to another server on the same host (strange, the fix won't work on my machine)
unc0rr
parents:
668
diff
changeset
|
435 |
_NetConnect("localhost", pnetserver->getRunningPort(), ui.pageOptions->editNetNick->text()); |
08ed55ea1e2a
- Fix a bug when server fails to start, and then connecting to another server on the same host (strange, the fix won't work on my machine)
unc0rr
parents:
668
diff
changeset
|
436 |
|
08ed55ea1e2a
- Fix a bug when server fails to start, and then connecting to another server on the same host (strange, the fix won't work on my machine)
unc0rr
parents:
668
diff
changeset
|
437 |
if (ui.pageNet->rbLocalGame->isChecked()) |
08ed55ea1e2a
- Fix a bug when server fails to start, and then connecting to another server on the same host (strange, the fix won't work on my machine)
unc0rr
parents:
668
diff
changeset
|
438 |
pRegisterServer = new HWNetUdpServer(0, ui.pageNetServer->leServerDescr->text(), ui.pageNetServer->sbPort->value()); |
08ed55ea1e2a
- Fix a bug when server fails to start, and then connecting to another server on the same host (strange, the fix won't work on my machine)
unc0rr
parents:
668
diff
changeset
|
439 |
else |
08ed55ea1e2a
- Fix a bug when server fails to start, and then connecting to another server on the same host (strange, the fix won't work on my machine)
unc0rr
parents:
668
diff
changeset
|
440 |
pRegisterServer = new HWNetWwwServer(0, ui.pageNetServer->leServerDescr->text(), ui.pageNetServer->sbPort->value()); |
314 | 441 |
} |
442 |
||
184 | 443 |
void HWForm::NetDisconnect() |
444 |
{ |
|
383 | 445 |
if(hwnet) { |
446 |
hwnet->Disconnect(); |
|
447 |
delete hwnet; |
|
448 |
hwnet=0; |
|
449 |
} |
|
314 | 450 |
if(pnetserver) { |
660 | 451 |
if (pRegisterServer) |
452 |
{ |
|
453 |
pRegisterServer->unregister(); |
|
454 |
pRegisterServer = 0; |
|
455 |
} |
|
659 | 456 |
|
314 | 457 |
pnetserver->StopServer(); |
458 |
delete pnetserver; |
|
459 |
pnetserver=0; |
|
460 |
} |
|
184 | 461 |
} |
462 |
||
383 | 463 |
void HWForm::ForcedDisconnect() |
464 |
{ |
|
465 |
if(pnetserver) return; // we have server - let it care of all things |
|
466 |
if (hwnet) { |
|
467 |
hwnet->deleteLater(); |
|
468 |
hwnet=0; |
|
425 | 469 |
QMessageBox::warning(this, QMessageBox::tr("Network"), |
407 | 470 |
QMessageBox::tr("Connection to server is lost")); |
383 | 471 |
} |
472 |
GoBack(); |
|
473 |
} |
|
474 |
||
184 | 475 |
void HWForm::NetGameEnter() |
476 |
{ |
|
290 | 477 |
GoToPage(ID_PAGE_NETCFG); |
184 | 478 |
} |
479 |
||
480 |
void HWForm::NetStartGame() |
|
481 |
{ |
|
448 | 482 |
ui.pageNetGame->BtnGo->setText(QPushButton::tr("Waiting")); |
483 |
ui.pageNetGame->BtnGo->setEnabled(false); |
|
484 |
hwnet->StartGame(); |
|
184 | 485 |
} |
486 |
||
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
487 |
void HWForm::AddNetTeam(const HWTeam& team) |
184 | 488 |
{ |
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
489 |
ui.pageNetGame->pNetTeamsWidget->addTeam(team); |
184 | 490 |
} |
491 |
||
492 |
void HWForm::StartMPGame() |
|
493 |
{ |
|
341 | 494 |
CreateGame(ui.pageMultiplayer->gameCFG, ui.pageMultiplayer->teamsSelect); |
306 | 495 |
|
184 | 496 |
game->StartLocal(); |
497 |
} |
|
306 | 498 |
|
499 |
void HWForm::GameStateChanged(GameState gameState) |
|
500 |
{ |
|
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
501 |
switch(gameState) { |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
502 |
case gsStarted: { |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
503 |
ui.pageGameStats->labelGameStats->setText(""); |
661
0523b15353a2
Unregister server in servers list when the game is started
unc0rr
parents:
660
diff
changeset
|
504 |
if (pRegisterServer) |
0523b15353a2
Unregister server in servers list when the game is started
unc0rr
parents:
660
diff
changeset
|
505 |
{ |
0523b15353a2
Unregister server in servers list when the game is started
unc0rr
parents:
660
diff
changeset
|
506 |
pRegisterServer->unregister(); |
0523b15353a2
Unregister server in servers list when the game is started
unc0rr
parents:
660
diff
changeset
|
507 |
pRegisterServer = 0; |
0523b15353a2
Unregister server in servers list when the game is started
unc0rr
parents:
660
diff
changeset
|
508 |
} |
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
509 |
break; |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
510 |
} |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
511 |
case gsFinished: { |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
512 |
GoToPage(ID_PAGE_GAMESTATS); |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
513 |
break; |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
514 |
} |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
515 |
default: ; |
307 | 516 |
} |
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
517 |
|
660 | 518 |
if (hwnet) |
519 |
{ |
|
520 |
ui.pageNetGame->BtnGo->setText(QPushButton::tr("Go!")); |
|
521 |
ui.pageNetGame->BtnGo->setEnabled(true); |
|
522 |
} |
|
307 | 523 |
} |
524 |
||
525 |
void HWForm::AddStatText(const QString & msg) |
|
526 |
{ |
|
527 |
ui.pageGameStats->labelGameStats->setText( |
|
528 |
ui.pageGameStats->labelGameStats->text() + msg); |
|
306 | 529 |
} |
530 |
||
531 |
void HWForm::GameStats(char type, const QString & info) |
|
532 |
{ |
|
533 |
switch(type) { |
|
307 | 534 |
case 'r' : { |
535 |
AddStatText(QString("<h1 align=\"center\">%1</h1>").arg(info)); |
|
536 |
break; |
|
537 |
} |
|
538 |
case 'D' : { |
|
539 |
int i = info.indexOf(' '); |
|
540 |
QString message = QLabel::tr("<p>The best shot award was won by <b>%1</b> with <b>%2</b> pts.</p>") |
|
541 |
.arg(info.mid(i + 1), info.left(i)); |
|
542 |
AddStatText(message); |
|
543 |
break; |
|
544 |
} |
|
545 |
case 'K' : { |
|
546 |
QString message = QLabel::tr("<p>A total of <b>%1</b> Hedgehog(s) were killed during this round.</p>").arg(info); |
|
547 |
AddStatText(message); |
|
548 |
break; |
|
549 |
} |
|
306 | 550 |
} |
551 |
} |
|
552 |
||
341 | 553 |
void HWForm::CreateGame(GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget) |
306 | 554 |
{ |
681 | 555 |
game = new HWGame(config, gamecfg, ui.pageSelectWeapon->pWeapons->getWeaponsString(), pTeamSelWidget); |
306 | 556 |
connect(game, SIGNAL(GameStateChanged(GameState)), this, SLOT(GameStateChanged(GameState))); |
557 |
connect(game, SIGNAL(GameStats(char, const QString &)), this, SLOT(GameStats(char, const QString &))); |
|
425 | 558 |
connect(game, SIGNAL(ErrorMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection); |
533 | 559 |
connect(game, SIGNAL(HaveRecord(bool, const QByteArray &)), this, SLOT(GetRecord(bool, const QByteArray &))); |
306 | 560 |
} |
425 | 561 |
|
562 |
void HWForm::ShowErrorMessage(const QString & msg) |
|
563 |
{ |
|
564 |
QMessageBox::warning(this, |
|
565 |
"Hedgewars", |
|
566 |
msg); |
|
567 |
} |
|
533 | 568 |
|
569 |
void HWForm::GetRecord(bool isDemo, const QByteArray & record) |
|
570 |
{ |
|
571 |
QString filename; |
|
572 |
QByteArray demo = record; |
|
573 |
if (isDemo) |
|
574 |
{ |
|
575 |
demo.replace(QByteArray("\x02TL"), QByteArray("\x02TD")); |
|
576 |
demo.replace(QByteArray("\x02TN"), QByteArray("\x02TD")); |
|
579 | 577 |
filename = cfgdir->absolutePath() + "/Demos/LastRound.hwd_" + *cProtoVer; |
533 | 578 |
} else |
579 |
{ |
|
580 |
demo.replace(QByteArray("\x02TL"), QByteArray("\x02TS")); |
|
581 |
demo.replace(QByteArray("\x02TN"), QByteArray("\x02TS")); |
|
579 | 582 |
filename = cfgdir->absolutePath() + "/Saves/LastRound.hws_" + *cProtoVer; |
533 | 583 |
} |
584 |
||
585 |
||
586 |
QFile demofile(filename); |
|
587 |
if (!demofile.open(QIODevice::WriteOnly)) |
|
588 |
{ |
|
589 |
ShowErrorMessage(tr("Cannot save record to file %1").arg(filename)); |
|
590 |
return ; |
|
591 |
} |
|
592 |
demofile.write(demo.constData(), demo.size()); |
|
593 |
demofile.close(); |
|
594 |
} |
|
587 | 595 |
|
596 |
void HWForm::StartTraining() |
|
597 |
{ |
|
598 |
CreateGame(0, 0); |
|
599 |
||
600 |
game->StartTraining(); |
|
601 |
} |
|
660 | 602 |
|
603 |
void HWForm::CreateNetGame() |
|
604 |
{ |
|
605 |
CreateGame(ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget); |
|
606 |
||
607 |
connect(game, SIGNAL(SendNet(const QByteArray &)), hwnet, SLOT(SendNet(const QByteArray &))); |
|
608 |
connect(hwnet, SIGNAL(FromNet(const QByteArray &)), game, SLOT(FromNet(const QByteArray &))); |
|
609 |
||
610 |
game->StartNet(); |
|
611 |
} |
|
674 | 612 |
|
613 |
void HWForm::closeEvent(QCloseEvent *event) |
|
614 |
{ |
|
615 |
config->SaveOptions(); |
|
616 |
event->accept(); |
|
617 |
} |