author | nemo |
Sat, 20 Feb 2010 18:58:51 +0000 | |
changeset 2831 | 797207d0c500 |
parent 2822 | 0533562bc3a4 |
child 2845 | 19db164dd20d |
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 |
} |
443 |
} |
|
444 |
||
289 | 445 |
void HWForm::GoToPage(quint8 id) |
446 |
{ |
|
1347 | 447 |
quint8 lastid = ui.Pages->currentIndex(); |
289 | 448 |
PagesStack.push(ui.Pages->currentIndex()); |
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
449 |
OnPageShown(id, lastid); |
289 | 450 |
ui.Pages->setCurrentIndex(id); |
451 |
} |
|
452 |
||
453 |
void HWForm::GoBack() |
|
454 |
{ |
|
455 |
quint8 id = PagesStack.isEmpty() ? ID_PAGE_MAIN : PagesStack.pop(); |
|
1347 | 456 |
quint8 curid = ui.Pages->currentIndex(); |
289 | 457 |
ui.Pages->setCurrentIndex(id); |
1347 | 458 |
OnPageShown(id, curid); |
2377 | 459 |
|
1845 | 460 |
if (id == ID_PAGE_CONNECTING) |
461 |
GoBack(); |
|
1672
6a451649558c
Properly handle room deletion in respect of pages switching
unc0rr
parents:
1671
diff
changeset
|
462 |
if (id == ID_PAGE_NETSERVER) |
6a451649558c
Properly handle room deletion in respect of pages switching
unc0rr
parents:
1671
diff
changeset
|
463 |
GoBack(); |
6a451649558c
Properly handle room deletion in respect of pages switching
unc0rr
parents:
1671
diff
changeset
|
464 |
if ((!hwnet) && (id == ID_PAGE_ROOMSLIST)) |
1359 | 465 |
GoBack(); |
2377 | 466 |
|
1672
6a451649558c
Properly handle room deletion in respect of pages switching
unc0rr
parents:
1671
diff
changeset
|
467 |
if ((!hwnet) || (!hwnet->isInRoom())) |
6a451649558c
Properly handle room deletion in respect of pages switching
unc0rr
parents:
1671
diff
changeset
|
468 |
if (id == ID_PAGE_NETGAME || id == ID_PAGE_NETGAME) |
6a451649558c
Properly handle room deletion in respect of pages switching
unc0rr
parents:
1671
diff
changeset
|
469 |
GoBack(); |
6a451649558c
Properly handle room deletion in respect of pages switching
unc0rr
parents:
1671
diff
changeset
|
470 |
|
1998 | 471 |
if (curid == ID_PAGE_ROOMSLIST) NetDisconnect(); |
1902
aeadb10c2d77
Add delete button and scheme selection combobox to scheme edit page
unc0rr
parents:
1899
diff
changeset
|
472 |
|
aeadb10c2d77
Add delete button and scheme selection combobox to scheme edit page
unc0rr
parents:
1899
diff
changeset
|
473 |
if (curid == ID_PAGE_SCHEME) |
aeadb10c2d77
Add delete button and scheme selection combobox to scheme edit page
unc0rr
parents:
1899
diff
changeset
|
474 |
ammoSchemeModel->Save(); |
184 | 475 |
} |
476 |
||
530 | 477 |
void HWForm::btnExitPressed() |
478 |
{ |
|
479 |
eggTimer.start(); |
|
480 |
} |
|
481 |
||
482 |
void HWForm::btnExitClicked() |
|
483 |
{ |
|
2400
2422ea85d100
added a utility that warns the user to install hedgewars when it's run from the diskimage
koda
parents:
2399
diff
changeset
|
484 |
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
|
485 |
#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
|
486 |
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
|
487 |
#endif |
530 | 488 |
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
|
489 |
} |
2422ea85d100
added a utility that warns the user to install hedgewars when it's run from the diskimage
koda
parents:
2399
diff
changeset
|
490 |
else |
530 | 491 |
{ |
492 |
QPushButton * btn = findChild<QPushButton *>("imageButt"); |
|
493 |
if (btn) |
|
494 |
{ |
|
495 |
btn->setIcon(QIcon(":/res/bonus.png")); |
|
496 |
} |
|
497 |
} |
|
498 |
} |
|
499 |
||
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
500 |
void HWForm::IntermediateSetup() |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
501 |
{ |
1509 | 502 |
quint8 id=ui.Pages->currentIndex(); |
503 |
TeamSelWidget* curTeamSelWidget; |
|
2377 | 504 |
|
1509 | 505 |
if(id == ID_PAGE_MULTIPLAYER) { |
506 |
curTeamSelWidget = ui.pageMultiplayer->teamsSelect; |
|
507 |
} else { |
|
508 |
curTeamSelWidget = ui.pageNetGame->pNetTeamsWidget; |
|
509 |
} |
|
2377 | 510 |
|
1509 | 511 |
QList<HWTeam> teams = curTeamSelWidget->getDontPlayingTeams(); |
512 |
QStringList tmnames; |
|
513 |
for(QList<HWTeam>::iterator it = teams.begin(); it != teams.end(); ++it) { |
|
514 |
tmnames += it->TeamName; |
|
515 |
} |
|
516 |
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
|
517 |
|
1509 | 518 |
GoToPage(ID_PAGE_SETUP); |
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
519 |
} |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
520 |
|
184 | 521 |
void HWForm::NewTeam() |
522 |
{ |
|
245 | 523 |
editedTeam = new HWTeam("unnamed"); |
524 |
editedTeam->SetToPage(this); |
|
290 | 525 |
GoToPage(ID_PAGE_SETUP_TEAM); |
184 | 526 |
} |
527 |
||
528 |
void HWForm::EditTeam() |
|
529 |
{ |
|
245 | 530 |
editedTeam = new HWTeam(ui.pageOptions->CBTeamName->currentText()); |
531 |
editedTeam->LoadFromFile(); |
|
532 |
editedTeam->SetToPage(this); |
|
290 | 533 |
GoToPage(ID_PAGE_SETUP_TEAM); |
184 | 534 |
} |
535 |
||
1840 | 536 |
void HWForm::RandomNames() |
537 |
{ |
|
538 |
editedTeam->GetFromPage(this); |
|
1907 | 539 |
namegen->TeamRandomNames(editedTeam,FALSE); |
1840 | 540 |
editedTeam->SetToPage(this); |
541 |
} |
|
542 |
||
543 |
void HWForm::RandomName(const int &i) |
|
544 |
{ |
|
545 |
editedTeam->GetFromPage(this); |
|
1907 | 546 |
namegen->TeamRandomName(editedTeam,i); |
1840 | 547 |
editedTeam->SetToPage(this); |
548 |
} |
|
549 |
||
184 | 550 |
void HWForm::TeamSave() |
551 |
{ |
|
245 | 552 |
editedTeam->GetFromPage(this); |
553 |
editedTeam->SaveToFile(); |
|
535
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
554 |
delete editedTeam; |
a14eaf35cf4b
"Setup" button instead of "New team", exclude playing teams from setup
displacer
parents:
533
diff
changeset
|
555 |
editedTeam=0; |
245 | 556 |
UpdateTeamsLists(); |
290 | 557 |
GoBack(); |
184 | 558 |
} |
559 |
||
560 |
void HWForm::TeamDiscard() |
|
561 |
{ |
|
245 | 562 |
delete editedTeam; |
496 | 563 |
editedTeam=0; |
290 | 564 |
GoBack(); |
184 | 565 |
} |
566 |
||
567 |
void HWForm::SimpleGame() |
|
568 |
{ |
|
1576
a02353129a41
Check for deprecated ammo schemes at startup and delete them
unc0rr
parents:
1569
diff
changeset
|
569 |
CreateGame(0, 0, *cDefaultAmmoStore); |
184 | 570 |
game->StartQuick(); |
571 |
} |
|
572 |
||
573 |
void HWForm::PlayDemo() |
|
574 |
{ |
|
575 |
QListWidgetItem * curritem = ui.pagePlayDemo->DemosList->currentItem(); |
|
576 |
if (!curritem) |
|
577 |
{ |
|
578 |
QMessageBox::critical(this, |
|
579 |
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
|
580 |
tr("Please select record from the list above"), |
184 | 581 |
tr("OK")); |
582 |
return ; |
|
583 |
} |
|
696 | 584 |
CreateGame(0, 0, 0); |
580 | 585 |
game->PlayDemo(curritem->data(Qt::UserRole).toString()); |
184 | 586 |
} |
587 |
||
666 | 588 |
void HWForm::NetConnectServer(const QString & host, quint16 port) |
416 | 589 |
{ |
1395 | 590 |
_NetConnect(host, port, ui.pageOptions->editNetNick->text()); |
591 |
} |
|
592 |
||
593 |
void HWForm::NetConnectOfficialServer() |
|
594 |
{ |
|
595 |
NetConnectServer("netserver.hedgewars.org", 46631); |
|
416 | 596 |
} |
597 |
||
314 | 598 |
void HWForm::_NetConnect(const QString & hostName, quint16 port, const QString & nick) |
184 | 599 |
{ |
637
8fa7ed5e13bd
Fix bad behavior when quickly click Connect button more than once
unc0rr
parents:
636
diff
changeset
|
600 |
if(hwnet) { |
8fa7ed5e13bd
Fix bad behavior when quickly click Connect button more than once
unc0rr
parents:
636
diff
changeset
|
601 |
hwnet->Disconnect(); |
8fa7ed5e13bd
Fix bad behavior when quickly click Connect button more than once
unc0rr
parents:
636
diff
changeset
|
602 |
delete hwnet; |
8fa7ed5e13bd
Fix bad behavior when quickly click Connect button more than once
unc0rr
parents:
636
diff
changeset
|
603 |
hwnet=0; |
8fa7ed5e13bd
Fix bad behavior when quickly click Connect button more than once
unc0rr
parents:
636
diff
changeset
|
604 |
} |
2377 | 605 |
|
1566
6b63c75fdc68
Start work on lobby: add/remove nick from the list on join/quit
unc0rr
parents:
1531
diff
changeset
|
606 |
ui.pageRoomsList->chatWidget->clear(); |
2377 | 607 |
|
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
608 |
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
|
609 |
|
1845 | 610 |
GoToPage(ID_PAGE_CONNECTING); |
1800 | 611 |
|
1512
43742041c211
- Don't send 'Bad param' msg, as the only reason of it is just some lag
unc0rr
parents:
1509
diff
changeset
|
612 |
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
|
613 |
|
660 | 614 |
connect(hwnet, SIGNAL(AskForRunGame()), this, SLOT(CreateNetGame())); |
1311 | 615 |
connect(hwnet, SIGNAL(Connected()), this, SLOT(NetConnected())); |
184 | 616 |
connect(hwnet, SIGNAL(EnteredGame()), this, SLOT(NetGameEnter())); |
1600 | 617 |
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
|
618 |
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
|
619 |
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
|
620 |
|
1874 | 621 |
// 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
|
622 |
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
|
623 |
ui.pageRoomsList, SLOT(setRoomsList(const QStringList&))); |
1856
e71dbf958c87
Enable admin button when have privilege. Button does nothing yet.
unc0rr
parents:
1846
diff
changeset
|
624 |
connect(hwnet, SIGNAL(adminAccess(bool)), |
e71dbf958c87
Enable admin button when have privilege. Button does nothing yet.
unc0rr
parents:
1846
diff
changeset
|
625 |
ui.pageRoomsList, SLOT(setAdmin(bool))); |
1860 | 626 |
connect(hwnet, SIGNAL(adminAccess(bool)), |
627 |
ui.pageRoomsList->chatWidget, SLOT(adminAccess(bool))); |
|
2377 | 628 |
|
1377 | 629 |
connect(hwnet, SIGNAL(serverMessage(const QString&)), |
1587 | 630 |
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
|
631 |
|
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(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
|
633 |
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
|
634 |
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
|
635 |
hwnet, SLOT(JoinRoom(const QString&))); |
2345
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
636 |
// 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
|
637 |
// this, SLOT(NetGameMaster())); |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
638 |
// 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
|
639 |
// this, SLOT(NetGameSlave())); |
1315 | 640 |
connect(ui.pageRoomsList, SIGNAL(askForRoomList()), |
641 |
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
|
642 |
|
2345
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
643 |
// room status stuff |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
644 |
connect(hwnet, SIGNAL(roomMaster(bool)), |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
645 |
this, SLOT(NetGameChangeStatus(bool))); |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
646 |
|
1874 | 647 |
// net page stuff |
1357 | 648 |
connect(hwnet, SIGNAL(chatStringFromNet(const QString&)), |
1360 | 649 |
ui.pageNetGame->pChatWidget, SLOT(onChatString(const QString&))); |
1405 | 650 |
connect(hwnet, SIGNAL(setReadyStatus(const QString &, bool)), |
651 |
ui.pageNetGame->pChatWidget, SLOT(setReadyStatus(const QString &, bool))); |
|
1364 | 652 |
connect(hwnet, SIGNAL(chatStringFromMe(const QString&)), |
1360 | 653 |
ui.pageNetGame->pChatWidget, SLOT(onChatString(const QString&))); |
1860 | 654 |
connect(hwnet, SIGNAL(roomMaster(bool)), |
655 |
ui.pageNetGame->pChatWidget, SLOT(adminAccess(bool))); |
|
461 | 656 |
connect(ui.pageNetGame->pChatWidget, SIGNAL(chatLine(const QString&)), |
657 |
hwnet, SLOT(chatLineToNet(const QString&))); |
|
1577 | 658 |
connect(ui.pageNetGame->BtnGo, SIGNAL(clicked()), hwnet, SLOT(ToggleReady())); |
1648 | 659 |
connect(hwnet, SIGNAL(setMyReadyStatus(bool)), |
660 |
ui.pageNetGame, SLOT(setReadyStatus(bool))); |
|
1577 | 661 |
|
1874 | 662 |
// chat widget actions |
1391 | 663 |
connect(ui.pageNetGame->pChatWidget, SIGNAL(kick(const QString&)), |
664 |
hwnet, SLOT(kickPlayer(const QString&))); |
|
1860 | 665 |
connect(ui.pageNetGame->pChatWidget, SIGNAL(ban(const QString&)), |
666 |
hwnet, SLOT(banPlayer(const QString&))); |
|
1577 | 667 |
connect(ui.pageNetGame->pChatWidget, SIGNAL(info(const QString&)), |
668 |
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
|
669 |
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
|
670 |
hwnet, SLOT(followPlayer(const QString&))); |
1860 | 671 |
connect(ui.pageRoomsList->chatWidget, SIGNAL(kick(const QString&)), |
672 |
hwnet, SLOT(kickPlayer(const QString&))); |
|
673 |
connect(ui.pageRoomsList->chatWidget, SIGNAL(ban(const QString&)), |
|
674 |
hwnet, SLOT(banPlayer(const QString&))); |
|
1577 | 675 |
connect(ui.pageRoomsList->chatWidget, SIGNAL(info(const QString&)), |
676 |
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
|
677 |
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
|
678 |
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
|
679 |
|
1874 | 680 |
// chatting |
1568 | 681 |
connect(ui.pageRoomsList->chatWidget, SIGNAL(chatLine(const QString&)), |
682 |
hwnet, SLOT(chatLineToLobby(const QString&))); |
|
683 |
connect(hwnet, SIGNAL(chatStringLobby(const QString&)), |
|
684 |
ui.pageRoomsList->chatWidget, SLOT(onChatString(const QString&))); |
|
685 |
connect(hwnet, SIGNAL(chatStringFromMeLobby(const QString&)), |
|
686 |
ui.pageRoomsList->chatWidget, SLOT(onChatString(const QString&))); |
|
687 |
||
1874 | 688 |
// nick list stuff |
2776 | 689 |
connect(hwnet, SIGNAL(nickAdded(const QString&, bool)), |
690 |
ui.pageNetGame->pChatWidget, SLOT(nickAdded(const QString&, bool))); |
|
471 | 691 |
connect(hwnet, SIGNAL(nickRemoved(const QString&)), |
465 | 692 |
ui.pageNetGame->pChatWidget, SLOT(nickRemoved(const QString&))); |
2776 | 693 |
connect(hwnet, SIGNAL(nickAddedLobby(const QString&, bool)), |
694 |
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
|
695 |
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
|
696 |
ui.pageRoomsList->chatWidget, SLOT(nickRemoved(const QString&))); |
461 | 697 |
|
1874 | 698 |
// teams selecting stuff |
352 | 699 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(hhogsNumChanged(const HWTeam&)), |
700 |
hwnet, SLOT(onHedgehogsNumChanged(const HWTeam&))); |
|
372 | 701 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamColorChanged(const HWTeam&)), |
702 |
hwnet, SLOT(onTeamColorChanged(const HWTeam&))); |
|
327 | 703 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamWillPlay(HWTeam)), hwnet, SLOT(AddTeam(HWTeam))); |
373 | 704 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(acceptRequested(HWTeam)), hwnet, SLOT(AddTeam(HWTeam))); |
347 | 705 |
connect(ui.pageNetGame->pNetTeamsWidget, SIGNAL(teamNotPlaying(const HWTeam&)), hwnet, SLOT(RemoveTeam(const HWTeam&))); |
425 | 706 |
connect(hwnet, SIGNAL(hhnumChanged(const HWTeam&)), |
352 | 707 |
ui.pageNetGame->pNetTeamsWidget, SLOT(changeHHNum(const HWTeam&))); |
425 | 708 |
connect(hwnet, SIGNAL(teamColorChanged(const HWTeam&)), |
372 | 709 |
ui.pageNetGame->pNetTeamsWidget, SLOT(changeTeamColor(const HWTeam&))); |
1874 | 710 |
|
1924 | 711 |
// admin stuff |
712 |
connect(hwnet, SIGNAL(serverMessage(const QString&)), ui.pageAdmin, SLOT(serverMessage(const QString &))); |
|
1925 | 713 |
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
|
714 |
connect(ui.pageAdmin->pbClearAccountsCache, SIGNAL(clicked()), hwnet, SLOT(clearAccountsCache())); |
1924 | 715 |
|
1898
f0ab0c77946d
Send scheme data over net (but recieving part isn't implemented yet)
unc0rr
parents:
1897
diff
changeset
|
716 |
// disconnect |
1873
815a3ff1fe4b
Start refactoring some things. Frontend becomes temporarily unusable for network game
unc0rr
parents:
1872
diff
changeset
|
717 |
connect(hwnet, SIGNAL(Disconnected()), this, SLOT(ForcedDisconnect()), Qt::QueuedConnection); |
2377 | 718 |
|
1874 | 719 |
hwnet->Connect(hostName, port, nick); |
184 | 720 |
} |
721 |
||
314 | 722 |
void HWForm::NetConnect() |
723 |
{ |
|
653
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
724 |
HWHostPortDialog * hpd = new HWHostPortDialog(this); |
654 | 725 |
hpd->leHost->setText(*netHost); |
726 |
hpd->sbPort->setValue(netPort); |
|
653
4f44fc06ca45
Class to ask host/port to connect to ('Specify' button on PageNet)
unc0rr
parents:
647
diff
changeset
|
727 |
|
654 | 728 |
if (hpd->exec() == QDialog::Accepted) |
729 |
{ |
|
730 |
config->SaveOptions(); |
|
731 |
delete netHost; |
|
732 |
netHost = new QString(hpd->leHost->text()); |
|
733 |
netPort = hpd->sbPort->value(); |
|
1418 | 734 |
NetConnectServer(*netHost, netPort); |
654 | 735 |
} |
314 | 736 |
} |
737 |
||
738 |
void HWForm::NetStartServer() |
|
739 |
{ |
|
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
|
740 |
config->SaveOptions(); |
636 | 741 |
|
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
|
742 |
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
|
743 |
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
|
744 |
{ |
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
|
745 |
QMessageBox::critical(0, tr("Error"), |
1509 | 746 |
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
|
747 |
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
|
748 |
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
|
749 |
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
|
750 |
} |
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
|
751 |
|
1418 | 752 |
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
|
753 |
|
1418 | 754 |
pRegisterServer = new HWNetUdpServer(0, |
755 |
ui.pageNetServer->leServerDescr->text(), |
|
756 |
ui.pageNetServer->sbPort->value()); |
|
757 |
} |
|
758 |
||
759 |
void HWForm::AsyncNetServerStart() |
|
760 |
{ |
|
761 |
NetConnectServer("localhost", pnetserver->getRunningPort()); |
|
314 | 762 |
} |
763 |
||
184 | 764 |
void HWForm::NetDisconnect() |
765 |
{ |
|
2108 | 766 |
//qDebug("NetDisconnect"); |
1509 | 767 |
if(hwnet) { |
768 |
hwnet->Disconnect(); |
|
769 |
delete hwnet; |
|
770 |
hwnet = 0; |
|
771 |
} |
|
772 |
if(pnetserver) { |
|
773 |
if (pRegisterServer) |
|
774 |
{ |
|
775 |
pRegisterServer->unregister(); |
|
776 |
pRegisterServer = 0; |
|
777 |
} |
|
659 | 778 |
|
1509 | 779 |
pnetserver->StopServer(); |
780 |
delete pnetserver; |
|
781 |
pnetserver = 0; |
|
782 |
} |
|
184 | 783 |
} |
784 |
||
383 | 785 |
void HWForm::ForcedDisconnect() |
786 |
{ |
|
1418 | 787 |
if(pnetserver) return; // we have server - let it care of all things |
788 |
if (hwnet) { |
|
789 |
hwnet->deleteLater(); |
|
790 |
hwnet = 0; |
|
791 |
QMessageBox::warning(this, QMessageBox::tr("Network"), |
|
792 |
QMessageBox::tr("Connection to server is lost")); |
|
2377 | 793 |
|
1418 | 794 |
} |
1800 | 795 |
if (ui.Pages->currentIndex() != ID_PAGE_NET) GoBack(); |
383 | 796 |
} |
797 |
||
1311 | 798 |
void HWForm::NetConnected() |
799 |
{ |
|
800 |
GoToPage(ID_PAGE_ROOMSLIST); |
|
801 |
} |
|
802 |
||
184 | 803 |
void HWForm::NetGameEnter() |
804 |
{ |
|
1593 | 805 |
ui.pageNetGame->pChatWidget->clear(); |
1354
a8dcdeb88a43
Various small insignificant improvements everywhere
unc0rr
parents:
1347
diff
changeset
|
806 |
GoToPage(ID_PAGE_NETGAME); |
184 | 807 |
} |
808 |
||
339
7535ab6c3820
Run game message added, team and config info provided for net game
displacer
parents:
338
diff
changeset
|
809 |
void HWForm::AddNetTeam(const HWTeam& team) |
184 | 810 |
{ |
1418 | 811 |
ui.pageNetGame->pNetTeamsWidget->addTeam(team); |
184 | 812 |
} |
813 |
||
814 |
void HWForm::StartMPGame() |
|
815 |
{ |
|
1531 | 816 |
QString ammo; |
817 |
ammo = ui.pageMultiplayer->gameCFG->WeaponsName->itemData( |
|
818 |
ui.pageMultiplayer->gameCFG->WeaponsName->currentIndex() |
|
819 |
).toString(); |
|
696 | 820 |
|
821 |
CreateGame(ui.pageMultiplayer->gameCFG, ui.pageMultiplayer->teamsSelect, ammo); |
|
306 | 822 |
|
184 | 823 |
game->StartLocal(); |
824 |
} |
|
306 | 825 |
|
826 |
void HWForm::GameStateChanged(GameState gameState) |
|
827 |
{ |
|
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
828 |
switch(gameState) { |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
829 |
case gsStarted: { |
1268
34c3795ecb63
Fix music starting to play after the round even if it was turned off
unc0rr
parents:
1235
diff
changeset
|
830 |
Music(false); |
2377 | 831 |
if (wBackground) wBackground->stopAnimation(); |
1223
41d7283934c1
Hackish way to play music in frontend... to be fixed
unc0rr
parents:
1165
diff
changeset
|
832 |
GoToPage(ID_PAGE_INGAME); |
1622 | 833 |
ui.pageGameStats->clear(); |
661
0523b15353a2
Unregister server in servers list when the game is started
unc0rr
parents:
660
diff
changeset
|
834 |
if (pRegisterServer) |
0523b15353a2
Unregister server in servers list when the game is started
unc0rr
parents:
660
diff
changeset
|
835 |
{ |
0523b15353a2
Unregister server in servers list when the game is started
unc0rr
parents:
660
diff
changeset
|
836 |
pRegisterServer->unregister(); |
0523b15353a2
Unregister server in servers list when the game is started
unc0rr
parents:
660
diff
changeset
|
837 |
pRegisterServer = 0; |
0523b15353a2
Unregister server in servers list when the game is started
unc0rr
parents:
660
diff
changeset
|
838 |
} |
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
|
839 |
//setVisible(false); |
2820 | 840 |
setFocusPolicy(Qt::NoFocus); |
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
841 |
break; |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
842 |
} |
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
843 |
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
|
844 |
//setVisible(true); |
2820 | 845 |
setFocusPolicy(Qt::StrongFocus); |
686 | 846 |
GoBack(); |
2776 | 847 |
Music(ui.pageOptions->CBEnableFrontendMusic->isChecked()); |
2377 | 848 |
if (wBackground) wBackground->startAnimation(); |
324
f4c109c82a0c
Don't show game stats in case of interrupted by command '/quit' game
unc0rr
parents:
323
diff
changeset
|
849 |
GoToPage(ID_PAGE_GAMESTATS); |
1344
4004e597f1bf
Clients send roundfinished message to server when the round is over
unc0rr
parents:
1343
diff
changeset
|
850 |
if (hwnet) hwnet->gameFinished(); |
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 |
} |
686 | 853 |
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
|
854 |
//setVisible(true); |
2820 | 855 |
setFocusPolicy(Qt::StrongFocus); |
686 | 856 |
quint8 id = ui.Pages->currentIndex(); |
1225
f882a92ef872
Play music in menu also, with fading effects when run game
unc0rr
parents:
1223
diff
changeset
|
857 |
if (id == ID_PAGE_INGAME) { |
f882a92ef872
Play music in menu also, with fading effects when run game
unc0rr
parents:
1223
diff
changeset
|
858 |
GoBack(); |
2776 | 859 |
Music(ui.pageOptions->CBEnableFrontendMusic->isChecked()); |
2377 | 860 |
if (wBackground) wBackground->startAnimation(); |
1344
4004e597f1bf
Clients send roundfinished message to server when the round is over
unc0rr
parents:
1343
diff
changeset
|
861 |
if (hwnet) hwnet->gameFinished(); |
1225
f882a92ef872
Play music in menu also, with fading effects when run game
unc0rr
parents:
1223
diff
changeset
|
862 |
} |
686 | 863 |
}; |
307 | 864 |
} |
865 |
} |
|
866 |
||
696 | 867 |
void HWForm::CreateGame(GameCFGWidget * gamecfg, TeamSelWidget* pTeamSelWidget, QString ammo) |
306 | 868 |
{ |
696 | 869 |
game = new HWGame(config, gamecfg, ammo, pTeamSelWidget); |
306 | 870 |
connect(game, SIGNAL(GameStateChanged(GameState)), this, SLOT(GameStateChanged(GameState))); |
1622 | 871 |
connect(game, SIGNAL(GameStats(char, const QString &)), ui.pageGameStats, SLOT(GameStats(char, const QString &))); |
425 | 872 |
connect(game, SIGNAL(ErrorMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection); |
533 | 873 |
connect(game, SIGNAL(HaveRecord(bool, const QByteArray &)), this, SLOT(GetRecord(bool, const QByteArray &))); |
306 | 874 |
} |
425 | 875 |
|
876 |
void HWForm::ShowErrorMessage(const QString & msg) |
|
877 |
{ |
|
878 |
QMessageBox::warning(this, |
|
879 |
"Hedgewars", |
|
880 |
msg); |
|
881 |
} |
|
533 | 882 |
|
883 |
void HWForm::GetRecord(bool isDemo, const QByteArray & record) |
|
884 |
{ |
|
885 |
QString filename; |
|
886 |
QByteArray demo = record; |
|
1487
b4cc59a6d50a
Add an option to name records with current date and time
unc0rr
parents:
1427
diff
changeset
|
887 |
QString recordFileName = |
b4cc59a6d50a
Add an option to name records with current date and time
unc0rr
parents:
1427
diff
changeset
|
888 |
config->appendDateTimeToRecordName() ? |
1664 | 889 |
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
|
890 |
"LastRound"; |
b4cc59a6d50a
Add an option to name records with current date and time
unc0rr
parents:
1427
diff
changeset
|
891 |
|
533 | 892 |
if (isDemo) |
893 |
{ |
|
894 |
demo.replace(QByteArray("\x02TL"), QByteArray("\x02TD")); |
|
895 |
demo.replace(QByteArray("\x02TN"), QByteArray("\x02TD")); |
|
989 | 896 |
demo.replace(QByteArray("\x02TS"), QByteArray("\x02TD")); |
2742 | 897 |
filename = cfgdir->absolutePath() + "/Demos/" + recordFileName + "." + *cProtoVer + ".hwd"; |
533 | 898 |
} else |
899 |
{ |
|
900 |
demo.replace(QByteArray("\x02TL"), QByteArray("\x02TS")); |
|
901 |
demo.replace(QByteArray("\x02TN"), QByteArray("\x02TS")); |
|
2742 | 902 |
filename = cfgdir->absolutePath() + "/Saves/" + recordFileName + "." + *cProtoVer + ".hws"; |
533 | 903 |
} |
904 |
||
905 |
||
906 |
QFile demofile(filename); |
|
907 |
if (!demofile.open(QIODevice::WriteOnly)) |
|
908 |
{ |
|
909 |
ShowErrorMessage(tr("Cannot save record to file %1").arg(filename)); |
|
910 |
return ; |
|
911 |
} |
|
912 |
demofile.write(demo.constData(), demo.size()); |
|
913 |
demofile.close(); |
|
914 |
} |
|
587 | 915 |
|
916 |
void HWForm::StartTraining() |
|
917 |
{ |
|
696 | 918 |
CreateGame(0, 0, 0); |
587 | 919 |
|
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
|
920 |
game->StartTraining(ui.pageTraining->CBSelect->currentText()); |
587 | 921 |
} |
660 | 922 |
|
923 |
void HWForm::CreateNetGame() |
|
924 |
{ |
|
697 | 925 |
QString ammo; |
1517 | 926 |
ammo = ui.pageNetGame->pGameCFG->WeaponsName->itemData( |
927 |
ui.pageNetGame->pGameCFG->WeaponsName->currentIndex() |
|
928 |
).toString(); |
|
929 |
||
696 | 930 |
CreateGame(ui.pageNetGame->pGameCFG, ui.pageNetGame->pNetTeamsWidget, ammo); |
660 | 931 |
|
932 |
connect(game, SIGNAL(SendNet(const QByteArray &)), hwnet, SLOT(SendNet(const QByteArray &))); |
|
1356 | 933 |
connect(game, SIGNAL(SendChat(const QString &)), hwnet, SLOT(chatLineToNet(const QString &))); |
2403 | 934 |
connect(game, SIGNAL(SendTeamMessage(const QString &)), hwnet, SLOT(SendTeamMessage(const QString &))); |
660 | 935 |
connect(hwnet, SIGNAL(FromNet(const QByteArray &)), game, SLOT(FromNet(const QByteArray &))); |
1356 | 936 |
connect(hwnet, SIGNAL(chatStringFromNet(const QString &)), game, SLOT(FromNetChat(const QString &))); |
660 | 937 |
|
938 |
game->StartNet(); |
|
939 |
} |
|
674 | 940 |
|
941 |
void HWForm::closeEvent(QCloseEvent *event) |
|
942 |
{ |
|
2822 | 943 |
#ifdef USE_XFIRE |
2821 | 944 |
xfire_free(); |
2822 | 945 |
#endif |
674 | 946 |
config->SaveOptions(); |
947 |
event->accept(); |
|
948 |
} |
|
1235 | 949 |
|
950 |
void HWForm::Music(bool checked) |
|
951 |
{ |
|
952 |
if (checked) |
|
2428 | 953 |
sdli.StartMusic(); |
1235 | 954 |
else |
2428 | 955 |
sdli.StopMusic(); |
1235 | 956 |
} |
1409
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1405
diff
changeset
|
957 |
|
2345
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
958 |
void HWForm::NetGameChangeStatus(bool isMaster) |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
959 |
{ |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
960 |
if (isMaster) |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
961 |
NetGameMaster(); |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
962 |
else |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
963 |
NetGameSlave(); |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
964 |
} |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
965 |
|
1409
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1405
diff
changeset
|
966 |
void HWForm::NetGameMaster() |
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1405
diff
changeset
|
967 |
{ |
1649 | 968 |
ui.pageNetGame->setMasterMode(true); |
1409
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1405
diff
changeset
|
969 |
ui.pageNetGame->restrictJoins->setChecked(false); |
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1405
diff
changeset
|
970 |
ui.pageNetGame->restrictTeamAdds->setChecked(false); |
1898
f0ab0c77946d
Send scheme data over net (but recieving part isn't implemented yet)
unc0rr
parents:
1897
diff
changeset
|
971 |
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
|
972 |
ui.pageNetGame->pGameCFG->setEnabled(true); |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
973 |
ui.pageNetGame->pNetTeamsWidget->setInteractivity(true); |
2377 | 974 |
|
1410
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1409
diff
changeset
|
975 |
if (hwnet) |
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1409
diff
changeset
|
976 |
{ |
1828
ba91a89f449a
Fix bug with not working toggles 'rectrict joins' and 'restrict team adding'
unc0rr
parents:
1802
diff
changeset
|
977 |
// disconnect connections first to ensure their inexistance and not to connect twice |
1951 | 978 |
ui.pageNetGame->BtnStart->disconnect(hwnet); |
1828
ba91a89f449a
Fix bug with not working toggles 'rectrict joins' and 'restrict team adding'
unc0rr
parents:
1802
diff
changeset
|
979 |
ui.pageNetGame->restrictJoins->disconnect(hwnet); |
ba91a89f449a
Fix bug with not working toggles 'rectrict joins' and 'restrict team adding'
unc0rr
parents:
1802
diff
changeset
|
980 |
ui.pageNetGame->restrictTeamAdds->disconnect(hwnet); |
1951 | 981 |
connect(ui.pageNetGame->BtnStart, SIGNAL(clicked()), hwnet, SLOT(startGame())); |
1413 | 982 |
connect(ui.pageNetGame->restrictJoins, SIGNAL(triggered()), hwnet, SLOT(toggleRestrictJoins())); |
983 |
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
|
984 |
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
|
985 |
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
|
986 |
ui.pageNetGame->pGameCFG, |
6d29370dc0dd
This should resend scheme info to net server when scheme got edited (not tested)
unc0rr
parents:
2027
diff
changeset
|
987 |
SLOT(resendSchemeData()) |
6d29370dc0dd
This should resend scheme info to net server when scheme got edited (not tested)
unc0rr
parents:
2027
diff
changeset
|
988 |
); |
1410
eece43296890
Send appropriate messages to server on control menu actions
unc0rr
parents:
1409
diff
changeset
|
989 |
} |
1409
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1405
diff
changeset
|
990 |
} |
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1405
diff
changeset
|
991 |
|
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1405
diff
changeset
|
992 |
void HWForm::NetGameSlave() |
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1405
diff
changeset
|
993 |
{ |
2345
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
994 |
ui.pageNetGame->pGameCFG->setEnabled(false); |
daf1785f2337
- Frontend: reorganize code controlling widgets state, fix problems getting room admin status
unc0rr
parents:
2261
diff
changeset
|
995 |
ui.pageNetGame->pNetTeamsWidget->setInteractivity(false); |
2377 | 996 |
|
1899
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
997 |
if (hwnet) |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
998 |
{ |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
999 |
NetAmmoSchemeModel * netAmmo = new NetAmmoSchemeModel(hwnet); |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1000 |
connect(hwnet, SIGNAL(netSchemeConfig(QStringList &)), netAmmo, SLOT(setNetSchemeConfig(QStringList &))); |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1001 |
ui.pageNetGame->pGameCFG->GameSchemes->setModel(netAmmo); |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1002 |
|
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1003 |
ui.pageNetGame->pGameCFG->GameSchemes->view()->disconnect(hwnet); |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1004 |
connect(hwnet, SIGNAL(netSchemeConfig(QStringList &)), |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1005 |
this, SLOT(selectFirstNetScheme())); |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1006 |
} |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1007 |
|
1649 | 1008 |
ui.pageNetGame->setMasterMode(false); |
1409
d1cbe4a57ebf
Add button for controlling room options (no usefull yet)
unc0rr
parents:
1405
diff
changeset
|
1009 |
} |
1600 | 1010 |
|
1899
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1011 |
void HWForm::selectFirstNetScheme() |
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->setCurrentIndex(0); |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1014 |
} |
5763f46d7486
Sync schemes config over net should work now (untested)
unc0rr
parents:
1898
diff
changeset
|
1015 |
|
1600 | 1016 |
void HWForm::NetLeftRoom() |
1017 |
{ |
|
1018 |
if (ui.Pages->currentIndex() == ID_PAGE_NETGAME) |
|
1019 |
GoBack(); |
|
1020 |
else |
|
1021 |
qWarning("Left room while not in room"); |
|
1022 |
} |
|
2012 | 1023 |
|
1024 |
void HWForm::resizeEvent(QResizeEvent * event) |
|
1025 |
{ |
|
1026 |
int w = event->size().width(); |
|
1027 |
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
|
1028 |
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
|
1029 |
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
|
1030 |
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
|
1031 |
} |
2012 | 1032 |
} |