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