Browse Source

Move background selector to a separate pane

habeebweeb 4 years ago
parent
commit
376ad0f411

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

@@ -0,0 +1,54 @@
+using UnityEngine;
+
+namespace COM3D2.MeidoPhotoStudio.Plugin
+{
+    class BackgroundSelectorPane : BasePane
+    {
+        private EnvironmentManager environmentManager;
+        private Dropdown bgDropdown;
+        private Button prevBGButton;
+        private Button nextBGButton;
+
+        public BackgroundSelectorPane(EnvironmentManager environmentManager)
+        {
+            this.environmentManager = environmentManager;
+
+            int theaterIndex = Constants.BGList.FindIndex(bg => bg == "Theater");
+
+            this.bgDropdown = new Dropdown(Translation.GetList("bgDropdown", Constants.BGList), theaterIndex);
+            this.bgDropdown.SelectionChange += (s, a) =>
+            {
+                string bg = Constants.BGList[this.bgDropdown.SelectedItemIndex];
+                environmentManager.ChangeBackground(bg);
+            };
+
+            this.prevBGButton = new Button("<");
+            this.prevBGButton.ControlEvent += (s, a) => this.bgDropdown.Step(-1);
+
+            this.nextBGButton = new Button(">");
+            this.nextBGButton.ControlEvent += (s, a) => this.bgDropdown.Step(1);
+        }
+
+        public override void Draw(params GUILayoutOption[] layoutOptions)
+        {
+            float arrowButtonSize = 30;
+            GUILayoutOption[] arrowLayoutOptions = {
+                GUILayout.Width(arrowButtonSize),
+                GUILayout.Height(arrowButtonSize)
+            };
+
+            float dropdownButtonHeight = arrowButtonSize;
+            float dropdownButtonWidth = 153f;
+            GUILayoutOption[] dropdownLayoutOptions = new GUILayoutOption[] {
+                GUILayout.Height(dropdownButtonHeight),
+                GUILayout.Width(dropdownButtonWidth)
+            };
+
+            GUILayout.BeginHorizontal();
+            this.prevBGButton.Draw(arrowLayoutOptions);
+            this.bgDropdown.Draw(dropdownLayoutOptions);
+            this.nextBGButton.Draw(arrowLayoutOptions);
+            GUILayout.EndHorizontal();
+        }
+    }
+}

+ 6 - 36
COM3D2.MeidoPhotoStudio.Plugin/MeidoPhotoStudio/GUI/Windows/MainWindows/BackgroundWindow.cs

@@ -8,50 +8,20 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
     public class BackgroundWindow : BaseMainWindow
     {
         private EnvironmentManager environmentManager;
-        private Dropdown bgDropdown;
-        private Button prevBGButton;
-        private Button nextBGButton;
+        private BackgroundSelectorPane backgroundSelectorPane;
+        private PropsPane propsPane;
 
         public BackgroundWindow(EnvironmentManager environmentManager)
         {
             this.environmentManager = environmentManager;
-
-            int theaterIndex = Constants.BGList.FindIndex(bg => bg == "Theater");
-
-            this.bgDropdown = new Dropdown(Translation.GetList("bgDropdown", Constants.BGList), theaterIndex);
-            this.bgDropdown.SelectionChange += (s, a) =>
-            {
-                string bg = Constants.BGList[this.bgDropdown.SelectedItemIndex];
-                environmentManager.ChangeBackground(bg);
-            };
-
-            this.prevBGButton = new Button("<");
-            this.prevBGButton.ControlEvent += (s, a) => this.bgDropdown.Step(-1);
-
-            this.nextBGButton = new Button(">");
-            this.nextBGButton.ControlEvent += (s, a) => this.bgDropdown.Step(1);
+            this.backgroundSelectorPane = new BackgroundSelectorPane(this.environmentManager);
+            this.propsPane = new PropsPane(this.environmentManager);
         }
 
         public override void Draw(params GUILayoutOption[] layoutOptions)
         {
-            float arrowButtonSize = 30;
-            GUILayoutOption[] arrowLayoutOptions = {
-                GUILayout.Width(arrowButtonSize),
-                GUILayout.Height(arrowButtonSize)
-            };
-
-            float dropdownButtonHeight = arrowButtonSize;
-            float dropdownButtonWidth = 143f;
-            GUILayoutOption[] dropdownLayoutOptions = new GUILayoutOption[] {
-                GUILayout.Height(dropdownButtonHeight),
-                GUILayout.Width(dropdownButtonWidth)
-            };
-
-            GUILayout.BeginHorizontal();
-            this.prevBGButton.Draw(arrowLayoutOptions);
-            this.bgDropdown.Draw(dropdownLayoutOptions);
-            this.nextBGButton.Draw(arrowLayoutOptions);
-            GUILayout.EndHorizontal();
+            this.backgroundSelectorPane.Draw();
+            this.propsPane.Draw();
         }
     }
 }