Browse Source

Add limited support for edit mode

MeidoPhotoStudio can be activated in edit mode but editing the maid will
break stuff.
habeebweeb 4 years ago
parent
commit
c277d591e5

+ 1 - 0
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/GUI/Windows/MainWindow.cs

@@ -18,6 +18,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             {
                 value.width = 240f;
                 value.height = Screen.height * 0.9f;
+                if (MeidoPhotoStudio.EditMode) value.height *= 0.85f;
                 value.x = Mathf.Clamp(value.x, 0, Screen.width - value.width);
                 value.y = Mathf.Clamp(value.y, -value.height + 30, Screen.height - 50);
                 windowRect = value;

+ 18 - 9
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/EnvironmentManager.cs

@@ -155,7 +155,6 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             cameraObject.SetActive(true);
 
             bgObject.SetActive(true);
-            GameMain.Instance.BgMgr.ChangeBg("Theater");
 
             ultimateOrbitCamera =
                 Utility.GetFieldValue<CameraMain, UltimateOrbitCamera>(GameMain.Instance.MainCamera, "m_UOCamera");
@@ -164,7 +163,12 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             defaultCameraMoveSpeed = ultimateOrbitCamera.moveSpeed;
             defaultCameraZoomSpeed = ultimateOrbitCamera.zoomSpeed;
 
-            ResetCamera();
+            if (!MeidoPhotoStudio.EditMode)
+            {
+                ResetCamera();
+                ChangeBackground("Theater");
+            }
+
             SaveCameraInfo();
 
             CubeSmallChange += OnCubeSmall;
@@ -184,15 +188,20 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             ultimateOrbitCamera.moveSpeed = defaultCameraMoveSpeed;
             ultimateOrbitCamera.zoomSpeed = defaultCameraZoomSpeed;
 
-            bool isNight = GameMain.Instance.CharacterMgr.status.GetFlag("時間帯") == 3;
+            if (MeidoPhotoStudio.EditMode) ChangeBackground("Theater");
+            else
+            {
+                bool isNight = GameMain.Instance.CharacterMgr.status.GetFlag("時間帯") == 3;
+
+                if (isNight) ChangeBackground("ShinShitsumu_ChairRot_Night");
+                else ChangeBackground("ShinShitsumu_ChairRot");
 
-            if (isNight) GameMain.Instance.BgMgr.ChangeBg("ShinShitsumu_ChairRot_Night");
-            else GameMain.Instance.BgMgr.ChangeBg("ShinShitsumu_ChairRot");
+                GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, true);
+                GameMain.Instance.MainCamera.SetTargetPos(new Vector3(0.5609447f, 1.380762f, -1.382336f), true);
+                GameMain.Instance.MainCamera.SetDistance(1.6f, true);
+                GameMain.Instance.MainCamera.SetAroundAngle(new Vector2(245.5691f, 6.273283f), true);
+            }
 
-            GameMain.Instance.MainCamera.Reset(CameraMain.CameraType.Target, true);
-            GameMain.Instance.MainCamera.SetTargetPos(new Vector3(0.5609447f, 1.380762f, -1.382336f), true);
-            GameMain.Instance.MainCamera.SetDistance(1.6f, true);
-            GameMain.Instance.MainCamera.SetAroundAngle(new Vector2(245.5691f, 6.273283f), true);
             bg.localScale = Vector3.one;
             CubeSmallChange -= OnCubeSmall;
             CubeActiveChange -= OnCubeActive;

+ 32 - 5
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Managers/MeidoManager.cs

@@ -68,6 +68,14 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             {
                 Meidos[stockMaidIndex] = new Meido(stockMaidIndex);
             }
+
+            if (MeidoPhotoStudio.EditMode)
+            {
+                Maid editMaid = GameMain.Instance.CharacterMgr.GetMaid(0);
+                EditMaidIndex = Array.FindIndex(Meidos, meido => meido.Maid.status.guid == editMaid.status.guid);
+            }
+
+            ClearSelectList();
         }
 
         public void Deactivate()
@@ -81,6 +89,14 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
             ActiveMeidoList.Clear();
             ClearSelectList();
+
+            if (MeidoPhotoStudio.EditMode)
+            {
+                Meido meido = Meidos[EditMaidIndex];
+                meido.Maid.Visible = true;
+                meido.Stop = false;
+                meido.EyeToCam = true;
+            }
         }
 
         public void Update()
