author | nemo |
Tue, 23 Feb 2010 03:57:27 +0000 | |
changeset 2851 | a9a5ce1d9f23 |
parent 2845 | 19db164dd20d |
child 2874 | 3c7c2bf1ba38 |
permissions | -rw-r--r-- |
184 | 1 |
/* |
1066 | 2 |
* Hedgewars, a free turn based strategy game |
1569 | 3 |
* Copyright (c) 2005-2009 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 <QFile> |
|
20 |
#include <QTextStream> |
|
407 | 21 |
#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
|
22 |
#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
|
23 |
#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
|
24 |
#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
|
25 |
#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
|
26 |
#include <QLabel> |
636 | 27 |
#include <QRadioButton> |
654 | 28 |
#include <QSpinBox> |
674 | 29 |
#include <QCloseEvent> |
1235 | 30 |
#include <QCheckBox> |
1377 | 31 |
#include <QTextBrowser> |
1409
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1405
diff
changeset
|
32 |
#include <QAction> |
1418 | 33 |
#include <QTimer> |
1419 | 34 |
#include <QScrollBar> |
1885 | 35 |
#include <QDataWidgetMapper> |
1887 | 36 |
#include <QTableView> |
184 | 37 |
|
38 |
#include "hwform.h" |
|
39 |
#include "game.h" |
|
40 |
#include "team.h" |
|
1907 | 41 |
#include "namegen.h" |
184 | 42 |
#include "teamselect.h" |
681 | 43 |
#include "selectWeapon.h" |
184 | 44 |
#include "gameuiconfig.h" |
45 |
#include "pages.h" |
|
1621 | 46 |
#include "statsPage.h" |
184 | 47 |
#include "hwconsts.h" |
314 | 48 |
#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
|
49 |
#include "gamecfgwidget.h" |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
625
diff
changeset
|
50 |
#include "netserverslist.h" |
634 | 51 |
#include "netudpserver.h" |
461 | 52 |
#include "chatwidget.h" |
579 | 53 |
#include "playrecordpage.h" |
653
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
54 |
#include "input_ip.h" |
1885 | 55 |
#include "ammoSchemeModel.h" |
2012 | 56 |
#include "bgwidget.h" |
2821 | 57 |
#include "xfire.h" |
184 | 58 |
|
2400
2422ea85d100
added a utility that warns the user to install hedgewars when it's run from the diskimage
koda
parents:
2399
diff
changeset
|
59 |
#ifdef __APPLE__ |
2261 | 60 |
#include "CocoaInitializer.h" |
2400
2422ea85d100
added a utility that warns the user to install hedgewars when it's run from the diskimage
koda
parents:
2399
diff
changeset
|
61 |
#include "M3Panel.h" |
2422ea85d100
added a utility that warns the user to install hedgewars when it's run from the diskimage
koda
parents:
2399
diff
changeset
|
62 |
#ifdef SPARKLE_ENABLED |
2511 | 63 |
#define SPARKLE_APPCAST_URL "http://www.hedgewars.org/download/appcast.xml" |
2261 | 64 |
#include "SparkleAutoUpdater.h" |
65 |
#endif |
|
2400
2422ea85d100
added a utility that warns the user to install hedgewars when it's run from the diskimage
koda
parents:
2399
diff
changeset
|
66 |
#endif |
2261 | 67 |
|
2098
c977d7f2aa09
Toggle for stars ("frontend effects") - also turns off optimisations for stars that were causing problems onone machine
nemo
parents:
2080
diff
changeset
|
68 |
// I started handing this down to each place it touches, but it was getting ridiculous |
c977d7f2aa09
Toggle for stars ("frontend effects") - also turns off optimisations for stars that were causing problems onone machine
nemo
parents:
2080
diff
changeset
|
69 |
// and this one flag does not warrant a static class |
c977d7f2aa09
Toggle for stars ("frontend effects") - also turns off optimisations for stars that were causing problems onone machine
nemo
parents:
2080
diff
changeset
|
70 |
bool frontendEffects = true; |
c977d7f2aa09
Toggle for stars ("frontend effects") - also turns off optimisations for stars that were causing problems onone machine
nemo
parents:
2080
diff
changeset
|
71 |
|
184 | 72 |
HWForm::HWForm(QWidget *parent) |
637
8fa7ed5e13bd
Fix bad behavior when quickly click Connect button more than once
unc0rr
parents:
636
diff
changeset
|
73 |
: QMainWindow(parent), pnetserver(0), pRegisterServer(0), editedTeam(0), hwnet(0) |
184 | 74 |
{ |
2822 | 75 |
#ifdef USE_XFIRE |
2821 | 76 |
xfire_init(); |
2822 | 77 |
#endif |
2773
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2742
diff
changeset
|
78 |
gameSettings = new QSettings(cfgdir->absolutePath() + "/hedgewars.ini", QSettings::IniFormat); |
e94f240a8a41
Have game beep when someone joins lobby/room. Controlled by Sound option
nemo
parents:
2742
diff
changeset
|
79 |
frontendEffects = gameSettings->value("video/frontendeffects", true).toBool(); |
2098
c977d7f2aa09
Toggle for stars ("frontend effects") - also turns off optimisations for stars that were causing problems onone machine
nemo
parents:
2080
diff
changeset
|
80 |
|
184 | 81 |
ui.setupUi(this); |
1225
f882a92ef872
Play music in menu also, with fading effects when run game
unc0rr
parents:
1223
diff
changeset
|
82 |
|
1419 | 83 |
CustomizePalettes(); |
2527 | 84 |
|
2428 | 85 |
ui.pageOptions->CBResolution->addItems(sdli.getResolutions()); |
1225
f882a92ef872
Play music in menu also, with fading effects when run game
unc0rr
parents:
1223
diff
changeset
|
86 |
|
301 | 87 |
config = new GameUIConfig(this, cfgdir->absolutePath() + "/hedgewars.ini"); |
2377 | 88 |
|
1907 | 89 |
namegen = new HWNamegen(); |
2377 | 90 |
|
2400
2422ea85d100
added a utility that warns the user to install hedgewars when it's run from the diskimage
koda
parents:
2399
diff
changeset
|
91 |
#ifdef __APPLE__ |
2422ea85d100
added a utility that warns the user to install hedgewars when it's run from the diskimage
koda
parents:
2399
diff
changeset
|
92 |
panel = new M3Panel; |
2395 | 93 |
#ifdef SPARKLE_ENABLED |
2261 | 94 |
AutoUpdater* updater; |
95 |
CocoaInitializer initializer; |
|
2511 | 96 |
updater = new SparkleAutoUpdater(SPARKLE_APPCAST_URL); |
97 |
if(updater && config->isAutoUpdateEnabled()) |
|
2261 | 98 |
updater->checkForUpdates(); |
2400
2422ea85d100
added a utility that warns the user to install hedgewars when it's run from the diskimage
koda
parents:
2399
diff
changeset
|
99 |
#endif |
2261 | 100 |
#endif |
2377 | 101 |
|
245 | 102 |
UpdateTeamsLists(); |
695 | 103 |
UpdateWeapons(); |
184 | 104 |
|
1162 | 105 |
connect(config, SIGNAL(frontendFullscreen(bool)), this, SLOT(onFrontendFullscreen(bool))); |
106 |
onFrontendFullscreen(config->isFrontendFullscreen()); |
|
107 |
||
1885 | 108 |
connect(ui.pageMain->BtnSinglePlayer, SIGNAL(clicked()), this, SLOT(GoToSinglePlayer())); |
109 |
connect(ui.pageMain->BtnSetup, SIGNAL(clicked()), this, SLOT(GoToSetup())); |
|
1950 | 110 |
connect(ui.pageMain->BtnNet, SIGNAL(clicked()), this, SLOT(GoToNetType())); |
1885 | 111 |
connect(ui.pageMain->BtnInfo, SIGNAL(clicked()), this, SLOT(GoToInfo())); |
530 | 112 |
connect(ui.pageMain->BtnExit, SIGNAL(pressed()), this, SLOT(btnExitPressed())); |
113 |
connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(btnExitClicked())); |
|
184 | 114 |
|
1885 | 115 |
connect(ui.pageEditTeam->BtnTeamSave, SIGNAL(clicked()), this, SLOT(TeamSave())); |
116 |
connect(ui.pageEditTeam->BtnTeamDiscard, SIGNAL(clicked()), this, SLOT(TeamDiscard())); |
|
184 | 117 |
|
1840 | 118 |
connect(ui.pageEditTeam->signalMapper, SIGNAL(mapped(const int &)), this, SLOT(RandomName(const int &))); |
119 |
connect(ui.pageEditTeam->randTeamButton, SIGNAL(clicked()), this, SLOT(RandomNames())); |
|
120 |
||
1885 | 121 |
connect(ui.pageMultiplayer->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
122 |
connect(ui.pageMultiplayer->BtnStartMPGame, SIGNAL(clicked()), this, SLOT(StartMPGame())); |
|
493 | 123 |
connect(ui.pageMultiplayer->teamsSelect, SIGNAL(setEnabledGameStart(bool)), |
492 | 124 |
ui.pageMultiplayer->BtnStartMPGame, SLOT(setEnabled(bool))); |
586 | 125 |
connect(ui.pageMultiplayer->teamsSelect, SIGNAL(SetupClicked()), this, SLOT(IntermediateSetup())); |
1885 | 126 |
connect(ui.pageMultiplayer->gameCFG, SIGNAL(goToSchemes()), this, SLOT(GoToSchemes())); |
2009 | 127 |
connect(ui.pageMultiplayer->gameCFG, SIGNAL(goToWeapons(const QString &)), this, SLOT(GoToSelectWeaponSet(const QString &))); |
184 | 128 |
|
1950 | 129 |
connect(ui.pagePlayDemo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
130 |
connect(ui.pagePlayDemo->BtnPlayDemo, SIGNAL(clicked()), this, SLOT(PlayDemo())); |
|
1951 | 131 |
connect(ui.pagePlayDemo->DemosList, SIGNAL(doubleClicked (const QModelIndex &)), this, SLOT(PlayDemo())); |
184 | 132 |
|
1950 | 133 |
connect(ui.pageOptions->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
134 |
connect(ui.pageOptions->BtnNewTeam, SIGNAL(clicked()), this, SLOT(NewTeam())); |
|
135 |
connect(ui.pageOptions->BtnEditTeam, SIGNAL(clicked()), this, SLOT(EditTeam())); |
|
136 |
connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), config, SLOT(SaveOptions())); |
|
137 |
connect(ui.pageOptions->BtnSaveOptions, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
695 | 138 |
|
1509 | 139 |
connect(ui.pageOptions->WeaponEdit, SIGNAL(clicked()), this, SLOT(GoToSelectWeapon())); |
140 |
connect(ui.pageOptions->WeaponsButt, SIGNAL(clicked()), this, SLOT(GoToSelectNewWeapon())); |
|
141 |
connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsChanged()), this, SLOT(UpdateWeapons())); |
|
184 | 142 |
|
1395 | 143 |
connect(ui.pageNet->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
144 |
connect(ui.pageNet->BtnSpecifyServer, SIGNAL(clicked()), this, SLOT(NetConnect())); |
|
145 |
connect(ui.pageNet->BtnNetSvrStart, SIGNAL(clicked()), this, SLOT(GoToNetServer())); |
|
146 |
connect(ui.pageNet, SIGNAL(connectClicked(const QString &, quint16)), this, SLOT(NetConnectServer(const QString &, quint16))); |
|
2377 | 147 |
|
1950 | 148 |
connect(ui.pageNetServer->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
149 |
connect(ui.pageNetServer->BtnStart, SIGNAL(clicked()), this, SLOT(NetStartServer())); |
|
184 | 150 |
|
1950 | 151 |
connect(ui.pageNetGame->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
493 | 152 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(setEnabledGameStart(bool)), |
492 | 153 |
ui.pageNetGame->BtnGo, SLOT(setEnabled(bool))); |
1951 | 154 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(setEnabledGameStart(bool)), |
155 |
ui.pageNetGame->BtnStart, SLOT(setEnabled(bool))); |
|
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
156 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(SetupClicked()), this, SLOT(IntermediateSetup())); |
1885 | 157 |
connect(ui.pageNetGame->pGameCFG, SIGNAL(goToSchemes()), this, SLOT(GoToSchemes())); |
2009 | 158 |
connect(ui.pageNetGame->pGameCFG, SIGNAL(goToWeapons(const QString &)), this, SLOT(GoToSelectWeaponSet(const QString &))); |
184 | 159 |
|
1312 | 160 |
connect(ui.pageRoomsList->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
1905 | 161 |
connect(ui.pageRoomsList->BtnAdmin, SIGNAL(clicked()), this, SLOT(GoToAdmin())); |
187 | 162 |
|
1312 | 163 |
connect(ui.pageInfo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
164 |
||
165 |
connect(ui.pageGameStats->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
306 | 166 |
|
1887 | 167 |
connect(ui.pageSinglePlayer->BtnSimpleGamePage, SIGNAL(clicked()), this, SLOT(SimpleGame())); |
168 |
connect(ui.pageSinglePlayer->BtnTrainPage, SIGNAL(clicked()), this, SLOT(GoToTraining())); |
|
169 |
connect(ui.pageSinglePlayer->BtnMultiplayer, SIGNAL(clicked()), this, SLOT(GoToMultiplayer())); |
|
170 |
connect(ui.pageSinglePlayer->BtnLoad, SIGNAL(clicked()), this, SLOT(GoToSaves())); |
|
171 |
connect(ui.pageSinglePlayer->BtnDemos, SIGNAL(clicked()), this, SLOT(GoToDemos())); |
|
172 |
connect(ui.pageSinglePlayer->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
311 | 173 |
|
1887 | 174 |
connect(ui.pageTraining->BtnStartTrain, SIGNAL(clicked()), this, SLOT(StartTraining())); |
175 |
connect(ui.pageTraining->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
587 | 176 |
|
1887 | 177 |
connect(ui.pageSelectWeapon->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
600 | 178 |
|
1887 | 179 |
connect(ui.pageSelectWeapon->BtnDelete, SIGNAL(clicked()), |
718 | 180 |
ui.pageSelectWeapon->pWeapons, SLOT(deleteWeaponsName())); // executed first |
1887 | 181 |
connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsDeleted()), |
718 | 182 |
this, SLOT(UpdateWeapons())); // executed second |
1887 | 183 |
connect(ui.pageSelectWeapon->pWeapons, SIGNAL(weaponsDeleted()), |
718 | 184 |
this, SLOT(GoBack())); // executed third |
185 |
||
1887 | 186 |
connect(ui.pageScheme->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
187 |
||
1905 | 188 |
connect(ui.pageAdmin->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
189 |
||
1950 | 190 |
connect(ui.pageNetType->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
191 |
connect(ui.pageNetType->BtnLAN, SIGNAL(clicked()), this, SLOT(GoToNet())); |
|
192 |
connect(ui.pageNetType->BtnOfficialServer, SIGNAL(clicked()), this, SLOT(NetConnectOfficialServer())); |
|
193 |
||
1885 | 194 |
|
1897 | 195 |
ammoSchemeModel = new AmmoSchemeModel(this, cfgdir->absolutePath() + "/schemes.ini"); |
1887 | 196 |
ui.pageScheme->setModel(ammoSchemeModel); |
1890 | 197 |
ui.pageMultiplayer->gameCFG->GameSchemes->setModel(ammoSchemeModel); |
1885 | 198 |
|
2098
c977d7f2aa09
Toggle for stars ("frontend effects") - also turns off optimisations for stars that were causing problems onone machine
nemo
parents:
2080
diff
changeset
|
199 |
wBackground = NULL; |
c977d7f2aa09
Toggle for stars ("frontend effects") - also turns off optimisations for stars that were causing problems onone machine
nemo
parents:
2080
diff
changeset
|
200 |
if (config->isFrontendEffects()) { |
c977d7f2aa09
Toggle for stars ("frontend effects") - also turns off optimisations for stars that were causing problems onone machine
nemo
parents:
2080
diff
changeset
|
201 |
wBackground = new BGWidget(this); |
c977d7f2aa09
Toggle for stars ("frontend effects") - also turns off optimisations for stars that were causing problems onone machine
nemo
parents:
2080
diff
changeset
|
202 |
wBackground->setFixedSize(this->width(), this->height()); |
c977d7f2aa09
Toggle for stars ("frontend effects") - also turns off optimisations for stars that were causing problems onone machine
nemo
parents:
2080
diff
changeset
|
203 |
wBackground->lower(); |
c977d7f2aa09
Toggle for stars ("frontend effects") - also turns off optimisations for stars that were causing problems onone machine
nemo
parents:
2080
diff
changeset
|
204 |
wBackground->init(); |
c977d7f2aa09
Toggle for stars ("frontend effects") - also turns off optimisations for stars that were causing problems onone machine
nemo
parents:
2080
diff
changeset
|
205 |
wBackground->startAnimation(); |
c977d7f2aa09
Toggle for stars ("frontend effects") - also turns off optimisations for stars that were causing problems onone machine
nemo
parents:
2080
diff
changeset
|
206 |
} |
2012 | 207 |
|
1845 | 208 |
PagesStack.push(ID_PAGE_MAIN); |
209 |
GoBack(); |
|
184 | 210 |
} |
211 |
||
2822 | 212 |
#ifdef USE_XFIRE |
2821 | 213 |
void HWForm::updateXfire(void) |
214 |
{ |
|
215 |
if(hwnet) |
|
216 |
{ |
|
217 |
xfire_setvalue(XFIRE_SERVER, !hwnet->getHost().compare("netserver.hedgewars.org:46631") ? "Official server" : hwnet->getHost().toAscii()); |
|
218 |
switch(hwnet->getClientState()) |
|
219 |
{ |
|
220 |
case 1: // Connecting |
|
221 |
xfire_setvalue(XFIRE_STATUS, "Connecting"); |
|
222 |
xfire_setvalue(XFIRE_NICKNAME, "-"); |
|
223 |
xfire_setvalue(XFIRE_ROOM, "-"); |
|
224 |
case 2: // In lobby |
|
225 |
xfire_setvalue(XFIRE_STATUS, "Online"); |
|
226 |
xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii()); |
|
227 |
xfire_setvalue(XFIRE_ROOM, "In game lobby"); |
|
228 |
break; |
|
229 |
case 3: // In room |
|
230 |
xfire_setvalue(XFIRE_STATUS, "Online"); |
|
231 |
xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii()); |
|
232 |
xfire_setvalue(XFIRE_ROOM, (hwnet->getRoom() + " (waiting for players)").toAscii()); |
|
233 |
break; |
|
234 |
case 5: // In game |
|
235 |
xfire_setvalue(XFIRE_STATUS, "Online"); |
|
236 |
xfire_setvalue(XFIRE_NICKNAME, hwnet->getNick().toAscii()); |
|
237 |
xfire_setvalue(XFIRE_ROOM, (hwnet->getRoom() + " (playing or spectating)").toAscii()); |
|
238 |
break; |
|
239 |
default: |
|
240 |
break; |
|
241 |
} |
|
242 |
} |
|
243 |
else |
|
244 |
{ |
|
245 |
xfire_setvalue(XFIRE_STATUS, "Offline"); |
|
246 |
xfire_setvalue(XFIRE_NICKNAME, "-"); |
|
247 |
xfire_setvalue(XFIRE_ROOM, "-"); |
|
248 |
xfire_setvalue(XFIRE_SERVER, "-"); |
|
249 |
} |
|
250 |
xfire_update(); |
|
251 |
} |
|
2822 | 252 |
#endif |
2821 | 253 |
|
1162 | 254 |
void HWForm::onFrontendFullscreen(bool value) |
255 |
{ |
|
1163 | 256 |
if (value) |
257 |
setWindowState(windowState() | Qt::WindowFullScreen); |
|
258 |
else { |
|
259 |
setWindowState(windowState() & !Qt::WindowFullScreen); |
|
260 |
} |
|
1162 | 261 |
} |
262 |
||
1419 | 263 |
void HWForm::CustomizePalettes() |
264 |
{ |
|
265 |
QList<QScrollBar *> allSBars = findChildren<QScrollBar *>(); |
|
266 |
QPalette pal = palette(); |
|
267 |
pal.setColor(QPalette::WindowText, QColor(0xff, 0xcc, 0x00)); |
|
268 |
pal.setColor(QPalette::Button, QColor(0x00, 0x35, 0x1d)); |
|
269 |
pal.setColor(QPalette::Base, QColor(0x00, 0x35, 0x1d)); |
|
270 |
pal.setColor(QPalette::Window, QColor(0x00, 0x00, 0x00)); |
|
271 |
||
272 |
for (int i = 0; i < allSBars.size(); ++i) |
|
273 |
allSBars.at(i)->setPalette(pal); |
|
274 |
} |
|
275 |
||
695 | 276 |
void HWForm::UpdateWeapons() |
277 |
{ |
|
1419 | 278 |
QVector<QComboBox*> combos; |
279 |
combos.push_back(ui.pageOptions->WeaponsName); |
|
280 |
combos.push_back(ui.pageMultiplayer->gameCFG->WeaponsName); |
|
281 |
combos.push_back(ui.pageNetGame->pGameCFG->WeaponsName); |
|
696 | 282 |
|
1517 | 283 |
QStringList names = ui.pageSelectWeapon->pWeapons->getWeaponNames(); |
284 |
||
285 |
for(QVector<QComboBox*>::iterator it = combos.begin(); it != combos.end(); ++it) { |
|
1419 | 286 |
(*it)->clear(); |
1517 | 287 |
|
288 |
for(int i = 0; i < names.size(); ++i) |
|
289 |
(*it)->addItem(names[i], ui.pageSelectWeapon->pWeapons->getWeaponsString(names[i])); |
|
2377 | 290 |
|
1509 | 291 |
int pos = (*it)->findText("Default"); |
292 |
if (pos != -1) { |
|
1419 | 293 |
(*it)->setCurrentIndex(pos); |
294 |
} |
|
295 |
} |
|
695 | 296 |
} |
297 |
||
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
298 |
void HWForm::UpdateTeamsLists(const QStringList* editable_teams) |
245 | 299 |
{ |
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
300 |
QStringList teamslist; |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
301 |
if(editable_teams) { |
1509 | 302 |
teamslist =* editable_teams; |
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
303 |
} else { |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
304 |
teamslist = config->GetTeamsList(); |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
305 |
} |
245 | 306 |
|
307 |
if(teamslist.empty()) { |
|
308 |
HWTeam defaultTeam("DefaultTeam"); |
|
309 |
defaultTeam.SaveToFile(); |
|
310 |
teamslist.push_back("DefaultTeam"); |
|
311 |
} |
|
312 |
||
313 |
ui.pageOptions->CBTeamName->clear(); |
|
314 |
ui.pageOptions->CBTeamName->addItems(teamslist); |
|
315 |
} |
|
316 |
||
184 | 317 |
void HWForm::GoToMain() |
318 |
{ |
|
289 | 319 |
GoToPage(ID_PAGE_MAIN); |
184 | 320 |
} |
321 |
||
322 |
void HWForm::GoToSinglePlayer() |
|
323 |
{ |
|
289 | 324 |
GoToPage(ID_PAGE_SINGLEPLAYER); |
184 | 325 |
} |
326 |
||
587 | 327 |
void HWForm::GoToTraining() |
328 |
{ |
|
329 |
GoToPage(ID_PAGE_TRAINING); |
|
330 |
} |
|
331 |
||
184 | 332 |
void HWForm::GoToSetup() |
333 |
{ |
|
289 | 334 |
GoToPage(ID_PAGE_SETUP); |
184 | 335 |
} |
336 |
||
694 | 337 |
void HWForm::GoToSelectNewWeapon() |
338 |
{ |
|
1509 | 339 |
ui.pageSelectWeapon->pWeapons->setWeaponsName(tr("new")); |
694 | 340 |
GoToPage(ID_PAGE_SELECTWEAPON); |
341 |
} |
|
342 |
||
600 | 343 |
void HWForm::GoToSelectWeapon() |
344 |
{ |
|
1509 | 345 |
ui.pageSelectWeapon->pWeapons->setWeaponsName(ui.pageOptions->WeaponsName->currentText()); |
600 | 346 |
GoToPage(ID_PAGE_SELECTWEAPON); |
347 |
} |
|
348 |
||
2009 | 349 |
void HWForm::GoToSelectWeaponSet(const QString & name) |
350 |
{ |
|
351 |
ui.pageSelectWeapon->pWeapons->setWeaponsName(name); |
|
352 |
GoToPage(ID_PAGE_SELECTWEAPON); |
|
353 |
} |
|
354 |
||
187 | 355 |
void HWForm::GoToInfo() |
356 |
{ |
|
289 | 357 |
GoToPage(ID_PAGE_INFO); |
187 | 358 |
} |
359 |
||
184 | 360 |
void HWForm::GoToMultiplayer() |
361 |
{ |
|
290 | 362 |
GoToPage(ID_PAGE_MULTIPLAYER); |
184 | 363 |
} |
364 |
||
579 | 365 |
void HWForm::GoToSaves() |
366 |
{ |
|
581 | 367 |
ui.pagePlayDemo->FillFromDir(PagePlayDemo::RT_Save); |
579 | 368 |
|
369 |
GoToPage(ID_PAGE_DEMOS); |
|
370 |
} |
|
371 |
||
184 | 372 |
void HWForm::GoToDemos() |
373 |
{ |
|
581 | 374 |
ui.pagePlayDemo->FillFromDir(PagePlayDemo::RT_Demo); |
579 | 375 |
|
290 | 376 |
GoToPage(ID_PAGE_DEMOS); |
184 | 377 |
} |
378 |
||
379 |
void HWForm::GoToNet() |
|
380 |
{ |
|
646 | 381 |
ui.pageNet->updateServersList(); |
632
5e09ae25729f
Half implement possibility for different backends of servers list
unc0rr
parents:
625
diff
changeset
|
382 |
|
289 | 383 |
GoToPage(ID_PAGE_NET); |
184 | 384 |
} |
385 |
||
1950 | 386 |
void HWForm::GoToNetType() |
387 |
{ |
|
388 |
GoToPage(ID_PAGE_NETTYPE); |
|
389 |
} |
|
390 |
||
646 | 391 |
void HWForm::GoToNetServer() |
392 |
{ |
|
393 |
GoToPage(ID_PAGE_NETSERVER); |
|
394 |
} |
|
395 |
||
1885 | 396 |
void HWForm::GoToSchemes() |
397 |
{ |
|
398 |
GoToPage(ID_PAGE_SCHEME); |
|
399 |
} |
|
400 |
||
1905 | 401 |
void HWForm::GoToAdmin() |
402 |
{ |
|
403 |
GoToPage(ID_PAGE_ADMIN); |
|
404 |
} |
|
405 |
||
496 | 406 |
void HWForm::OnPageShown(quint8 id, quint8 lastid) |
311 | 407 |
{ |
2822 | 408 |
#ifdef USE_XFIRE |
2821 | 409 |
updateXfire(); |
2822 | 410 |
#endif |
1354
a8dcdeb88a43
Various small insignificant improvements everywhere
unc0rr
parents:
1347
diff
changeset
|
411 |
if (id == ID_PAGE_MULTIPLAYER || id == ID_PAGE_NETGAME) { |
1343 | 412 |
QStringList tmNames = config->GetTeamsList(); |
322 | 413 |
TeamSelWidget* curTeamSelWidget; |
2377 | 414 |
|
496 | 415 |
if(id == ID_PAGE_MULTIPLAYER) { |
1343 | 416 |
curTeamSelWidget = ui.pageMultiplayer->teamsSelect; |
496 | 417 |
} else { |
1343 | 418 |
curTeamSelWidget = ui.pageNetGame->pNetTeamsWidget; |
496 | 419 |
} |
2377 | 420 |
|
311 | 421 |
QList<HWTeam> teamsList; |
1343 | 422 |
for(QStringList::iterator it = tmNames.begin(); it != tmNames.end(); it++) { |
311 | 423 |
HWTeam team(*it); |
424 |
team.LoadFromFile(); |
|
425 |
teamsList.push_back(team); |
|
426 |
} |
|
2377 | 427 |
|
1343 | 428 |
if(lastid == ID_PAGE_SETUP) { // _TEAM |
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
429 |
if (editedTeam) { |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
430 |
curTeamSelWidget->addTeam(*editedTeam); |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
431 |
} |
2010 | 432 |
} else if(lastid != ID_PAGE_GAMESTATS |
433 |
&& lastid != ID_PAGE_INGAME |
|
434 |
&& lastid != ID_PAGE_SCHEME |
|
435 |
&& lastid != ID_PAGE_SELECTWEAPON) { |
|
1627 | 436 |
curTeamSelWidget->resetPlayingTeams(teamsList); |
496 | 437 |
} |
1625 | 438 |
} else |
439 |
if (id == ID_PAGE_GAMESTATS) |
|
440 |
{ |
|
441 |
ui.pageGameStats->renderStats(); |
|
311 | 442 |
} |
2845 | 443 |
|
444 |
// load and save ignore/friends lists |
|
445 |
if(lastid == ID_PAGE_MULTIPLAYER || lastid == ID_PAGE_NETGAME) // leaving a room |
|
446 |
ui.pageNetGame->pChatWidget->saveLists(ui.pageOptions->editNetNick->text()); |
|
447 |
else if(lastid == ID_PAGE_ROOMSLIST) // leaving the lobby |
|
448 |
ui.pageRoomsList->chatWidget->saveLists(ui.pageOptions->editNetNick->text()); |
|
449 |
if(id == ID_PAGE_MULTIPLAYER || id == ID_PAGE_NETGAME) // joining a room |
|
450 |
ui.pageNetGame->pChatWidget->loadLists(ui.pageOptions->editNetNick->text()); |
|
451 |
else if(id == ID_PAGE_ROOMSLIST) // joining the lobby |
|
452 |
ui.pageRoomsList->chatWidget->loadLists(ui.pageOptions->editNetNick->text()); |
|
311 | 453 |
} |
454 |
||
289 | 455 |
void HWForm::GoToPage(quint8 id) |
456 |
{ |
|
1347 | 457 |
quint8 lastid = ui.Pages->currentIndex(); |
289 | 458 |
PagesStack.push(ui.Pages->currentIndex()); |
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
459 |
OnPageShown(id, lastid); |
289 | 460 |
ui.Pages->setCurrentIndex(id); |
461 |
} |
|
462 |
||
463 |
void HWForm::GoBack() |
|
464 |
{ |
|
465 |
quint8 id = PagesStack.isEmpty() ? ID_PAGE_MAIN : PagesStack.pop(); |
|
1347 | 466 |
quint8 curid = ui.Pages->currentIndex(); |
289 | 467 |
ui.Pages->setCurrentIndex(id); |
1347 | 468 |
OnPageShown(id, curid); |
2377 | 469 |
|
1845 | 470 |
if (id == ID_PAGE_CONNECTING) |
471 |
GoBack(); |
|
1672
6a451649558c
Properly handle room deletion in respect of pages switching
unc0rr
parents:
1671
diff
changeset
|
472 |
if (id == ID_PAGE_NETSERVER) |
6a451649558c
Properly handle room deletion in respect of pages switching
unc0rr
parents:
1671
diff
changeset
|
473 |
GoBack(); |
6a451649558c
Properly handle room deletion in respect of pages switching
unc0rr
parents:
1671
diff
changeset
|
474 |
if ((!hwnet) && (id == ID_PAGE_ROOMSLIST)) |
1359 | 475 |
GoBack(); |
2377 | 476 |
|
1672
6a451649558c
Properly handle room deletion in respect of pages switching
unc0rr
parents:
1671
diff
changeset
|
477 |
if ((!hwnet) || (!hwnet->isInRoom())) |
6a451649558c
Properly handle room deletion in respect of pages switching
unc0rr
parents:
1671
diff
changeset
|
478 |
if (id == ID_PAGE_NETGAME || id == ID_PAGE_NETGAME) |
6a451649558c
Properly handle room deletion in respect of pages switching
unc0rr
parents:
1671
diff
changeset
|
479 |
GoBack(); |
6a451649558c
Properly handle room deletion in respect of pages switching
unc0rr
parents:
1671
diff
changeset
|
480 |
|
1998 | 481 |
if (curid == ID_PAGE_ROOMSLIST) NetDisconnect(); |
1902
aeadb10c2d77
Add delete button and scheme selection combobox to scheme edit page
unc0rr
parents:
1899
diff
changeset
|
482 |
|
aeadb10c2d77
Add delete button and scheme selection combobox to scheme edit page
unc0rr
parents:
1899
diff
changeset
|
483 |
if (curid == ID_PAGE_SCHEME) |
aeadb10c2d77
Add delete button and scheme selection combobox to scheme edit page
unc0rr
parents:
1899
diff
changeset
|
484 |
ammoSchemeModel->Save(); |
184 | 485 |
} |
486 |
||
530 | 487 |
void HWForm::btnExitPressed() |
488 |
{ |
|
489 |
eggTimer.start(); |
|
490 |
} |
|
491 |
||
492 |
void HWForm::btnExitClicked() |
|
493 |
{ |
|
2400
2422ea85d100
added a utility that warns the user to install hedgewars when it's run from the diskimage
koda
parents:
2399
diff
changeset
|
494 |
if (eggTimer.elapsed() < 3000){ |
2422ea85d100
added a utility that warns the user to install hedgewars when it's run from the diskimage
koda
parents:
2399
diff
changeset
|
495 |
#ifdef __APPLE__ |
2422ea85d100
added a utility that warns the user to install hedgewars when it's run from the diskimage
koda
parents:
2399
diff
changeset
|
496 |
panel->showInstallController(); |
2422ea85d100
added a utility that warns the user to install hedgewars when it's run from the diskimage
koda
parents:
2399
diff
changeset
|
497 |
#endif |
530 | 498 |
close(); |
2400
2422ea85d100
added a utility that warns the user to install hedgewars when it's run from the diskimage
koda
parents:
2399
diff
changeset
|
499 |
} |
2422ea85d100
added a utility that warns the user to install hedgewars when it's run from the diskimage
koda
parents:
2399
diff
changeset
|
500 |
else |
530 | 501 |
{ |
502 |
QPushButton * btn = findChild<QPushButton *>("imageButt"); |
|
503 |
if (btn) |
|
504 |
{ |
|
505 |
btn->setIcon(QIcon(":/res/bonus.png")); |
|
506 |
} |
|
507 |
} |
|
508 |
} |
|
509 |
||
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
510 |
void HWForm::IntermediateSetup() |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
511 |
{ |
1509 | 512 |
quint8 id=ui.Pages->currentIndex(); |
513 |
TeamSelWidget* curTeamSelWidget; |
|
2377 | 514 |
|
1509 | 515 |
if(id == ID_PAGE_MULTIPLAYER) { |
516 |
curTeamSelWidget = ui.pageMultiplayer->teamsSelect; |
|
517 |
} else { |
|
518 |
curTeamSelWidget = ui.pageNetGame->pNetTeamsWidget; |
|
519 |
} |
|
2377 | 520 |
|
1509 | 521 |
QList<HWTeam> teams = curTeamSelWidget->getDontPlayingTeams(); |
522 |
QStringList tmnames; |
|
523 |
for(QList<HWTeam>::iterator it = teams.begin(); it != teams.end(); ++it) { |
|
524 |
tmnames += it->TeamName; |
|
525 |
} |
|
526 |
UpdateTeamsLists(&tmnames); // FIXME: still need more work if teamname is updated while configuring |
|
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
527 |
|
1509 | 528 |
GoToPage(ID_PAGE_SETUP); |
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
529 |
} |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
530 |
|
184 | 531 |
void HWForm::NewTeam() |
532 |
{ |
|
245 | 533 |
editedTeam = new HWTeam("unnamed"); |
534 |
editedTeam->SetToPage(this); |
|
290 | 535 |
GoToPage(ID_PAGE_SETUP_TEAM); |
184 | 536 |
} |
537 |
||
538 |
void HWForm::EditTeam() |
|
539 |
{ |
|
245 | 540 |
editedTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText()); |
541 |
editedTeam->LoadFromFile(); |
|
542 |
editedTeam->SetToPage(this); |
|
290 | 543 |
GoToPage(ID_PAGE_SETUP_TEAM); |
184 | 544 |
} |
545 |
||
1840 | 546 |
void HWForm::RandomNames() |
547 |
{ |
|
548 |
editedTeam->GetFromPage(this); |
|
1907 | 549 |
namegen->TeamRandomNames(editedTeam,FALSE); |
1840 | 550 |
editedTeam->SetToPage(this); |
551 |
} |
|
552 |
||
553 |
void HWForm::RandomName(const int &i) |
|
554 |
{ |
|
555 |
editedTeam->GetFromPage(this); |
|
1907 | 556 |
namegen->TeamRandomName(editedTeam,i); |
1840 | 557 |
editedTeam->SetToPage(this); |
558 |
} |
|
559 |
||
184 | 560 |
void HWForm::TeamSave() |
561 |
{ |
|
245 | 562 |
editedTeam->GetFromPage(this); |
563 |
editedTeam->SaveToFile(); |
|
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
564 |
delete editedTeam; |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
565 |
editedTeam=0; |
245 | 566 |
UpdateTeamsLists(); |
290 | 567 |
GoBack(); |
184 | 568 |
} |
569 |
||
570 |
void HWForm::TeamDiscard() |
|
571 |
{ |
|
245 | 572 |
delete editedTeam; |
496 | 573 |
editedTeam=0; |
290 | 574 |
GoBack(); |
184 | 575 |
} |
576 |
||
577 |
void HWForm::SimpleGame() |
|
578 |
{ |
|
1576
a02353129a41
Check for deprecated ammo schemes at startup and delete them
unc0rr
parents:
1569
diff
changeset
|
579 |
CreateGame(0, 0, *cDefaultAmmoStore); |
184 | 580 |
game->StartQuick(); |
581 |
} |
|
582 |
||
583 |
void HWForm::PlayDemo() |
|
584 |
{ |
|
585 |
QListWidgetItem * curritem = ui.pagePlayDemo->DemosList->currentItem(); |
|
586 |
if (!curritem) |
|
587 |
{ |
|
588 |
QMessageBox::critical(this, |
|
589 |
tr("Error"), |
|
2631
163b0128bd21
A rather tedious rename of "Please," to "Please" triggered by bruce89 in interests of proper grammar. Also updated lrelease-qt4 which should pick up artart78's prior hedgewars_fr.ts fixes. Also a couple of typos in en.txt / fi.txt / pl.txt
nemo
parents:
2532
diff
changeset
|
590 |
tr("Please select record from the list above"), |
184 | 591 |
tr("OK")); |
592 |
return ; |
|
593 |
} |
|
696 | 594 |
CreateGame(0, 0, 0); |
580 | 595 |
game->PlayDemo(curritem->data(Qt::UserRole).toString()); |
184 | 596 |
} |
597 |
||
666 | 598 |
void HWForm::NetConnectServer(const QString & host, quint16 port) |
416 | 599 |
{ |
1395 | 600 |
_NetConnect(host, port, ui.pageOptions->editNetNick->text()); |
601 |
} |
|
602 |
||
603 |
void HWForm::NetConnectOfficialServer() |
|
604 |
{ |
|
605 |
NetConnectServer("netserver.hedgewars.org", 46631); |
|
416 | 606 |
} |
607 |
||
314 | 608 |
void HWForm::_NetConnect(const QString & hostName, quint16 port, const QString & nick) |
184 | 609 |
{ |
637
8fa7ed5e13bd
Fix bad behavior when quickly click Connect button more than once
unc0rr
parents:
636
diff
changeset
|
610 |
if(hwnet) { |
8fa7ed5e13bd
Fix bad behavior when quickly click Connect button more than once
unc0rr
parents:
636
diff
changeset
|
611 |
hwnet->Disconnect(); |
8fa7ed5e13bd
Fix bad behavior when quickly click Connect button more than once
unc0rr
parents:
636
diff
changeset
|
612 |
delete hwnet; |
8fa7ed5e13bd
Fix bad behavior when quickly click Connect button more than once
unc0rr
parents:
636
diff
changeset
|
613 |
hwnet=0; |
8fa7ed5e13bd
Fix bad behavior when quickly click Connect button more than once
unc0rr
parents:
636
diff
changeset
|
614 |
} |
2377 | 615 |
|
1566
6b63c75fdc68
Start work on lobby: add/remove nick from the list on join/quit
unc0rr
parents:
1531
diff
changeset
|
616 |
ui.pageRoomsList->chatWidget->clear(); |
2377 | 617 |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
618 |
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
|
619 |
|
1845 | 620 |
GoToPage(ID_PAGE_CONNECTING); |
1800 | 621 |
|
1512
43742041c211
- Don't send 'Bad param' msg, as the only reason of it is just some lag
unc0rr
parents:
1509
diff
changeset
|
622 |
connect(hwnet, SIGNAL(showMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection); |
43742041c211
- Don't send 'Bad param' msg, as the only reason of it is just some lag
unc0rr
parents:
1509
diff
changeset
|
623 |
|
660 | 624 |
connect(hwnet, SIGNAL(AskForRunGame()), this, SLOT(CreateNetGame())); |
1311 | 625 |
connect(hwnet, SIGNAL(Connected()), this, SLOT(NetConnected())); |
184 | 626 |
connect(hwnet, SIGNAL(EnteredGame()), this, SLOT(NetGameEnter())); |
1600 | 627 |
connect(hwnet, SIGNAL(LeftRoom()), this, SLOT(NetLeftRoom())); |
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
628 |
connect(hwnet, SIGNAL(AddNetTeam(const HWTeam&)), this, SLOT(AddNetTeam(const HWTeam&))); |
1592
5ee77ee470a6
Start converting network protocol to no-disconnecting religion
unc0rr
parents:
1587
diff
changeset
|
629 |
connect(ui.pageNetGame->BtnBack, SIGNAL(clicked()), hwnet, SLOT(partRoom())); |
329
4c3aad46baa5
Send game parameters by net... Currently it leads to infinite loop, flooding traffic with messages about changes
unc0rr
parents:
328
diff
changeset
|
630 |
|
1874 | 631 |
// rooms list page stuff |
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1312
diff
changeset
|
632 |
connect(hwnet, SIGNAL(roomsList(const QStringList&)), |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1312
diff
changeset
|
633 |
ui.pageRoomsList, SLOT(setRoomsList(const QStringList&))); |
1856
e71dbf958c87
Enable admin button when have privilege. Button does nothing yet.
unc0rr
parents:
1846
diff
changeset
|
634 |
connect(hwnet, SIGNAL(adminAccess(bool)), |
e71dbf958c87
Enable admin button when have privilege. Button does nothing yet.
unc0rr
parents:
1846
diff
changeset
|
635 |
ui.pageRoomsList, SLOT(setAdmin(bool))); |
1860 | 636 |
connect(hwnet, SIGNAL(adminAccess(bool)), |
637 |
ui.pageRoomsList->chatWidget, SLOT(adminAccess(bool))); |
|
2377 | 638 |
|
1377 | 639 |
connect(hwnet, SIGNAL(serverMessage(const QString&)), |
1587 | 640 |
ui.pageRoomsList->chatWidget, SLOT(onServerMessage(const QString&))); |
1584
90f6a5abad17
Save much space for chat widget on lobby page by removing server message widget (now this messages goes to chat)
unc0rr
parents:
1577
diff
changeset
|
641 |
|
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1312
diff
changeset
|
642 |
connect(ui.pageRoomsList, SIGNAL(askForCreateRoom(const QString &)), |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1312
diff
changeset
|
643 |
hwnet, SLOT(CreateRoom(const QString&))); |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1312
diff
changeset
|
644 |
connect(ui.pageRoomsList, SIGNAL(askForJoinRoom(const QString &)), |
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1312
diff
changeset
|
645 |
hwnet, SLOT(JoinRoom(const QString&))); |
2345
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
646 |
// connect(ui.pageRoomsList, SIGNAL(askForCreateRoom(const QString &)), |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
647 |
// this, SLOT(NetGameMaster())); |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
648 |
// connect(ui.pageRoomsList, SIGNAL(askForJoinRoom(const QString &)), |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
649 |
// this, SLOT(NetGameSlave())); |
1315 | 650 |
connect(ui.pageRoomsList, SIGNAL(askForRoomList()), |
651 |
hwnet, SLOT(askRoomsList())); |
|
1313
f4c54e9e1b8c
- Introduce a bit of state miachine in client code (should be more robust and verbosive now)
unc0rr
parents:
1312
diff
changeset
|
652 |
|
2345
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
653 |
// room status stuff |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
654 |
connect(hwnet, SIGNAL(roomMaster(bool)), |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
655 |
this, SLOT(NetGameChangeStatus(bool))); |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
656 |
|
1874 | 657 |
// net page stuff |
1357 | 658 |
connect(hwnet, SIGNAL(chatStringFromNet(const QString&)), |
1360 | 659 |
ui.pageNetGame->pChatWidget, SLOT(onChatString(const QString&))); |
1405 | 660 |
connect(hwnet, SIGNAL(setReadyStatus(const QString &, bool)), |
661 |
ui.pageNetGame->pChatWidget, SLOT(setReadyStatus(const QString &, bool))); |
|
1364 | 662 |
connect(hwnet, SIGNAL(chatStringFromMe(const QString&)), |
1360 | 663 |
ui.pageNetGame->pChatWidget, SLOT(onChatString(const QString&))); |
1860 | 664 |
connect(hwnet, SIGNAL(roomMaster(bool)), |
665 |
ui.pageNetGame->pChatWidget, SLOT(adminAccess(bool))); |
|
461 | 666 |
connect(ui.pageNetGame->pChatWidget, SIGNAL(chatLine(const QString&)), |
667 |
hwnet, SLOT(chatLineToNet(const QString&))); |
|
1577 | 668 |
connect(ui.pageNetGame->BtnGo, SIGNAL(clicked()), hwnet, SLOT(ToggleReady())); |
1648 | 669 |
connect(hwnet, SIGNAL(setMyReadyStatus(bool)), |
670 |
ui.pageNetGame, SLOT(setReadyStatus(bool))); |
|
1577 | 671 |
|
1874 | 672 |
// chat widget actions |
1391 | 673 |
connect(ui.pageNetGame->pChatWidget, SIGNAL(kick(const QString&)), |
674 |
hwnet, SLOT(kickPlayer(const QString&))); |
|
1860 | 675 |
connect(ui.pageNetGame->pChatWidget, SIGNAL(ban(const QString&)), |
676 |
hwnet, SLOT(banPlayer(const QString&))); |
|
1577 | 677 |
connect(ui.pageNetGame->pChatWidget, SIGNAL(info(const QString&)), |
678 |
hwnet, SLOT(infoPlayer(const QString&))); |
|
2706
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2631
diff
changeset
|
679 |
connect(ui.pageNetGame->pChatWidget, SIGNAL(follow(const QString&)), |
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2631
diff
changeset
|
680 |
hwnet, SLOT(followPlayer(const QString&))); |
1860 | 681 |
connect(ui.pageRoomsList->chatWidget, SIGNAL(kick(const QString&)), |
682 |
hwnet, SLOT(kickPlayer(const QString&))); |
|
683 |
connect(ui.pageRoomsList->chatWidget, SIGNAL(ban(const QString&)), |
|
684 |
hwnet, SLOT(banPlayer(const QString&))); |
|
1577 | 685 |
connect(ui.pageRoomsList->chatWidget, SIGNAL(info(const QString&)), |
686 |
hwnet, SLOT(infoPlayer(const QString&))); |
|
2706
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2631
diff
changeset
|
687 |
connect(ui.pageRoomsList->chatWidget, SIGNAL(follow(const QString&)), |
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2631
diff
changeset
|
688 |
hwnet, SLOT(followPlayer(const QString&))); |
1566
6b63c75fdc68
Start work on lobby: add/remove nick from the list on join/quit
unc0rr
parents:
1531
diff
changeset
|
689 |
|
1874 | 690 |
// chatting |
1568 | 691 |
connect(ui.pageRoomsList->chatWidget, SIGNAL(chatLine(const QString&)), |
692 |
hwnet, SLOT(chatLineToLobby(const QString&))); |
|
693 |
connect(hwnet, SIGNAL(chatStringLobby(const QString&)), |
|
694 |
ui.pageRoomsList->chatWidget, SLOT(onChatString(const QString&))); |
|
695 |
connect(hwnet, SIGNAL(chatStringFromMeLobby(const QString&)), |
|
696 |
ui.pageRoomsList->chatWidget, SLOT(onChatString(const QString&))); |
|
697 |
||
1874 | 698 |
// nick list stuff |
2776 | 699 |
connect(hwnet, SIGNAL(nickAdded(const QString&, bool)), |
700 |
ui.pageNetGame->pChatWidget, SLOT(nickAdded(const QString&, bool))); |
|
471 | 701 |
connect(hwnet, SIGNAL(nickRemoved(const QString&)), |
465 | 702 |
ui.pageNetGame->pChatWidget, SLOT(nickRemoved(const QString&))); |
2776 | 703 |
connect(hwnet, SIGNAL(nickAddedLobby(const QString&, bool)), |
704 |
ui.pageRoomsList->chatWidget, SLOT(nickAdded(const QString&, bool))); |
|
1566
6b63c75fdc68
Start work on lobby: add/remove nick from the list on join/quit
unc0rr
parents:
1531
diff
changeset
|
705 |
connect(hwnet, SIGNAL(nickRemovedLobby(const QString&)), |
6b63c75fdc68
Start work on lobby: add/remove nick from the list on join/quit
unc0rr
parents:
1531
diff
changeset
|
706 |
ui.pageRoomsList->chatWidget, SLOT(nickRemoved(const QString&))); |
461 | 707 |
|
1874 | 708 |
// teams selecting stuff |
352 | 709 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(hhogsNumChanged(const HWTeam&)), |
710 |
hwnet, SLOT(onHedgehogsNumChanged(const HWTeam&))); |
|
372 | 711 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamColorChanged(const HWTeam&)), |
712 |
hwnet, SLOT(onTeamColorChanged(const HWTeam&))); |
|
327 | 713 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamWillPlay(HWTeam)), hwnet, SLOT(AddTeam(HWTeam))); |
373 | 714 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(acceptRequested(HWTeam)), hwnet, SLOT(AddTeam(HWTeam))); |
347 | 715 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamNotPlaying(const HWTeam&)), hwnet, SLOT(RemoveTeam(const HWTeam&))); |
425 | 716 |
connect(hwnet, SIGNAL(hhnumChanged(const HWTeam&)), |
352 | 717 |
ui.pageNetGame->pNetTeamsWidget, SLOT(changeHHNum(const HWTeam&))); |
425 | 718 |
connect(hwnet, SIGNAL(teamColorChanged(const HWTeam&)), |
372 | 719 |
ui.pageNetGame->pNetTeamsWidget, SLOT(changeTeamColor(const HWTeam&))); |
1874 | 720 |
|
1924 | 721 |
// admin stuff |
722 |
connect(hwnet, SIGNAL(serverMessage(const QString&)), ui.pageAdmin, SLOT(serverMessage(const QString &))); |
|
1925 | 723 |
connect(ui.pageAdmin, SIGNAL(setServerMessage(const QString&)), hwnet, SLOT(newServerMessage(const QString &))); |
2155
d897222d3339
Implement ability for server admin to clear accounts cache
unc0rr
parents:
2108
diff
changeset
|
724 |
connect(ui.pageAdmin->pbClearAccountsCache, SIGNAL(clicked()), hwnet, SLOT(clearAccountsCache())); |
1924 | 725 |
|
1898
f0ab0c77946d
Send scheme data over net (but recieving part isn't implemented yet)
unc0rr
parents:
1897
diff
changeset
|
726 |
// disconnect |
1873
815a3ff1fe4b
Start refactoring some things. Frontend becomes temporarily unusable for network game
unc0rr
parents:
1872
diff
changeset
|
727 |
connect(hwnet, SIGNAL(Disconnected()), this, SLOT(ForcedDisconnect()), Qt::QueuedConnection); |
2377 | 728 |
|
1874 | 729 |
hwnet->Connect(hostName, port, nick); |
184 | 730 |
} |
731 |
||
314 | 732 |
void HWForm::NetConnect() |
733 |
{ |
|
653
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
734 |
HWHostPortDialog * hpd = new HWHostPortDialog(this); |
654 | 735 |
hpd->leHost->setText(*netHost); |
736 |
hpd->sbPort->setValue(netPort); |
|
653
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
737 |
|
654 | 738 |
if (hpd->exec() == QDialog::Accepted) |
739 |
{ |
|
740 |
config->SaveOptions(); |
|
741 |
delete netHost; |
|
742 |
netHost = new QString(hpd->leHost->text()); |
|
743 |
netPort = hpd->sbPort->value(); |
|
1418 | 744 |
NetConnectServer(*netHost, netPort); |
654 | 745 |
} |
314 | 746 |
} |
747 |
||
748 |
void HWForm::NetStartServer() |
|
749 |
{ |
|
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
|
750 |
config->SaveOptions(); |
636 | 751 |
|
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
|
752 |
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
|
753 |
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
|
754 |
{ |
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
|
755 |
QMessageBox::critical(0, tr("Error"), |
1509 | 756 |
tr("Unable to start the server")); |
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
|
757 |
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
|
758 |
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
|
759 |
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
|
760 |
} |
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
|
761 |
|
1418 | 762 |
QTimer::singleShot(250, this, SLOT(AsyncNetServerStart())); |
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
|
763 |
|
1418 | 764 |
pRegisterServer = new HWNetUdpServer(0, |
765 |
ui.pageNetServer->leServerDescr->text(), |
|
766 |
ui.pageNetServer->sbPort->value()); |
|
767 |
} |
|
768 |
||
769 |
void HWForm::AsyncNetServerStart() |
|
770 |
{ |
|
771 |
NetConnectServer("localhost", pnetserver->getRunningPort()); |
|
314 | 772 |
} |
773 |
||
184 | 774 |
void HWForm::NetDisconnect() |
775 |
{ |
|
2108 | 776 |
//qDebug("NetDisconnect"); |
1509 | 777 |
if(hwnet) { |
778 |
hwnet->Disconnect(); |
|
779 |
delete hwnet; |
|
780 |
hwnet = 0; |
|
781 |
} |
|
782 |
if(pnetserver) { |
|
783 |
if (pRegisterServer) |
|
784 |
{ |
|
785 |
pRegisterServer->unregister(); |
|
786 |
pRegisterServer = 0; |
|
787 |
} |
|
659 | 788 |
|
1509 | 789 |
pnetserver->StopServer(); |
790 |
delete pnetserver; |
|
791 |
pnetserver = 0; |
|
792 |
} |
|
184 | 793 |
} |
794 |
||
383 | 795 |
void HWForm::ForcedDisconnect() |
796 |
{ |
|
1418 | 797 |
if(pnetserver) return; // we have server - let it care of all things |
798 |
if (hwnet) { |
|
799 |
hwnet->deleteLater(); |
|
800 |
hwnet = 0; |
|
801 |
QMessageBox::warning(this, QMessageBox::tr("Network"), |
|
802 |
QMessageBox::tr("Connection to server is lost")); |
|
2377 | 803 |
|
1418 | 804 |
} |
1800 | 805 |
if (ui.Pages->currentIndex() != ID_PAGE_NET) GoBack(); |
383 | 806 |
} |
807 |
||
1311 | 808 |
void HWForm::NetConnected() |
809 |
{ |
|
810 |
GoToPage(ID_PAGE_ROOMSLIST); |
|
811 |
} |
|
812 |
||
184 | 813 |
void HWForm::NetGameEnter() |
814 |
{ |
|
1593 | 815 |
ui.pageNetGame->pChatWidget->clear(); |
1354
a8dcdeb88a43
Various small insignificant improvements everywhere
unc0rr
parents:
1347
diff
changeset
|
816 |
GoToPage(ID_PAGE_NETGAME); |
184 | 817 |
} |
818 |
||
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
819 |
void HWForm::AddNetTeam(const HWTeam& team) |
184 | 820 |
{ |
1418 | 821 |
ui.pageNetGame->pNetTeamsWidget->addTeam(team); |
184 | 822 |
} |
823 |
||
824 |
void HWForm::StartMPGame() |
|
825 |
{ |
|
1531 | 826 |
QString ammo; |
827 |
ammo = ui.pageMultiplayer->gameCFG->WeaponsName->itemData( |
|
828 |
ui.pageMultiplayer->gameCFG->WeaponsName->currentIndex() |
|
829 |
).toString(); |
|
696 | 830 |
|
831 |
CreateGame(ui.pageMultiplayer->gameCFG, ui.pageMultiplayer->teamsSelect, ammo); |
|
306 | 832 |
|
184 | 833 |
game->StartLocal(); |
834 |
} |
|
306 | 835 |
|
836 |
void HWForm::GameStateChanged(GameState gameState) |
|
837 |
{ |
|
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
838 |
switch(gameState) { |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
839 |
case gsStarted: { |
1268
34c3795ecb63
Fix music starting to play after the round even if it was turned off
unc0rr
parents:
1235
diff
changeset
|
840 |
Music(false); |
2377 | 841 |
if (wBackground) wBackground->stopAnimation(); |
1223
41d7283934c1
Hackish way to play music in frontend... to be fixed
unc0rr
parents:
1165
diff
changeset
|
842 |
GoToPage(ID_PAGE_INGAME); |
1622 | 843 |
ui.pageGameStats->clear(); |
661
0523b15353a2
Unregister server in servers list when the game is started
unc0rr
parents:
660
diff
changeset
|
844 |
if (pRegisterServer) |
0523b15353a2
Unregister server in servers list when the game is started
unc0rr
parents:
660
diff
changeset
|
845 |
{ |
0523b15353a2
Unregister server in servers list when the game is started
unc0rr
parents:
660
diff
changeset
|
846 |
pRegisterServer->unregister(); |
0523b15353a2
Unregister server in servers list when the game is started
unc0rr
parents:
660
diff
changeset
|
847 |
pRegisterServer = 0; |
0523b15353a2
Unregister server in servers list when the game is started
unc0rr
parents:
660
diff
changeset
|
848 |
} |
2532
43d700d8dad0
Disable hiding of frontend for now - seems it might be reasons for frontend shutting down when host quits.
nemo
parents:
2527
diff
changeset
|
849 |
//setVisible(false); |
2820 | 850 |
setFocusPolicy(Qt::NoFocus); |
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
851 |
break; |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
852 |
} |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
853 |
case gsFinished: { |
2532
43d700d8dad0
Disable hiding of frontend for now - seems it might be reasons for frontend shutting down when host quits.
nemo
parents:
2527
diff
changeset
|
854 |
//setVisible(true); |
2820 | 855 |
setFocusPolicy(Qt::StrongFocus); |
686 | 856 |
GoBack(); |
2776 | 857 |
Music(ui.pageOptions->CBEnableFrontendMusic->isChecked()); |
2377 | 858 |
if (wBackground) wBackground->startAnimation(); |
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
859 |
GoToPage(ID_PAGE_GAMESTATS); |
1344
4004e597f1bf
Clients send roundfinished message to server when the round is over
unc0rr
parents:
1343
diff
changeset
|
860 |
if (hwnet) hwnet->gameFinished(); |
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
861 |
break; |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
862 |
} |
686 | 863 |
default: { |
2532
43d700d8dad0
Disable hiding of frontend for now - seems it might be reasons for frontend shutting down when host quits.
nemo
parents:
2527
diff
changeset
|
864 |
//setVisible(true); |
2820 | 865 |
setFocusPolicy(Qt::StrongFocus); |
686 | 866 |
quint8 id = ui.Pages->currentIndex(); |
1225
f882a92ef872
Play music in menu also, with fading effects when run game
unc0rr
parents:
1223
diff
changeset
|
867 |
if (id == ID_PAGE_INGAME) { |
f882a92ef872
Play music in menu also, with fading effects when run game
unc0rr
parents:
1223
diff
changeset
|
868 |
GoBack(); |
2776 | 869 |
Music(ui.pageOptions->CBEnableFrontendMusic->isChecked()); |
2377 | 870 |
if (wBackground) wBackground->startAnimation(); |
1344
4004e597f1bf
Clients send roundfinished message to server when the round is over
unc0rr
parents:
1343
diff
changeset
|
871 |
if (hwnet) hwnet->gameFinished(); |
1225
f882a92ef872
Play music in menu also, with fading effects when run game
unc0rr
parents:
1223
diff
changeset
|
872 |
} |
686 | 873 |
}; |
307 | 874 |
} |
875 |
} |
|
876 |
||
696 | 877 |
void HWForm::CreateGame(GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget, QString ammo) |
306 | 878 |
{ |
696 | 879 |
game = new HWGame(config, gamecfg, ammo, pTeamSelWidget); |
306 | 880 |
connect(game, SIGNAL(GameStateChanged(GameState)), this, SLOT(GameStateChanged(GameState))); |
1622 | 881 |
connect(game, SIGNAL(GameStats(char, const QString &)), ui.pageGameStats, SLOT(GameStats(char, const QString &))); |
425 | 882 |
connect(game, SIGNAL(ErrorMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection); |
533 | 883 |
connect(game, SIGNAL(HaveRecord(bool, const QByteArray &)), this, SLOT(GetRecord(bool, const QByteArray &))); |
306 | 884 |
} |
425 | 885 |
|
886 |
void HWForm::ShowErrorMessage(const QString & msg) |
|
887 |
{ |
|
888 |
QMessageBox::warning(this, |
|
889 |
"Hedgewars", |
|
890 |
msg); |
|
891 |
} |
|
533 | 892 |
|
893 |
void HWForm::GetRecord(bool isDemo, const QByteArray & record) |
|
894 |
{ |
|
895 |
QString filename; |
|
896 |
QByteArray demo = record; |
|
1487
b4cc59a6d50a
Add an option to name records with current date and time
unc0rr
parents:
1427
diff
changeset
|
897 |
QString recordFileName = |
b4cc59a6d50a
Add an option to name records with current date and time
unc0rr
parents:
1427
diff
changeset
|
898 |
config->appendDateTimeToRecordName() ? |
1664 | 899 |
QDateTime::currentDateTime().toString("yyyy-MM-dd_hh-mm") : |
1487
b4cc59a6d50a
Add an option to name records with current date and time
unc0rr
parents:
1427
diff
changeset
|
900 |
"LastRound"; |
b4cc59a6d50a
Add an option to name records with current date and time
unc0rr
parents:
1427
diff
changeset
|
901 |
|
533 | 902 |
if (isDemo) |
903 |
{ |
|
904 |
demo.replace(QByteArray("\x02TL"), QByteArray("\x02TD")); |
|
905 |
demo.replace(QByteArray("\x02TN"), QByteArray("\x02TD")); |
|
989 | 906 |
demo.replace(QByteArray("\x02TS"), QByteArray("\x02TD")); |
2742 | 907 |
filename = cfgdir->absolutePath() + "/Demos/" + recordFileName + "." + *cProtoVer + ".hwd"; |
533 | 908 |
} else |
909 |
{ |
|
910 |
demo.replace(QByteArray("\x02TL"), QByteArray("\x02TS")); |
|
911 |
demo.replace(QByteArray("\x02TN"), QByteArray("\x02TS")); |
|
2742 | 912 |
filename = cfgdir->absolutePath() + "/Saves/" + recordFileName + "." + *cProtoVer + ".hws"; |
533 | 913 |
} |
914 |
||
915 |
||
916 |
QFile demofile(filename); |
|
917 |
if (!demofile.open(QIODevice::WriteOnly)) |
|
918 |
{ |
|
919 |
ShowErrorMessage(tr("Cannot save record to file %1").arg(filename)); |
|
920 |
return ; |
|
921 |
} |
|
922 |
demofile.write(demo.constData(), demo.size()); |
|
923 |
demofile.close(); |
|
924 |
} |
|
587 | 925 |
|
926 |
void HWForm::StartTraining() |
|
927 |
{ |
|
696 | 928 |
CreateGame(0, 0, 0); |
587 | 929 |
|
2468
0b62498c201a
openal fix, training map selection and rcplane adjustments from Smaxx (untested, but look reasonable). Bunch of new graphics from Tiy, new translation for pt-pt from inu_
nemo
parents:
2443
diff
changeset
|
930 |
game->StartTraining(ui.pageTraining->CBSelect->currentText()); |
587 | 931 |
} |
660 | 932 |
|
933 |
void HWForm::CreateNetGame() |
|
934 |
{ |
|
697 | 935 |
QString ammo; |
1517 | 936 |
ammo = ui.pageNetGame->pGameCFG->WeaponsName->itemData( |
937 |
ui.pageNetGame->pGameCFG->WeaponsName->currentIndex() |
|
938 |
).toString(); |
|
939 |
||
696 | 940 |
CreateGame(ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget, ammo); |
660 | 941 |
|
942 |
connect(game, SIGNAL(SendNet(const QByteArray &)), hwnet, SLOT(SendNet(const QByteArray &))); |
|
1356 | 943 |
connect(game, SIGNAL(SendChat(const QString &)), hwnet, SLOT(chatLineToNet(const QString &))); |
2403 | 944 |
connect(game, SIGNAL(SendTeamMessage(const QString &)), hwnet, SLOT(SendTeamMessage(const QString &))); |
660 | 945 |
connect(hwnet, SIGNAL(FromNet(const QByteArray &)), game, SLOT(FromNet(const QByteArray &))); |
1356 | 946 |
connect(hwnet, SIGNAL(chatStringFromNet(const QString &)), game, SLOT(FromNetChat(const QString &))); |
660 | 947 |
|
948 |
game->StartNet(); |
|
949 |
} |
|
674 | 950 |
|
951 |
void HWForm::closeEvent(QCloseEvent *event) |
|
952 |
{ |
|
2822 | 953 |
#ifdef USE_XFIRE |
2821 | 954 |
xfire_free(); |
2822 | 955 |
#endif |
674 | 956 |
config->SaveOptions(); |
957 |
event->accept(); |
|
958 |
} |
|
1235 | 959 |
|
960 |
void HWForm::Music(bool checked) |
|
961 |
{ |
|
962 |
if (checked) |
|
2428 | 963 |
sdli.StartMusic(); |
1235 | 964 |
else |
2428 | 965 |
sdli.StopMusic(); |
1235 | 966 |
} |
1409
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1405
diff
changeset
|
967 |
|
2345
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
968 |
void HWForm::NetGameChangeStatus(bool isMaster) |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
969 |
{ |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
970 |
if (isMaster) |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
971 |
NetGameMaster(); |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
972 |
else |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
973 |
NetGameSlave(); |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
974 |
} |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
975 |
|
1409
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1405
diff
changeset
|
976 |
void HWForm::NetGameMaster() |
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1405
diff
changeset
|
977 |
{ |
1649 | 978 |
ui.pageNetGame->setMasterMode(true); |
1409
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1405
diff
changeset
|
979 |
ui.pageNetGame->restrictJoins->setChecked(false); |
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1405
diff
changeset
|
980 |
ui.pageNetGame->restrictTeamAdds->setChecked(false); |
1898
f0ab0c77946d
Send scheme data over net (but recieving part isn't implemented yet)
unc0rr
parents:
1897
diff
changeset
|
981 |
ui.pageNetGame->pGameCFG->GameSchemes->setModel(ammoSchemeModel); |
2345
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
982 |
ui.pageNetGame->pGameCFG->setEnabled(true); |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
983 |
ui.pageNetGame->pNetTeamsWidget->setInteractivity(true); |
2377 | 984 |
|
1410
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1409
diff
changeset
|
985 |
if (hwnet) |
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1409
diff
changeset
|
986 |
{ |
1828
ba91a89f449a
Fix bug with not working toggles 'rectrict joins' and 'restrict team adding'
unc0rr
parents:
1802
diff
changeset
|
987 |
// disconnect connections first to ensure their inexistance and not to connect twice |
1951 | 988 |
ui.pageNetGame->BtnStart->disconnect(hwnet); |
1828
ba91a89f449a
Fix bug with not working toggles 'rectrict joins' and 'restrict team adding'
unc0rr
parents:
1802
diff
changeset
|
989 |
ui.pageNetGame->restrictJoins->disconnect(hwnet); |
ba91a89f449a
Fix bug with not working toggles 'rectrict joins' and 'restrict team adding'
unc0rr
parents:
1802
diff
changeset
|
990 |
ui.pageNetGame->restrictTeamAdds->disconnect(hwnet); |
1951 | 991 |
connect(ui.pageNetGame->BtnStart, SIGNAL(clicked()), hwnet, SLOT(startGame())); |
1413 | 992 |
connect(ui.pageNetGame->restrictJoins, SIGNAL(triggered()), hwnet, SLOT(toggleRestrictJoins())); |
993 |
connect(ui.pageNetGame->restrictTeamAdds, SIGNAL(triggered()), hwnet, SLOT(toggleRestrictTeamAdds())); |
|
2080
6d29370dc0dd
This should resend scheme info to net server when scheme got edited (not tested)
unc0rr
parents:
2027
diff
changeset
|
994 |
connect(ui.pageNetGame->pGameCFG->GameSchemes->model(), |
6d29370dc0dd
This should resend scheme info to net server when scheme got edited (not tested)
unc0rr
parents:
2027
diff
changeset
|
995 |
SIGNAL(dataChanged(const QModelIndex &, const QModelIndex &)), |
6d29370dc0dd
This should resend scheme info to net server when scheme got edited (not tested)
unc0rr
parents:
2027
diff
changeset
|
996 |
ui.pageNetGame->pGameCFG, |
6d29370dc0dd
This should resend scheme info to net server when scheme got edited (not tested)
unc0rr
parents:
2027
diff
changeset
|
997 |
SLOT(resendSchemeData()) |
6d29370dc0dd
This should resend scheme info to net server when scheme got edited (not tested)
unc0rr
parents:
2027
diff
changeset
|
998 |
); |
1410
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1409
diff
changeset
|
999 |
} |
1409
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1405
diff
changeset
|
1000 |
} |
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1405
diff
changeset
|
1001 |
|
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1405
diff
changeset
|
1002 |
void HWForm::NetGameSlave() |
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1405
diff
changeset
|
1003 |
{ |
2345
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
1004 |
ui.pageNetGame->pGameCFG->setEnabled(false); |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
1005 |
ui.pageNetGame->pNetTeamsWidget->setInteractivity(false); |
2377 | 1006 |
|
1899
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1007 |
if (hwnet) |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1008 |
{ |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1009 |
NetAmmoSchemeModel * netAmmo = new NetAmmoSchemeModel(hwnet); |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1010 |
connect(hwnet, SIGNAL(netSchemeConfig(QStringList &)), netAmmo, SLOT(setNetSchemeConfig(QStringList &))); |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1011 |
ui.pageNetGame->pGameCFG->GameSchemes->setModel(netAmmo); |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1012 |
|
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1013 |
ui.pageNetGame->pGameCFG->GameSchemes->view()->disconnect(hwnet); |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1014 |
connect(hwnet, SIGNAL(netSchemeConfig(QStringList &)), |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1015 |
this, SLOT(selectFirstNetScheme())); |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1016 |
} |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1017 |
|
1649 | 1018 |
ui.pageNetGame->setMasterMode(false); |
1409
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1405
diff
changeset
|
1019 |
} |
1600 | 1020 |
|
1899
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1021 |
void HWForm::selectFirstNetScheme() |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1022 |
{ |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1023 |
ui.pageNetGame->pGameCFG->GameSchemes->setCurrentIndex(0); |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1024 |
} |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1025 |
|
1600 | 1026 |
void HWForm::NetLeftRoom() |
1027 |
{ |
|
1028 |
if (ui.Pages->currentIndex() == ID_PAGE_NETGAME) |
|
1029 |
GoBack(); |
|
1030 |
else |
|
1031 |
qWarning("Left room while not in room"); |
|
1032 |
} |
|
2012 | 1033 |
|
1034 |
void HWForm::resizeEvent(QResizeEvent * event) |
|
1035 |
{ |
|
1036 |
int w = event->size().width(); |
|
1037 |
int h = event->size().height(); |
|
2098
c977d7f2aa09
Toggle for stars ("frontend effects") - also turns off optimisations for stars that were causing problems onone machine
nemo
parents:
2080
diff
changeset
|
1038 |
if (wBackground) { |
c977d7f2aa09
Toggle for stars ("frontend effects") - also turns off optimisations for stars that were causing problems onone machine
nemo
parents:
2080
diff
changeset
|
1039 |
wBackground->setFixedSize(w, h); |
c977d7f2aa09
Toggle for stars ("frontend effects") - also turns off optimisations for stars that were causing problems onone machine
nemo
parents:
2080
diff
changeset
|
1040 |
wBackground->move(0, 0); |
c977d7f2aa09
Toggle for stars ("frontend effects") - also turns off optimisations for stars that were causing problems onone machine
nemo
parents:
2080
diff
changeset
|
1041 |
} |
2012 | 1042 |
} |