/// <summary>
        /// Creates a dropdown menu without text label or enclosing panel.
        /// </summary>
        /// <param name="parent">Parent component</param>
        /// <param name="xPos">Relative x position (default 20)</param>
        /// <param name="yPos">Relative y position (default 0)</param>
        /// <param name="width">Dropdown menu width, excluding label (default 220f)</param>
        /// <param name="height">Dropdown button height (default 25f)</param>
        /// <param name="itemTextScale">Text scaling (default 0.7f)</param>
        /// <param name="itemHeight">Dropdown menu item height (default 20)</param>
        /// <param name="itemVertPadding">Dropdown menu item vertical text padding (default 8)</param>
        /// <param name="tooltip">Tooltip, if any</param>
        /// <returns>New dropdown menu *without* an attached text label or enclosing panel</returns>
        public static UIDropDown AddDropDown(UIComponent parent, float xPos, float yPos, float width = 220f, float height = 25f, float itemTextScale = 0.7f, int itemHeight = 20, int itemVertPadding = 8, string tooltip = null)
        {
            // Create dropdown menu.
            UIDropDown dropDown = parent.AddUIComponent <UIDropDown>();

            dropDown.listBackground       = "GenericPanelLight";
            dropDown.itemHover            = "ListItemHover";
            dropDown.itemHighlight        = "ListItemHighlight";
            dropDown.normalBgSprite       = "ButtonMenu";
            dropDown.disabledBgSprite     = "ButtonMenuDisabled";
            dropDown.hoveredBgSprite      = "ButtonMenuHovered";
            dropDown.focusedBgSprite      = "ButtonMenu";
            dropDown.foregroundSpriteMode = UIForegroundSpriteMode.Stretch;
            dropDown.popupColor           = new Color32(45, 52, 61, 255);
            dropDown.popupTextColor       = new Color32(170, 170, 170, 255);
            dropDown.zOrder              = 1;
            dropDown.verticalAlignment   = UIVerticalAlignment.Middle;
            dropDown.horizontalAlignment = UIHorizontalAlignment.Left;
            dropDown.textFieldPadding    = new RectOffset(8, 0, itemVertPadding, 0);
            dropDown.itemPadding         = new RectOffset(14, 0, itemVertPadding, 0);

            dropDown.relativePosition = new Vector3(xPos, yPos);

            // Dropdown size parameters.
            dropDown.size       = new Vector2(width, height);
            dropDown.listWidth  = (int)width;
            dropDown.listHeight = 500;
            dropDown.itemHeight = itemHeight;
            dropDown.textScale  = itemTextScale;

            // Create dropdown button.
            UIButton button = dropDown.AddUIComponent <UIButton>();

            dropDown.triggerButton         = button;
            button.size                    = dropDown.size;
            button.text                    = "";
            button.relativePosition        = new Vector2(0f, 0f);
            button.textVerticalAlignment   = UIVerticalAlignment.Middle;
            button.textHorizontalAlignment = UIHorizontalAlignment.Left;
            button.normalFgSprite          = "IconDownArrow";
            button.hoveredFgSprite         = "IconDownArrowHovered";
            button.pressedFgSprite         = "IconDownArrowPressed";
            button.focusedFgSprite         = "IconDownArrowFocused";
            button.disabledFgSprite        = "IconDownArrowDisabled";
            button.spritePadding           = new RectOffset(3, 3, 3, 3);
            button.foregroundSpriteMode    = UIForegroundSpriteMode.Fill;
            button.horizontalAlignment     = UIHorizontalAlignment.Right;
            button.verticalAlignment       = UIVerticalAlignment.Middle;
            button.zOrder                  = 0;

            // Add tooltip.
            if (tooltip != null)
            {
                dropDown.tooltip = tooltip;
            }

            return(dropDown);
        }
Esempio n. 2
0
        public static UIDropDown CreateDropDown(UIComponent parent)
        {
            UIDropDown dropDown = parent.AddUIComponent <UIDropDown>();

            dropDown.atlas                = GetAtlas("Ingame");
            dropDown.size                 = new Vector2(90f, 30f);
            dropDown.listBackground       = "GenericPanelLight";
            dropDown.itemHeight           = 30;
            dropDown.itemHover            = "ListItemHover";
            dropDown.itemHighlight        = "ListItemHighlight";
            dropDown.normalBgSprite       = "ButtonMenu";
            dropDown.disabledBgSprite     = "ButtonMenuDisabled";
            dropDown.hoveredBgSprite      = "ButtonMenuHovered";
            dropDown.focusedBgSprite      = "ButtonMenu";
            dropDown.listWidth            = 90;
            dropDown.listHeight           = 500;
            dropDown.foregroundSpriteMode = UIForegroundSpriteMode.Stretch;
            dropDown.popupColor           = new Color32(45, 52, 61, 255);
            dropDown.popupTextColor       = new Color32(170, 170, 170, 255);
            dropDown.zOrder               = 1;
            dropDown.textScale            = 0.9f;
            dropDown.verticalAlignment    = UIVerticalAlignment.Middle;
            dropDown.horizontalAlignment  = UIHorizontalAlignment.Center;
            dropDown.selectedIndex        = 0;
            dropDown.textFieldPadding     = new RectOffset(8, 0, 8, 0);
            dropDown.itemPadding          = new RectOffset(14, 0, 8, 0);

            UIButton button = dropDown.AddUIComponent <UIButton>();

            dropDown.triggerButton         = button;
            button.atlas                   = GetAtlas("Ingame");
            button.text                    = "";
            button.size                    = dropDown.size;
            button.relativePosition        = new Vector3(0f, 0f);
            button.textVerticalAlignment   = UIVerticalAlignment.Middle;
            button.textHorizontalAlignment = UIHorizontalAlignment.Center;
            button.normalFgSprite          = "IconDownArrow";
            button.hoveredFgSprite         = "IconDownArrowHovered";
            button.pressedFgSprite         = "IconDownArrowPressed";
            button.focusedFgSprite         = "IconDownArrowFocused";
            button.disabledFgSprite        = "IconDownArrowDisabled";
            button.foregroundSpriteMode    = UIForegroundSpriteMode.Fill;
            button.horizontalAlignment     = UIHorizontalAlignment.Right;
            button.verticalAlignment       = UIVerticalAlignment.Middle;
            button.zOrder                  = 0;
            button.textScale               = 0.9f;
            button.textHorizontalAlignment = UIHorizontalAlignment.Center;

            dropDown.eventSizeChanged += new PropertyChangedEventHandler <Vector2>((c, t) =>
            {
                button.size = t; dropDown.listWidth = (int)t.x;
            });

            return(dropDown);
        }
