예제 #1
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);
        }
예제 #2
0
        public void Close()
        {
            GUIDropDown root = this;

            while (root.Parent != null && root.Parent is GUIDropDown)
            {
                root.Open = false;
                root      = (GUIDropDown)root.Parent;
            }

            root.Open = false;
        }
예제 #3
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);
        }
예제 #4
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);
            }
        }
예제 #5
0
        public GUIDropDownButton(UDim2 position, UDim2 size, GUITheme theme,
                                 string text, GUIButtonClick onClick, GUIDropDown dropdown, object value,
                                 GUIDropDown sub, GUIDropDownButtonClick callback, int index)
            : base(position, size, text + (sub != null ? " >" : ""), theme)
        {
            Sub           = sub;
            this.dropdown = dropdown;
            Parent        = dropdown;
            Value         = value;
            Callback      = callback;
            Index         = index;

            if (sub != null)
            {
                ActiveImage = HoverImage;
            }

            Visible       = false;
            Label.Visible = false;
        }