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