Esempio n. 3
0
        public static UIDropDown CreateDropDown(UIComponent parent)
        {
            UIDropDown dropDown = parent.AddUIComponent <UIDropDown>();

            dropDown.atlas                = GetAtlas("Ingame");
            dropDown.size                 = new Vector2(90f, 30f);
            dropDown.listBackground       = "GenericPanelLight";
            dropDown.itemHeight           = 30;
            dropDown.itemHover            = "ListItemHover";
            dropDown.itemHighlight        = "ListItemHighlight";
            dropDown.normalBgSprite       = "TextFieldPanel";
            dropDown.focusedBgSprite      = "TextFieldPanelHovered";
            dropDown.hoveredBgSprite      = "TextFieldPanelHovered";
            dropDown.listPosition         = UIDropDown.PopupListPosition.Above;
            dropDown.listWidth            = 90;
            dropDown.listHeight           = 500;
            dropDown.foregroundSpriteMode = UIForegroundSpriteMode.Stretch;
            dropDown.popupColor           = new Color32(45, 52, 61, 255);
            dropDown.popupTextColor       = new Color32(170, 170, 170, 255);
            dropDown.zOrder               = 1;
            dropDown.textColor            = new Color32(0, 0, 0, 255);
            dropDown.textScale            = 0.8f;
            dropDown.verticalAlignment    = UIVerticalAlignment.Middle;
            dropDown.horizontalAlignment  = UIHorizontalAlignment.Left;
            dropDown.selectedIndex        = 0;
            dropDown.textFieldPadding     = new RectOffset(8, 0, 8, 0);
            dropDown.itemPadding          = new RectOffset(14, 0, 8, 0);
            dropDown.builtinKeyNavigation = true;

            UIButton button = dropDown.AddUIComponent <UIButton>();

            dropDown.triggerButton         = button;
            button.atlas                   = GetAtlas("Ingame");
            button.text                    = "";
            button.size                    = dropDown.size;
            button.relativePosition        = new Vector3(0f, 0f);
            button.textVerticalAlignment   = UIVerticalAlignment.Middle;
            button.textHorizontalAlignment = UIHorizontalAlignment.Left;
            button.normalFgSprite          = "OptionsScrollbarThumb";
            button.spritePadding           = new RectOffset(0, 3, 3, 0);
            button.foregroundSpriteMode    = UIForegroundSpriteMode.Fill;
            button.horizontalAlignment     = UIHorizontalAlignment.Right;
            button.verticalAlignment       = UIVerticalAlignment.Middle;
            button.zOrder                  = 0;
            button.textScale               = 0.8f;

            dropDown.eventSizeChanged += new PropertyChangedEventHandler <Vector2>((c, t) =>
            {
                button.size = t; dropDown.listWidth = (int)t.x;
            });

            return(dropDown);
        }
Esempio n. 4
0
        public static UIDropDown CreateDropDown(UIComponent parent, string name)
        {
            UIDropDown dropDown = parent.AddUIComponent <UIDropDown>();

            dropDown.name = name;

            dropDown.height               = 32f;
            dropDown.width                = parent.width - 10f;
            dropDown.relativePosition     = new Vector3(0f, 0f);
            dropDown.listBackground       = "OptionsDropboxListbox";
            dropDown.listHeight           = 200;
            dropDown.itemHeight           = 24;
            dropDown.itemHover            = "ListItemHover";
            dropDown.itemHighlight        = "ListItemHighlight";
            dropDown.normalBgSprite       = "OptionsDropbox";
            dropDown.hoveredBgSprite      = "OptionsDropboxHovered";
            dropDown.focusedBgSprite      = "OptionsDropboxFocused";
            dropDown.disabledBgSprite     = "OptionsDropboxDisabled";
            dropDown.foregroundSpriteMode = UIForegroundSpriteMode.Stretch;
            dropDown.horizontalAlignment  = UIHorizontalAlignment.Left;
            dropDown.verticalAlignment    = UIVerticalAlignment.Middle;
            dropDown.textFieldPadding     = new RectOffset(14, 0, 8, 0);
            dropDown.itemPadding          = new RectOffset(14, 0, 4, 0);
            dropDown.popupColor           = new Color32(170, 170, 170, 255);

            UIButton button = dropDown.AddUIComponent <UIButton>();

            button.height                  = dropDown.height;
            button.width                   = dropDown.width;
            button.relativePosition        = new Vector3(0f, 0f);
            button.textHorizontalAlignment = UIHorizontalAlignment.Center;
            button.textVerticalAlignment   = UIVerticalAlignment.Middle;
            button.horizontalAlignment     = UIHorizontalAlignment.Right;
            button.verticalAlignment       = UIVerticalAlignment.Middle;

            dropDown.triggerButton = button;

            dropDown.eventSizeChanged += (component, value) =>
            {
                dropDown.listWidth = (int)value.x;
                button.size        = value;
            };

            return(dropDown);
        }
Esempio n. 5
0
        public static void CreateDropDownScrollBar(UIDropDown dropDown)
        {
            // Scrollbar
            dropDown.listScrollbar                 = dropDown.AddUIComponent <UIScrollbar>();
            dropDown.listScrollbar.width           = 20f;
            dropDown.listScrollbar.height          = dropDown.listHeight;
            dropDown.listScrollbar.orientation     = UIOrientation.Vertical;
            dropDown.listScrollbar.pivot           = UIPivotPoint.TopRight;
            dropDown.listScrollbar.thumbPadding    = new RectOffset(0, 0, 5, 5);
            dropDown.listScrollbar.minValue        = 0;
            dropDown.listScrollbar.value           = 0;
            dropDown.listScrollbar.incrementAmount = 50;
            dropDown.listScrollbar.AlignTo(dropDown, UIAlignAnchor.TopRight);
            dropDown.listScrollbar.autoHide  = true;
            dropDown.listScrollbar.isVisible = false;
            // the game automatically creates 2 scrollbar clones: one for the drowdown itself and one for the dropdown popup list box
            // we only need the one inside the dropdown popup which will automatically be placed inside the popup
            // move the other one off screen to hide it(we can't set it to invisible or both would become invisible)
            Vector3 newPosition = FindIt.FindIt.instance.mainButton.relativePosition;

            newPosition.x += 50000;
            newPosition.y += 50000;
            dropDown.listScrollbar.relativePosition = newPosition;

            UISlicedSprite tracSprite = dropDown.listScrollbar.AddUIComponent <UISlicedSprite>();

            tracSprite.relativePosition        = Vector2.zero;
            tracSprite.autoSize                = true;
            tracSprite.size                    = tracSprite.parent.size;
            tracSprite.fillDirection           = UIFillDirection.Vertical;
            tracSprite.spriteName              = "ScrollbarTrack";
            dropDown.listScrollbar.trackObject = tracSprite;

            UISlicedSprite thumbSprite = tracSprite.AddUIComponent <UISlicedSprite>();

            thumbSprite.relativePosition       = Vector2.zero;
            thumbSprite.fillDirection          = UIFillDirection.Vertical;
            thumbSprite.autoSize               = true;
            thumbSprite.width                  = thumbSprite.parent.width - 8;
            thumbSprite.spriteName             = "ScrollbarThumb";
            dropDown.listScrollbar.thumbObject = thumbSprite;

            dropDown.listScrollbar.transform.localScale = dropDown.transform.localScale;
        }
