author | nemo |
Mon, 01 Feb 2010 07:10:33 +0000 | |
changeset 2736 | cc04e98dd535 |
parent 2706 | 935b7d618cf0 |
child 2742 | 21c0d2e69753 |
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&))); |
|
2706
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2631
diff
changeset
|
620 |
connect(ui.pageNetGame->pChatWidget, SIGNAL(follow(const QString&)), |
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2631
diff
changeset
|
621 |
hwnet, SLOT(followPlayer(const QString&))); |
1860 | 622 |
connect(ui.pageRoomsList->chatWidget, SIGNAL(kick(const QString&)), |
623 |
hwnet, SLOT(kickPlayer(const QString&))); |
|
624 |
connect(ui.pageRoomsList->chatWidget, SIGNAL(ban(const QString&)), |
|
625 |
hwnet, SLOT(banPlayer(const QString&))); |
|
1577 | 626 |
connect(ui.pageRoomsList->chatWidget, SIGNAL(info(const QString&)), |
627 |
hwnet, SLOT(infoPlayer(const QString&))); |
|
2706
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2631
diff
changeset
|
628 |
connect(ui.pageRoomsList->chatWidget, SIGNAL(follow(const QString&)), |
935b7d618cf0
sheepluva's patch to add a "follow" command to server and frontend, in order to stalk people and join them in their rooms
koda
parents:
2631
diff
changeset
|
629 |
hwnet, SLOT(followPlayer(const QString&))); |
1566
6b63c75fdc68
Start work on lobby: add/remove nick from the list on join/quit
unc0rr
parents:
1531
diff
changeset
|
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 |
} |
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(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: { |
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
|
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: { |
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
|
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 |
} |