221 |
222 |
222 connect(ui.pageInfo->BtnSnapshots, SIGNAL(clicked()), this, SLOT(OpenSnapshotFolder())); |
223 connect(ui.pageInfo->BtnSnapshots, SIGNAL(clicked()), this, SLOT(OpenSnapshotFolder())); |
223 connect(ui.pageInfo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
224 connect(ui.pageInfo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
224 |
225 |
225 connect(ui.pageGameStats->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
226 connect(ui.pageGameStats->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); |
|
227 connect(ui.pageGameStats, SIGNAL(saveDemoRequested()), this, SLOT(saveDemoWithCustomName())); |
226 |
228 |
227 connect(ui.pageSinglePlayer->BtnSimpleGamePage, SIGNAL(clicked()), this, SLOT(SimpleGame())); |
229 connect(ui.pageSinglePlayer->BtnSimpleGamePage, SIGNAL(clicked()), this, SLOT(SimpleGame())); |
228 connect(ui.pageSinglePlayer->BtnTrainPage, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
230 connect(ui.pageSinglePlayer->BtnTrainPage, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); |
229 pageSwitchMapper->setMapping(ui.pageSinglePlayer->BtnTrainPage, ID_PAGE_TRAINING); |
231 pageSwitchMapper->setMapping(ui.pageSinglePlayer->BtnTrainPage, ID_PAGE_TRAINING); |
230 |
232 |
1031 game = new HWGame(config, gamecfg, ammo, pTeamSelWidget); |
1033 game = new HWGame(config, gamecfg, ammo, pTeamSelWidget); |
1032 connect(game, SIGNAL(GameStateChanged(GameState)), this, SLOT(GameStateChanged(GameState))); |
1034 connect(game, SIGNAL(GameStateChanged(GameState)), this, SLOT(GameStateChanged(GameState))); |
1033 connect(game, SIGNAL(GameStats(char, const QString &)), ui.pageGameStats, SLOT(GameStats(char, const QString &))); |
1035 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); |
1036 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 &))); |
1037 connect(game, SIGNAL(HaveRecord(bool, const QByteArray &)), this, SLOT(GetRecord(bool, const QByteArray &))); |
|
1038 m_lastDemo = QByteArray(); |
1036 } |
1039 } |
1037 |
1040 |
1038 void HWForm::ShowErrorMessage(const QString & msg) |
1041 void HWForm::ShowErrorMessage(const QString & msg) |
1039 { |
1042 { |
1040 QMessageBox::warning(this, |
1043 QMessageBox::warning(this, |
1059 { |
1062 { |
1060 demo.replace(QByteArray("\x02TL"), QByteArray("\x02TD")); |
1063 demo.replace(QByteArray("\x02TL"), QByteArray("\x02TD")); |
1061 demo.replace(QByteArray("\x02TN"), QByteArray("\x02TD")); |
1064 demo.replace(QByteArray("\x02TN"), QByteArray("\x02TD")); |
1062 demo.replace(QByteArray("\x02TS"), QByteArray("\x02TD")); |
1065 demo.replace(QByteArray("\x02TS"), QByteArray("\x02TD")); |
1063 filename = cfgdir->absolutePath() + "/Demos/" + recordFileName + "." + *cProtoVer + ".hwd"; |
1066 filename = cfgdir->absolutePath() + "/Demos/" + recordFileName + "." + *cProtoVer + ".hwd"; |
|
1067 m_lastDemo = demo; |
1064 } else |
1068 } else |
1065 { |
1069 { |
1066 demo.replace(QByteArray("\x02TL"), QByteArray("\x02TS")); |
1070 demo.replace(QByteArray("\x02TL"), QByteArray("\x02TS")); |
1067 demo.replace(QByteArray("\x02TN"), QByteArray("\x02TS")); |
1071 demo.replace(QByteArray("\x02TN"), QByteArray("\x02TS")); |
1068 filename = cfgdir->absolutePath() + "/Saves/" + recordFileName + "." + *cProtoVer + ".hws"; |
1072 filename = cfgdir->absolutePath() + "/Saves/" + recordFileName + "." + *cProtoVer + ".hws"; |
1291 #endif |
1295 #endif |
1292 if (success) QMessageBox::information(0, "", QMessageBox::tr("All file associations have been set.")); |
1296 if (success) QMessageBox::information(0, "", QMessageBox::tr("All file associations have been set.")); |
1293 else QMessageBox::information(0, "", QMessageBox::tr("File association failed.")); |
1297 else QMessageBox::information(0, "", QMessageBox::tr("File association failed.")); |
1294 } |
1298 } |
1295 |
1299 |
|
1300 void HWForm::saveDemoWithCustomName() |
|
1301 { |
|
1302 if(!m_lastDemo.isEmpty()) |
|
1303 { |
|
1304 QString fileName; |
|
1305 bool ok = false; |
|
1306 do |
|
1307 { |
|
1308 fileName = QInputDialog::getText(this, tr("Demo name"), tr("Demo name:")); |
|
1309 |
|
1310 if(!fileName.isEmpty()) |
|
1311 { |
|
1312 QString filePath = cfgdir->absolutePath() + "/Demos/" + fileName + "." + *cProtoVer + ".hwd"; |
|
1313 QFile demofile(filePath); |
|
1314 ok = demofile.open(QIODevice::WriteOnly); |
|
1315 if (!ok) |
|
1316 ShowErrorMessage(tr("Cannot save record to file %1").arg(filePath)); |
|
1317 else |
|
1318 { |
|
1319 ok = -1 != demofile.write(m_lastDemo); |
|
1320 demofile.close(); |
|
1321 } |
|
1322 } |
|
1323 } while(!fileName.isEmpty() && !ok); |
|
1324 } |
|
1325 } |