Beispiel #1
0
        void OnSubClick(GUIButton _btn, MouseButton mbtn)
        {
            if (mbtn != MouseButton.Left)
            {
                return;
            }

            GUIDropDownButton btn = (GUIDropDownButton)_btn;

            if (applyTextOnClick && btn.Sub == null)
            {
                Label.Text   = btn.Label.Text;
                CurrentValue = btn.Value;
            }

            if (btn.Callback != null)
            {
                btn.Callback(this, btn);
            }

            if (btn.Sub == null)
            {
                Open = false;
            }
        }
Beispiel #2
0
        //<!-- sc -->

        public GUIDropDownButton AddItemSub(string text, GUIDropDown opensSub, GUIDropDownButtonClick callback = null)
        {
            GUIDropDownButton btn = AddButton(text, null, opensSub, callback);

            opensSub.Visible  = false;
            opensSub.Parent   = this;
            opensSub.Position = new UDim2(1, 0, Size.Y.Scale * ItemCount, Size.Y.Offset * ItemCount);
            return(btn);
        }
Beispiel #3
0
        //<-- sc -->
        public GUIDropDownButton AddItemSub(GUIDropDownButtonConfig button)
        {
            GUIDropDownButton btn = AddButton(button.text, button.value, button.opensSub, button.callback);

            button.opensSub.Visible  = false;
            button.opensSub.Parent   = this;
            button.opensSub.Position = new UDim2(1, 0, Size.Y.Scale * ItemCount, Size.Y.Offset * ItemCount);
            return(btn);
        }
Beispiel #4
0
        GUIDropDownButton AddButton(string text, object value, GUIDropDown sub, GUIDropDownButtonClick callback)
        {
            GUIDropDownButton btn = new GUIDropDownButton(new UDim2(0, 0, ItemCount + (HideMainButton ? 0 : 1), 0), new UDim2(1, 0, 1, 0),
                                                          Theme, text, OnSubClick, this, value, sub, callback, ItemCount);

            Items.Add(btn);

            if (ItemCount == 1 && applyTextOnClick)
            {
                Label.Text   = text;
                CurrentValue = value;
            }

            return(btn);
        }
Beispiel #5
0
        public ToolBarHelper(GUIFrame toolbar)
        {
            this.ToolBar = toolbar;

            TopMost  = new Dictionary <string, GUIDropDown>();
            LevelOne = new Dictionary <string, Dictionary <string, GUIDropDownButton> >();
            SubMenu  = new Dictionary <string, Dictionary <string, GUIDropDownButton> >();

            foreach (GUIDropDown ddb in ToolBar.Children)
            {
                TopMost.Add(ddb.Label.Text, ddb);
            }

            foreach (KeyValuePair <string, GUIDropDown> btnLevelOne in TopMost)
            {
                GUIDropDown main = btnLevelOne.Value;
                Dictionary <string, GUIDropDownButton> tmpChildren = new Dictionary <string, GUIDropDownButton>();
                foreach (GUIElement child in main.Children)
                {
                    if (child.GetType() == typeof(GUIDropDownButton))  //we check for GUILabel
                    //We can now safely cast as GUIDropDownButton
                    {
                        GUIDropDownButton Safechild = child as GUIDropDownButton;

                        if (Safechild.Sub == null)                            //check if it's a dropdown menu
                        {
                            tmpChildren.Add(Safechild.Label.Text, Safechild); //if not then just add to LevelTop
                        }
                        else if (Safechild.Sub != null)                       //if it's a dropdown then loop once more
                        {
                            Dictionary <string, GUIDropDownButton> tmpSubMenu = new Dictionary <string, GUIDropDownButton>();
                            foreach (GUIElement childSub in Safechild.Sub.Items)
                            {
                                if (childSub.GetType() == typeof(GUIDropDownButton))
                                {
                                    GUIDropDownButton childButton = childSub as GUIDropDownButton;
                                    tmpSubMenu.Add(childButton.Label.Text, childButton);
                                }
                            }
                            SubMenu.Add(Safechild.Label.Text.Replace(">", "").Trim(), tmpSubMenu); //ffs the space was causing errors
                        }
                    }
                }
                LevelOne.Add(main.Label.Text, tmpChildren);
            }
        }