Browse Source

Change SetDropdownItems default to selected index

No argument required to change items without changing index
habeebweeb 4 years ago
parent
commit
90ef1ad616

+ 2 - 1
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/GUI/Controls/DropDown.cs

@@ -57,8 +57,9 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             DropdownHelper.DropdownClose -= OnCloseDropdown;
         }
 
-        public void SetDropdownItems(string[] itemList, int selectedItemIndex = 0)
+        public void SetDropdownItems(string[] itemList, int selectedItemIndex = -1)
         {
+            if (selectedItemIndex < 0) selectedItemIndex = this.SelectedItemIndex;
             this.elementSize = Vector2.zero;
 
             // TODO: Calculate scrollpos position maybe

+ 1 - 1
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/GUI/Panes/BackgroundWindowPanes/BackgroundSelectorPane.cs

@@ -57,7 +57,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             }
 
             updating = true;
-            this.bgDropdown.SetDropdownItems(bgList.ToArray(), this.bgDropdown.SelectedItemIndex);
+            this.bgDropdown.SetDropdownItems(bgList.ToArray());
             updating = false;
         }
 

+ 2 - 9
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/GUI/Panes/BackgroundWindowPanes/PropsPane.cs

@@ -54,15 +54,8 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         protected override void ReloadTranslation()
         {
-            this.doguDropdown.SetDropdownItems(
-                Translation.GetArray("props1Dropdown", Constants.DoguList),
-                this.doguDropdown.SelectedItemIndex
-            );
-
-            this.otherDoguDropdown.SetDropdownItems(
-                Translation.GetArray("props2Dropdown", Constants.OtherDoguList),
-                this.otherDoguDropdown.SelectedItemIndex
-            );
+            this.doguDropdown.SetDropdownItems(Translation.GetArray("props1Dropdown", Constants.DoguList));
+            this.otherDoguDropdown.SetDropdownItems(Translation.GetArray("props2Dropdown", Constants.OtherDoguList));
         }
 
         public override void Draw(params GUILayoutOption[] layoutOptions)

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

@@ -65,7 +65,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
             }
 
             updating = true;
-            this.poseGroupDropdown.SetDropdownItems(poseGroups.ToArray(), this.poseGroupDropdown.SelectedItemIndex);
+            this.poseGroupDropdown.SetDropdownItems(poseGroups.ToArray());
             updating = false;
         }
 
@@ -82,11 +82,11 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 selectedPoseGroup = newPoseGroup;
                 if (this.poseGroupDropdown.SelectedItemIndex >= Constants.CustomPoseGroupsIndex)
                 {
-                    this.poseDropdown.SetDropdownItems(MakePoseList(Constants.CustomPoseDict[selectedPoseGroup]));
+                    this.poseDropdown.SetDropdownItems(MakePoseList(Constants.CustomPoseDict[selectedPoseGroup]), 0);
                 }
                 else
                 {
-                    this.poseDropdown.SetDropdownItems(MakePoseList(Constants.PoseDict[selectedPoseGroup]));
+                    this.poseDropdown.SetDropdownItems(MakePoseList(Constants.PoseDict[selectedPoseGroup]), 0);
                 }
             }
         }

+ 1 - 2
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/GUI/Windows/MainWindows/MaidFaceWindow.cs

@@ -50,8 +50,7 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         {
             updating = true;
             faceBlendDropdown.SetDropdownItems(
-                Translation.GetArray("faceBlendPresetsDropdown", Constants.FaceBlendList),
-                faceBlendDropdown.SelectedItemIndex
+                Translation.GetArray("faceBlendPresetsDropdown", Constants.FaceBlendList)
             );
             updating = false;
         }