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