void Awake()
 {
     this.m_strip = GetComponentInChildren <UITabstrip>();
     this.m_strip.relativePosition   = new Vector3(13, -25);
     this.m_strip.startSelectedIndex = 0;
     this.m_atlas = UIUtils.LoadThumbnailsTextureAtlas("UIThumbnails");
     UIUtils.SetThumbnails("TabBg", sm_thumbnailCoords["TabBackgrounds"], this.m_atlas, sm_thumbnailStates);
     this.m_objectIndex = 0;
 }
Exemple #2
0
        protected void SetVehicleButtonsThumbnails(UIButton btn)
        {
            string iconName = btn.name;

            UIUtils.SetThumbnails(iconName, sm_thumbnailCoords[iconName], btn.atlas, iconName == "Emergency" ? sm_emergencyVehicleThumbnailStates : sm_vehicleThumbnailStates);

            btn.normalFgSprite   = iconName;
            btn.focusedFgSprite  = iconName;
            btn.hoveredFgSprite  = iconName;
            btn.pressedFgSprite  = iconName;
            btn.disabledFgSprite = iconName + "Disabled";

            btn.eventMouseEnter += (UIComponent comp, UIMouseEventParameter p) =>
            {
                if (btn.state == UIButton.ButtonState.Focused)
                {
                    if (String.IsNullOrEmpty(btn.stringUserData))
                    {
                        btn.focusedFgSprite = iconName + "80%";
                    }
                    else
                    {
                        btn.focusedFgSprite = iconName + "90%";
                    }
                }
            };

            btn.eventMouseLeave += (UIComponent comp, UIMouseEventParameter p) =>
            {
                if (btn.state == UIButton.ButtonState.Focused)
                {
                    if (String.IsNullOrEmpty(btn.stringUserData))
                    {
                        btn.focusedFgSprite = iconName + "Deselected";
                    }
                    else
                    {
                        btn.focusedFgSprite = iconName;
                    }
                }
            };

            btn.eventMouseDown += (UIComponent comp, UIMouseEventParameter p) =>
            {
                if (btn.state == UIButton.ButtonState.Focused)
                {
                    if (String.IsNullOrEmpty(btn.stringUserData))
                    {
                        btn.focusedFgSprite = iconName + "90%";
                    }
                    else
                    {
                        btn.focusedFgSprite = iconName + "80%";
                    }
                }
            };
        }
Exemple #3
0
        protected void SetSpeedButtonsThumbnails(UIButton btn)
        {
            string iconName = btn.name;

            UIUtils.SetThumbnails(iconName, sm_thumbnailCoords[iconName], btn.atlas);

            btn.normalBgSprite   = "SpeedSignBackground";
            btn.disabledBgSprite = "SpeedSignBackgroundDisabled";
            btn.focusedBgSprite  = "SpeedSignBackgroundFocused";
            btn.hoveredBgSprite  = btn.pressedBgSprite = "SpeedSignBackgroundHovered";

            btn.normalFgSprite   = iconName;
            btn.focusedFgSprite  = iconName;
            btn.hoveredFgSprite  = iconName;
            btn.pressedFgSprite  = iconName;
            btn.disabledFgSprite = iconName;
        }
        protected UIButton SpawnEntry(string name, string localeID, string unlockText, string spriteBase, bool enabled)
        {
            UIButton btn;

            if (m_strip.childCount > this.m_objectIndex)
            {
                btn = (m_strip.components[this.m_objectIndex] as UIButton);
            }
            else
            {
                GameObject asGameObject  = UITemplateManager.GetAsGameObject(kSubbarButtonTemplate);
                GameObject asGameObject2 = UITemplateManager.GetAsGameObject(kSubbarPanelTemplate);
                btn = m_strip.AttachUIComponent(asGameObject) as UIButton;
                //btn = m_strip.AddTab(name, asGameObject, asGameObject2, typeof(RoadCustomizerPanel)) as UIButton;
                //btn.eventClick += OnClick;
            }
            btn.isEnabled = enabled;

            btn.atlas = this.m_atlas;
            //btn.gameObject.GetComponent<TutorialUITag>().tutorialTag = name;
            string text = spriteBase + name;

            UIUtils.SetThumbnails(text, sm_thumbnailCoords[text], this.m_atlas);
            btn.normalFgSprite   = text;
            btn.focusedFgSprite  = text; // +"Focused";
            btn.hoveredFgSprite  = text; // +"Hovered";
            btn.pressedFgSprite  = text; // +"Pressed";
            btn.disabledFgSprite = text; // +"Disabled";

            btn.normalBgSprite   = "TabBg";
            btn.focusedBgSprite  = "TabBg" + "Focused";
            btn.hoveredBgSprite  = btn.pressedBgSprite = "TabBg" + "Hovered";
            btn.disabledBgSprite = "TabBg" + "Disabled";

            if (!string.IsNullOrEmpty(localeID) && !string.IsNullOrEmpty(unlockText))
            {
                btn.tooltip = Locale.Get(localeID, name) + " - " + unlockText;
            }
            else if (!string.IsNullOrEmpty(localeID))
            {
                btn.tooltip = Locale.Get(localeID, name);
            }
            this.m_objectIndex++;
            return(btn);
        }
Exemple #5
0
        protected UIButton CreateButton(string name, string tooltip, string baseIconName, int index, UITextureAtlas atlas, UIComponent tooltipBox, bool enabled, bool grouped)
        {
            UIButton btn;

            if (this.m_scrollablePanel.childCount > this.m_objectIndex)
            {
                btn = (this.m_scrollablePanel.components[this.m_objectIndex] as UIButton);
            }
            else
            {
                GameObject asGameObject = UITemplateManager.GetAsGameObject(RoadCustomizerPanel.kItemTemplate);
                btn             = (this.m_scrollablePanel.AttachUIComponent(asGameObject) as UIButton);
                btn.eventClick += OnClick;
            }
            btn.gameObject.GetComponent <TutorialUITag>().tutorialTag = name;
            btn.text                = string.Empty;
            btn.name                = name;
            btn.tooltipAnchor       = UITooltipAnchor.Anchored;
            btn.tabStrip            = true;
            btn.horizontalAlignment = UIHorizontalAlignment.Center;
            btn.verticalAlignment   = UIVerticalAlignment.Middle;
            btn.pivot               = UIPivotPoint.TopCenter;
            if (atlas != null)
            {
                btn.atlas = atlas;
                switch (m_panelType)
                {
                case Panel.VehicleRestrictions:
                    SetVehicleButtonsThumbnails(btn);
                    break;

                case Panel.SpeedRestrictions:
                    UIUtils.SetThumbnails("SpeedSignBackground", sm_thumbnailCoords["SpeedSignBackground"], atlas, sm_speedThumbnailStates);
                    SetSpeedButtonsThumbnails(btn);
                    break;

                default:
                    break;
                }
            }
            if (index != -1)
            {
                btn.zOrder = index;
            }
            btn.verticalAlignment    = UIVerticalAlignment.Bottom;
            btn.foregroundSpriteMode = UIForegroundSpriteMode.Fill;

            UIComponent uIComponent = (btn.childCount <= 0) ? null : btn.components[0];

            if (uIComponent != null)
            {
                uIComponent.isVisible = false;
            }
            btn.isEnabled  = enabled;
            btn.state      = UIButton.ButtonState.Disabled;
            btn.tooltip    = tooltip;
            btn.tooltipBox = tooltipBox;
            btn.group      = grouped ? this.m_scrollablePanel : null;
            this.m_objectIndex++;
            return(btn);
        }