149 connect(ui.pageMain->BtnSetup, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
150 connect(ui.pageMain->BtnSetup, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
150 pageSwitchMapper->setMapping(ui.pageMain->BtnSetup, ID_PAGE_SETUP); |
151 pageSwitchMapper->setMapping(ui.pageMain->BtnSetup, ID_PAGE_SETUP); |
151 |
152 |
152 connect(ui.pageMain->BtnNet, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
153 connect(ui.pageMain->BtnNet, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
153 pageSwitchMapper->setMapping(ui.pageMain->BtnNet, ID_PAGE_NETTYPE); |
154 pageSwitchMapper->setMapping(ui.pageMain->BtnNet, ID_PAGE_NETTYPE); |
|
155 |
154 connect(ui.pageMain->BtnInfo, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
156 connect(ui.pageMain->BtnInfo, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
155 pageSwitchMapper->setMapping(ui.pageMain->BtnInfo, ID_PAGE_DATADOWNLOAD); |
157 pageSwitchMapper->setMapping(ui.pageMain->BtnInfo, ID_PAGE_INFO); |
|
158 |
|
159 connect(ui.pageMain->BtnDataDownload, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
|
160 pageSwitchMapper->setMapping(ui.pageMain->BtnDataDownload, ID_PAGE_DATADOWNLOAD); |
156 |
161 |
157 connect(ui.pageMain->BtnExit, SIGNAL(pressed()), this, SLOT(btnExitPressed())); |
162 connect(ui.pageMain->BtnExit, SIGNAL(pressed()), this, SLOT(btnExitPressed())); |
158 connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(btnExitClicked())); |
163 connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(btnExitClicked())); |
159 |
164 |
|
165 connect(ui.pageInfo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
160 connect(ui.pageDataDownload->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
166 connect(ui.pageDataDownload->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
161 |
167 |
162 connect(ui.pageEditTeam->BtnTeamSave, SIGNAL(clicked()), this, SLOT(TeamSave())); |
168 connect(ui.pageEditTeam->BtnTeamSave, SIGNAL(clicked()), this, SLOT(TeamSave())); |
163 connect(ui.pageEditTeam->BtnTeamDiscard, SIGNAL(clicked()), this, SLOT(TeamDiscard())); |
169 connect(ui.pageEditTeam->BtnTeamDiscard, SIGNAL(clicked()), this, SLOT(TeamDiscard())); |
164 |
170 |
221 |
227 |
222 connect(ui.pageInfo->BtnSnapshots, SIGNAL(clicked()), this, SLOT(OpenSnapshotFolder())); |
228 connect(ui.pageInfo->BtnSnapshots, SIGNAL(clicked()), this, SLOT(OpenSnapshotFolder())); |
223 connect(ui.pageInfo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
229 connect(ui.pageInfo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
224 |
230 |
225 connect(ui.pageGameStats->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
231 connect(ui.pageGameStats->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
232 connect(ui.pageGameStats, SIGNAL(saveDemoRequested()), this, SLOT(saveDemoWithCustomName())); |
226 |
233 |
227 connect(ui.pageSinglePlayer->BtnSimpleGamePage, SIGNAL(clicked()), this, SLOT(SimpleGame())); |
234 connect(ui.pageSinglePlayer->BtnSimpleGamePage, SIGNAL(clicked()), this, SLOT(SimpleGame())); |
228 connect(ui.pageSinglePlayer->BtnTrainPage, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
235 connect(ui.pageSinglePlayer->BtnTrainPage, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
229 pageSwitchMapper->setMapping(ui.pageSinglePlayer->BtnTrainPage, ID_PAGE_TRAINING); |
236 pageSwitchMapper->setMapping(ui.pageSinglePlayer->BtnTrainPage, ID_PAGE_TRAINING); |
230 |
237 |
1031 game = new HWGame(config, gamecfg, ammo, pTeamSelWidget); |
1039 game = new HWGame(config, gamecfg, ammo, pTeamSelWidget); |
1032 connect(game, SIGNAL(GameStateChanged(GameState)), this, SLOT(GameStateChanged(GameState))); |
1040 connect(game, SIGNAL(GameStateChanged(GameState)), this, SLOT(GameStateChanged(GameState))); |
1033 connect(game, SIGNAL(GameStats(char, const QString &)), ui.pageGameStats, SLOT(GameStats(char, const QString &))); |
1041 connect(game, SIGNAL(GameStats(char, const QString &)), ui.pageGameStats, SLOT(GameStats(char, const QString &))); |
1034 connect(game, SIGNAL(ErrorMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection); |
1042 connect(game, SIGNAL(ErrorMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection); |
1035 connect(game, SIGNAL(HaveRecord(bool, const QByteArray &)), this, SLOT(GetRecord(bool, const QByteArray &))); |
1043 connect(game, SIGNAL(HaveRecord(bool, const QByteArray &)), this, SLOT(GetRecord(bool, const QByteArray &))); |
|
1044 m_lastDemo = QByteArray(); |
1036 } |
1045 } |
1037 |
1046 |
1038 void HWForm::ShowErrorMessage(const QString & msg) |
1047 void HWForm::ShowErrorMessage(const QString & msg) |
1039 { |
1048 { |
1040 QMessageBox::warning(this, |
1049 QMessageBox::warning(this, |
1059 { |
1068 { |
1060 demo.replace(QByteArray("\x02TL"), QByteArray("\x02TD")); |
1069 demo.replace(QByteArray("\x02TL"), QByteArray("\x02TD")); |
1061 demo.replace(QByteArray("\x02TN"), QByteArray("\x02TD")); |
1070 demo.replace(QByteArray("\x02TN"), QByteArray("\x02TD")); |
1062 demo.replace(QByteArray("\x02TS"), QByteArray("\x02TD")); |
1071 demo.replace(QByteArray("\x02TS"), QByteArray("\x02TD")); |
1063 filename = cfgdir->absolutePath() + "/Demos/" + recordFileName + "." + *cProtoVer + ".hwd"; |
1072 filename = cfgdir->absolutePath() + "/Demos/" + recordFileName + "." + *cProtoVer + ".hwd"; |
|
1073 m_lastDemo = demo; |
1064 } else |
1074 } else |
1065 { |
1075 { |
1066 demo.replace(QByteArray("\x02TL"), QByteArray("\x02TS")); |
1076 demo.replace(QByteArray("\x02TL"), QByteArray("\x02TS")); |
1067 demo.replace(QByteArray("\x02TN"), QByteArray("\x02TS")); |
1077 demo.replace(QByteArray("\x02TN"), QByteArray("\x02TS")); |
1068 filename = cfgdir->absolutePath() + "/Saves/" + recordFileName + "." + *cProtoVer + ".hws"; |
1078 filename = cfgdir->absolutePath() + "/Saves/" + recordFileName + "." + *cProtoVer + ".hws"; |
1291 #endif |
1301 #endif |
1292 if (success) QMessageBox::information(0, "", QMessageBox::tr("All file associations have been set.")); |
1302 if (success) QMessageBox::information(0, "", QMessageBox::tr("All file associations have been set.")); |
1293 else QMessageBox::information(0, "", QMessageBox::tr("File association failed.")); |
1303 else QMessageBox::information(0, "", QMessageBox::tr("File association failed.")); |
1294 } |
1304 } |
1295 |
1305 |
|
1306 void HWForm::saveDemoWithCustomName() |
|
1307 { |
|
1308 if(!m_lastDemo.isEmpty()) |
|
1309 { |
|
1310 QString fileName; |
|
1311 bool ok = false; |
|
1312 do |
|
1313 { |
|
1314 fileName = QInputDialog::getText(this, tr("Demo name"), tr("Demo name:")); |
|
1315 |
|
1316 if(!fileName.isEmpty()) |
|
1317 { |
|
1318 QString filePath = cfgdir->absolutePath() + "/Demos/" + fileName + "." + *cProtoVer + ".hwd"; |
|
1319 QFile demofile(filePath); |
|
1320 ok = demofile.open(QIODevice::WriteOnly); |
|
1321 if (!ok) |
|
1322 ShowErrorMessage(tr("Cannot save record to file %1").arg(filePath)); |
|
1323 else |
|
1324 { |
|
1325 ok = -1 != demofile.write(m_lastDemo); |
|
1326 demofile.close(); |
|
1327 } |
|
1328 } |
|
1329 } while(!fileName.isEmpty() && !ok); |
|
1330 } |
|
1331 } |
|
1332 |