Save demo when loaded from save game finishes
authorunc0rr
Sun, 11 Sep 2011 21:45:28 +0400
changeset 5865 35387d27f73a
parent 5864 6cc72b333c5f
child 5866 9017a0ff4201
Save demo when loaded from save game finishes
QTfrontend/game.cpp
QTfrontend/game.h
QTfrontend/hwform.cpp
QTfrontend/pageplayrecord.cpp
QTfrontend/pageplayrecord.h
--- a/QTfrontend/game.cpp	Sun Sep 11 13:21:50 2011 -0400
+++ b/QTfrontend/game.cpp	Sun Sep 11 21:45:28 2011 +0400
@@ -53,8 +53,13 @@
 void HWGame::onClientDisconnect()
 {
     switch (gameType) {
-        case gtDemo: 
-            if (gameState == gsInterrupted || gameState == gsHalted) emit HaveRecord(false, demo);
+        case gtSave:
+            if (gameState == gsInterrupted || gameState == gsHalted)
+                emit HaveRecord(false, demo);
+            else if (gameState == gsFinished)
+                 emit HaveRecord(true, demo);
+            break;
+        case gtDemo:
             break;
         case gtNet:
             emit HaveRecord(true, demo);
@@ -188,6 +193,7 @@
                     SendQuickConfig();
                     break;
                 }
+                case gtSave:
                 case gtDemo: break;
                 case gtNet: {
                     SendNetConfig();
@@ -321,9 +327,9 @@
     TeamCount++;
 }
 
-void HWGame::PlayDemo(const QString & demofilename)
+void HWGame::PlayDemo(const QString & demofilename, bool isSave)
 {
-    gameType = gtDemo;
+    gameType = isSave ? gtSave : gtDemo;
     QFile demofile(demofilename);
     if (!demofile.open(QIODevice::ReadOnly))
     {
--- a/QTfrontend/game.h	Sun Sep 11 13:21:50 2011 -0400
+++ b/QTfrontend/game.h	Sun Sep 11 21:45:28 2011 +0400
@@ -48,7 +48,7 @@
     HWGame(GameUIConfig * config, GameCFGWidget * gamecfg, QString ammo, TeamSelWidget* pTeamSelWidget = 0);
     virtual ~HWGame();
     void AddTeam(const QString & team);
-    void PlayDemo(const QString & demofilename);
+    void PlayDemo(const QString & demofilename, bool isSave);
     void StartLocal();
     void StartQuick();
     void StartNet();
@@ -84,6 +84,7 @@
         gtNet      = 4,
         gtTraining = 5,
         gtCampaign = 6,
+        gtSave     = 7,
     };
     char msgbuf[MAXMSGCHARS];
     QString teams[5];
--- a/QTfrontend/hwform.cpp	Sun Sep 11 13:21:50 2011 -0400
+++ b/QTfrontend/hwform.cpp	Sun Sep 11 21:45:28 2011 +0400
@@ -731,7 +731,7 @@
         return;
     }
     CreateGame(0, 0, 0);
-    game->PlayDemo(curritem->data(Qt::UserRole).toString());
+    game->PlayDemo(curritem->data(Qt::UserRole).toString(), ui.pagePlayDemo->isSave());
 }
 
 void HWForm::PlayDemoQuick(const QString & demofilename)
@@ -740,7 +740,7 @@
     GoBack(); //needed to cleanly disconnect from netgame
     GoToPage(ID_PAGE_MAIN);
     CreateGame(0, 0, 0);
-    game->PlayDemo(demofilename);
+    game->PlayDemo(demofilename, false);
 }
 
 void HWForm::NetConnectServer(const QString & host, quint16 port)
--- a/QTfrontend/pageplayrecord.cpp	Sun Sep 11 13:21:50 2011 -0400
+++ b/QTfrontend/pageplayrecord.cpp	Sun Sep 11 21:45:28 2011 +0400
@@ -150,3 +150,8 @@
     else
         FillFromDir(recType);
 }
+
+bool PagePlayDemo::isSave()
+{
+    return recType == RT_Save;
+}
--- a/QTfrontend/pageplayrecord.h	Sun Sep 11 13:21:50 2011 -0400
+++ b/QTfrontend/pageplayrecord.h	Sun Sep 11 21:45:28 2011 +0400
@@ -39,6 +39,7 @@
     PagePlayDemo(QWidget* parent = 0);
 
     void FillFromDir(RecordType rectype);
+    bool isSave();
 
     QPushButton *BtnBack;
     QPushButton *BtnPlayDemo;