Browse Source

Show number of maids in scene preview

habeebweeb 4 years ago
parent
commit
db305bd7ee

+ 32 - 0
MultipleMaids/CM3D2/MultipleMaids/Plugin/MultipleMaids.Gui.cs

@@ -9181,6 +9181,9 @@ namespace CM3D2.MultipleMaids.Plugin
                         ReadScene();
                         if (sceneData != null)
                         {
+                            int numMaids = int.Parse(sceneData.Split(',')[1]);
+                            string maids = numMaids == 1 ? "Maid" : "Maids";
+                            infoString = new GUIContent($"{numMaids} {maids}");
                             manageSaveFlag = true;
                         }
                     }
@@ -9225,9 +9228,17 @@ namespace CM3D2.MultipleMaids.Plugin
             GUIStyle labelStyle = new GUIStyle("label");
             labelStyle.fontSize = GetPix(12);
             labelStyle.alignment = TextAnchor.MiddleCenter;
+            GUIStyle infoLabelStyle = new GUIStyle("label");
+            infoLabelStyle.fontSize = GetPix(13);
+            infoLabelStyle.alignment = TextAnchor.MiddleCenter;
+            // infoLabelStyle.normal.textColor = new Color(1f, 0.44f, 0f);
+            GUIStyle infoLabelShadow = new GUIStyle(infoLabelStyle);
+            infoLabelShadow.normal.textColor = new Color(0f, 0f, 0f, 0.55f);
             GUIStyle saveControlStyle = new GUIStyle("button");
             saveControlStyle.fontSize = GetPix(12);
             saveControlStyle.alignment = TextAnchor.MiddleCenter;
+            GUIStyle infoHighlightStyle = new GUIStyle("box");
+            infoHighlightStyle.normal.background = infoHighlight;
 
             int index = deleteDirectoryFlag ? saveScenes.Count - 1 : selectedSave;
             Texture2D previewImage = saveScenes.ElementAtOrDefault(index)?.screenshot;
@@ -9266,6 +9277,26 @@ namespace CM3D2.MultipleMaids.Plugin
                 ), previewImage);
             }
 
+
+            if (!deleteDirectoryFlag)
+            {
+                Vector2 infoLabelSize = infoLabelStyle.CalcSize(infoString);
+
+                GUI.Box(new Rect(
+                    previewX + GetPix(7),
+                    previewY + previewHeight - infoLabelSize.y - GetPix(7),
+                    infoLabelSize.x + GetPix(8),
+                    infoLabelSize.y
+                ), "", infoHighlightStyle);
+
+                GUI.Label(new Rect(
+                    previewX + GetPix(10),
+                    previewY + previewHeight - infoLabelSize.y - GetPix(8),
+                    infoLabelSize.x,
+                    infoLabelSize.y
+                ), infoString, infoLabelStyle);
+            }
+
             string title = deleteDirectoryFlag
                 ? $"Are you sure you want to delete \"{directoryList[selectedDirectory]}\"?"
                 : deleteFileFlag
@@ -9325,6 +9356,7 @@ namespace CM3D2.MultipleMaids.Plugin
                     manageSaveFlag = false;
                     loadSaveFlag = true;
                     loadScene = 1;
+                    LoadScene();
                 }
 
                 if (GUI.Button(new Rect(

+ 0 - 1
MultipleMaids/CM3D2/MultipleMaids/Plugin/MultipleMaids.Update.cs

@@ -4150,7 +4150,6 @@ namespace CM3D2.MultipleMaids.Plugin
             {
                 if (loadSaveFlag && !kankyoLoadFlg)
                 {
-                    LoadSave();
                     loadSaveFlag = false;
                 }
                 else

+ 12 - 9
MultipleMaids/SaveManager.cs

@@ -10,15 +10,17 @@ namespace CM3D2.MultipleMaids.Plugin
 {
     public partial class MultipleMaids
     {
-        private static readonly byte[] pngEnd = Encoding.ASCII.GetBytes("IEND");
+        internal static readonly byte[] pngEnd = Encoding.ASCII.GetBytes("IEND");
         internal static readonly int[] border = { -1, 0, 0, 0, 0 };
+        internal static readonly string baseDirectoryName = "< Base Directory >";
+        internal readonly string saveScenePath = Path.Combine(Path.GetFullPath(".\\"), "Mod\\MultipleMaidsSave");
         private static string sceneData;
-        private const string baseDirectoryName = "< Base Directory >";
-        private string saveScenePath = Path.Combine(Path.GetFullPath(".\\"), "Mod\\MultipleMaidsSave");
-        private List<SavePng> saveScenes = new List<SavePng>(50);
+        private static List<SavePng> saveScenes = new List<SavePng>(50);
         private GUIStyle selectedButtonStyle;
+        private GUIContent infoString;
         private string[] directoryList;
         private Texture2D frame;
+        private Texture2D infoHighlight;
         private Rect saveManagerRect;
         private Rect saveModalRect;
         private Rect resizeManagerRect;
@@ -41,6 +43,7 @@ namespace CM3D2.MultipleMaids.Plugin
         public void InitializeSaveManager()
         {
             frame = MakeTex(2, 2, Color.white);
+            infoHighlight = MakeTex(2, 2, new Color(0f, 0f, 0f, 0.8f));
 
             if (!Directory.Exists(saveScenePath))
             {
@@ -52,17 +55,17 @@ namespace CM3D2.MultipleMaids.Plugin
             selectedButtonStyle.normal.textColor = Color.white;
 
             GetSaveDirectories();
-            InitializeSaveList();
+            GetSaveScenes();
             saveManagerInitialize = true;
         }
         private void RefreshSaveManager()
         {
             SwitchDirectory(currentDirectory);
             GetSaveDirectories();
-            InitializeSaveList();
+            GetSaveScenes();
         }
 
-        private void InitializeSaveList()
+        private void GetSaveScenes()
         {
             saveScenes.Clear();
 
@@ -117,7 +120,7 @@ namespace CM3D2.MultipleMaids.Plugin
 
                 currentDirectory = target;
             }
-            InitializeSaveList();
+            GetSaveScenes();
         }
 
         private void LoadScene()
@@ -285,7 +288,7 @@ namespace CM3D2.MultipleMaids.Plugin
             }
         }
 
-        class SavePng
+        private class SavePng
         {
             public FileInfo info { get; }
             public Texture2D screenshot { get; }