Browse Source

Add additional attach points for props

Props can now be attached to the spine bones.

Closes #29
habeebweeb 4 years ago
parent
commit
f253f77917

+ 16 - 12
COM3D2.MeidoPhotoStudio.Plugin/Config/MeidoPhotoStudio/Translations/en/translation.ui.json

@@ -358,19 +358,23 @@
         "neck": "Neck",
         "neck": "Neck",
         "upperArmL": "Shoulder L",
         "upperArmL": "Shoulder L",
         "upperArmR": "Shoulder R",
         "upperArmR": "Shoulder R",
-        "forearmL": "Forearm L",
-        "forearmR": "Forearm R",
-        "muneL": "Breast Left",
-        "muneR": "Breast Right",
-        "handL": "Hand Left",
-        "handR": "Hand Right",
+        "forearmL": "Elbow L",
+        "forearmR": "Elbow R",
+        "muneL": "Mune L",
+        "muneR": "Mune R",
+        "handL": "Hand L",
+        "handR": "Hand R",
         "pelvis": "Pelvis",
         "pelvis": "Pelvis",
-        "thighL": "Thigh Left",
-        "thighR": "Thigh Right",
-        "calfL": "Calf Left",
-        "calfR": "Calf Right",
-        "footL": "Foot Left",
-        "footR": "Foot Right"
+        "thighL": "Thigh L",
+        "thighR": "Thigh R",
+        "calfL": "Knee L",
+        "calfR": "Knee R",
+        "footL": "Foot L",
+        "footR": "Foot R",
+        "spine1a": "Spine 1",
+        "spine1": "Spine 2",
+        "spine0a": "Spine 3",
+        "spine0": "Spine 4"
     },
     },
     "sceneManagerModal": {
     "sceneManagerModal": {
         "deleteDirectoryConfirm": "Are you sure you want to permanently delete '{0}' and all of its files?",
         "deleteDirectoryConfirm": "Are you sure you want to permanently delete '{0}' and all of its files?",

+ 21 - 35
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/GUI/Panes/BackgroundWindow2Panes/AttachPropPane.cs

@@ -30,10 +30,12 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 [AttachPoint.CalfR] = "calfR",
                 [AttachPoint.CalfR] = "calfR",
                 [AttachPoint.FootL] = "footL",
                 [AttachPoint.FootL] = "footL",
                 [AttachPoint.FootR] = "footR",
                 [AttachPoint.FootR] = "footR",
+                [AttachPoint.Spine1a] = "spine1a",
+                [AttachPoint.Spine1] = "spine1",
+                [AttachPoint.Spine0a] = "spine0a",
+                [AttachPoint.Spine0] = "spine0"
             };
             };
         private readonly Toggle keepWorldPositionToggle;
         private readonly Toggle keepWorldPositionToggle;
-        private readonly Button previousMaidButton;
-        private readonly Button nextMaidButton;
         private readonly Dropdown meidoDropdown;
         private readonly Dropdown meidoDropdown;
         private bool meidoDropdownActive;
         private bool meidoDropdownActive;
         private bool doguDropdownActive;
         private bool doguDropdownActive;
@@ -54,19 +56,13 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             meidoDropdown = new Dropdown(new[] { Translation.Get("systemMessage", "noMaids") });
             meidoDropdown = new Dropdown(new[] { Translation.Get("systemMessage", "noMaids") });
             meidoDropdown.SelectionChange += (s, a) => SwitchMaid();
             meidoDropdown.SelectionChange += (s, a) => SwitchMaid();
 
 