@@ -139,6 +155,8 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
             BeginCallMeidos?.Invoke(this, EventArgs.Empty);
 
+            bool moreThanEditMaid = ActiveMeidoList.Count > 1;
+
             UnloadMeidos();
 
             if (SelectMeidoList.Count == 0)
@@ -147,9 +165,10 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 return;
             }
 
-            GameMain.Instance.MainCamera.FadeOut(
-                0.01f, f_bSkipable: false, f_dg: () => GameMain.Instance.StartCoroutine(LoadMeidos())
-            );
+            void callMeidos() => GameMain.Instance.StartCoroutine(LoadMeidos());
+
+            if (MeidoPhotoStudio.EditMode && !moreThanEditMaid && SelectMeidoList.Count == 1) callMeidos();
+            else GameMain.Instance.MainCamera.FadeOut(0.01f, f_bSkipable: false, f_dg: callMeidos);
         }
 
         private System.Collections.IEnumerator LoadMeidos()
@@ -169,8 +188,11 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
             if (SelectedMeidoSet.Contains(index))
             {
-                SelectedMeidoSet.Remove(index);
-                SelectMeidoList.Remove(index);
+                if (!MeidoPhotoStudio.EditMode || index != EditMaidIndex)
+                {
+                    SelectedMeidoSet.Remove(index);
+                    SelectMeidoList.Remove(index);
+                }
             }
             else
             {
@@ -183,6 +205,11 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
             SelectedMeidoSet.Clear();
             SelectMeidoList.Clear();
+            if (MeidoPhotoStudio.EditMode)
+            {
+                SelectedMeidoSet.Add(EditMaidIndex);
+                SelectMeidoList.Add(EditMaidIndex);
+            }
         }
 
         public Meido GetMeido(string guid)

+ 19 - 13
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/MeidoPhotoStudio.cs

@@ -1,4 +1,4 @@
-using System;
+using System;
 using System.IO;
 using System.Collections;
 using System.Collections.Generic;
@@ -21,6 +21,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         public const int sceneVersion = 1000;
         public const int kankyoMagic = -765;
         public static string pluginString = $"{pluginName} {pluginVersion}";
+        public static bool EditMode => currentScene == Constants.Scene.Edit;
         private WindowManager windowManager;
         private SceneManager sceneManager;
         private MeidoManager meidoManager;
@@ -29,7 +30,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         private LightManager lightManager;
         private PropManager propManager;
         private EffectManager effectManager;
-        private Constants.Scene currentScene;
+        private static Constants.Scene currentScene;
         private bool initialized;
         private bool active;
         private bool uiActive;
@@ -229,7 +230,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         private void Update()
         {
-            if (currentScene == Constants.Scene.Daily)
+            if (currentScene == Constants.Scene.Daily || currentScene == Constants.Scene.Edit)
             {
                 if (Input.GetKeyDown(MpsKey.Activate))
                 {
@@ -411,8 +412,12 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             uiActive = true;
             active = true;
 
-            GameObject dailyPanel = GameObject.Find("UI Root").transform.Find("DailyPanel").gameObject;
-            dailyPanel.SetActive(false);
+            if (!EditMode)
+            {
+                GameObject dailyPanel = GameObject.Find("UI Root")?.transform.Find("DailyPanel")?.gameObject;
+                if (dailyPanel) dailyPanel.SetActive(false);
+            }
+            else meidoManager.CallMeidos();
         }
 
         private void Deactivate(bool force = false)
@@ -437,20 +442,21 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
                 Modal.Close();
 
-                GameObject dailyPanel = GameObject.Find("UI Root")?.transform.Find("DailyPanel")?.gameObject;
-                dailyPanel?.SetActive(true);
+                if (!EditMode)
+                {
+                    GameObject dailyPanel = GameObject.Find("UI Root")?.transform.Find("DailyPanel")?.gameObject;
+                    dailyPanel?.SetActive(true);
+                }
+
                 Configuration.Config.Save();
             }
 
-            if (force || sysDialog.IsDecided)
+            if (sysDialog.IsDecided || EditMode || force)
             {
                 uiActive = false;
                 active = false;
-                if (force)
-                {
-                    sysDialog.Close();
-                    exit();
-                }
+
+                if (EditMode || force) exit();
                 else
                 {
                     string exitMessage = string.Format(Translation.Get("systemMessage", "exitConfirm"), pluginName);