Browse Source

Update readme changelog

Added pose selector and edit mode ok button fixes to changelog
habeebweeb 2 years ago
parent
commit
87274d535e

+ 4 - 0
Documentation/readme.adoc

@@ -275,6 +275,10 @@ longer offset from maid body.
 * Fix message box and text disappearing after leaving edit mode
 * Fix background switcher breaking when `MyRoom` directory is missing from game root
 * Fix blur effect not turning off properly
+* Fix issue where loading a scene that uses a non-existent pose breaks the pose selector
+* Fix MPS naively restoring edit mode's OK button's original functionality
+** Other plugins may have hooked onto the OK button and MPS restoring original functionality effectively removes those
+hooks
 
 === {pluginname}.1.0.0-beta.4
 

+ 1 - 1
src/MeidoPhotoStudio.Converter/MeidoPhotoStudio.Converter.csproj

@@ -1,8 +1,8 @@
 <Project Sdk="Microsoft.NET.Sdk">
   <PropertyGroup>
     <TargetFramework>net35</TargetFramework>
-    <FrameworkPathOverride Condition="'$(TargetFramework)' == 'net35'">$(MSBuildProgramFiles32)\Reference Assemblies\Microsoft\Framework\.NETFramework\v3.5\Profile\Client</FrameworkPathOverride>
     <ProjectGuid>{19D28B0C-3537-4FEE-B7B3-1ABF70B16D5E}</ProjectGuid>
+    <LangVersion>latest</LangVersion>
   </PropertyGroup>
   <ItemGroup>
     <Reference Include="..\..\lib\Assembly-CSharp.dll" />

+ 5 - 4
src/MeidoPhotoStudio.Plugin/DragPoint/DragPoint.cs

@@ -14,7 +14,7 @@ namespace MeidoPhotoStudio.Plugin
         private Func<Vector3> rotation;
         private Collider collider;
         private Renderer renderer;
-        private bool reinitializeDrag;
+        protected bool ReinitializeDrag { get; private set; }
         protected bool Transforming => CurrentDragType >= DragType.MoveXZ;
         protected bool Special => CurrentDragType == DragType.Select || CurrentDragType == DragType.Delete;
         protected bool Moving => CurrentDragType == DragType.MoveXZ || CurrentDragType == DragType.MoveY;
@@ -72,7 +72,7 @@ namespace MeidoPhotoStudio.Plugin
                 if (value != oldDragType)
                 {
                     currentDragType = value;
-                    reinitializeDrag = true;
+                    ReinitializeDrag = true;
                     oldDragType = currentDragType;
                     ApplyDragType();
                 }
