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