Esempio n. 6
0
        public static void DropDown(UIDropDown dropdown)
        {
            dropdown.size                 = new Vector2(180.0f, 32.0f);
            dropdown.relativePosition     = new Vector3(10.0f, 78.0f);
            dropdown.listBackground       = "GenericPanelLight";
            dropdown.itemHeight           = 32;
            dropdown.itemHover            = "ListItemHover";
            dropdown.itemHighlight        = "ListItemHighlight";
            dropdown.normalBgSprite       = "ButtonMenu";
            dropdown.listWidth            = 200;
            dropdown.listHeight           = 500;
            dropdown.foregroundSpriteMode = UIForegroundSpriteMode.Stretch;
            dropdown.popupColor           = new Color32(45, 52, 61, 255);
            dropdown.popupTextColor       = new Color32(170, 170, 170, 255);
            dropdown.zOrder               = 1;
            dropdown.textScale            = 0.8f;
            dropdown.verticalAlignment    = UIVerticalAlignment.Middle;
            dropdown.horizontalAlignment  = UIHorizontalAlignment.Left;
            dropdown.selectedIndex        = 0;
            dropdown.textFieldPadding     = new RectOffset(8, 0, 8, 0);
            dropdown.itemPadding          = new RectOffset(14, 0, 0, 0);

            var dropdownButton = dropdown.AddUIComponent <UIButton>();

            dropdown.triggerButton = dropdownButton;

            dropdownButton.text                    = "";
            dropdownButton.size                    = dropdown.size;
            dropdownButton.relativePosition        = new Vector3(0.0f, 0.0f);
            dropdownButton.textVerticalAlignment   = UIVerticalAlignment.Middle;
            dropdownButton.textHorizontalAlignment = UIHorizontalAlignment.Left;
            dropdownButton.normalFgSprite          = "IconDownArrow";
            dropdownButton.hoveredFgSprite         = "IconDownArrowHovered";
            dropdownButton.pressedFgSprite         = "IconDownArrowPressed";
            dropdownButton.focusedFgSprite         = "IconDownArrowFocused";
            dropdownButton.disabledFgSprite        = "IconDownArrowDisabled";
            dropdownButton.foregroundSpriteMode    = UIForegroundSpriteMode.Fill;
            dropdownButton.horizontalAlignment     = UIHorizontalAlignment.Right;
            dropdownButton.verticalAlignment       = UIVerticalAlignment.Middle;
            dropdownButton.zOrder                  = 0;
            dropdownButton.textScale               = 0.8f;
        }
Esempio n. 7
0
        /// <summary>
        /// Creates a dropdown menu with an attached text label.
        /// </summary>
        /// <param name="parent">Parent component</param>
        /// <param name="xPos">Relative x position</param>
        /// <param name="yPos">Relative y position</param>
        /// <param name="text">Text label</param>
        /// <param name="width">Dropdown menu width, excluding label (default 220f)</param>
        /// <returns>New dropdown menu with an attached text label and enclosing panel</returns>
        public static UIDropDown AddLabelledDropDown(UIComponent parent, float xPos, float yPos, string text, float width = 220f)
        {
            // Create dropdown.
            UIDropDown dropDown = AddDropDown(parent, xPos, yPos, width);

            // Add label.
            UILabel label = dropDown.AddUIComponent<UILabel>();
            label.textScale = 0.8f;
            label.text = text;

            // Get width and position.
            float labelWidth = label.width + 10f;

            label.relativePosition = new Vector3(-labelWidth, 6f);

            // Move dropdown to accomodate label.
            dropDown.relativePosition += new Vector3(labelWidth, 0f);

            return dropDown;
        }
        protected void AwakePrefixFilter()
        {
            m_prefixFilter = UIHelperExtension.CloneBasicDropDownNoLabel(new string[] {
                "All"
            }, (x) =>
            {
                isUpdated = false;
            }, titleLine);


            var prefixFilterLabel = m_prefixFilter.AddUIComponent <UILabel>();

            prefixFilterLabel.text             = Locale.Get("TLM_PREFIX_FILTER");
            prefixFilterLabel.relativePosition = new Vector3(0, -35);
            prefixFilterLabel.textAlignment    = UIHorizontalAlignment.Center;
            prefixFilterLabel.wordWrap         = true;
            prefixFilterLabel.autoSize         = false;
            prefixFilterLabel.width            = 100;
            prefixFilterLabel.height           = 36;
            m_prefixFilter.area = new Vector4(765, 0, 100, 35);

            ReloadPrefixFilter();
        }
