Ejemplo n.º 1
0
        /// <summary>
        /// Adds a submenu to a parent menu and to the MenuPool.
        /// </summary>
        /// <param name="SubMenu">The submenu</param>
        /// <param name="ParentMenu">The parent menu.</param>
        /// <param name="text">The text of the menu item in the parent menu that leads to the submenu when entered.</param>
        /// <param name="description">The description of the menu item that leads to the submenu when entered.</param>
        public void AddSubMenu(UIMenu SubMenu, UIMenu ParentMenu, string text, string description, bool UseSameColorsAsParent = true)
        {
            AddMenu(SubMenu);
            //SubMenu.ParentMenu = ParentMenu;
            //ParentMenu.NextMenu = SubMenu;
            var item = new UIMenuItem(text, null, description);

            //ParentMenu.BindingMenuItem = BindingItem;
            ParentMenu.AddMenuItem(item);
            //ParentMenu.BindingMenuItem = item;
            ParentMenu.BindItemToSubmenu(SubMenu, item);

            if (UseSameColorsAsParent)
            {
                SubMenu.TitleColor           = ParentMenu.TitleColor;
                SubMenu.TitleUnderlineColor  = ParentMenu.TitleUnderlineColor;
                SubMenu.TitleBackgroundColor = ParentMenu.TitleBackgroundColor;

                SubMenu.DefaultTextColor         = ParentMenu.DefaultTextColor;
                SubMenu.DefaultBoxColor          = ParentMenu.DefaultBoxColor;
                SubMenu.HighlightedItemTextColor = ParentMenu.HighlightedItemTextColor;
                SubMenu.HighlightedBoxColor      = ParentMenu.HighlightedBoxColor;

                SubMenu.DescriptionTextColor = ParentMenu.DescriptionTextColor;
                SubMenu.DescriptionBoxColor  = ParentMenu.DescriptionBoxColor;
            }
        }
Ejemplo n.º 2
0
        protected void DisplayMenu()
        {
            DrawCustomText(Title, TitleFont, 1, TitleColor.R, TitleColor.G, TitleColor.B, TitleColor.A, xPosBG, yPosTitleText, TextJustification.Center);                   //Draw title text
            DrawRectangle(xPosBG, yPosTitleBG, MenuBGWidth, TitleBGHeight, TitleBackgroundColor.R, TitleBackgroundColor.G, TitleBackgroundColor.B, TitleBackgroundColor.A); //Draw main rectangle
            DrawRectangle(xPosBG, yPosUnderline, MenuBGWidth, UnderlineHeight, TitleUnderlineColor.R, TitleUnderlineColor.G, TitleUnderlineColor.B, TitleUnderlineColor.A); //Draw rectangle as underline of title

            foreach (UIMenuItem item in _itemList)
            {
                bool ScrollOrNotDecision = (UseScroll && _itemList.IndexOf(item) >= minItem && _itemList.IndexOf(item) <= maxItem) || !UseScroll;
                if (ScrollOrNotDecision)
                {
                    YPosBasedOnScroll = UseScroll && _itemList.Count > MaxItemsOnScreen?CalculatePosition(_itemList.IndexOf(item), minItem, maxItem, 0, MaxItemsOnScreen - 1) : _itemList.IndexOf(item);

                    YPosDescBasedOnScroll = UseScroll && _itemList.Count > MaxItemsOnScreen ? MaxItemsOnScreen : _itemList.Count;

                    if (_itemList.IndexOf(item) == SelectedIndex)
                    {
                        DrawCustomText(item.Text, ItemTextFontSize, ItemTextFontType, HighlightedItemTextColor.R, HighlightedItemTextColor.G, HighlightedItemTextColor.B, HighlightedItemTextColor.A, xPosItemText, yPosItemBG - yTextOffset + YPosBasedOnScroll * posMultiplier); //Draw highlighted item text

                        if (item.Value != null)
                        {
                            DrawCustomText(Convert.ToString(item.Value), ItemTextFontSize, ItemTextFontType, HighlightedItemTextColor.R, HighlightedItemTextColor.G, HighlightedItemTextColor.B, HighlightedItemTextColor.A, xPosItemValue, yPosItemBG - yTextOffset + YPosBasedOnScroll * posMultiplier, TextJustification.Right);
                        }                                                                                                                                                                                             //Draw highlighted item value

                        DrawRectangle(xPosBG, yPosItemBG + YPosBasedOnScroll * posMultiplier, MenuBGWidth, heightItemBG, HighlightedBoxColor.R, HighlightedBoxColor.G, HighlightedBoxColor.B, HighlightedBoxColor.A); //Draw rectangle over highlighted text

                        if (item.Description != null)
                        {
                            foreach (string desc in item.DescriptionTexts)
                            {
                                DrawCustomText(desc, ItemTextFontSize, ItemTextFontType, DescriptionTextColor.R, DescriptionTextColor.G, DescriptionTextColor.B, DescriptionTextColor.A, xPosItemText, yPosItemBG - yTextOffset + (item.DescriptionTexts.IndexOf(desc) + YPosDescBasedOnScroll) * posMultiplier, TextJustification.Left, false); // Draw description text at bottom of menu
                                DrawRectangle(xPosBG, yPosItemBG + (item.DescriptionTexts.IndexOf(desc) + YPosDescBasedOnScroll) * posMultiplier, MenuBGWidth, heightItemBG, DescriptionBoxColor.R, DescriptionBoxColor.G, DescriptionBoxColor.B, DescriptionBoxColor.A);                                                                        //Draw rectangle over description text at bottom of the list.
                            }
                        }

                        SelectedItem = item;
                    }
                    else
                    {
                        DrawCustomText(item.Text, ItemTextFontSize, ItemTextFontType, DefaultTextColor.R, DefaultTextColor.G, DefaultTextColor.B, DefaultTextColor.A, xPosItemText, yPosItemBG - yTextOffset + YPosBasedOnScroll * posMultiplier); //Draw item text

                        if (item.Value != null)
                        {
                            DrawCustomText(Convert.ToString(item.Value), ItemTextFontSize, ItemTextFontType, DefaultTextColor.R, DefaultTextColor.G, DefaultTextColor.B, DefaultTextColor.A, xPosItemValue, yPosItemBG - yTextOffset + YPosBasedOnScroll * posMultiplier, TextJustification.Right);
                        }                                                                                                                                                                             //Draw item value

                        DrawRectangle(xPosBG, yPosItemBG + YPosBasedOnScroll * posMultiplier, MenuBGWidth, heightItemBG, DefaultBoxColor.R, DefaultBoxColor.G, DefaultBoxColor.B, DefaultBoxColor.A); //Draw background rectangles around all items.
                    }
                }
            }

            //DevMenuPositioner();
        }
