Ejemplo n.º 1
0
        public OptionsDropDown AddDropdown <T>(string label, string tooltip, Func <T> get, Action <T> set, params KeyValuePair <string, T>[] dropdown_options)
        {
            OptionsDropDown option_element = new OptionsDropDown(label, -999);

            tooltips[option_element] = tooltip;
            KeyValuePair <string, T>[] array = dropdown_options;
            for (int j = 0; j < array.Length; j++)
            {
                KeyValuePair <string, T> option = array[j];
                option_element.dropDownDisplayOptions.Add(option.Key);
                option_element.dropDownOptions.Add(option.Value.ToString());
            }
            option_element.RecalculateBounds();
            T   selected_value  = get();
            int selected_option = 0;

            for (int i = 0; i < dropdown_options.Length; i++)
            {
                KeyValuePair <string, T> dropdown_option = dropdown_options[i];
                if ((dropdown_option.Value == null && selected_value == null) || (dropdown_option.Value != null && selected_value != null && dropdown_option.Value.Equals(selected_value)))
                {
                    selected_option = i;
                    break;
                }
            }
            option_element.selectedOption = selected_option;
            applySettingCallbacks.Add(delegate
            {
                set(dropdown_options[option_element.selectedOption].Value);
            });
            options.Add(option_element);
            return(option_element);
        }
Ejemplo n.º 2
0
 public override void receiveLeftClick(int x, int y)
 {
     if (!this.greyedOut)
     {
         base.receiveLeftClick(x, y);
         this.startingSelected = this.selectedOption;
         this.leftClickHeld(x, y);
         Game1.playSound("shwip");
         OptionsDropDown.selected = this;
     }
 }
Ejemplo n.º 3
0
 public override void receiveKeyPress(Keys key)
 {
     base.receiveKeyPress(key);
     if (!Game1.options.SnappyMenus || greyedOut)
     {
         return;
     }
     if (!clicked)
     {
         if (Game1.options.doesInputListContain(Game1.options.moveRightButton, key))
         {
             selectedOption++;
             if (selectedOption >= dropDownOptions.Count)
             {
                 selectedOption = 0;
             }
             selected = this;
             Game1.options.changeDropDownOption(whichOption, dropDownOptions[selectedOption]);
             selected = null;
         }
         else if (Game1.options.doesInputListContain(Game1.options.moveLeftButton, key))
         {
             selectedOption--;
             if (selectedOption < 0)
             {
                 selectedOption = dropDownOptions.Count - 1;
             }
             selected = this;
             Game1.options.changeDropDownOption(whichOption, dropDownOptions[selectedOption]);
             selected = null;
         }
     }
     else if (Game1.options.doesInputListContain(Game1.options.moveDownButton, key))
     {
         Game1.playSound("shiny4");
         selectedOption++;
         if (selectedOption >= dropDownOptions.Count)
         {
             selectedOption = 0;
         }
     }
     else if (Game1.options.doesInputListContain(Game1.options.moveUpButton, key))
     {
         Game1.playSound("shiny4");
         selectedOption--;
         if (selectedOption < 0)
         {
             selectedOption = dropDownOptions.Count - 1;
         }
     }
 }
Ejemplo n.º 4
0
 public override void receiveLeftClick(int x, int y)
 {
     if (!greyedOut)
     {
         base.receiveLeftClick(x, y);
         startingSelected = selectedOption;
         if (!clicked)
         {
             Game1.playSound("shwip");
         }
         leftClickHeld(x, y);
         selected = this;
     }
 }
Ejemplo n.º 5
0
 public override void leftClickReleased(int x, int y)
 {
     if (!this.greyedOut && this.dropDownOptions.Count > 0)
     {
         base.leftClickReleased(x, y);
         this.clicked = false;
         if (this.dropDownBounds.Contains(x, y))
         {
             Game1.options.changeDropDownOption(this.whichOption, this.selectedOption, this.dropDownOptions);
         }
         else
         {
             this.selectedOption = this.startingSelected;
         }
         OptionsDropDown.selected = null;
     }
 }
Ejemplo n.º 6
0
 public override void leftClickReleased(int x, int y)
 {
     if (!greyedOut && dropDownOptions.Count > 0)
     {
         base.leftClickReleased(x, y);
         if (clicked)
         {
             Game1.playSound("drumkit6");
         }
         clicked = false;
         if (dropDownBounds.Contains(x, y) || (Game1.options.gamepadControls && !Game1.lastCursorMotionWasMouse))
         {
             Game1.options.changeDropDownOption(whichOption, selectedOption, dropDownOptions);
         }
         else
         {
             selectedOption = startingSelected;
         }
         selected = null;
     }
 }