@@ -210,9 +210,10 @@ namespace MeidoPhotoStudio.Plugin
 
         protected virtual void OnMouseDrag()
         {
-            if (reinitializeDrag)
+            if (ReinitializeDrag)
             {
-                reinitializeDrag = false;
+                // NOTE: Order matters here.
+                ReinitializeDrag = false;
                 OnMouseDown();
             }
 

+ 13 - 10
src/MeidoPhotoStudio.Plugin/DragPoint/DragPointGeneral.cs

@@ -91,16 +91,19 @@ namespace MeidoPhotoStudio.Plugin
 
         protected override void OnMouseDown()
         {
-            if (Deleting)
-            {
-                OnDelete();
-                return;
-            }
-
-            if (Selecting)
-            {
-                OnSelect();
-                return;
+            if (!ReinitializeDrag)
+            {
+                if (Deleting)
+                {
+                    OnDelete();
+                    return;
+                }
+
+                if (Selecting)
+                {
+                    OnSelect();
+                    return;
+                }
             }
 
             base.OnMouseDown();

+ 2 - 1
src/MeidoPhotoStudio.Plugin/Meido/IK/DragPointHead.cs

@@ -51,7 +51,8 @@ namespace MeidoPhotoStudio.Plugin
         {
             base.OnMouseDown();
 
-            if (CurrentDragType == DragType.Select) Select?.Invoke(this, EventArgs.Empty);
+            if (Selecting && !ReinitializeDrag)
+                Select?.Invoke(this, EventArgs.Empty);
 
             headRotation = MyObject.rotation;
 

+ 40 - 33
src/MeidoPhotoStudio.Plugin/Meido/Meido.cs

@@ -120,7 +120,7 @@ namespace MeidoPhotoStudio.Plugin
                 {
                     Body.boEyeToCam = true;
                     Body.boHeadToCam = true;
-                    SetPose(CachedPose.Pose);
+                    SetPose(CachedPose);
                 }
 
                 OnUpdateMeido();
@@ -337,7 +337,7 @@ namespace MeidoPhotoStudio.Plugin
             Maid.Visible = false;
 
             IKManager.Destroy();
-            
+
             Active = false;
         }
 
@@ -359,26 +359,24 @@ namespace MeidoPhotoStudio.Plugin
 
         public void SetPose(PoseInfo poseInfo)
         {
-            CachedPose = poseInfo;
-            SetPose(poseInfo.Pose);
-        }
-
-        public void SetPose(string pose)
-        {
-            if (!Body.isLoadedBody) return;
+            if (!Body.isLoadedBody)
+                return;
 
-            if (pose.StartsWith(Constants.customPosePath))
+            if (poseInfo.CustomPose)
             {
-                string poseFilename = Path.GetFileNameWithoutExtension(pose);
                 try
                 {
-                    byte[] poseBuffer = File.ReadAllBytes(pose);
-                    string hash = Path.GetFileName(pose).GetHashCode().ToString();
-                    Body.CrossFade(hash, poseBuffer, loop: true, fade: 0f);
+                    var poseData = File.ReadAllBytes(poseInfo.Pose);
+                    var poseHash = Path.GetFileName(poseInfo.Pose).GetHashCode().ToString();
+
+                    Body.CrossFade(poseHash, poseData, loop: true, fade: 0f);
+
+                    SetMune(true, true);
+                    SetMune(true);
                 }
-                catch (Exception e) when (e is DirectoryNotFoundException || e is FileNotFoundException)
+                catch (IOException ioException)
                 {
-                    Utility.LogWarning($"{poseFilename}: Could not open because {e.Message}");
+                    Utility.LogWarning($"Could not open {poseInfo.Pose} because {ioException.Message}");
                     Constants.InitializeCustomPoses();
                     SetPose(PoseInfo.DefaultPose);
                     OnUpdateMeido();
@@ -386,31 +384,47 @@ namespace MeidoPhotoStudio.Plugin
                 }
                 catch (Exception e)
                 {
-                    Utility.LogWarning($"{poseFilename}: Could not apply pose because {e.Message}");
+                    Utility.LogWarning($"Could not apply pose {poseInfo.Pose} because {e.Message}");
                     SetPose(PoseInfo.DefaultPose);
                     OnUpdateMeido();
                     return;
                 }
-                SetMune(true, left: true);
-                SetMune(true, left: false);
             }
             else
             {
-                string[] poseComponents = pose.Split(',');
-                pose = poseComponents[0] + ".anm";
+                const int poseName = 0;
+                const int poseTime = 1;
+                const char componentSeparator = ',';
+
+                var poseComponents = poseInfo.Pose.Split(componentSeparator);
+
+                var poseFilename = poseComponents[poseName] + ".anm";
 
-                Maid.CrossFade(pose, loop: true, val: 0f);
-                Maid.GetAnimation().Play();
+                var animeTag = Maid.CrossFade(poseFilename, loop: true, val: 0f);
+
+                if (string.IsNullOrEmpty(animeTag))
+                    return;
+
+                var animation = Maid.GetAnimation();
+                animation.Play();
 
                 if (poseComponents.Length > 1)
                 {
-                    Maid.GetAnimation()[pose].time = float.Parse(poseComponents[1]);
-                    Maid.GetAnimation()[pose].speed = 0f;
+                    if (float.TryParse(poseComponents[poseTime], out var animationTime))
+                    {
+                        animation[animeTag].time = animationTime;
+                        animation[animeTag].speed = 0f;
+                    }
                 }
-                SetPoseMune();
+
+                var momiOrPaizuri = CachedPose.Pose.Contains("_momi") || CachedPose.Pose.Contains("paizuri_");
+                SetMune(!momiOrPaizuri, true);
+                SetMune(!momiOrPaizuri);
             }
 
             Maid.SetAutoTwistAll(true);
+
+            CachedPose = poseInfo;
         }
 
         public KeyValuePair<bool, bool> SetFrameBinary(byte[] poseBuffer)
@@ -439,13 +453,6 @@ namespace MeidoPhotoStudio.Plugin
             }
         }
 
-        private void SetPoseMune()
-        {
-            bool momiOrPaizuri = CachedPose.Pose.Contains("_momi") || CachedPose.Pose.Contains("paizuri_");
-            SetMune(!momiOrPaizuri, left: true);
-            SetMune(!momiOrPaizuri, left: false);
-        }
-
         public void SetHandPreset(string filename, bool right)
         {
             string faceFilename = Path.GetFileNameWithoutExtension(filename);