Ejemplo n.º 3
0
        public void BindItemToSubmenu(UIMenu submenu, UIMenuItem itemToBindTo)
        {
            submenu.ParentMenu = this;
            submenu.ParentItem = itemToBindTo;

            /*if (Binded.ContainsKey(itemToBindTo))
             *  Binded[itemToBindTo] = submenu;
             * else
             *  Binded.Add(itemToBindTo, submenu);*/
            _bindedList.Add(new BindedItem {
                BindedSubmenu = submenu, BindedItemToSubmenu = itemToBindTo
            });
        }
Ejemplo n.º 4
0
        public bool ControlBoolValue(UIMenuItem item, bool boolToControl)
        {
            item.Value = boolToControl;

            if (SelectedItem == item)
            {
                if (JustPressedAccept())
                {
                    boolToControl = !boolToControl;
                    item.Value    = boolToControl;
                    InputTimer    = DateTime.Now.AddMilliseconds(InputWait);
                    return(boolToControl);
                }
            }
            return(boolToControl);
        }
Ejemplo n.º 5
0
        public int ControlIntValue(UIMenuItem item, int numberToControl, int incrementValue, int incrementValueFast)
        {
            item.Value = "< " + numberToControl + " >";

            if (SelectedItem == item)
            {
                if (JustPressedLeft())
                {
                    if (IsHoldingSpeedupControl())
                    {
                        numberToControl -= incrementValueFast;
                    }
                    else
                    {
                        numberToControl -= incrementValue;
                    }

                    item.Value = "< " + numberToControl + " >";

                    InputTimer = DateTime.Now.AddMilliseconds(InputWait);

                    return(numberToControl);
                }
                if (JustPressedRight())
                {
                    if (IsHoldingSpeedupControl())
                    {
                        numberToControl += incrementValueFast;
                    }
                    else
                    {
                        numberToControl += incrementValue;
                    }

                    item.Value = "< " + numberToControl + " >";

                    InputTimer = DateTime.Now.AddMilliseconds(InputWait);

                    return(numberToControl);
                }
            }
            return(numberToControl);
        }
Ejemplo n.º 6
0
        public float ControlFloatValue(UIMenuItem item, float numberToControl, float incrementValue, float incrementValueFast, int decimals = 2)
        {
            item.Value = "< " + numberToControl + " >";

            if (SelectedItem == item)
            {
                if (JustPressedLeft())
                {
                    if (IsHoldingSpeedupControl())
                    {
                        numberToControl -= incrementValueFast;
                    }
                    else
                    {
                        numberToControl -= incrementValue;
                    }

                    item.Value = "< " + numberToControl + " >";

                    InputTimer = DateTime.Now.AddMilliseconds(InputWait);

                    return((float)Math.Round(numberToControl, decimals));
                }
                if (JustPressedRight())
                {
                    if (IsHoldingSpeedupControl())
                    {
                        numberToControl += incrementValueFast;
                    }
                    else
                    {
                        numberToControl += incrementValue;
                    }

                    item.Value = "< " + numberToControl + " >";

                    InputTimer = DateTime.Now.AddMilliseconds(InputWait);

                    return((float)Math.Round(numberToControl, decimals));
                }
            }
            return(numberToControl);
        }
Ejemplo n.º 7
0
 public void AddMenuItem(UIMenuItem item)
 {
     _itemList.Add(item);
 }