Esempio n. 9
0
        /// <summary>
        /// Creates a dropdown menu with an attached text label.
        /// </summary>
        /// <param name="parent">Parent component</param>
        /// <param name="xPos">Relative x position</param>
        /// <param name="yPos">Relative y position</param>
        /// <param name="text">Text label</param>
        /// <param name="width">Dropdown menu width, excluding label (default 220f)</param>
        /// <param name="itemTextScale">Text scaling (default 0.7f)</param>
        /// <param name="height">Dropdown button height (default 25f)</param>
        /// <param name="itemHeight">Dropdown menu item height (default 20)</param>
        /// <param name="itemVertPadding">Dropdown menu item vertical text padding (default 8)</param>
        /// <param name="accomodateLabel">True (default) to move menu to accomodate text label width, false otherwise</param>
        /// <param name="tooltip">Tooltip, if any</param>
        /// <returns>New dropdown menu with an attached text label and enclosing panel</returns>
        public static UIDropDown AddLabelledDropDown(UIComponent parent, float xPos, float yPos, string text, float width = 220f, float height = 25f, float itemTextScale = 0.7f, int itemHeight = 20, int itemVertPadding = 8, bool accomodateLabel = true, string tooltip = null)
        {
            // Create dropdown.
            UIDropDown dropDown = AddDropDown(parent, xPos, yPos, width, height, itemTextScale, itemHeight, itemVertPadding, tooltip);

            // Add label.
            UILabel label = dropDown.AddUIComponent<UILabel>();
            label.textScale = 0.8f;
            label.text = text;

            // Get width and position.
            float labelWidth = label.width + 10f;

            label.relativePosition = new Vector2(-labelWidth, (height - label.height) / 2f);

            // Move dropdown to accomodate label if that setting is set.
            if (accomodateLabel)
            {
                dropDown.relativePosition += new Vector3(labelWidth, 0f);
            }

            return dropDown;
        }
        public static UIDropDown CreateStyledDropDown(UIComponent parent)
        {
            UIDropDown dropDown = parent.AddUIComponent <UIDropDown>();

            dropDown.size = new Vector2(105f, 24f);
            //dropDown.listBackground = "GenericPanelLight";
            dropDown.listWidth        = 105;
            dropDown.listHeight       = 500;
            dropDown.listBackground   = "LevelBarBackground";
            dropDown.disabledBgSprite = "LevelBarBackground";
            dropDown.focusedBgSprite  = "LevelBarBackground";
            //dropDown.hoveredBgSprite = "LevelBarBackground";
            dropDown.normalBgSprite       = "LevelBarBackground";
            dropDown.foregroundSpriteMode = UIForegroundSpriteMode.Stretch;

            dropDown.textColor           = new Color32(255, 255, 255, 255);
            dropDown.popupColor          = new Color32(255, 255, 255, 255);
            dropDown.popupTextColor      = new Color32(255, 255, 255, 255);
            dropDown.textScale           = 0.9f;
            dropDown.verticalAlignment   = UIVerticalAlignment.Middle;
            dropDown.horizontalAlignment = UIHorizontalAlignment.Left;
            dropDown.textFieldPadding    = new RectOffset(4, 0, 7, 0);
            dropDown.itemHeight          = 24;
            dropDown.itemPadding         = new RectOffset(4, 0, 7, 0);
            //dropDown.itemHover = "LevelBarBackground";
            //dropDown.itemHighlight = "LevelBarBackground";
            dropDown.selectedIndex = 0;
            dropDown.zOrder        = 1;


            //
            UIButton button = dropDown.AddUIComponent <UIButton>();

            dropDown.triggerButton = button;
            //button.text = "";
            button.size                 = new Vector2(105f, 24f);
            button.relativePosition     = new Vector3(0f, 0f);
            button.foregroundSpriteMode = UIForegroundSpriteMode.Fill;
            button.textPadding          = new RectOffset(0, 0, 5, 0);
            button.horizontalAlignment  = UIHorizontalAlignment.Right;
            button.verticalAlignment    = UIVerticalAlignment.Middle;
            //button.color = new Color32(238, 238, 238, 255);
            button.textColor         = new Color32(255, 255, 255, 255);
            button.hoveredTextColor  = new Color32(200, 200, 200, 255);
            button.pressedTextColor  = new Color32(200, 200, 200, 255);
            button.focusedTextColor  = new Color32(200, 200, 200, 255);
            button.disabledTextColor = new Color32(155, 155, 155, 255);
            button.textScale         = 0.8f;
            //button.hoveredBgSprite = "TextFieldUnderline";
            //button.pressedBgSprite = "TextFieldUnderline";
            //button.focusedBgSprite = "TextFieldUnderline";
            button.zOrder = 0;


            dropDown.eventSizeChanged += new PropertyChangedEventHandler <Vector2>((c, t) =>
            {
                button.size = t; dropDown.listWidth = (int)t.x;
            });

            return(dropDown);
        }
