|
@@ -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);
|