author | unc0rr |
Wed, 19 Dec 2007 20:54:00 +0000 | |
changeset 682 | a37b6966de84 |
parent 681 | 7a20c50988ec |
child 683 | 57d624f71e65 |
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())); |
121 |
||
290 | 122 |
GoToPage(ID_PAGE_MAIN); |
184 | 123 |
} |
124 |
||
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
125 |
void HWForm::UpdateTeamsLists(const QStringList* editable_teams) |
245 | 126 |
{ |
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
127 |
QStringList teamslist; |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
128 |
if(editable_teams) { |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
129 |
teamslist=*editable_teams; |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
130 |
} else { |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
131 |
teamslist = config->GetTeamsList(); |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
132 |
} |
245 | 133 |
|
134 |
if(teamslist.empty()) { |
|
135 |
HWTeam defaultTeam("DefaultTeam"); |
|
136 |
defaultTeam.SaveToFile(); |
|
137 |
teamslist.push_back("DefaultTeam"); |
|
138 |
} |
|
139 |
||
140 |
ui.pageOptions->CBTeamName->clear(); |
|
141 |
ui.pageOptions->CBTeamName->addItems(teamslist); |
|
142 |
} |
|
143 |
||
184 | 144 |
void HWForm::GoToMain() |
145 |
{ |
|
289 | 146 |
GoToPage(ID_PAGE_MAIN); |
184 | 147 |
} |
148 |
||
149 |
void HWForm::GoToSinglePlayer() |
|
150 |
{ |
|
289 | 151 |
GoToPage(ID_PAGE_SINGLEPLAYER); |
184 | 152 |
} |
153 |
||
586 | 154 |
void HWForm::GoToSimpleGame() |
155 |
{ |
|
156 |
GoToPage(ID_PAGE_SIMPLEGAME); |
|
157 |
} |
|
158 |
||
587 | 159 |
void HWForm::GoToTraining() |
160 |
{ |
|
161 |
GoToPage(ID_PAGE_TRAINING); |
|
162 |
} |
|
163 |
||
184 | 164 |
void HWForm::GoToSetup() |
165 |
{ |
|
289 | 166 |
GoToPage(ID_PAGE_SETUP); |
184 | 167 |
} |
168 |
||
600 | 169 |
void HWForm::GoToSelectWeapon() |
170 |
{ |
|
171 |
GoToPage(ID_PAGE_SELECTWEAPON); |
|
172 |
} |
|
173 |
||
187 | 174 |
void HWForm::GoToInfo() |
175 |
{ |
|
289 | 176 |
GoToPage(ID_PAGE_INFO); |
187 | 177 |
} |
178 |
||
184 | 179 |
void HWForm::GoToMultiplayer() |
180 |
{ |
|
290 | 181 |
GoToPage(ID_PAGE_MULTIPLAYER); |
184 | 182 |
} |
183 |
||
579 | 184 |
void HWForm::GoToSaves() |
185 |
{ |
|
581 | 186 |
ui.pagePlayDemo->FillFromDir(PagePlayDemo::RT_Save); |
579 | 187 |
|
188 |
GoToPage(ID_PAGE_DEMOS); |
|
189 |
} |
|
190 |
||
184 | 191 |
void HWForm::GoToDemos() |
192 |
{ |
|
581 | 193 |
ui.pagePlayDemo->FillFromDir(PagePlayDemo::RT_Demo); |
579 | 194 |
|
290 | 195 |
GoToPage(ID_PAGE_DEMOS); |
184 | 196 |
} |
197 |
||
198 |
void HWForm::GoToNet() |
|
199 |
{ |
|
646 | 200 |
ui.pageNet->updateServersList(); |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
625
diff
changeset
|
201 |
|
289 | 202 |
GoToPage(ID_PAGE_NET); |
184 | 203 |
} |
204 |
||
646 | 205 |
void HWForm::GoToNetServer() |
206 |
{ |
|
207 |
GoToPage(ID_PAGE_NETSERVER); |
|
208 |
} |
|
209 |
||
496 | 210 |
void HWForm::OnPageShown(quint8 id, quint8 lastid) |
311 | 211 |
{ |
322 | 212 |
if (id == ID_PAGE_MULTIPLAYER || id == ID_PAGE_NETCFG) { |
311 | 213 |
QStringList tmNames=config->GetTeamsList(); |
322 | 214 |
TeamSelWidget* curTeamSelWidget; |
496 | 215 |
if(id == ID_PAGE_MULTIPLAYER) { |
216 |
curTeamSelWidget=ui.pageMultiplayer->teamsSelect; |
|
217 |
} else { |
|
322 | 218 |
curTeamSelWidget=ui.pageNetGame->pNetTeamsWidget; |
496 | 219 |
} |
311 | 220 |
QList<HWTeam> teamsList; |
221 |
for(QStringList::iterator it=tmNames.begin(); it!=tmNames.end(); it++) { |
|
222 |
HWTeam team(*it); |
|
223 |
team.LoadFromFile(); |
|
224 |
teamsList.push_back(team); |
|
225 |
} |
|
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
226 |
if(lastid==ID_PAGE_SETUP) { // _TEAM |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
227 |
if (editedTeam) { |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
228 |
curTeamSelWidget->addTeam(*editedTeam); |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
229 |
} |
496 | 230 |
} else { |
231 |
curTeamSelWidget->resetPlayingTeams(teamsList); |
|
232 |
} |
|
311 | 233 |
} |
234 |
} |
|
235 |
||
289 | 236 |
void HWForm::GoToPage(quint8 id) |
237 |
{ |
|
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
238 |
quint8 lastid=ui.Pages->currentIndex(); |
289 | 239 |
PagesStack.push(ui.Pages->currentIndex()); |
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
240 |
OnPageShown(id, lastid); |
289 | 241 |
ui.Pages->setCurrentIndex(id); |
242 |
} |
|
243 |
||
244 |
void HWForm::GoBack() |
|
245 |
{ |
|
350 | 246 |
if (!PagesStack.isEmpty() && PagesStack.top() == ID_PAGE_NET) { |
383 | 247 |
if(hwnet || pnetserver) NetDisconnect(); |
350 | 248 |
} |
289 | 249 |
quint8 id = PagesStack.isEmpty() ? ID_PAGE_MAIN : PagesStack.pop(); |
496 | 250 |
OnPageShown(id, ui.Pages->currentIndex()); |
289 | 251 |
ui.Pages->setCurrentIndex(id); |
184 | 252 |
} |
253 |
||
530 | 254 |
void HWForm::btnExitPressed() |
255 |
{ |
|
256 |
eggTimer.start(); |
|
257 |
} |
|
258 |
||
259 |
void HWForm::btnExitClicked() |
|
260 |
{ |
|
261 |
if (eggTimer.elapsed() < 3000) |
|
262 |
close(); |
|
263 |
else |
|
264 |
{ |
|
265 |
QPushButton * btn = findChild<QPushButton *>("imageButt"); |
|
266 |
if (btn) |
|
267 |
{ |
|
268 |
btn->setIcon(QIcon(":/res/bonus.png")); |
|
269 |
} |
|
270 |
} |
|
271 |
} |
|
272 |
||
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
273 |
void HWForm::IntermediateSetup() |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
274 |
{ |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
275 |
quint8 id=ui.Pages->currentIndex(); |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
276 |
TeamSelWidget* curTeamSelWidget; |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
277 |
if(id == ID_PAGE_MULTIPLAYER) { |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
278 |
curTeamSelWidget=ui.pageMultiplayer->teamsSelect; |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
279 |
} else { |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
280 |
curTeamSelWidget=ui.pageNetGame->pNetTeamsWidget; |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
281 |
} |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
282 |
QList<HWTeam> teams=curTeamSelWidget->getDontPlayingTeams(); |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
283 |
QStringList tmnames; |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
284 |
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
|
285 |
tmnames+=it->TeamName; |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
286 |
} |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
287 |
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
|
288 |
|
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
289 |
GoToPage(ID_PAGE_SETUP); |
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 |
|
184 | 292 |
void HWForm::NewTeam() |
293 |
{ |
|
245 | 294 |
editedTeam = new HWTeam("unnamed"); |
295 |
editedTeam->SetToPage(this); |
|
290 | 296 |
GoToPage(ID_PAGE_SETUP_TEAM); |
184 | 297 |
} |
298 |
||
299 |
void HWForm::EditTeam() |
|
300 |
{ |
|
245 | 301 |
editedTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText()); |
302 |
editedTeam->LoadFromFile(); |
|
303 |
editedTeam->SetToPage(this); |
|
290 | 304 |
GoToPage(ID_PAGE_SETUP_TEAM); |
184 | 305 |
} |
306 |
||
307 |
void HWForm::TeamSave() |
|
308 |
{ |
|
245 | 309 |
editedTeam->GetFromPage(this); |
310 |
editedTeam->SaveToFile(); |
|
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
311 |
delete editedTeam; |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
312 |
editedTeam=0; |
245 | 313 |
UpdateTeamsLists(); |
290 | 314 |
GoBack(); |
184 | 315 |
} |
316 |
||
317 |
void HWForm::TeamDiscard() |
|
318 |
{ |
|
245 | 319 |
delete editedTeam; |
496 | 320 |
editedTeam=0; |
290 | 321 |
GoBack(); |
184 | 322 |
} |
323 |
||
324 |
void HWForm::SimpleGame() |
|
325 |
{ |
|
585
7531ae5b146e
Rename PageLocalGame -> PageSimpleGame due to future changes
unc0rr
parents:
581
diff
changeset
|
326 |
CreateGame(ui.pageSimpleGame->gameCFG, 0); |
184 | 327 |
game->StartQuick(); |
328 |
} |
|
329 |
||
330 |
void HWForm::PlayDemo() |
|
331 |
{ |
|
332 |
QListWidgetItem * curritem = ui.pagePlayDemo->DemosList->currentItem(); |
|
333 |
if (!curritem) |
|
334 |
{ |
|
335 |
QMessageBox::critical(this, |
|
336 |
tr("Error"), |
|
581 | 337 |
tr("Please, select record from the list above"), |
184 | 338 |
tr("OK")); |
339 |
return ; |
|
340 |
} |
|
341 | 341 |
CreateGame(0, 0); |
580 | 342 |
game->PlayDemo(curritem->data(Qt::UserRole).toString()); |
184 | 343 |
} |
344 |
||
666 | 345 |
void HWForm::NetConnectServer(const QString & host, quint16 port) |
416 | 346 |
{ |
666 | 347 |
_NetConnect(host, port, ui.pageOptions->editNetNick->text()); |
416 | 348 |
} |
349 |
||
314 | 350 |
void HWForm::_NetConnect(const QString & hostName, quint16 port, const QString & nick) |
184 | 351 |
{ |
637
8fa7ed5e13bd
Fix bad behavior when quickly click Connect button more than once
unc0rr
parents:
636
diff
changeset
|
352 |
if(hwnet) { |
8fa7ed5e13bd
Fix bad behavior when quickly click Connect button more than once
unc0rr
parents:
636
diff
changeset
|
353 |
hwnet->Disconnect(); |
8fa7ed5e13bd
Fix bad behavior when quickly click Connect button more than once
unc0rr
parents:
636
diff
changeset
|
354 |
delete hwnet; |
8fa7ed5e13bd
Fix bad behavior when quickly click Connect button more than once
unc0rr
parents:
636
diff
changeset
|
355 |
hwnet=0; |
8fa7ed5e13bd
Fix bad behavior when quickly click Connect button more than once
unc0rr
parents:
636
diff
changeset
|
356 |
} |
465 | 357 |
ui.pageNetGame->pChatWidget->clear(); |
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
358 |
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
|
359 |
|
660 | 360 |
connect(hwnet, SIGNAL(AskForRunGame()), this, SLOT(CreateNetGame())); |
184 | 361 |
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
|
362 |
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
|
363 |
|
471 | 364 |
connect(hwnet, SIGNAL(chatStringFromNet(const QStringList&)), |
461 | 365 |
ui.pageNetGame->pChatWidget, SLOT(onChatStringFromNet(const QStringList&))); |
366 |
connect(ui.pageNetGame->pChatWidget, SIGNAL(chatLine(const QString&)), |
|
367 |
hwnet, SLOT(chatLineToNet(const QString&))); |
|
471 | 368 |
connect(hwnet, SIGNAL(nickAdded(const QString&)), |
465 | 369 |
ui.pageNetGame->pChatWidget, SLOT(nickAdded(const QString&))); |
471 | 370 |
connect(hwnet, SIGNAL(nickRemoved(const QString&)), |
465 | 371 |
ui.pageNetGame->pChatWidget, SLOT(nickRemoved(const QString&))); |
461 | 372 |
|
352 | 373 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(hhogsNumChanged(const HWTeam&)), |
374 |
hwnet, SLOT(onHedgehogsNumChanged(const HWTeam&))); |
|
372 | 375 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamColorChanged(const HWTeam&)), |
376 |
hwnet, SLOT(onTeamColorChanged(const HWTeam&))); |
|
327 | 377 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamWillPlay(HWTeam)), hwnet, SLOT(AddTeam(HWTeam))); |
373 | 378 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(acceptRequested(HWTeam)), hwnet, SLOT(AddTeam(HWTeam))); |
347 | 379 |
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
|
380 |
|
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
328
diff
changeset
|
381 |
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
|
382 |
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
|
383 |
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
|
384 |
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
|
385 |
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
|
386 |
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
|
387 |
|
383 | 388 |
connect(hwnet, SIGNAL(Disconnected()), this, SLOT(ForcedDisconnect())); |
330 | 389 |
connect(hwnet, SIGNAL(seedChanged(const QString &)), ui.pageNetGame->pGameCFG, SLOT(setSeed(const QString &))); |
390 |
connect(hwnet, SIGNAL(mapChanged(const QString &)), ui.pageNetGame->pGameCFG, SLOT(setMap(const QString &))); |
|
391 |
connect(hwnet, SIGNAL(themeChanged(const QString &)), ui.pageNetGame->pGameCFG, SLOT(setTheme(const QString &))); |
|
392 |
connect(hwnet, SIGNAL(initHealthChanged(quint32)), ui.pageNetGame->pGameCFG, SLOT(setInitHealth(quint32))); |
|
393 |
connect(hwnet, SIGNAL(turnTimeChanged(quint32)), ui.pageNetGame->pGameCFG, SLOT(setTurnTime(quint32))); |
|
394 |
connect(hwnet, SIGNAL(fortsModeChanged(bool)), ui.pageNetGame->pGameCFG, SLOT(setFortsMode(bool))); |
|
425 | 395 |
connect(hwnet, SIGNAL(hhnumChanged(const HWTeam&)), |
352 | 396 |
ui.pageNetGame->pNetTeamsWidget, SLOT(changeHHNum(const HWTeam&))); |
425 | 397 |
connect(hwnet, SIGNAL(teamColorChanged(const HWTeam&)), |
372 | 398 |
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
|
399 |
|
314 | 400 |
hwnet->Connect(hostName, port, nick); |
184 | 401 |
} |
402 |
||
314 | 403 |
void HWForm::NetConnect() |
404 |
{ |
|
653
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
405 |
HWHostPortDialog * hpd = new HWHostPortDialog(this); |
654 | 406 |
hpd->leHost->setText(*netHost); |
407 |
hpd->sbPort->setValue(netPort); |
|
653
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
408 |
|
654 | 409 |
if (hpd->exec() == QDialog::Accepted) |
410 |
{ |
|
411 |
config->SaveOptions(); |
|
412 |
delete netHost; |
|
413 |
netHost = new QString(hpd->leHost->text()); |
|
414 |
netPort = hpd->sbPort->value(); |
|
415 |
_NetConnect(*netHost, netPort, ui.pageOptions->editNetNick->text()); |
|
416 |
} |
|
314 | 417 |
} |
418 |
||
419 |
void HWForm::NetStartServer() |
|
420 |
{ |
|
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
|
421 |
config->SaveOptions(); |
636 | 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 |
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
|
424 |
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
|
425 |
{ |
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 |
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
|
427 |
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
|
428 |
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
|
429 |
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
|
430 |
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
|
431 |
} |
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 |
|
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 |
_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
|
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 |
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
|
436 |
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
|
437 |
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
|
438 |
pRegisterServer = new HWNetWwwServer(0, ui.pageNetServer->leServerDescr->text(), ui.pageNetServer->sbPort->value()); |
314 | 439 |
} |
440 |
||
184 | 441 |
void HWForm::NetDisconnect() |
442 |
{ |
|
383 | 443 |
if(hwnet) { |
444 |
hwnet->Disconnect(); |
|
445 |
delete hwnet; |
|
446 |
hwnet=0; |
|
447 |
} |
|
314 | 448 |
if(pnetserver) { |
660 | 449 |
if (pRegisterServer) |
450 |
{ |
|
451 |
pRegisterServer->unregister(); |
|
452 |
pRegisterServer = 0; |
|
453 |
} |
|
659 | 454 |
|
314 | 455 |
pnetserver->StopServer(); |
456 |
delete pnetserver; |
|
457 |
pnetserver=0; |
|
458 |
} |
|
184 | 459 |
} |
460 |
||
383 | 461 |
void HWForm::ForcedDisconnect() |
462 |
{ |
|
463 |
if(pnetserver) return; // we have server - let it care of all things |
|
464 |
if (hwnet) { |
|
465 |
hwnet->deleteLater(); |
|
466 |
hwnet=0; |
|
425 | 467 |
QMessageBox::warning(this, QMessageBox::tr("Network"), |
407 | 468 |
QMessageBox::tr("Connection to server is lost")); |
383 | 469 |
} |
470 |
GoBack(); |
|
471 |
} |
|
472 |
||
184 | 473 |
void HWForm::NetGameEnter() |
474 |
{ |
|
290 | 475 |
GoToPage(ID_PAGE_NETCFG); |
184 | 476 |
} |
477 |
||
478 |
void HWForm::NetStartGame() |
|
479 |
{ |
|
448 | 480 |
ui.pageNetGame->BtnGo->setText(QPushButton::tr("Waiting")); |
481 |
ui.pageNetGame->BtnGo->setEnabled(false); |
|
482 |
hwnet->StartGame(); |
|
184 | 483 |
} |
484 |
||
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
485 |
void HWForm::AddNetTeam(const HWTeam& team) |
184 | 486 |
{ |
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
487 |
ui.pageNetGame->pNetTeamsWidget->addTeam(team); |
184 | 488 |
} |
489 |
||
490 |
void HWForm::StartMPGame() |
|
491 |
{ |
|
341 | 492 |
CreateGame(ui.pageMultiplayer->gameCFG, ui.pageMultiplayer->teamsSelect); |
306 | 493 |
|
184 | 494 |
game->StartLocal(); |
495 |
} |
|
306 | 496 |
|
497 |
void HWForm::GameStateChanged(GameState gameState) |
|
498 |
{ |
|
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
499 |
switch(gameState) { |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
500 |
case gsStarted: { |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
501 |
ui.pageGameStats->labelGameStats->setText(""); |
661
0523b15353a2
Unregister server in servers list when the game is started
unc0rr
parents:
660
diff
changeset
|
502 |
if (pRegisterServer) |
0523b15353a2
Unregister server in servers list when the game is started
unc0rr
parents:
660
diff
changeset
|
503 |
{ |
0523b15353a2
Unregister server in servers list when the game is started
unc0rr
parents:
660
diff
changeset
|
504 |
pRegisterServer->unregister(); |
0523b15353a2
Unregister server in servers list when the game is started
unc0rr
parents:
660
diff
changeset
|
505 |
pRegisterServer = 0; |
0523b15353a2
Unregister server in servers list when the game is started
unc0rr
parents:
660
diff
changeset
|
506 |
} |
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
507 |
break; |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
508 |
} |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
509 |
case gsFinished: { |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
510 |
GoToPage(ID_PAGE_GAMESTATS); |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
511 |
break; |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
512 |
} |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
513 |
default: ; |
307 | 514 |
} |
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
515 |
|
660 | 516 |
if (hwnet) |
517 |
{ |
|
518 |
ui.pageNetGame->BtnGo->setText(QPushButton::tr("Go!")); |
|
519 |
ui.pageNetGame->BtnGo->setEnabled(true); |
|
520 |
} |
|
307 | 521 |
} |
522 |
||
523 |
void HWForm::AddStatText(const QString & msg) |
|
524 |
{ |
|
525 |
ui.pageGameStats->labelGameStats->setText( |
|
526 |
ui.pageGameStats->labelGameStats->text() + msg); |
|
306 | 527 |
} |
528 |
||
529 |
void HWForm::GameStats(char type, const QString & info) |
|
530 |
{ |
|
531 |
switch(type) { |
|
307 | 532 |
case 'r' : { |
533 |
AddStatText(QString("<h1 align=\"center\">%1</h1>").arg(info)); |
|
534 |
break; |
|
535 |
} |
|
536 |
case 'D' : { |
|
537 |
int i = info.indexOf(' '); |
|
538 |
QString message = QLabel::tr("<p>The best shot award was won by <b>%1</b> with <b>%2</b> pts.</p>") |
|
539 |
.arg(info.mid(i + 1), info.left(i)); |
|
540 |
AddStatText(message); |
|
541 |
break; |
|
542 |
} |
|
543 |
case 'K' : { |
|
544 |
QString message = QLabel::tr("<p>A total of <b>%1</b> Hedgehog(s) were killed during this round.</p>").arg(info); |
|
545 |
AddStatText(message); |
|
546 |
break; |
|
547 |
} |
|
306 | 548 |
} |
549 |
} |
|
550 |
||
341 | 551 |
void HWForm::CreateGame(GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget) |
306 | 552 |
{ |
681 | 553 |
game = new HWGame(config, gamecfg, ui.pageSelectWeapon->pWeapons->getWeaponsString(), pTeamSelWidget); |
306 | 554 |
connect(game, SIGNAL(GameStateChanged(GameState)), this, SLOT(GameStateChanged(GameState))); |
555 |
connect(game, SIGNAL(GameStats(char, const QString &)), this, SLOT(GameStats(char, const QString &))); |
|
425 | 556 |
connect(game, SIGNAL(ErrorMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection); |
533 | 557 |
connect(game, SIGNAL(HaveRecord(bool, const QByteArray &)), this, SLOT(GetRecord(bool, const QByteArray &))); |
306 | 558 |
} |
425 | 559 |
|
560 |
void HWForm::ShowErrorMessage(const QString & msg) |
|
561 |
{ |
|
562 |
QMessageBox::warning(this, |
|
563 |
"Hedgewars", |
|
564 |
msg); |
|
565 |
} |
|
533 | 566 |
|
567 |
void HWForm::GetRecord(bool isDemo, const QByteArray & record) |
|
568 |
{ |
|
569 |
QString filename; |
|
570 |
QByteArray demo = record; |
|
571 |
if (isDemo) |
|
572 |
{ |
|
573 |
demo.replace(QByteArray("\x02TL"), QByteArray("\x02TD")); |
|
574 |
demo.replace(QByteArray("\x02TN"), QByteArray("\x02TD")); |
|
579 | 575 |
filename = cfgdir->absolutePath() + "/Demos/LastRound.hwd_" + *cProtoVer; |
533 | 576 |
} else |
577 |
{ |
|
578 |
demo.replace(QByteArray("\x02TL"), QByteArray("\x02TS")); |
|
579 |
demo.replace(QByteArray("\x02TN"), QByteArray("\x02TS")); |
|
579 | 580 |
filename = cfgdir->absolutePath() + "/Saves/LastRound.hws_" + *cProtoVer; |
533 | 581 |
} |
582 |
||
583 |
||
584 |
QFile demofile(filename); |
|
585 |
if (!demofile.open(QIODevice::WriteOnly)) |
|
586 |
{ |
|
587 |
ShowErrorMessage(tr("Cannot save record to file %1").arg(filename)); |
|
588 |
return ; |
|
589 |
} |
|
590 |
demofile.write(demo.constData(), demo.size()); |
|
591 |
demofile.close(); |
|
592 |
} |
|
587 | 593 |
|
594 |
void HWForm::StartTraining() |
|
595 |
{ |
|
596 |
CreateGame(0, 0); |
|
597 |
||
598 |
game->StartTraining(); |
|
599 |
} |
|
660 | 600 |
|
601 |
void HWForm::CreateNetGame() |
|
602 |
{ |
|
603 |
CreateGame(ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget); |
|
604 |
||
605 |
connect(game, SIGNAL(SendNet(const QByteArray &)), hwnet, SLOT(SendNet(const QByteArray &))); |
|
606 |
connect(hwnet, SIGNAL(FromNet(const QByteArray &)), game, SLOT(FromNet(const QByteArray &))); |
|
607 |
||
608 |
game->StartNet(); |
|
609 |
} |
|
674 | 610 |
|
611 |
void HWForm::closeEvent(QCloseEvent *event) |
|
612 |
{ |
|
613 |
config->SaveOptions(); |
|
614 |
event->accept(); |
|
615 |
} |