Esempio n. 11
0
		private UIPanel CreateQuartzPanel()
        {
            var uiView = GameObject.Find("UIView").GetComponent<UIView>();
            if (uiView == null)
            {
                Debug.LogError("UIView is null!");
                return null;
            }

            var panel = uiView.AddUIComponent(typeof(UIPanel)) as UIPanel;

	        if (panel != null)
	        {
		        panel.size = new Vector2(300, 290);
		        panel.isVisible = false;
		        panel.atlas = EmbeddedResources.GetQuartzAtlas();
		        panel.backgroundSprite = "DefaultPanelBackground";

				Vector2 viewSize = uiView.GetScreenResolution();

		        panel.relativePosition = _currentModuleClass == Skin.ModuleClass.MainMenu ? new Vector3(viewSize.x - 2.0f - panel.size.x, 34.0f) : new Vector3(viewSize.x - 2.0f - panel.size.x, 34.0f + 64.0f);

				panel.name = "QuartzSkinManager";

		        var title = panel.AddUIComponent<UILabel>();
				title.relativePosition = new Vector3(2.0f, 2.0f);
				title.text = "Quartz Skin Manager";
				title.textColor = Color.black;
	        }

            float y = 32.0f;

			UIUtil.MakeCheckbox(panel, "ShowIconInGame", "Show Quartz icon in-game", new Vector2(4.0f, y), ConfigManager.ShowQuartzIconInGame, value =>
            {
				ConfigManager.ShowQuartzIconInGame = value;

                if (_quartzButton != null && !ConfigManager.ShowQuartzIconInGame && _currentModuleClass == Skin.ModuleClass.InGame)
                {
                    _quartzButton.isVisible = false;
                    if (_quartzPanel != null)
                    {
                        _quartzPanel.isVisible = false;
                    }
                }
                else if(_quartzButton != null)
                {
                    _quartzButton.isVisible = true;
                }
            });

            y += 28.0f;

			UIUtil.MakeCheckbox(panel, "AutoApplySkin", "Apply skin on start-up", new Vector2(4.0f, y), ConfigManager.ApplySkinOnStartup, value =>
            {
				ConfigManager.ApplySkinOnStartup = value;
            });

            y += 28.0f;

            UIUtil.MakeCheckbox(panel, "DrawDebugInfo", "Developer mode (Ctrl+D)", new Vector2(4.0f, y), false, value =>
            {
                if (_debugRenderer != null)
                {
                    _debugRenderer.drawDebugInfo = value;
                }
            });

            y += 28.0f;

            UIUtil.MakeCheckbox(panel, "AutoReload", "Auto-reload active skin on file change", new Vector2(4.0f, y), false, value =>
            {
                _autoReloadSkinOnChange = value;
                ReloadAndApplyActiveSkin();
            });

			y += 28.0f;

			UIUtil.MakeCheckbox(panel, "IgnoreMissing", "Force load (May break stuff)", new Vector2(4.0f, y), ConfigManager.IgnoreMissingComponents, value =>
			{
				ConfigManager.IgnoreMissingComponents = value;
			});

            y += 28.0f;

            _skinsDropdown = panel.AddUIComponent<UIDropDown>();

            _skinsDropdown.AddItem("Vanilla (by Colossal Order)");
            foreach (var skin in _availableSkins)
            {
                _skinsDropdown.AddItem(String.Format("{0} (by {1}){2}", skin.Name, skin.Author, skin.Legacy ? " [LEGACY]" : string.Empty));
            }

            _skinsDropdown.size = new Vector2(296.0f, 32.0f);
            _skinsDropdown.relativePosition = new Vector3(2.0f, y);
            _skinsDropdown.listBackground = "GenericPanelLight";
            _skinsDropdown.itemHeight = 32;
            _skinsDropdown.itemHover = "ListItemHover";
            _skinsDropdown.itemHighlight = "ListItemHighlight";
            _skinsDropdown.normalBgSprite = "ButtonMenu";
            _skinsDropdown.listWidth = 300;
            _skinsDropdown.listHeight = 500;
            _skinsDropdown.foregroundSpriteMode = UIForegroundSpriteMode.Stretch;
            _skinsDropdown.popupColor = new Color32(45, 52, 61, 255);
            _skinsDropdown.popupTextColor = new Color32(170, 170, 170, 255);
            _skinsDropdown.zOrder = 1;
            _skinsDropdown.textScale = 0.8f;
            _skinsDropdown.verticalAlignment = UIVerticalAlignment.Middle;
            _skinsDropdown.horizontalAlignment = UIHorizontalAlignment.Center;
            _skinsDropdown.textFieldPadding = new RectOffset(8, 0, 8, 0);
            _skinsDropdown.itemPadding = new RectOffset(8, 0, 2, 0);

            _skinsDropdown.selectedIndex = 0;

            if(_currentSkin != null)
            {
                int i = 1;
                foreach (var skin in _availableSkins)
                {
                    if (skin.Path == _currentSkin.SapphirePath)
                    {
                        _skinsDropdown.selectedIndex = i;
                    }

                    i++;
                }
            }

            _skinsDropdown.eventSelectedIndexChanged += (component, index) =>
            {
                if (index == 0)
                {
                    if (_currentSkin != null)
                    {
                        _currentSkin.Dispose();
                    }

                    _currentSkin = null;
                    return;
                }

                var skin = _availableSkins[index-1];
                if (_currentSkin != null && _currentSkin.SapphirePath == skin.Path)
                {
                    return;
                }

                if (_currentSkin != null)
                {
                    _currentSkin.Dispose();
                }

                _currentSkin = Skin.FromXmlFile(Path.Combine(skin.Path, "skin.xml"), _autoReloadSkinOnChange);

                if (_currentSkin.IsValid)
                {
                    _currentSkin.Apply(_currentModuleClass);
                }
                else
                {
                    Debug.LogWarning("Skin is invalid, will not apply.. (check messages above for errors)");
                }

				ConfigManager.SelectedSkinPath = _currentSkin.SapphirePath;
                panel.isVisible = false;
            };
                        
            var skinsDropdownButton = _skinsDropdown.AddUIComponent<UIButton>();
            _skinsDropdown.triggerButton = skinsDropdownButton;

            skinsDropdownButton.text = "";
            skinsDropdownButton.size = _skinsDropdown.size;
            skinsDropdownButton.relativePosition = new Vector3(0.0f, 0.0f);
            skinsDropdownButton.textVerticalAlignment = UIVerticalAlignment.Middle;
            skinsDropdownButton.textHorizontalAlignment = UIHorizontalAlignment.Center;
            skinsDropdownButton.normalFgSprite = "IconDownArrow";
            skinsDropdownButton.hoveredFgSprite = "IconDownArrowHovered";
            skinsDropdownButton.pressedFgSprite = "IconDownArrowPressed";
            skinsDropdownButton.focusedFgSprite = "IconDownArrowFocused";
            skinsDropdownButton.disabledFgSprite = "IconDownArrowDisabled";
            skinsDropdownButton.foregroundSpriteMode = UIForegroundSpriteMode.Fill;
            skinsDropdownButton.horizontalAlignment = UIHorizontalAlignment.Right;
            skinsDropdownButton.verticalAlignment = UIVerticalAlignment.Middle;
            skinsDropdownButton.zOrder = 0;
            skinsDropdownButton.textScale = 0.8f;

            y += 40.0f;

            UIUtil.MakeButton(panel, "ReloadSkin", "Reload active skin (Ctrl+Shift+S)", new Vector2(4.0f, y), ReloadAndApplyActiveSkin);

            y += 36.0f;

            UIUtil.MakeButton(panel, "RefreshSkins", "Refresh available skins", new Vector2(4.0f, y), RefreshSkinsList);

            return panel;
        }
Esempio n. 12
0
        public static UIDropDown CreateDropDown(UIComponent parent, float offset, string label)
        {
            UIPanel container = parent.AddUIComponent <UIPanel>();

            container.height           = 25;
            container.relativePosition = new Vector3(0, offset, 0);

            UILabel serviceLabel = container.AddUIComponent <UILabel>();

            serviceLabel.textScale        = 0.8f;
            serviceLabel.text             = label;
            serviceLabel.relativePosition = new Vector3(15, 6, 0);


            UIDropDown dropDown = container.AddUIComponent <UIDropDown>();

            dropDown.size                 = new Vector2(120f, 25f);
            dropDown.listBackground       = "GenericPanelLight";
            dropDown.itemHeight           = 25;
            dropDown.itemHover            = "ListItemHover";
            dropDown.itemHighlight        = "ListItemHighlight";
            dropDown.normalBgSprite       = "ButtonMenu";
            dropDown.disabledBgSprite     = "ButtonMenuDisabled";
            dropDown.hoveredBgSprite      = "ButtonMenuHovered";
            dropDown.focusedBgSprite      = "ButtonMenu";
            dropDown.listWidth            = 90;
            dropDown.listHeight           = 500;
            dropDown.foregroundSpriteMode = UIForegroundSpriteMode.Stretch;
            dropDown.popupColor           = new Color32(45, 52, 61, 255);
            dropDown.popupTextColor       = new Color32(170, 170, 170, 255);
            dropDown.zOrder               = 1;
            dropDown.textScale            = 0.7f;
            dropDown.verticalAlignment    = UIVerticalAlignment.Middle;
            dropDown.horizontalAlignment  = UIHorizontalAlignment.Left;

            dropDown.textFieldPadding = new RectOffset(8, 0, 8, 0);
            dropDown.itemPadding      = new RectOffset(14, 0, 8, 0);

            dropDown.relativePosition = new Vector3(112, 0, 0);

            UIButton button = dropDown.AddUIComponent <UIButton>();

            dropDown.triggerButton         = button;
            button.text                    = "";
            button.size                    = dropDown.size;
            button.relativePosition        = new Vector3(0f, 0f);
            button.textVerticalAlignment   = UIVerticalAlignment.Middle;
            button.textHorizontalAlignment = UIHorizontalAlignment.Left;
            button.normalFgSprite          = "IconDownArrow";
            button.hoveredFgSprite         = "IconDownArrowHovered";
            button.pressedFgSprite         = "IconDownArrowPressed";
            button.focusedFgSprite         = "IconDownArrowFocused";
            button.disabledFgSprite        = "IconDownArrowDisabled";
            button.foregroundSpriteMode    = UIForegroundSpriteMode.Fill;
            button.horizontalAlignment     = UIHorizontalAlignment.Right;
            button.verticalAlignment       = UIVerticalAlignment.Middle;
            button.zOrder                  = 0;
            button.textScale               = 0.8f;

            dropDown.eventSizeChanged += new PropertyChangedEventHandler <Vector2>((c, t) =>
            {
                button.size = t; dropDown.listWidth = (int)t.x;
            });

            return(dropDown);
        }
