Explorar o código

Add option for static dropdown button

Dropdown button can just show the given label rather than the currently
selected item.
habeebweeb %!s(int64=4) %!d(string=hai) anos
pai
achega
09e5118537

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

@@ -11,6 +11,8 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
         public event EventHandler DropdownClose;
         private bool clickedYou = false;
         private bool showDropdown = false;
+        private string label;
+        private bool isMenu = false;
         public string[] DropdownList { get; private set; }
         public int DropdownID { get; private set; }
         private Vector2 scrollPos;
@@ -41,6 +43,14 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
                 OnDropdownEvent(SelectionChange);
             }
         }
+        public string SelectedItem => DropdownList[SelectedItemIndex];
+
+        public Dropdown(string label, string[] itemList, int selectedItemIndex = 0)
+            : this(itemList, selectedItemIndex)
+        {
+            isMenu = true;
+            this.label = label;
+        }
 
         public Dropdown(string[] itemList, int selectedItemIndex = 0)
         {
@@ -95,7 +105,9 @@ namespace COM3D2.MeidoPhotoStudio.Plugin
 
         public void Draw(GUIStyle buttonStyle, params GUILayoutOption[] layoutOptions)
         {
-            bool clicked = GUILayout.Button(DropdownList[selectedItemIndex], buttonStyle, layoutOptions);
+            bool clicked = GUILayout.Button(
+                isMenu ? label : DropdownList[selectedItemIndex], buttonStyle, layoutOptions
+            );
 
             if (clicked)
             {