Browse Source

Add free look updating

habeebweeb 4 years ago
parent
commit
0dc8068f7a

+ 16 - 3
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/GUI/Panes/PoseWindowPanes/MaidFaceLookPane.cs

@@ -12,6 +12,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         public MaidFaceLookPane(MeidoManager meidoManager)
         {
             this.meidoManager = meidoManager;
+            this.meidoManager.AnimeChange += (s, a) => SetBounds();
 
             this.lookXSlider = new Slider(Translation.Get("freeLook", "x"), -0.6f, 0.6f);
             this.lookXSlider.ControlEvent += (s, a) => SetMaidLook();
@@ -27,14 +28,26 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
             TBody body = this.meidoManager.ActiveMeido.Maid.body0;
 
-            bool isPlaying = this.meidoManager.ActiveMeido.Maid.GetAnimation().isPlaying;
-            body.offsetLookTarget = new Vector3(lookYSlider.Value * (isPlaying ? 1f : 0.6f), 1f, lookXSlider.Value);
+            body.offsetLookTarget = new Vector3(lookYSlider.Value, 1f, lookXSlider.Value);
+        }
+
+        public void SetBounds()
+        {
+            float left = 0.5f;
+            float right = -0.55f;
+            if (this.meidoManager.ActiveMeido.IsStop)
+            {
+                left *= 0.6f;
+                right *= 0.6f;
+            }
+            this.lookYSlider.SetBounds(left, right);
         }
 
         public override void Update()
         {
             TBody body = this.meidoManager.ActiveMeido.Maid.body0;
             this.updating = true;
+            this.SetBounds();
             this.lookXSlider.Value = body.offsetLookTarget.z;
             this.lookYSlider.Value = body.offsetLookTarget.x;
             this.updating = false;
@@ -42,7 +55,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         public override void Draw(params GUILayoutOption[] layoutOptions)
         {
-            GUI.enabled = this.Enabled;
+            GUI.enabled = this.meidoManager.HasActiveMeido && this.meidoManager.ActiveMeido.IsFreeLook;
             GUILayout.BeginHorizontal();
             lookXSlider.Draw();
             lookYSlider.Draw();

+ 21 - 8
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/GUI/Windows/MainWindows/MaidPoseWindow.cs

@@ -30,13 +30,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             TabsPane.TabChange += OnTabChange;
 
             this.freeLookToggle = new Toggle(Translation.Get("freeLook", "freeLookToggle"), false);
-            this.freeLookToggle.ControlEvent += (s, a) =>
-            {
-                TBody body = this.meidoManager.ActiveMeido.Maid.body0;
-                body.trsLookTarget = this.freeLookToggle.Value ? null : GameMain.Instance.MainCamera.transform;
-                this.maidFaceLookPane.Enabled = this.freeLookToggle.Value;
-                if (this.freeLookToggle.Value) this.maidFaceLookPane.SetMaidLook();
-            };
+            this.freeLookToggle.ControlEvent += (s, a) => SetMaidFreeLook();
         }
 
         ~MaidPoseWindow()
@@ -67,12 +61,31 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             GUILayout.EndScrollView();
         }
 
+        private void SetMaidFreeLook()
+        {
+            if (this.updating) return;
+            TBody body = this.meidoManager.ActiveMeido.Maid.body0;
+            bool isFreeLook = this.freeLookToggle.Value;
+            body.trsLookTarget = isFreeLook ? null : GameMain.Instance.MainCamera.transform;
+            this.meidoManager.ActiveMeido.IsFreeLook = isFreeLook;
+            if (isFreeLook) this.maidFaceLookPane.SetMaidLook();
+        }
+
         private void UpdatePanes()
         {
-            if (!this.meidoManager.HasActiveMeido) return;
+            if (this.meidoManager.ActiveMeido == null)
+            {
+                this.updating = true;
+                this.freeLookToggle.Value = false;
+                this.updating = false;
+                return;
+            }
 
             if (TabsPane.SelectedTab == Constants.Window.Pose)
             {
+                this.updating = true;
+                this.freeLookToggle.Value = this.meidoManager.ActiveMeido?.IsFreeLook ?? false;
+                this.updating = false;
                 maidPosePane.Update();
                 maidFaceLookPane.Update();
                 maidDressingPane.Update();

+ 2 - 0
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/Meido.cs

@@ -23,6 +23,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         public event EventHandler BodyLoad;
         public event EventHandler AnimeChange;
         private bool isLoading = false;
+        public bool IsFreeLook { get; set; }
         private bool isIK = false;
         public bool IsIK
         {
@@ -105,6 +106,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 this.IsBone = false;
             }
 
+            this.IsFreeLook = false;
             Maid.body0.boHeadToCam = true;
             Maid.body0.boEyeToCam = true;
             Maid.body0.SetBoneHitHeightY(-1000f);