Esempio n. 13
0
        private UIPanel CreateQuartzPanel()
        {
            var uiView = GameObject.Find("UIView").GetComponent <UIView>();

            if (uiView == null)
            {
                Debug.LogError("UIView is null!");
                return(null);
            }

            var panel = uiView.AddUIComponent(typeof(UIPanel)) as UIPanel;

            if (panel != null)
            {
                panel.size             = new Vector2(300, 290);
                panel.isVisible        = false;
                panel.atlas            = EmbeddedResources.GetQuartzAtlas();
                panel.backgroundSprite = "DefaultPanelBackground";

                Vector2 viewSize = uiView.GetScreenResolution();

                panel.relativePosition = _currentModuleClass == Skin.ModuleClass.MainMenu
                    ? new Vector3(viewSize.x - 2.0f - panel.size.x, 34.0f)
                    : new Vector3(viewSize.x - 2.0f - panel.size.x, 34.0f + 64.0f + 15.0f);

                panel.name = "QuartzSkinManager";

                var title = panel.AddUIComponent <UILabel>();
                title.relativePosition = new Vector3(2.0f, 2.0f);
                title.text             = "Quartz Skin Manager";
                title.textColor        = Color.black;
            }

            float y = 32.0f;

            UIUtil.MakeCheckbox(panel, "ShowIconInGame", "Show Quartz icon in-game", new Vector2(4.0f, y), ConfigManager.ShowQuartzIconInGame, value =>
            {
                ConfigManager.ShowQuartzIconInGame = value;

                if (_quartzButton != null && !ConfigManager.ShowQuartzIconInGame && _currentModuleClass == Skin.ModuleClass.InGame)
                {
                    _quartzButton.isVisible = false;
                    if (_quartzPanel != null)
                    {
                        _quartzPanel.isVisible = false;
                    }
                }
                else if (_quartzButton != null)
                {
                    _quartzButton.isVisible = true;
                }
            });

            y += 28.0f;

            UIUtil.MakeCheckbox(panel, "AutoApplySkin", "Apply skin on start-up", new Vector2(4.0f, y), ConfigManager.ApplySkinOnStartup, value =>
            {
                ConfigManager.ApplySkinOnStartup = value;
            });

            y += 28.0f;

            UIUtil.MakeCheckbox(panel, "DrawDebugInfo", "Developer mode (Ctrl+D)", new Vector2(4.0f, y), false, value =>
            {
                if (_debugRenderer != null)
                {
                    _debugRenderer.drawDebugInfo = value;
                }
            });

            y += 28.0f;

            UIUtil.MakeCheckbox(panel, "AutoReload", "Auto-reload active skin on file change", new Vector2(4.0f, y), false, value =>
            {
                _autoReloadSkinOnChange = value;
                ReloadAndApplyActiveSkin();
            });

            y += 28.0f;

            UIUtil.MakeCheckbox(panel, "IgnoreMissing", "Force load (May break stuff)", new Vector2(4.0f, y), ConfigManager.IgnoreMissingComponents, value =>
            {
                ConfigManager.IgnoreMissingComponents = value;
            });

            y += 28.0f;

            _skinsDropdown = panel.AddUIComponent <UIDropDown>();

            _skinsDropdown.AddItem("Vanilla (by Colossal Order)");
            foreach (var skin in _availableSkins)
            {
                _skinsDropdown.AddItem(String.Format("{0} (by {1}){2}", skin.Name, skin.Author, skin.Legacy ? " [LEGACY]" : string.Empty));
            }

            _skinsDropdown.size                 = new Vector2(296.0f, 32.0f);
            _skinsDropdown.relativePosition     = new Vector3(2.0f, y);
            _skinsDropdown.listBackground       = "GenericPanelLight";
            _skinsDropdown.itemHeight           = 32;
            _skinsDropdown.itemHover            = "ListItemHover";
            _skinsDropdown.itemHighlight        = "ListItemHighlight";
            _skinsDropdown.normalBgSprite       = "ButtonMenu";
            _skinsDropdown.listWidth            = 300;
            _skinsDropdown.listHeight           = 500;
            _skinsDropdown.foregroundSpriteMode = UIForegroundSpriteMode.Stretch;
            _skinsDropdown.popupColor           = new Color32(45, 52, 61, 255);
            _skinsDropdown.popupTextColor       = new Color32(170, 170, 170, 255);
            _skinsDropdown.zOrder               = 1;
            _skinsDropdown.textScale            = 0.8f;
            _skinsDropdown.verticalAlignment    = UIVerticalAlignment.Middle;
            _skinsDropdown.horizontalAlignment  = UIHorizontalAlignment.Center;
            _skinsDropdown.textFieldPadding     = new RectOffset(8, 0, 8, 0);
            _skinsDropdown.itemPadding          = new RectOffset(8, 0, 2, 0);

            _skinsDropdown.selectedIndex = 0;

            if (_currentSkin != null)
            {
                int i = 1;
                foreach (var skin in _availableSkins)
                {
                    if (skin.Path == _currentSkin.SapphirePath)
                    {
                        _skinsDropdown.selectedIndex = i;
                    }

                    i++;
                }
            }

            _skinsDropdown.eventSelectedIndexChanged += (component, index) =>
            {
                if (index == 0)
                {
                    if (_currentSkin != null)
                    {
                        _currentSkin.Dispose();
                    }

                    _currentSkin = null;
                    return;
                }

                var skin = _availableSkins[index - 1];
                if (_currentSkin != null && _currentSkin.SapphirePath == skin.Path)
                {
                    return;
                }

                if (_currentSkin != null)
                {
                    _currentSkin.Dispose();
                }

                _currentSkin = Skin.FromXmlFile(Path.Combine(skin.Path, "skin.xml"), _autoReloadSkinOnChange);

                if (_currentSkin.IsValid)
                {
                    _currentSkin.Apply(_currentModuleClass);
                }
                else
                {
                    Debug.LogWarning("Skin is invalid, will not apply.. (check messages above for errors)");
                }

                ConfigManager.SelectedSkinPath = _currentSkin.SapphirePath;
                panel.isVisible = false;
            };

            var skinsDropdownButton = _skinsDropdown.AddUIComponent <UIButton>();

            _skinsDropdown.triggerButton = skinsDropdownButton;

            skinsDropdownButton.text                    = "";
            skinsDropdownButton.size                    = _skinsDropdown.size;
            skinsDropdownButton.relativePosition        = new Vector3(0.0f, 0.0f);
            skinsDropdownButton.textVerticalAlignment   = UIVerticalAlignment.Middle;
            skinsDropdownButton.textHorizontalAlignment = UIHorizontalAlignment.Center;
            skinsDropdownButton.normalFgSprite          = "IconDownArrow";
            skinsDropdownButton.hoveredFgSprite         = "IconDownArrowHovered";
            skinsDropdownButton.pressedFgSprite         = "IconDownArrowPressed";
            skinsDropdownButton.focusedFgSprite         = "IconDownArrowFocused";
            skinsDropdownButton.disabledFgSprite        = "IconDownArrowDisabled";
            skinsDropdownButton.foregroundSpriteMode    = UIForegroundSpriteMode.Fill;
            skinsDropdownButton.horizontalAlignment     = UIHorizontalAlignment.Right;
            skinsDropdownButton.verticalAlignment       = UIVerticalAlignment.Middle;
            skinsDropdownButton.zOrder                  = 0;
            skinsDropdownButton.textScale               = 0.8f;

            y += 40.0f;

            UIUtil.MakeButton(panel, "ReloadSkin", "Reload active skin (Ctrl+Shift+S)", new Vector2(4.0f, y), ReloadAndApplyActiveSkin);

            y += 36.0f;

            UIUtil.MakeButton(panel, "RefreshSkins", "Refresh available skins", new Vector2(4.0f, y), RefreshSkinsList);

            return(panel);
        }
