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