diff -r 5ab22736bdb6 -r 2e5835130d9a QTfrontend/hwform.cpp --- a/QTfrontend/hwform.cpp Fri Sep 09 04:39:17 2011 +0200 +++ b/QTfrontend/hwform.cpp Fri Sep 09 05:15:45 2011 +0200 @@ -38,6 +38,7 @@ #include #include #include +#include #include "hwform.h" #include "game.h" @@ -151,12 +152,17 @@ connect(ui.pageMain->BtnNet, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); pageSwitchMapper->setMapping(ui.pageMain->BtnNet, ID_PAGE_NETTYPE); + connect(ui.pageMain->BtnInfo, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); - pageSwitchMapper->setMapping(ui.pageMain->BtnInfo, ID_PAGE_DATADOWNLOAD); + pageSwitchMapper->setMapping(ui.pageMain->BtnInfo, ID_PAGE_INFO); + + connect(ui.pageMain->BtnDataDownload, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); + pageSwitchMapper->setMapping(ui.pageMain->BtnDataDownload, ID_PAGE_DATADOWNLOAD); connect(ui.pageMain->BtnExit, SIGNAL(pressed()), this, SLOT(btnExitPressed())); connect(ui.pageMain->BtnExit, SIGNAL(clicked()), this, SLOT(btnExitClicked())); + connect(ui.pageInfo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); connect(ui.pageDataDownload->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); connect(ui.pageEditTeam->BtnTeamSave, SIGNAL(clicked()), this, SLOT(TeamSave())); @@ -223,6 +229,7 @@ connect(ui.pageInfo->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); connect(ui.pageGameStats->BtnBack, SIGNAL(clicked()), this, SLOT(GoBack())); + connect(ui.pageGameStats, SIGNAL(saveDemoRequested()), this, SLOT(saveDemoWithCustomName())); connect(ui.pageSinglePlayer->BtnSimpleGamePage, SIGNAL(clicked()), this, SLOT(SimpleGame())); connect(ui.pageSinglePlayer->BtnTrainPage, SIGNAL(clicked()), pageSwitchMapper, SLOT(map())); @@ -619,8 +626,9 @@ } QStringList tmnames; - QListIterator it(curTeamSelWidget->getDontPlayingTeams()); - while(it.hasNext()) tmnames += it.next().TeamName; + + foreach(HWTeam team, curTeamSelWidget->getNotPlayingTeams()) + tmnames += team.TeamName; //UpdateTeamsLists(&tmnames); // FIXME: still need more work if teamname is updated while configuring UpdateTeamsLists(); @@ -1033,6 +1041,7 @@ connect(game, SIGNAL(GameStats(char, const QString &)), ui.pageGameStats, SLOT(GameStats(char, const QString &))); connect(game, SIGNAL(ErrorMessage(const QString &)), this, SLOT(ShowErrorMessage(const QString &)), Qt::QueuedConnection); connect(game, SIGNAL(HaveRecord(bool, const QByteArray &)), this, SLOT(GetRecord(bool, const QByteArray &))); + m_lastDemo = QByteArray(); } void HWForm::ShowErrorMessage(const QString & msg) @@ -1061,6 +1070,7 @@ demo.replace(QByteArray("\x02TN"), QByteArray("\x02TD")); demo.replace(QByteArray("\x02TS"), QByteArray("\x02TD")); filename = cfgdir->absolutePath() + "/Demos/" + recordFileName + "." + *cProtoVer + ".hwd"; + m_lastDemo = demo; } else { demo.replace(QByteArray("\x02TL"), QByteArray("\x02TS")); @@ -1075,7 +1085,7 @@ ShowErrorMessage(tr("Cannot save record to file %1").arg(filename)); return ; } - demofile.write(demo.constData(), demo.size()); + demofile.write(demo); demofile.close(); } @@ -1293,3 +1303,30 @@ else QMessageBox::information(0, "", QMessageBox::tr("File association failed.")); } +void HWForm::saveDemoWithCustomName() +{ + if(!m_lastDemo.isEmpty()) + { + QString fileName; + bool ok = false; + do + { + fileName = QInputDialog::getText(this, tr("Demo name"), tr("Demo name:")); + + if(!fileName.isEmpty()) + { + QString filePath = cfgdir->absolutePath() + "/Demos/" + fileName + "." + *cProtoVer + ".hwd"; + QFile demofile(filePath); + ok = demofile.open(QIODevice::WriteOnly); + if (!ok) + ShowErrorMessage(tr("Cannot save record to file %1").arg(filePath)); + else + { + ok = -1 != demofile.write(m_lastDemo); + demofile.close(); + } + } + } while(!fileName.isEmpty() && !ok); + } +} +