Esempio n. 14
0
        private UIDropDown CreateCargoDropDown(UIComponent parent)
        {
            UIDropDown dropCargo = parent.AddUIComponent <UIDropDown>();

            dropCargo.anchor               = UIAnchorStyle.Top | UIAnchorStyle.Left;
            dropCargo.height               = 30f;
            dropCargo.width                = 250f;
            dropCargo.relativePosition     = new Vector3(25f, 59f);
            dropCargo.size                 = new Vector2(250f, 30f);
            dropCargo.listBackground       = "GenericPanelLight";
            dropCargo.itemHeight           = 30;
            dropCargo.itemHover            = "ListItemHover";
            dropCargo.itemHighlight        = "ListItemHighlight";
            dropCargo.normalBgSprite       = "ButtonMenu";
            dropCargo.disabledBgSprite     = "ButtonMenuDisabled";
            dropCargo.hoveredBgSprite      = "ButtonMenuHovered";
            dropCargo.focusedBgSprite      = "ButtonMenu";
            dropCargo.listWidth            = 250;
            dropCargo.listHeight           = 720;
            dropCargo.foregroundSpriteMode = UIForegroundSpriteMode.Stretch;
            dropCargo.popupColor           = new Color32(45, 52, 61, 255);
            dropCargo.popupTextColor       = new Color32(170, 170, 170, 255);
            dropCargo.zOrder               = 1;
            dropCargo.textScale            = 0.8f;
            dropCargo.verticalAlignment    = UIVerticalAlignment.Middle;
            dropCargo.horizontalAlignment  = UIHorizontalAlignment.Left;
            dropCargo.selectedIndex        = 0;
            dropCargo.textFieldPadding     = new RectOffset(8, 0, 8, 0);
            dropCargo.itemPadding          = new RectOffset(14, 0, 8, 0);

            UIButton button = dropCargo.AddUIComponent <UIButton>();

            dropCargo.triggerButton        = button;
            button.text                    = "";
            button.size                    = dropCargo.size;
            button.relativePosition        = new Vector3(0f, 0f);
            button.textVerticalAlignment   = UIVerticalAlignment.Middle;
            button.textHorizontalAlignment = UIHorizontalAlignment.Left;
            button.normalFgSprite          = "IconDownArrow";
            button.hoveredFgSprite         = "IconDownArrowHovered";
            button.pressedFgSprite         = "IconDownArrowPressed";
            button.focusedFgSprite         = "IconDownArrowFocused";
            button.disabledFgSprite        = "IconDownArrowDisabled";
            button.foregroundSpriteMode    = UIForegroundSpriteMode.Fill;
            button.horizontalAlignment     = UIHorizontalAlignment.Right;
            button.verticalAlignment       = UIVerticalAlignment.Middle;
            button.zOrder                  = 0;
            button.textScale               = 0.8f;
            dropCargo.eventSizeChanged    += new PropertyChangedEventHandler <Vector2>((c, t) =>
            {
                button.size = t; dropCargo.listWidth = (int)t.x;
            });

            Dictionary <string, ushort> cargoTypes = new Dictionary <string, ushort>
            {
                { "none", 255 },
                { "Oil", 13 },
                { "Ore", 14 },
                { "Logs", 15 },
                { "Crops", 16 },     // Looks like it was called Grain before Industries DLC, but never displayed to user?
                { "Goods", 17 },
                { "Coal", 19 },
                { "Petrol", 31 },
                { "Food", 32 },
                { "Lumber", 37 },
                { "AnimalProducts", 97 },
                { "Flours", 98 },
                { "Paper", 99 },
                { "PlanedTimber", 100 },
                { "Petroleum", 101 },
                { "Plastics", 102 },
                { "Glass", 103 },
                { "Metals", 104 },
                { "LuxuryProducts", 105 },
                { "Fish", 108 },
                { "ZI-Oil", (13 << 8) + 31 },      // 3359
                { "ZI-Ore", (14 << 8) + 19 },      // 3603
                { "ZI-Forestry", (15 << 8) + 37 }, // 3877
                { "ZI-Farming", (16 << 8) + 32 }   // 4128
            };

            foreach (KeyValuePair <string, ushort> kvp in cargoTypes)
            {
                dropCargo.AddItem(kvp.Key);
            }
            dropCargo.eventSelectedIndexChanged += (c, e) =>
            {
                cargoTypes.TryGetValue(dropCargo.selectedValue, out ushort myResource);
                if (myResource > 255)                                         // if top byte present
                {
                    m_selectedResource2 = (byte)((myResource & 0xFF00) >> 8); // Extract top byte
                }
                else
                {
                    m_selectedResource2 = 0;
                }
                m_selectedResource = (byte)(myResource & 0xFF);  // Extract low byte
                m_selectedBuilding = 0;
                m_forceRefresh     = true;
            };
            dropCargo.selectedIndex = 3;
            dropCargo.selectedValue = "Grain";
            return(dropCargo);
        }