-            previousMaidButton = new Button("<");
-            previousMaidButton.ControlEvent += (s, a) => meidoDropdown.Step(-1);
-
-            nextMaidButton = new Button(">");
-            nextMaidButton.ControlEvent += (s, a) => meidoDropdown.Step(1);
-
             keepWorldPositionToggle = new Toggle(Translation.Get("attachPropPane", "keepWorldPosition"));
             keepWorldPositionToggle = new Toggle(Translation.Get("attachPropPane", "keepWorldPosition"));
 
 
             foreach (AttachPoint attachPoint in Enum.GetValues(typeof(AttachPoint)))
             foreach (AttachPoint attachPoint in Enum.GetValues(typeof(AttachPoint)))
             {
             {
                 if (attachPoint == AttachPoint.None) continue;
                 if (attachPoint == AttachPoint.None) continue;
                 AttachPoint point = attachPoint;
                 AttachPoint point = attachPoint;
-                Toggle toggle = new Toggle(Translation.Get("attachPropPane", toggleTranslation[point]));
+                var toggle = new Toggle(Translation.Get("attachPropPane", toggleTranslation[point]));
                 toggle.ControlEvent += (s, a) =>
                 toggle.ControlEvent += (s, a) =>
                 {
                 {
                     if (updating) return;
                     if (updating) return;
@@ -91,9 +87,8 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
         {
             const float dropdownButtonHeight = 30;
             const float dropdownButtonHeight = 30;
             const float dropdownButtonWidth = 153f;
             const float dropdownButtonWidth = 153f;
-            GUILayoutOption[] dropdownLayoutOptions = new GUILayoutOption[] {
-                GUILayout.Height(dropdownButtonHeight),
-                GUILayout.Width(dropdownButtonWidth)
+            GUILayoutOption[] dropdownLayoutOptions = {
+                GUILayout.Height(dropdownButtonHeight), GUILayout.Width(dropdownButtonWidth)
             };
             };
 
 
             MpsGui.Header(header);
             MpsGui.Header(header);
@@ -106,11 +101,11 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             keepWorldPositionToggle.Draw();
             keepWorldPositionToggle.Draw();
 
 
             DrawToggleGroup(AttachPoint.Head, AttachPoint.Neck);
             DrawToggleGroup(AttachPoint.Head, AttachPoint.Neck);
-            DrawToggleGroup(AttachPoint.UpperArmR, AttachPoint.UpperArmL);
-            DrawToggleGroup(AttachPoint.ForearmR, AttachPoint.ForearmL);
-            DrawToggleGroup(AttachPoint.MuneR, AttachPoint.MuneL);
-            DrawToggleGroup(AttachPoint.HandR, AttachPoint.Pelvis, AttachPoint.HandL);
-            DrawToggleGroup(AttachPoint.ThighR, AttachPoint.ThighL);
+            DrawToggleGroup(AttachPoint.UpperArmR, AttachPoint.Spine1a, AttachPoint.UpperArmL);
+            DrawToggleGroup(AttachPoint.ForearmR, AttachPoint.Spine1, AttachPoint.ForearmL);
+            DrawToggleGroup(AttachPoint.MuneR, AttachPoint.Spine0a, AttachPoint.MuneL);
+            DrawToggleGroup(AttachPoint.HandR, AttachPoint.Spine0,AttachPoint.HandL);
+            DrawToggleGroup(AttachPoint.ThighR,AttachPoint.Pelvis, AttachPoint.ThighL);
             DrawToggleGroup(AttachPoint.CalfR, AttachPoint.CalfL);
             DrawToggleGroup(AttachPoint.CalfR, AttachPoint.CalfL);
             DrawToggleGroup(AttachPoint.FootR, AttachPoint.FootL);
             DrawToggleGroup(AttachPoint.FootR, AttachPoint.FootL);
 
 
@@ -121,10 +116,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
         {
             GUILayout.BeginHorizontal();
             GUILayout.BeginHorizontal();
             GUILayout.FlexibleSpace();
             GUILayout.FlexibleSpace();
-            foreach (AttachPoint point in attachPoints)
-            {
-                Toggles[point].Draw();
-            }
+            foreach (AttachPoint point in attachPoints) Toggles[point].Draw();
             GUILayout.FlexibleSpace();
             GUILayout.FlexibleSpace();
             GUILayout.EndHorizontal();
             GUILayout.EndHorizontal();
         }
         }
@@ -132,27 +124,22 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         private void SetAttachPointToggle(AttachPoint point, bool value)
         private void SetAttachPointToggle(AttachPoint point, bool value)
         {
         {
             updating = true;
             updating = true;
-            foreach (Toggle toggle in Toggles.Values)
-            {
-                toggle.Value = false;
-            }
+            foreach (Toggle toggle in Toggles.Values) toggle.Value = false;
             if (point != AttachPoint.None) Toggles[point].Value = value;
             if (point != AttachPoint.None) Toggles[point].Value = value;
             updating = false;
             updating = false;
         }
         }
 
 
         private void ChangeAttachPoint(AttachPoint point)
         private void ChangeAttachPoint(AttachPoint point)
         {
         {
-            bool toggleValue = point != AttachPoint.None && Toggles[point].Value;
+            var toggleValue = point != AttachPoint.None && Toggles[point].Value;
             SetAttachPointToggle(point, toggleValue);
             SetAttachPointToggle(point, toggleValue);
 
 
             Meido meido = null;
             Meido meido = null;
 
 
             if (point != AttachPoint.None)
             if (point != AttachPoint.None)
-            {
                 meido = Toggles[point].Value
                 meido = Toggles[point].Value
                     ? meidoManager.ActiveMeidoList[meidoDropdown.SelectedItemIndex]
                     ? meidoManager.ActiveMeidoList[meidoDropdown.SelectedItemIndex]
                     : null;
                     : null;
-            }
 
 
             propManager.AttachProp(
             propManager.AttachProp(
                 propManager.CurrentDoguIndex, point, meido, keepWorldPositionToggle.Value
                 propManager.CurrentDoguIndex, point, meido, keepWorldPositionToggle.Value
@@ -164,18 +151,16 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             if (updating || selectedMaid == meidoDropdown.SelectedItemIndex) return;
             if (updating || selectedMaid == meidoDropdown.SelectedItemIndex) return;
             selectedMaid = meidoDropdown.SelectedItemIndex;
             selectedMaid = meidoDropdown.SelectedItemIndex;
             DragPointDogu dragDogu = propManager.CurrentDogu;
             DragPointDogu dragDogu = propManager.CurrentDogu;
-            if (dragDogu != null)
-            {
-                if (dragDogu.attachPointInfo.AttachPoint == AttachPoint.None) return;
-                ChangeAttachPoint(dragDogu.attachPointInfo.AttachPoint);
-            }
+            if (!dragDogu) return;
+            if (dragDogu.attachPointInfo.AttachPoint == AttachPoint.None) return;
+            ChangeAttachPoint(dragDogu.attachPointInfo.AttachPoint);
         }
         }
 
 
         private void SwitchDogu()
         private void SwitchDogu()
         {
         {
             if (updating) return;
             if (updating) return;
             DragPointDogu dragDogu = propManager.CurrentDogu;
             DragPointDogu dragDogu = propManager.CurrentDogu;
-            if (dragDogu != null) SetAttachPointToggle(dragDogu.attachPointInfo.AttachPoint, true);
+            if (dragDogu) SetAttachPointToggle(dragDogu.attachPointInfo.AttachPoint, true);
         }
         }
 
 
         private void SetMeidoDropdown()
         private void SetMeidoDropdown()
@@ -184,13 +169,14 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             {
             {
                 SetAttachPointToggle(AttachPoint.Head, false);
                 SetAttachPointToggle(AttachPoint.Head, false);
             }
             }
-            int index = Mathf.Clamp(meidoDropdown.SelectedItemIndex, 0, meidoManager.ActiveMeidoList.Count);
+            var index = Mathf.Clamp(meidoDropdown.SelectedItemIndex, 0, meidoManager.ActiveMeidoList.Count);
 
 
             string[] dropdownList = meidoManager.ActiveMeidoList.Count == 0
             string[] dropdownList = meidoManager.ActiveMeidoList.Count == 0
                 ? new[] { Translation.Get("systemMessage", "noMaids") }
                 ? new[] { Translation.Get("systemMessage", "noMaids") }
                 : meidoManager.ActiveMeidoList.Select(
                 : meidoManager.ActiveMeidoList.Select(
                     meido => $"{meido.Slot + 1}: {meido.FirstName} {meido.LastName}"
                     meido => $"{meido.Slot + 1}: {meido.FirstName} {meido.LastName}"
                 ).ToArray();
                 ).ToArray();
+
             updating = true;
             updating = true;
             meidoDropdown.SetDropdownItems(dropdownList, index);
             meidoDropdown.SetDropdownItems(dropdownList, index);
             updating = false;
             updating = false;

+ 9 - 5
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/GUI/Panes/MainWindowPanes/BG2WindowPane.cs

@@ -1,3 +1,5 @@
+using UnityEngine;
+
 namespace COM3D2.MeidoPhotoStudio.Plugin
 namespace COM3D2.MeidoPhotoStudio.Plugin
 {
 {
     public class BG2WindowPane : BaseMainWindowPane
     public class BG2WindowPane : BaseMainWindowPane
@@ -40,11 +42,13 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             propTabs.Draw();
             propTabs.Draw();
             MpsGui.WhiteLine();
             MpsGui.WhiteLine();
             currentPropsPane.Draw();
             currentPropsPane.Draw();
-            if (propTabs.SelectedItemIndex == 0)
-            {
-                propManagerPane.Draw();
-                attachPropPane.Draw();
-            }
+
+            if (propTabs.SelectedItemIndex != 0) return;
+
+            propManagerPane.Draw();
+            scrollPos = GUILayout.BeginScrollView(scrollPos);
+            attachPropPane.Draw();
+            GUILayout.EndScrollView();
         }
         }
 
 
         public override void UpdatePanes()
         public override void UpdatePanes()

+ 6 - 2
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/Meido/MeidoDragPointManager.cs

@@ -9,7 +9,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
     public enum AttachPoint
     public enum AttachPoint
     {
     {
         None, Head, Neck, UpperArmL, UpperArmR, ForearmL, ForearmR, MuneL, MuneR, HandL, HandR,
         None, Head, Neck, UpperArmL, UpperArmR, ForearmL, ForearmR, MuneL, MuneR, HandL, HandR,
-        Pelvis, ThighL, ThighR, CalfL, CalfR, FootL, FootR
+        Pelvis, ThighL, ThighR, CalfL, CalfR, FootL, FootR, Spine1a, Spine1, Spine0a, Spine0
     }
     }
 
 
     public class MeidoDragPointManager
     public class MeidoDragPointManager
@@ -63,6 +63,10 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             [AttachPoint.CalfR] = Bone.CalfR,
             [AttachPoint.CalfR] = Bone.CalfR,
             [AttachPoint.FootL] = Bone.FootL,
             [AttachPoint.FootL] = Bone.FootL,
             [AttachPoint.FootR] = Bone.FootR,
             [AttachPoint.FootR] = Bone.FootR,
+            [AttachPoint.Spine1a] = Bone.Spine1a,
+            [AttachPoint.Spine1] = Bone.Spine1,
+            [AttachPoint.Spine0a] = Bone.Spine0a,
+            [AttachPoint.Spine0] = Bone.Spine
         };
         };
         private static readonly Bone[] SpineBones =
         private static readonly Bone[] SpineBones =
         {
         {
@@ -164,7 +168,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             GameMain.Instance.StartCoroutine(ApplyHipPosition(binaryReader.ReadVector3()));
             GameMain.Instance.StartCoroutine(ApplyHipPosition(binaryReader.ReadVector3()));
         }
         }
 
 
-        /* 
+        /*
             Somebody smarter than me please help me find a way to do this better T_T
             Somebody smarter than me please help me find a way to do this better T_T
             inb4 for loop.
             inb4 for loop.
          */
          */