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