Esempio n. 15
0
        public override void Start()
        {
            backgroundSprite = "GenericPanel";
            width            = 400;
            height           = 800;
            anchor           = UIAnchorStyle.CenterHorizontal | UIAnchorStyle.CenterVertical;

            ////allow resizing. Don't know why it's not showing up.
            //UIResizeHandle resizeHandle = AddUIComponent<UIResizeHandle>();
            //resizeHandle.backgroundSprite = "buttonresize";

            //Container for the titlebar stuff.
            UISlicedSprite caption = AddUIComponent <UISlicedSprite>();

            caption.anchor           = UIAnchorStyle.Top | UIAnchorStyle.Left | UIAnchorStyle.Right;
            caption.fillDirection    = UIFillDirection.Horizontal;
            caption.fillAmount       = 1;
            caption.relativePosition = new Vector3(0, 0, 0);
            caption.width            = 400;
            caption.height           = 40;

            //Window title
            UILabel label = caption.AddUIComponent <UILabel>();

            label.autoSize          = true;
            label.textAlignment     = UIHorizontalAlignment.Center;
            label.verticalAlignment = UIVerticalAlignment.Top;
            label.textScale         = 1.3f;
            label.text             = "Extended Properties";
            label.anchor           = UIAnchorStyle.CenterVertical | UIAnchorStyle.CenterHorizontal;
            label.relativePosition = new Vector3(0, 0, 0);

            //Window dragging.
            UIDragHandle dragHandle = caption.AddUIComponent <UIDragHandle>();

            dragHandle.width            = 400;
            dragHandle.height           = 40;
            dragHandle.relativePosition = new Vector3(0, 0, 0);
            dragHandle.target           = this;

            // Allow automated layout
            this.autoLayoutDirection = LayoutDirection.Vertical;
            this.autoLayoutStart     = LayoutStart.TopLeft;
            this.autoLayoutPadding   = new RectOffset(10, 10, 0, 10);
            this.autoLayout          = true;

            //setup the building label
            buildingType        = AddUIComponent <UILabel>();
            buildingAISelection = AddUIComponent <UIDropDown>();
            buildingAISelection.listBackground = "InfoDisplay";
            buildingAISelection.itemHover      = "ListItemHover";
            buildingAISelection.itemHighlight  = "ListItemHilight";
            buildingAISelection.normalBgSprite = "InfoDisplay";
            buildingAISelection.width          = 300;
            buildingAISelection.height         = 28;
            buildingAISelection.listWidth      = 300;

            buildingAISelection.eventSelectedIndexChanged += buildingAISelection_eventSelectedIndexChanged;

            UIButton buildingAISelectionButton = buildingAISelection.AddUIComponent <UIButton>();

            buildingAISelectionButton.normalFgSprite      = "IconUpArrow";
            buildingAISelectionButton.width               = 47;
            buildingAISelectionButton.height              = 26;
            buildingAISelectionButton.verticalAlignment   = UIVerticalAlignment.Middle;
            buildingAISelectionButton.horizontalAlignment = UIHorizontalAlignment.Right;
            buildingAISelectionButton.relativePosition    = new Vector3(1, 2);
            buildingAISelection.triggerButton             = buildingAISelectionButton;

            RefreshBuildingAIs();
            RefreshItemClasses();
        }
        //Special Thanks to boformer's NetworkSkins.UI.Util for this!
        public static UIDropDown CreateDropDown(UIComponent parent, float textScale, RectOffset textPadding, Vector2 size, int itemWidth, int itemHeight, int maxItems, int itemSpacing)
        {
            //dropdown
            UIDropDown _dropDown = parent.AddUIComponent <UIDropDown>();

            _dropDown.size = size;
            _dropDown.horizontalAlignment = UIHorizontalAlignment.Left;
            _dropDown.verticalAlignment   = UIVerticalAlignment.Middle;

            itemSpacing = Mathf.Clamp(itemSpacing, 0, itemHeight * 10);
            maxItems    = Mathf.Clamp(maxItems, 1, 50);

            _dropDown.autoListWidth  = false;
            _dropDown.autoSize       = false;
            _dropDown.listBackground = "OptionsDropboxListbox";
            _dropDown.listWidth      = itemWidth;
            _dropDown.listHeight     = itemSpacing + ((itemHeight + itemSpacing) * maxItems);
            _dropDown.listPosition   = UIDropDown.PopupListPosition.Below;
            _dropDown.listPadding    = new RectOffset(itemSpacing, itemSpacing, itemSpacing, itemSpacing);

            _dropDown.itemHeight    = itemHeight;
            _dropDown.itemHover     = "ListItemHover";
            _dropDown.itemHover     = "ListItemHover";
            _dropDown.itemHighlight = "ListItemHighlight";
            _dropDown.itemPadding   = new RectOffset(14, 0, itemSpacing * 2, 0);

            _dropDown.normalBgSprite   = "OptionsDropbox";
            _dropDown.disabledBgSprite = "OptionsDropboxDisabled";
            _dropDown.hoveredBgSprite  = "OptionsDropboxHovered";
            _dropDown.focusedBgSprite  = "OptionsDropboxFocused";

            _dropDown.foregroundSpriteMode = UIForegroundSpriteMode.Stretch;

            _dropDown.popupColor     = new Color32(45, 52, 61, 255);
            _dropDown.popupTextColor = new Color32(170, 170, 170, 255);

            _dropDown.textScale        = textScale;
            _dropDown.textFieldPadding = textPadding;

            _dropDown.playAudioEvents = true;

            _dropDown.zOrder        = 1;
            _dropDown.selectedIndex = 0;

            //button
            UIButton _button = _dropDown.AddUIComponent <UIButton>();

            _dropDown.triggerButton = _button;

            _button.size                = _dropDown.size;
            _button.relativePosition    = new Vector3(0f, 0f);
            _button.horizontalAlignment = UIHorizontalAlignment.Right;
            _button.verticalAlignment   = UIVerticalAlignment.Middle;

            _button.text      = "";
            _button.textScale = textScale;
            _button.textHorizontalAlignment = UIHorizontalAlignment.Left;
            _button.textVerticalAlignment   = UIVerticalAlignment.Middle;
            _button.textPadding             = textPadding;

            _button.playAudioEvents = true;

            _button.zOrder = 0;

            //events
            _dropDown.eventSizeChanged += delegate(UIComponent c, Vector2 t)
            {
                _button.size        = t;
                _dropDown.listWidth = (int)t.x;
            };

            //finally
            return(_dropDown);
        }