Browse Source

Fix issue with quick saving not functioning at all

habeebweeb 4 years ago
parent
commit
c31a6f5d73

+ 7 - 2
MultipleMaids/CM3D2/MultipleMaids/Plugin/MultipleMaids.Gui.cs

@@ -9188,12 +9188,17 @@ namespace CM3D2.MultipleMaids.Plugin
                     try
                     {
                         if (overwriteFlag)
+                        {
                             OverwriteScene();
+                        }
                         SaveScene();
                     }
                     catch { }
-                    createSceneFlag = false;
-                    overwriteFlag = false;
+                    finally
+                    {
+                        overwriteFlag = false;
+                        createSceneFlag = false;
+                    }
                 }
             }
 

+ 1 - 2
MultipleMaids/CM3D2/MultipleMaids/Plugin/MultipleMaids.MaidUpdate.cs

@@ -15540,8 +15540,7 @@ namespace CM3D2.MultipleMaids.Plugin
 
                 if (getModKeyPressing(modKey.Ctrl) && Input.GetKeyDown(KeyCode.S) && !sFlg)
                 {
-                    saveScene = 9999;
-                    saveScene2 = saveScene;
+                    quickSaveFlag = true;
                     GameMain.Instance.SoundMgr.PlaySe("se002.ogg", false);
                     try
                     {

+ 19 - 7
MultipleMaids/CM3D2/MultipleMaids/Plugin/MultipleMaids.Update.cs

@@ -1542,6 +1542,17 @@ namespace CM3D2.MultipleMaids.Plugin
                 isStop[selectMaidIndex] = true;
             }
 
+            if (quickSaveFlag)
+            {
+                string serializedScene = SerializeScene();
+                if (quickSaveFlag)
+                {
+                    Preferences["scene"]["s9999"].Value = serializedScene;
+                    SaveConfig();
+                    quickSaveFlag = false;
+                }
+            }
+
             for (int index = 0; index < maidCnt; ++index)
             {
                 if (haraCount[index] > 0)
@@ -6942,17 +6953,16 @@ namespace CM3D2.MultipleMaids.Plugin
 
         public string SerializeScene()
         {
-            page = 0;
-            saveScene = 1;
             string str1 = "";
             string str2 = "";
             DateTime now = DateTime.Now;
             string str3 = now.Year.ToString() + "/" + now.Month.ToString("00") + "/" + now.Day.ToString("00") + " "
-                          + now.Hour.ToString("00") + ":" + now.Minute.ToString("00");
-            if (saveScene < 9999)
+                + now.Hour.ToString("00") + ":" + now.Minute.ToString("00");
+
+            if (!quickSaveFlag)
             {
-                date[saveScene - 1 - page * 10] = str3;
-                ninzu[saveScene - 1 - page * 10] = maidCnt.ToString() + "人";
+                date[0] = str3;
+                ninzu[0] = maidCnt.ToString() + "人";
             }
 
             string[] strArray1 = new string[7]
@@ -8481,7 +8491,9 @@ namespace CM3D2.MultipleMaids.Plugin
                          + ";";
             }
 
-            return str36 + str1 + str255 + str256 + str257 + str258;
+            string serializedScene = str36 + str1 + str255 + str256 + str257 + str258;
+
+            return serializedScene;
         }
     }
 }

+ 0 - 2
MultipleMaids/CM3D2/MultipleMaids/Plugin/MultipleMaids.cs

@@ -4866,8 +4866,6 @@ namespace CM3D2.MultipleMaids.Plugin
         private bool qFlg;
         private Rect rectWin;
         private Rect rectWin2;
-        private int saveScene;
-        private int saveScene2;
         private bool sceneFlg;
         private int sceneLevel;
         private Vector2 screenSize = new Vector2(0.0f, 0.0f);

+ 1 - 0
MultipleMaids/SaveManager.cs

@@ -32,6 +32,7 @@ namespace CM3D2.MultipleMaids.Plugin
         private bool loadSceneFlag = false;
         private bool overwriteFlag = false;
         private bool createSceneFlag = false;
+        private bool quickSaveFlag = false;
         private bool manageSceneFlag = false;
         private bool kankyoModeFlag = false;
         private bool kankyoToggle = false;