Exemplo n.º 1
0
        private void CreateButtons()
        {
            UIButton        tabTemplate = (UIButton)builtinTabstrip.tabs[0];
            UITextureAtlas  atlas       = AtlasCreator.CreateTextureAtlas("sprites.png", "ChangeRoadHeightUI", tabTemplate.atlas.material, spriteWidth, spriteHeight);
            List <UIButton> buttons     = new List <UIButton>();

            buttons.Add(tabstrip.AddTab("", null, false));
            buttons.Add(tabstrip.AddTab("", null, false));
            foreach (UIButton button in buttons)
            {
                SetDefaultSettingsForButton(button, atlas);
            }
            SetButtonSpecificProperties(buttons[0], "ChangeRoadHeightButtonUp", "Move road up", SpriteName.IconRoadUp, SpriteName.IconRoadUpPressed);
            SetButtonSpecificProperties(buttons[1], "ChangeRoadHeightButtonDown", "Move road down", SpriteName.IconRoadDown, SpriteName.IconRoadDownPressed);
        }
Exemplo n.º 2
0
        private ToggleButtonComponents CreateToggleButtonComponents(UITabstrip tabstrip)
        {
            SeparatorComponents preSeparatorComponents = CreateSeparatorComponents(tabstrip);

            GameObject tabStripPage = UITemplateManager.GetAsGameObject(kEmptyContainer);
            GameObject mainToolbarButtonTemplate = UITemplateManager.GetAsGameObject(kMainToolbarButtonTemplate);

            UIButton toggleButton = tabstrip.AddTab(kToggleButton, mainToolbarButtonTemplate, tabStripPage, new Type[0]) as UIButton;

            toggleButton.atlas = Resources.ResourceLoader.ForestBrushAtlas;

            toggleButton.normalFgSprite   = "ForestBrushNormal";
            toggleButton.disabledFgSprite = "ForestBrushDisabled";
            toggleButton.focusedFgSprite  = "ForestBrushFocused";
            toggleButton.hoveredFgSprite  = "ForestBrushHovered";
            toggleButton.pressedFgSprite  = "ForestBrushPressed";

            toggleButton.normalBgSprite   = "ToolbarIconGroup6Normal";
            toggleButton.disabledBgSprite = "ToolbarIconGroup6Disabled";
            toggleButton.focusedBgSprite  = "ToolbarIconGroup6Focused";
            toggleButton.hoveredBgSprite  = "ToolbarIconGroup6Hovered";
            toggleButton.pressedBgSprite  = "ToolbarIconGroup6Pressed";
            toggleButton.parent.height    = 1f;

            IncrementObjectIndex();

            SeparatorComponents postSeparatorComponents = CreateSeparatorComponents(tabstrip);

            return(new ToggleButtonComponents(preSeparatorComponents, tabStripPage, mainToolbarButtonTemplate, toggleButton, postSeparatorComponents));
        }
Exemplo n.º 3
0
        private static GameObject CreateTabInternal(UITabstrip stripMain, string sprite, string text, string objectName, bool scroll, UITextureAtlas textureAtlas, Vector2?nullableSize, bool isHorizontal)
        {
            Vector2  size = nullableSize ?? (isHorizontal ? new Vector2(sprite.IsNullOrWhiteSpace() ? 100 : stripMain.height, stripMain.height) : new Vector2(stripMain.width, 40));
            UIButton tab  = CreateTabTemplate(out UISprite logo, size, textureAtlas);

            if (sprite.IsNullOrWhiteSpace())
            {
                tab.text = text;
            }
            else
            {
                logo.spriteName = sprite;
                tab.tooltip     = text;
            }

            KlyteMonoUtils.CreateUIElement(out UIPanel contentContainer, null);
            contentContainer.name = "Container";
            contentContainer.size = new Vector4(stripMain.tabContainer.width, stripMain.tabContainer.height);
            stripMain.AddTab(objectName, tab.gameObject, contentContainer.gameObject);
            GameObject go;

            if (scroll)
            {
                go = KlyteMonoUtils.CreateScrollPanel(contentContainer, out UIScrollablePanel scrollablePanel, out _, contentContainer.width - 20, contentContainer.height - 5, new Vector3()).Self.gameObject;
                scrollablePanel.scrollPadding = new RectOffset(10, 10, 10, 10);
            }
            else
            {
                go = contentContainer.gameObject;
            }

            return(go);
        }
Exemplo n.º 4
0
        internal void AddTab(ModTab cat, Type customControl, UITextureAtlas atlas, string fgTexture, string tooltip, PropertyChangedEventHandler <bool> onVisibilityChanged, float?width = null)
        {
            if (m_StripMain.Find <UIComponent>(cat.ToString()) != null)
            {
                return;
            }

            UIButton superTab = CreateTabTemplate();

            superTab.atlas                = atlas;
            superTab.normalFgSprite       = fgTexture;
            superTab.color                = Color.gray;
            superTab.focusedColor         = Color.white;
            superTab.hoveredColor         = Color.white;
            superTab.disabledColor        = Color.black;
            superTab.playAudioEvents      = true;
            superTab.tooltip              = tooltip;
            superTab.foregroundSpriteMode = UIForegroundSpriteMode.Stretch;

            KlyteUtils.createUIElement(out UIPanel content, null);
            content.name = "Container";
            content.area = new Vector4(0, 0, width ?? mainPanel.width, mainPanel.height);

            m_StripMain.AddTab(cat.ToString(), superTab.gameObject, content.gameObject, customControl);

            content.eventVisibilityChanged += onVisibilityChanged;
        }
Exemplo n.º 5
0
        public override void OnLevelLoaded(LoadMode m)
        {
            if (m != LoadMode.NewMap)
            {
                return;
            }

            window = new GameObject("Terrain Panel");

            UIView v = UIView.GetAView();

            strip = UIView.Find <UITabstrip>("MainToolstrip");

            button1                = UITemplateManager.GetAsGameObject("MainToolbarButtonTemplate");
            button2                = UITemplateManager.GetAsGameObject("ScrollablePanelTemplate");
            menuButton             = strip.AddTab("TerrainGenerator", button1, button2, new Type[] { }) as UIButton;
            menuButton.eventClick += uiButton_eventClick;

            menuButton.normalFgSprite  = "InfoIconTerrainHeight";
            menuButton.hoveredFgSprite = "InfoIconTerrainHeightHovered";
            menuButton.focusedFgSprite = "InfoIconTerrainHeightFocused";
            menuButton.pressedFgSprite = "InfoIconTerrainHeightPressed";
            menuButton.tooltip         = "Generate Terrain";

            panel = window.AddComponent <TerrainUIMainPanel>();
            panel.transform.parent = v.transform;
            panel.position         = new Vector3(menuButton.position.x - 240, menuButton.position.y - 105);
            panel.Hide();

            initialized = true;
        }
        internal void AddTab()
        {
            if (!(m_modsTabstrip.Find <UIComponent>(CommonProperties.Acronym) is null))
            {
                return;
            }

            UIButton superTab = CreateTabTemplate();

            superTab.normalFgSprite       = IconName;
            superTab.color                = Color.gray;
            superTab.focusedColor         = Color.white;
            superTab.hoveredColor         = Color.white;
            superTab.disabledColor        = Color.black;
            superTab.playAudioEvents      = true;
            superTab.tooltip              = GeneralName;
            superTab.foregroundSpriteMode = UIForegroundSpriteMode.Stretch;

            KlyteMonoUtils.CreateUIElement(out UIPanel content, null);
            content.name = "Container";
            content.size = new Vector4(TabWidth ?? m_modsPanel.width, m_modsPanel.height);

            m_modsTabstrip.AddTab(CommonProperties.Acronym, superTab.gameObject, content.gameObject, typeof(T));

            content.eventVisibilityChanged += (x, y) => { if (y)
                                                          {
                                                              ShowVersionInfoPopup();
                                                          }
            };
        }
Exemplo n.º 7
0
        /// <summary>
        /// Creates a tab.
        /// </summary>
        /// <param name="helper">The <see cref="UIHelper"/>.</param>
        /// <param name="tabstrip">The <see cref="UITabstrip"/> this tab should belong to.</param>
        /// <param name="buttonWidth">The width of the tab button.</param>
        /// <param name="title">The title of the tab.</param>
        /// <returns>A <see cref="UIHelper"/> object of the newly created tab.</returns>
        public static UIHelper AddTab(this UIHelper helper, UITabstrip tabstrip, float buttonWidth, string title)
        {
            var tabstripGo = GameObject.Find(GameObjectDefs.ID_KEYMAPPING_TABSTRIP);  //TODO(earalov): replace with custom code

            if (tabstripGo == null)
            {
                return(helper);
            }
            UITabstrip keyMappingTabstrip = tabstripGo.GetComponent <UITabstrip>();
            UIButton   buttonTemplate     = null;

            if (keyMappingTabstrip == null)
            {
                buttonTemplate = keyMappingTabstrip.GetComponentInChildren <UIButton>();
            }

            UIButton tabButton = tabstrip.AddTab(title, buttonTemplate, true);

            tabButton.playAudioEvents   = buttonTemplate.playAudioEvents;
            tabButton.pressedTextColor  = buttonTemplate.pressedTextColor;
            tabButton.focusedTextColor  = buttonTemplate.focusedTextColor;
            tabButton.disabledTextColor = buttonTemplate.disabledTextColor;
            tabButton.width             = buttonWidth;

            UIPanel tab = tabstrip.tabPages.components.Last() as UIPanel;

            tab.autoLayout          = true;
            tab.autoLayoutDirection = LayoutDirection.Vertical;
            tab.autoLayoutPadding   = new RectOffset(0, 0, 2, 0);
            return(new UIHelper(tab));
        }
Exemplo n.º 8
0
        private static void addTab(UITabstrip strip, int tabIndex, IModule module, string moduleName = "", string uiCategory = "")
        {
            if (moduleName == "")
            {
                moduleName = module.Name;
            }
            UIButton tabButton = strip.AddTab(moduleName);

            tabButton.normalBgSprite   = "SubBarButtonBase";
            tabButton.disabledBgSprite = "SubBarButtonBaseDisabled";
            tabButton.focusedBgSprite  = "SubBarButtonBaseFocused";
            tabButton.hoveredBgSprite  = "SubBarButtonBaseHovered";
            tabButton.pressedBgSprite  = "SubBarButtonBasePressed";
            tabButton.textPadding      = new RectOffset(10, 10, 10, 10);
            tabButton.autoSize         = true;
            tabButton.tooltip          = moduleName;

            strip.selectedIndex = tabIndex;
            // Get the current container and use the UIHelper to have something in there
            UIPanel stripRoot = strip.tabContainer.components[tabIndex] as UIPanel;

            stripRoot.autoLayout             = true;
            stripRoot.autoLayoutDirection    = LayoutDirection.Vertical;
            stripRoot.autoLayoutPadding.top  = 5;
            stripRoot.autoLayoutPadding.left = 10;
            stripRoot.name = $"{uiCategory}";
            UIHelper stripHelper = new UIHelper(stripRoot);

            module.OnSettingsUI(stripHelper);
        }
Exemplo n.º 9
0
        public override void OnLevelLoaded(LoadMode mode)
        {
            if (mode != LoadMode.LoadGame && mode != LoadMode.NewGame && mode != LoadMode.NewMap &&
                mode != LoadMode.LoadMap)
            {
                return;
            }
            _mode = mode;

            buildingWindowGameObject = new GameObject("buildingWindowObject");

            var view = UIView.GetAView();

            this.buildingWindow = buildingWindowGameObject.AddComponent <MapperWindow7>();
            this.buildingWindow.transform.parent = view.transform;
            this.buildingWindow.position         = new Vector3(300, 122);
            this.buildingWindow.Hide();


            UITabstrip strip = null;

            if (mode == LoadMode.NewGame || mode == LoadMode.LoadGame)
            {
                strip = ToolsModifierControl.mainToolbar.component as UITabstrip;
            }
            else
            {
                strip = UIView.Find <UITabstrip>("MainToolstrip");
            }

            buttonObject           = UITemplateManager.GetAsGameObject("MainToolbarButtonTemplate");
            buttonObject2          = UITemplateManager.GetAsGameObject("ScrollablePanelTemplate");
            menuButton             = strip.AddTab("mapperMod", buttonObject, buttonObject2, new Type[] {}) as UIButton;
            menuButton.eventClick += uiButton_eventClick;
        }
Exemplo n.º 10
0
        private void CreateTsdTabstrip()
        {
            UIButton tabTemplate = CreateTabSubStripTemplate();

            UIComponent bodyContent = CreateContentTemplate(m_stripMain.tabContainer.width, m_stripMain.tabContainer.height, false);

            foreach (var targetType in ReflectionUtils.GetSubtypesRecursive(typeof(UVMLinesPanel), GetType()))
            {
                TransportSystemDefinition tsd = (targetType.GetConstructor(new Type[0]).Invoke(null) as UVMLinesPanel).TSD;
                GameObject tab       = Instantiate(tabTemplate.gameObject);
                GameObject body      = Instantiate(bodyContent.gameObject);
                string     name      = tsd.GetTransportName();
                string     bgIcon    = KlyteResourceLoader.GetDefaultSpriteNameFor(TLMPrefixesUtils.GetLineIcon(0, tsd), true);
                string     fgIcon    = tsd.GetTransportTypeIcon();
                UIButton   tabButton = tab.GetComponent <UIButton>();
                tabButton.tooltip          = name;
                tabButton.hoveredBgSprite  = bgIcon;
                tabButton.focusedBgSprite  = bgIcon;
                tabButton.normalBgSprite   = bgIcon;
                tabButton.disabledBgSprite = bgIcon;
                tabButton.focusedColor     = Color.green;
                tabButton.hoveredColor     = new Color(0, 0.5f, 0f);
                tabButton.color            = Color.black;
                tabButton.disabledColor    = Color.gray;
                if (!string.IsNullOrEmpty(fgIcon))
                {
                    KlyteMonoUtils.CreateUIElement(out UIButton secSprite, tabButton.transform, "OverSprite", new Vector4(5, 5, 30, 30));
                    secSprite.normalFgSprite       = fgIcon;
                    secSprite.foregroundSpriteMode = UIForegroundSpriteMode.Scale;
                    secSprite.isInteractive        = false;
                    secSprite.disabledColor        = Color.black;
                }
                m_stripMain.AddTab(name, tab, body, new Type[] { targetType });
            }
        }
Exemplo n.º 11
0
        /// <summary>
        /// Adds a tab to a UI tabstrip.
        /// </summary>
        /// <param name="tabStrip">UIT tabstrip to add to</param>
        /// <param name="tabName">Name of this tab</param>
        /// <param name="tabIndex">Index number of this tab</param>
        /// <returns>UIHelper instance for the new tab panel</returns>
        internal static UIPanel AddTab(UITabstrip tabStrip, string tabName, int tabIndex, bool autoLayout = false)
        {
            // Create tab.
            UIButton tabButton = tabStrip.AddTab(tabName);

            // Sprites.
            tabButton.normalBgSprite   = "SubBarButtonBase";
            tabButton.disabledBgSprite = "SubBarButtonBaseDisabled";
            tabButton.focusedBgSprite  = "SubBarButtonBaseFocused";
            tabButton.hoveredBgSprite  = "SubBarButtonBaseHovered";
            tabButton.pressedBgSprite  = "SubBarButtonBasePressed";

            // Tooltip.
            tabButton.tooltip = tabName;

            tabStrip.selectedIndex = tabIndex;

            // Force width.
            tabButton.width = 120;

            // Get tab root panel.
            UIPanel rootPanel = tabStrip.tabContainer.components[tabIndex] as UIPanel;

            // Panel setup.
            rootPanel.autoLayout             = autoLayout;
            rootPanel.autoLayoutDirection    = LayoutDirection.Vertical;
            rootPanel.autoLayoutPadding.top  = 5;
            rootPanel.autoLayoutPadding.left = 10;

            return(rootPanel);
        }
Exemplo n.º 12
0
        protected SeparatorComponents CreateSeparatorComponents(UITabstrip strip)
        {
            GameObject  mainToolbarSeparatorTemplate = UITemplateManager.GetAsGameObject(kMainToolbarSeparatorTemplate);
            GameObject  emptyContainer = UITemplateManager.GetAsGameObject(kEmptyContainer);
            UIComponent separatorTab   = strip.AddTab("Separator", mainToolbarSeparatorTemplate, emptyContainer, new Type[0]);

            separatorTab.width    *= 0.5f;
            separatorTab.isEnabled = false;
            IncrementObjectIndex();
            return(new SeparatorComponents(mainToolbarSeparatorTemplate, emptyContainer, separatorTab));
        }
Exemplo n.º 13
0
        private void AttachToolOptionsButton(RoadPrefab prefab)
        {
            m_buttonExists = false;

            RoadsOptionPanel[] panels = GameObject.FindObjectsOfType <RoadsOptionPanel>();

            foreach (RoadsOptionPanel panel in panels)
            {
                // Find the visible RoadsOptionPanel
                if (panel.component.isVisible)
                {
                    UIComponent button = panel.component.Find <UIComponent>("ElevationStep");
                    if (button == null)
                    {
                        continue;
                    }

                    // Put the main button in ElevationStep
                    m_toolOptionButton.transform.SetParent(button.transform);
                    m_buttonInOptionsBar = false;
                    button.tooltip       = null;
                    m_buttonExists       = true;

                    // Add Upgrade button if needed
                    List <NetTool.Mode> list = new List <NetTool.Mode>(panel.m_Modes);
                    if (m_upgradeButtonTemplate != null && prefab != null && prefab.hasVariation && !list.Contains(NetTool.Mode.Upgrade))
                    {
                        UITabstrip toolMode = panel.component.Find <UITabstrip>("ToolMode");
                        if (toolMode != null)
                        {
                            list.Add(NetTool.Mode.Upgrade);
                            panel.m_Modes = list.ToArray();

                            toolMode.AddTab("Upgrade", m_upgradeButtonTemplate, false);

                            DebugUtils.Log("Upgrade button added.");
                        }
                    }

                    return;
                }
            }

            // No visible RoadsOptionPanel found. Put the main button in OptionsBar instead
            UIPanel optionBar = UIView.Find <UIPanel>("OptionsBar");

            if (optionBar == null)
            {
                DebugUtils.Log("OptionBar not found!");
                return;
            }
            m_toolOptionButton.transform.SetParent(optionBar.transform);
            m_buttonInOptionsBar = true;
        }
Exemplo n.º 14
0
        private void CreateTsdTabstrip(out UITabstrip strip, UIComponent parent, UiCategoryTab category)
        {
            TLMUtils.createUIElement(out strip, parent.transform, "TLMTabstrip", new Vector4(5, 0, parent.width - 10, 40));
            var effectiveOffsetY = strip.height;

            TLMUtils.createUIElement(out UITabContainer tabContainer, parent.transform, "TLMTabContainer", new Vector4(0, 40, parent.width, parent.height - 40));
            strip.tabPages = tabContainer;

            UIButton tabTemplate = CreateTabSubStripTemplate();

            UIComponent bodyContent = CreateContentTemplate(parent.width, parent.height - effectiveOffsetY - 10, category.isScrollable());

            foreach (var kv in TransportSystemDefinition.sysDefinitions)
            {
                Type[] components;
                Type   targetType;
                try
                {
                    targetType = KlyteUtils.GetImplementationForGenericType(category.getTabGenericContentImpl(), kv.Value);
                    components = new Type[] { targetType };
                }
                catch
                {
                    continue;
                }

                GameObject tab       = Instantiate(tabTemplate.gameObject);
                GameObject body      = Instantiate(bodyContent.gameObject);
                var        configIdx = kv.Key.toConfigIndex();
                String     name      = kv.Value.Name;
                TLMUtils.doLog($"configIdx = {configIdx};kv.Key = {kv.Key}; kv.Value= {kv.Value} ");
                String   bgIcon    = TLMConfigWarehouse.getBgIconForIndex(configIdx);
                String   fgIcon    = kv.Key.getTransportTypeIcon();
                UIButton tabButton = tab.GetComponent <UIButton>();
                tabButton.tooltip          = TLMConfigWarehouse.getNameForTransportType(configIdx);
                tabButton.hoveredBgSprite  = bgIcon;
                tabButton.focusedBgSprite  = bgIcon;
                tabButton.normalBgSprite   = bgIcon;
                tabButton.disabledBgSprite = bgIcon;
                tabButton.focusedColor     = Color.green;
                tabButton.hoveredColor     = new Color(0, 0.5f, 0f);
                tabButton.color            = Color.black;
                tabButton.disabledColor    = Color.gray;
                if (!string.IsNullOrEmpty(fgIcon))
                {
                    TLMUtils.createUIElement(out UIButton secSprite, tabButton.transform, "OverSprite", new Vector4(5, 5, 30, 30));
                    secSprite.normalFgSprite       = fgIcon;
                    secSprite.foregroundSpriteMode = UIForegroundSpriteMode.Scale;
                    secSprite.isInteractive        = false;
                    secSprite.disabledColor        = Color.black;
                }
                strip.AddTab(name, tab, body, components);
            }
        }
Exemplo n.º 15
0
        private void CreateTab<T>(string sprite, string localeKey, string objectName) where T : UICustomControl
        {
            UIButton tab = CreateTabTemplate();
            tab.normalFgSprite = sprite;
            tab.tooltip = Locale.Get(localeKey);

            KlyteMonoUtils.CreateUIElement(out UIPanel contentContainer, null);
            contentContainer.name = "Container";
            contentContainer.area = new Vector4(15, 0, MainPanel.width - 30, MainPanel.height - 70);
            m_stripMain.AddTab(objectName, tab.gameObject, contentContainer.gameObject);

            KlyteMonoUtils.CreateScrollPanel(contentContainer, out _, out _, contentContainer.width - 20, contentContainer.height - 5, new Vector3()).Self.gameObject.AddComponent<T>();
        }
Exemplo n.º 16
0
        protected UIButton SpawnSubEntry(UITabstrip strip, PositionData <ItemClass.Service> kService)
        {
            UIButton uIButton = strip.AddTab(kService.GetLocalizedName(), _templateButton, false);
            string   text     = kService.GetIconSpriteName();

            uIButton.normalFgSprite   = text;
            uIButton.focusedFgSprite  = text + "Focused";
            uIButton.hoveredFgSprite  = text + "Hovered";
            uIButton.pressedFgSprite  = text + "Pressed";
            uIButton.disabledFgSprite = text + "Disabled";
            uIButton.tooltip          = kService.GetLocalizedName();
            return(uIButton);
        }
Exemplo n.º 17
0
        public static void SetUpOptions(UIHelperBase helper)
        {
            UIHelper    actualHelper = helper as UIHelper;
            UIComponent container    = actualHelper.self as UIComponent;

            //Find the tab button in the KeyMappingPanel, so we can copy it
            UIButton tabTemplate = GameObject.Find("KeyMappingTabStrip").GetComponentInChildren <UIButton>();

            UITabstrip tabStrip = container.AddUIComponent <UITabstrip>();

            tabStrip.relativePosition = new Vector3(0, 0);
            tabStrip.size             = new Vector2(container.width - 20, 40);

            UITabContainer tabContainer = container.AddUIComponent <UITabContainer>();

            tabContainer.relativePosition = new Vector3(0, 40);
            tabContainer.size             = new Vector2(container.width - 20, container.height - tabStrip.height - 20);
            tabStrip.tabPages             = tabContainer;

            int currentIndex = 0;

            foreach (KeyValuePair <string, List <OptionsItemBase> > optionGroup in allOptions)
            {
                UIButton settingsButton = tabStrip.AddTab(optionGroup.Key, tabTemplate, true);
                settingsButton.textPadding = new RectOffset(10, 10, 10, 10);
                settingsButton.autoSize    = true;
                settingsButton.tooltip     = optionGroup.Key;
                tabStrip.selectedIndex     = currentIndex;
                TranslateTab(settingsButton, optionGroup.Key);

                CimTools.CimToolsHandler.CimToolBase.Translation.OnLanguageChanged += delegate(string languageIdentifier)
                {
                    TranslateTab(settingsButton, optionGroup.Key);
                };

                UIPanel currentPanel = tabStrip.tabContainer.components[currentIndex++] as UIPanel;
                currentPanel.autoLayout              = true;
                currentPanel.autoLayoutDirection     = LayoutDirection.Vertical;
                currentPanel.autoLayoutPadding.top   = 5;
                currentPanel.autoLayoutPadding.left  = 10;
                currentPanel.autoLayoutPadding.right = 10;

                UIHelper panelHelper = new UIHelper(currentPanel);

                CimTools.CimToolsHandler.CimToolBase.ModPanelOptions.CreateOptions(panelHelper, optionGroup.Value, optionGroup.Key, optionGroup.Key);
            }

            loadSettingsFromSaveFile();

            CimTools.CimToolsHandler.CimToolBase.ModPanelOptions.OnOptionPanelSaved += new OptionPanelSavedEventHandler(loadSettingsFromSaveFile);
        }
Exemplo n.º 18
0
        public void Start()
        {
            UITabstrip toolStrip = ToolsModifierControl.mainToolbar.GetComponentInChildren <UITabstrip>();

            openSVMPanelButton                       = toolStrip.AddTab();
            this.openSVMPanelButton.size             = new Vector2(49f, 49f);
            this.openSVMPanelButton.name             = "ServiceVehiclesManagerButton";
            this.openSVMPanelButton.tooltip          = "Service Vehicles Manager (v" + ServiceVehiclesManagerMod.version + ")";
            this.openSVMPanelButton.relativePosition = new Vector3(0f, 5f);
            toolStrip.AddTab("ServiceVehiclesManagerButton", this.openSVMPanelButton.gameObject, null, null);
            openSVMPanelButton.atlas           = taSVM;
            openSVMPanelButton.normalBgSprite  = "ServiceVehiclesManagerIconSmall";
            openSVMPanelButton.focusedFgSprite = "ToolbarIconGroup6Focused";
            openSVMPanelButton.hoveredFgSprite = "ToolbarIconGroup6Hovered";
            this.openSVMPanelButton.eventButtonStateChanged += delegate(UIComponent c, UIButton.ButtonState s)
            {
                if (s == UIButton.ButtonState.Focused)
                {
                    internal_OpenSVMPanel();
                }
                else
                {
                    internal_CloseSVMPanel();
                }
            };
            m_listPanel = SVMServiceBuildingDetailPanel.Get();

            SVMUtils.createUIElement(out buildingInfoParent, FindObjectOfType <UIView>().transform, "SVMBuildingInfoPanel", new Vector4(0, 0, 0, 1));

            buildingInfoParent.gameObject.AddComponent <SVMBuildingInfoPanel>();
            var         typeTarg  = typeof(Redirector <>);
            List <Type> instances = GetSubtypesRecursive(typeTarg);

            foreach (Type t in instances)
            {
                gameObject.AddComponent(t);
            }
        }
Exemplo n.º 19
0
        public override void Awake()
        {
            base.Awake();

            //setup tabstrip
            this.size                      = DEFAULT_TABSTRIP_SIZE;
            this.tabstrip                  = base.AddUIComponent <UITabstrip>();
            this.tabstrip.size             = DEFAULT_TABSTRIP_SIZE;
            this.tabstrip.relativePosition = new Vector3(0f, 0f);
            this.tabstrip.padding          = DEFAULT_TAB_PADDING;

            //setup first button
            UIButton _buttonItemwise = tabstrip.AddTab();

            _buttonItemwise.autoSize        = false;
            _buttonItemwise.playAudioEvents = true;
            UISimpleElems.ModifyToCustomButton(ref _buttonItemwise, DEFAULT_BUTTON_SIZE, new Vector3(0f, 0f), "PLT_ItemwiseZero", "", SpriteManager.atlasPLT);
            //setup second button
            UIButton _buttonSpacing = tabstrip.AddTab("Spacing", _buttonItemwise, false);

            UISimpleElems.ModifyToCustomButton(ref _buttonSpacing, DEFAULT_BUTTON_SIZE, DEFAULT_BUTTON_SIZE + DEFAULT_TAB_SPACING, "PLT_SpacingwiseZero", "", SpriteManager.atlasPLT);
            //finalize buttons
            _buttonItemwise.focusedBgSprite = "PLT_ItemwiseOneFocused";
            _buttonItemwise.tooltip         = "[PLT]: Itemwise Control\n\nPlace one item at a time along the curve.";
            _buttonSpacing.focusedBgSprite  = "PLT_SpacingwiseOneFocused";
            _buttonSpacing.tooltip          = "[PLT]: Spacingwise Control (Default)\n\nPlace items at discrete intervals.";

            //penultimately
            tabstrip.startSelectedIndex = (int)PropLineTool.controlMode;
            tabstrip.selectedIndex      = (int)PropLineTool.controlMode;

            //finally
            //event subscriptions
            this.tabstrip.eventSelectedIndexChanged += delegate(UIComponent c, int index)
            {
                PropLineTool.controlMode = (PropLineTool.ControlMode)index;
            };
        }
Exemplo n.º 20
0
        private static void addTab(UITabstrip strip, string name)
        {
            var tabButton = strip.AddTab(name);

            tabButton.normalBgSprite   = "SubBarButtonBase";
            tabButton.disabledBgSprite = "SubBarButtonBaseDisabled";
            tabButton.focusedBgSprite  = "SubBarButtonBaseFocused";
            tabButton.hoveredBgSprite  = "SubBarButtonBaseHovered";
            tabButton.pressedBgSprite  = "SubBarButtonBasePressed";

            tabButton.textPadding = new RectOffset(5, 10, 5, 10);
            tabButton.autoSize    = true;
            tabButton.tooltip     = name;
        }
        public static void AddOptionTab(UITabstrip tabStrip, string caption)
        {
            UIButton tabButton = tabStrip.AddTab(caption);

            tabButton.normalBgSprite   = "SubBarButtonBase";
            tabButton.disabledBgSprite = "SubBarButtonBaseDisabled";
            tabButton.focusedBgSprite  = "SubBarButtonBaseFocused";
            tabButton.hoveredBgSprite  = "SubBarButtonBaseHovered";
            tabButton.pressedBgSprite  = "SubBarButtonBasePressed";

            tabButton.textPadding = new RectOffset(10, 10, 10, 10);
            tabButton.autoSize    = true;
            tabButton.tooltip     = caption;
        }
        private UIHelperExtension createNewAsteriskTab(string title)
        {
            formatTabButton(m_StripAsteriskTab.AddTab(title));
            UIHelperExtension newTab = new UIHelperExtension(m_StripAsteriskTab.tabContainer.components[m_StripAsteriskTab.tabContainer.components.Count - 1]);

            ((UIPanel)newTab.self).autoLayoutDirection = LayoutDirection.Horizontal;
            ((UIPanel)newTab.self).autoLayoutPadding   = new RectOffset(2, 2, 0, 0);
            ((UIPanel)newTab.self).wrapLayout          = true;
            ((UIPanel)newTab.self).autoSize            = true;
            ((UIPanel)newTab.self).autoLayout          = true;
            ((UIPanel)newTab.self).width     = 680;
            ((UIPanel)newTab.self).isVisible = false;
            ((UIPanel)newTab.self).padding   = new RectOffset(0, 0, 0, 0);
            return(newTab);
        }
Exemplo n.º 23
0
        private void CreateTsdTabstrip()
        {
            UIButton tabTemplate = CreateTabSubStripTemplate();

            UIComponent bodyContent = CreateContentTemplate(m_stripMain.tabContainer.width, m_stripMain.tabContainer.height, false);

            foreach (KeyValuePair <TransportSystemDefinition, Func <ITLMSysDef> > kv in TransportSystemDefinition.SysDefinitions)
            {
                Type[] components;
                Type   targetType;
                try
                {
                    targetType = ReflectionUtils.GetImplementationForGenericType(typeof(UVMLinesPanel <>), kv.Value().GetType());
                    components = new Type[] { targetType };
                }
                catch
                {
                    continue;
                }
                TransportSystemDefinition tsd = kv.Key;
                GameObject tab       = Instantiate(tabTemplate.gameObject);
                GameObject body      = Instantiate(bodyContent.gameObject);
                var        configIdx = kv.Key.ToConfigIndex();
                string     name      = kv.Value().GetType().Name;
                TLMUtils.doLog($"configIdx = {configIdx};kv.Key = {kv.Key}; kv.Value= {kv.Value} ");
                string   bgIcon    = KlyteResourceLoader.GetDefaultSpriteNameFor(TLMUtils.GetLineIcon(0, configIdx, ref tsd), true);
                string   fgIcon    = kv.Key.GetTransportTypeIcon();
                UIButton tabButton = tab.GetComponent <UIButton>();
                tabButton.tooltip          = TLMConfigWarehouse.getNameForTransportType(configIdx);
                tabButton.hoveredBgSprite  = bgIcon;
                tabButton.focusedBgSprite  = bgIcon;
                tabButton.normalBgSprite   = bgIcon;
                tabButton.disabledBgSprite = bgIcon;
                tabButton.focusedColor     = Color.green;
                tabButton.hoveredColor     = new Color(0, 0.5f, 0f);
                tabButton.color            = Color.black;
                tabButton.disabledColor    = Color.gray;
                if (!string.IsNullOrEmpty(fgIcon))
                {
                    KlyteMonoUtils.CreateUIElement(out UIButton secSprite, tabButton.transform, "OverSprite", new Vector4(5, 5, 30, 30));
                    secSprite.normalFgSprite       = fgIcon;
                    secSprite.foregroundSpriteMode = UIForegroundSpriteMode.Scale;
                    secSprite.isInteractive        = false;
                    secSprite.disabledColor        = Color.black;
                }
                m_stripMain.AddTab(name, tab, body, components);
            }
        }
Exemplo n.º 24
0
        private static UIButton AddTab(UITabstrip tabStrip, string title)
        {
            UIButton tabButton = tabStrip.AddTab(title);

            tabButton.normalBgSprite   = "SubBarButtonBase";
            tabButton.disabledBgSprite = "SubBarButtonBaseDisabled";
            tabButton.focusedBgSprite  = "SubBarButtonBaseFocused";
            tabButton.hoveredBgSprite  = "SubBarButtonBaseHovered";
            tabButton.pressedBgSprite  = "SubBarButtonBasePressed";

            tabButton.textPadding = new RectOffset(10, 10, 10, 10);
            tabButton.autoSize    = true;
            tabButton.tooltip     = title;

            return(tabButton);
        }
Exemplo n.º 25
0
        private UIHelperBase AddTab(string name)
        {
            m_TabStrip.AddTab(name, m_TabTemplate, true);
            m_TabStrip.selectedIndex = m_TabIndex;

            // Get the current container and use the UIHelper to have something in there
            UIPanel stripRoot = m_TabStrip.tabContainer.components[m_TabIndex++] as UIPanel;

            stripRoot.autoLayout             = true;
            stripRoot.autoLayoutDirection    = LayoutDirection.Vertical;
            stripRoot.autoLayoutPadding.top  = 5;
            stripRoot.autoLayoutPadding.left = 10;
            UIHelper stripHelper = new UIHelper(stripRoot);

            return(stripHelper);
        }
Exemplo n.º 26
0
        private void Awake()
        {
            m_instance                 = this;
            controlContainer           = GetComponent <UIPanel>();
            controlContainer.area      = new Vector4(0, 0, 0, 0);
            controlContainer.isVisible = false;
            controlContainer.name      = "TLMPanel";

            TLMUtils.createUIElement(out UIPanel _mainPanel, GetComponent <UIPanel>().transform, "TLMListPanel", new Vector4(0, 0, controlContainer.parent.width, controlContainer.parent.height));
            mainPanel = _mainPanel;
            mainPanel.backgroundSprite = "MenuPanel2";

            CreateTitleBar();

            TLMUtils.createUIElement(out m_StripMain, mainPanel.transform, "TLMTabstrip", new Vector4(5, 40, mainPanel.width - 10, 40));

            TLMUtils.createUIElement(out UITabContainer tabContainer, mainPanel.transform, "TLMTabContainer", new Vector4(0, 80, mainPanel.width, mainPanel.height - 80));
            m_StripMain.tabPages = tabContainer;

            foreach (UiCategoryTab tab in Enum.GetValues(typeof(UiCategoryTab)))
            {
                UIButton superTab = CreateTabTemplate();
                superTab.normalFgSprite = tab.getTabFgSprite();
                superTab.tooltip        = tab.getTabName();

                TLMUtils.createUIElement(out UIPanel content, null);
                content.name = "Container";
                content.area = new Vector4(0, 40, mainPanel.width, mainPanel.height - 80);

                m_StripMain.AddTab("TLMTab" + tab, superTab.gameObject, content.gameObject);
                CreateTsdTabstrip(out UITabstrip subStrip, content, tab);
                m_StripsSubcategories[tab] = subStrip;
                if (m_StripsSubcategories[tab].tabCount > 0)
                {
                    m_StripsSubcategories[tab].selectedIndex = 0;
                    m_StripsSubcategories[tab].selectedIndex = -1;
                }
                else
                {
                    m_StripsSubcategories[tab].enabled = false;
                }
            }
            m_StripMain.selectedIndex              = 0;
            m_StripMain.selectedIndex              = -1;
            m_StripMain.eventSelectedIndexChanged += SetViewMode;
            m_StripMain.eventVisibilityChanged    += OnOpenClosePanel;
        }
Exemplo n.º 27
0
        /// <summary>Creates and sets up an instance of the <see cref="CitiesTabItem"/> class.</summary>
        /// <param name="tabStrip">The tab strip to use as parent for the new tab item.</param>
        /// <param name="id">The unique ID of the new tab item.</param>
        /// <returns>An instance of <see cref="CitiesTabItem"/> or null on failure.</returns>
        /// <exception cref="ArgumentNullException">Thrown when <paramref name="tabStrip"/> is null.</exception>
        /// <exception cref="ArgumentException">Thrown when <paramref name="id"/> is null or an empty string.</exception>
        public static CitiesTabItem Create(UITabstrip tabStrip, string id)
        {
            if (tabStrip == null)
            {
                throw new ArgumentNullException(nameof(tabStrip));
            }

            if (string.IsNullOrEmpty(id))
            {
                throw new ArgumentException("The tab item's id cannot be null or an empty string", nameof(id));
            }

            UIButton tabButton = tabStrip.AddTab();

            if (tabButton == null)
            {
                return(null);
            }

            tabButton.autoSize           = true;
            tabButton.textPadding.left   = 10;
            tabButton.textPadding.right  = 10;
            tabButton.textPadding.top    = 10;
            tabButton.textPadding.bottom = 6;
            tabButton.wordWrap           = false;
            tabButton.normalBgSprite     = "SubBarButtonBase";
            tabButton.disabledBgSprite   = "SubBarButtonBaseDisabled";
            tabButton.focusedBgSprite    = "SubBarButtonBaseFocused";
            tabButton.hoveredBgSprite    = "SubBarButtonBaseHovered";
            tabButton.pressedBgSprite    = "SubBarButtonBasePressed";

            var tabContainer = tabStrip.tabContainer.components[tabStrip.tabCount - 1] as UIPanel;

            if (tabContainer == null)
            {
                return(null);
            }

            tabContainer.padding.top              = 30;
            tabContainer.autoLayout               = true;
            tabContainer.autoLayoutDirection      = LayoutDirection.Vertical;
            tabContainer.autoLayoutPadding.bottom = 20;
            tabContainer.autoLayoutPadding.left   = 10;
            tabContainer.autoLayoutPadding.right  = 10;
            return(new CitiesTabItem(tabButton, new UIHelper(tabContainer), id));
        }
Exemplo n.º 28
0
        public void OnSettingsUI(UIHelperBase helper)
        {
            UIButton tabTemplate = Resources.FindObjectsOfTypeAll <OptionsKeymappingPanel>()[0]
                                   .GetComponentInChildren <UITabstrip>()
                                   .GetComponentInChildren <UIButton>();

            _optionsPanel            = ((UIHelper)helper).self as UIScrollablePanel;
            _optionsPanel.autoLayout = false;

            if (IsTAMInstalled)
            {
                UILabel label = _optionsPanel.AddUIComponent <UILabel>();
                label.text = "Transit Addons Mod (TAM) has been detected - Network Extensions have been disabled";
                return;
            }

            UITabstrip strip = _optionsPanel.AddUIComponent <UITabstrip>();

            strip.relativePosition = new Vector3(0, 0);
            strip.size             = new Vector2(744, 40);

            UITabContainer container = _optionsPanel.AddUIComponent <UITabContainer>();

            container.relativePosition = new Vector3(0, 40);
            container.size             = new Vector3(744, 713);
            strip.tabPages             = container;

            int tabIndex = 0;

            foreach (IModule module in Modules)
            {
                strip.AddTab(module.Name, tabTemplate, true);
                strip.selectedIndex = tabIndex;

                // Get the current container and use the UIHelper to have something in there
                UIPanel stripRoot = strip.tabContainer.components[tabIndex++] as UIPanel;
                stripRoot.autoLayout             = true;
                stripRoot.autoLayoutDirection    = LayoutDirection.Vertical;
                stripRoot.autoLayoutPadding.top  = 5;
                stripRoot.autoLayoutPadding.left = 10;
                UIHelper stripHelper = new UIHelper(stripRoot);

                module.OnSettingsUI(stripHelper);
            }
        }
Exemplo n.º 29
0
        private void Awake()
        {
            m_instance                       = this;
            m_controlContainer               = GetComponent <UIComponent>();
            m_controlContainer.name          = "SSPanel";
            m_controlContainer.isInteractive = false;

            var lateralListWidth = 180;


            KlyteUtils.createUIElement(out UIPanel _mainPanel, GetComponent <UIPanel>().transform, "SSListPanel", new Vector4(0, 0, m_controlContainer.width, m_controlContainer.height));
            MainPanel = _mainPanel;
            MainPanel.backgroundSprite = "MenuPanel2";



            CreateTitleBar();
            KlyteUtils.CreateScrollPanel(_mainPanel, out m_profileList, out UIScrollbar scrollbar, lateralListWidth, m_controlContainer.height - 110, new Vector3(10, 100));

            KlyteUtils.createUIElement(out m_tabstripCategories, MainPanel.transform, "SSTabstrip", new Vector4(lateralListWidth + 30, 50, MainPanel.width - 340, 40));

            KlyteUtils.createUIElement(out UITabContainer tabContainer, MainPanel.transform, "SSTabContainer", new Vector4(lateralListWidth + 30, 90, MainPanel.width - 350, MainPanel.height - 90));
            m_tabstripCategories.tabPages = tabContainer;

            UIButton tabTrees = CreateTabTemplate();

            KlyteUtils.createUIElement(out UIPanel containerTrees, null);
            containerTrees.area             = new Vector4(0, 0, tabContainer.width, tabContainer.height);
            containerTrees.backgroundSprite = "MainPanelInfo";
            containerTrees.color            = Color.gray;

            List <Type> tabs = KlyteUtils.GetSubtypesRecursive(typeof(SSDecorationTab <,>), GetType());

            foreach (var tab in tabs)
            {
                m_tabstripCategories.AddTab(tab.Name, tabTrees.gameObject, containerTrees.gameObject);
                var tabController = (SSDecorationTab)containerTrees.gameObject.AddComponent(tab);
                tabTrees.normalFgSprite     = tabController.TabIcon;
                tabTrees.tooltipLocaleID    = tabController.TabDescriptionLocale;
                tabTrees.isTooltipLocalized = true;
            }
            m_tabstripCategories.selectedIndex = -1;
        }
Exemplo n.º 30
0
        public static UIButton MakeTab(UITabstrip tabStrip, string txt, int width, UIPanel p, ColossalFramework.UI.MouseEventHandler eventClick)
        {
            UIButton tab = tabStrip.AddTab(txt, null, true);

            tab.name             = txt;
            tab.text             = txt;
            tab.size             = new Vector2(width, 22);
            tab.textScale        = 0.8f;
            tab.tabStrip         = true;
            tab.eventClick      += eventClick;
            tab.hoveredTextColor = new Color(1, 1, .45f, 1);
            tab.normalBgSprite   = "SubBarButtonBase";
            tab.hoveredBgSprite  = "SubBarButtonBaseHovered";
            tab.disabledBgSprite = "SubBarButtonBaseDisabled";
            tab.focusedBgSprite  = "SubBarButtonBaseFocused";
            tab.pressedBgSprite  = "SubBarButtonBasePressed";
            tab.objectUserData   = p;
            return(tab);
        }
Exemplo n.º 31
0
    private UIButton OwnSpawnButtonEntry(UITabstrip strip, string name, string category, bool isDefaultCategory, string localeID, string unlockText, string spriteBase, bool enabled, bool forceFillContainer)
    {
        Debug.Print("SpawnButtonEntry");
        System.Type type = System.Type.GetType(name + "Panel");
        type = typeof(SearchPanel);
        if (type != null && !type.IsSubclassOf(typeof(GeneratedScrollPanel)))
            type = (System.Type)null;
        UIButton uiButton;
        if (strip.childCount > GetObjectIndex(this)) {
            uiButton = strip.components[GetObjectIndex(this)] as UIButton;
        } else {
            GameObject asGameObject1 = UITemplateManager.GetAsGameObject("SubbarButtonTemplate");
            GameObject asGameObject2 = UITemplateManager.GetAsGameObject("SubbarPanelTemplate");
            uiButton = strip.AddTab(category, asGameObject1, asGameObject2, type) as UIButton;
        }
        uiButton.isEnabled = enabled;
        uiButton.gameObject.GetComponent<TutorialUITag>().tutorialTag = category;
        SearchPanel generatedScrollPanel = strip.GetComponentInContainer(uiButton, type) as SearchPanel;
        Debug.Print(generatedScrollPanel);

        if ((UnityEngine.Object)generatedScrollPanel != (UnityEngine.Object)null) {
            generatedScrollPanel.component.isInteractive = true;
            generatedScrollPanel.m_OptionsBar = this.m_OptionsBar;
            generatedScrollPanel.m_DefaultInfoTooltipAtlas = this.m_DefaultInfoTooltipAtlas;
            if (forceFillContainer || enabled) {
                generatedScrollPanel.category = !isDefaultCategory ? category : string.Empty;
                generatedScrollPanel.RefreshPanel();
            }
        }
        string str = spriteBase + category;
        uiButton.normalFgSprite = str;
        uiButton.focusedFgSprite = str + "Focused";
        uiButton.hoveredFgSprite = str + "Hovered";
        uiButton.pressedFgSprite = str + "Pressed";
        uiButton.disabledFgSprite = str + "Disabled";
        //if (!string.IsNullOrEmpty(localeID) && !string.IsNullOrEmpty(unlockText))
        //	uiButton.tooltip = Locale.Get(localeID, category) + " - " + unlockText;
        //else if (!string.IsNullOrEmpty(localeID))
        //	uiButton.tooltip = Locale.Get(localeID, category);
        IncObjectIndex(this);
        return uiButton;
    }
Exemplo n.º 32
0
        protected UIButton SpawnSubEntry(MainToolbar tb, UITabstrip strip, string name, string localeID, string unlockText, string spriteBase, bool enabled)
        {
            System.Type type = System.Type.GetType(name + "Group" + "Panel");
            type = typeof(SearchGroupPanel);
            if (type != null && !type.IsSubclassOf(typeof(GeneratedGroupPanel)))
                type = (System.Type)null;
            if (type == null)
                return (UIButton)null;
            UIButton button;
            GameObject asGameObject1 = UITemplateManager.GetAsGameObject("MainToolbarButtonTemplate");
            GameObject asGameObject2 = UITemplateManager.GetAsGameObject("ScrollableSubPanelTemplate");
            button = strip.AddTab(name, asGameObject1, asGameObject2, type) as UIButton;

            button.isEnabled = enabled;
            //button.gameObject.GetComponent<TutorialUITag>().tutorialTag = name;
            //GeneratedGroupPanel generatedGroupPanel = strip.tabContainer.Find<UIPanel>("SearchPanel").GetComponent<GeneratedGroupPanel>() as GeneratedGroupPanel;
            SearchGroupPanel generatedGroupPanel = strip.GetComponentInContainer(button, type) as SearchGroupPanel;

            generatedGroupPanel.enabled = true;
            if ((UnityEngine.Object)generatedGroupPanel != (UnityEngine.Object)null) {
                generatedGroupPanel.component.isInteractive = true;
                generatedGroupPanel.m_OptionsBar = this.GetOptionsBar(tb);
                generatedGroupPanel.m_DefaultInfoTooltipAtlas = this.GetDefaultInfoTooltipAtlas(tb);
                if (enabled) {
                    generatedGroupPanel.RefreshPanel();
                }
            }
            /*
            button.normalBgSprite = this.GetBackgroundSprite(button, spriteBase, name, "Normal");
            button.focusedBgSprite = this.GetBackgroundSprite(button, spriteBase, name, "Focused");
            button.hoveredBgSprite = this.GetBackgroundSprite(button, spriteBase, name, "Hovered");
            button.pressedBgSprite = this.GetBackgroundSprite(button, spriteBase, name, "Pressed");
            button.disabledBgSprite = this.GetBackgroundSprite(button, spriteBase, name, "Disabled");*/

            this.IncObjectIndex(tb);

            return button;
        }
Exemplo n.º 33
0
        void CreateView() {
            ModDebug.Log("Creating view");

            GameObject rootObject = new GameObject("ExtendedRoadUpgradePanel");
            tabstrip = rootObject.AddComponent<UITabstrip>();

            UIButton tabTemplate = (UIButton)builtinTabstrip.tabs[0];

            int spriteWidth = 31;
            int spriteHeight = 31;
            string[] spriteNames = {
                                           "ERUButtonBg", 
                                           "ERUButtonBgPressed", 
                                           "ERUButtonBgHovered", 
                                           "ERUIconTwoway", 
                                           "ERUIconTwowayPressed", 
                                           "ERUIconOneway", 
                                           "ERUIconOnewayPressed"
                                       };

            UITextureAtlas atlas = CreateTextureAtlas("sprites.png", "ExtendedRoadUpgradeUI", tabTemplate.atlas.material, spriteWidth, spriteHeight, spriteNames);

            List<UIButton> tabs = new List<UIButton>();
            tabs.Add(tabstrip.AddTab("", null, false));
            tabs.Add(tabstrip.AddTab("", null, false));

            foreach (UIButton tab in tabs) {
                tab.name = "ExtendedRoadUpgradeButton";
                tab.atlas = atlas;
                tab.size = new Vector2(spriteWidth, spriteHeight);
                tab.normalBgSprite = "ERUButtonBg";
                tab.disabledBgSprite = "ERUButtonBg";
                tab.hoveredBgSprite = "ERUButtonBgHovered";
                tab.pressedBgSprite = "ERUButtonBgPressed";
                tab.focusedBgSprite = "ERUButtonBgPressed";
                tab.playAudioEvents = true;
            }

            tabs[0].name = "ExtendedRoadUpgradeButtonTwoWay";
            tabs[0].tooltip = "Upgrade To Two-Way Road";
            tabs[0].normalFgSprite = tabs[0].disabledFgSprite = tabs[0].hoveredFgSprite = "ERUIconTwoway";
            tabs[0].pressedFgSprite = tabs[0].focusedFgSprite = "ERUIconTwowayPressed";

            tabs[1].name = "ExtendedRoadUpgradeButtonOneWay";
            tabs[1].tooltip = "Upgrade To One-Way Road";
            tabs[1].normalFgSprite = tabs[1].disabledFgSprite = tabs[1].hoveredFgSprite = "ERUIconOneway";
            tabs[1].pressedFgSprite = tabs[1].focusedFgSprite = "ERUIconOnewayPressed";


            roadsOptionPanel.AttachUIComponent(tabstrip.gameObject);
            tabstrip.relativePosition = new Vector3(169, 38);
            tabstrip.width = 80;
            tabstrip.selectedIndex = -1;
            tabstrip.padding = new RectOffset(0, 1, 0, 0);

            if (builtinModeChangedHandler == null) {
                builtinModeChangedHandler = (UIComponent component, int index) => {
                    if (!ignoreBuiltinTabstripEvents) {
                        if (selectedToolModeChanged != null) selectedToolModeChanged(ToolMode.None);
                    }
                };
            }

            builtinTabstrip.eventSelectedIndexChanged += builtinModeChangedHandler;

            // Setting selectedIndex needs to be delayed for some reason
            tabstrip.StartCoroutine(FinishCreatingView());
        }
Exemplo n.º 34
0
        public override void Awake()
        {
            base.Awake();

            Debug.Log("Begin UINetworkSkinsPanel.Awake");

            LoadSprites();

            this.backgroundSprite = "MenuPanel2";
            this.width = Width + 2 * Padding;
            //this.padding = new RectOffset(PADDING, 0, PADDING, 0);

            _titleBar = this.AddUIComponent<UIDragHandle>();
            _titleBar.name = "TitlePanel";
            _titleBar.width = this.width;
            _titleBar.height = TabHeight + PaddingTop;
            _titleBar.target = this;
            _titleBar.relativePosition = new Vector3(0, 0);

            // display a drag cursor sprite in the top right corner of the panel
            var dragSprite = _titleBar.AddUIComponent<UISprite>();
            dragSprite.atlas = SpriteUtilities.GetAtlas(Atlas);
            dragSprite.spriteName = "DragCursor";
            dragSprite.relativePosition = new Vector3(Width - 20, PaddingTop + 1);
            dragSprite.MakePixelPerfect();

            _tabstrip = _titleBar.AddUIComponent<UITabstrip>();
            _tabstrip.relativePosition = new Vector3(Padding, PaddingTop, 0);
            _tabstrip.width = Width;
            _tabstrip.height = TabHeight;
            _tabstrip.tabPages = this.AddUIComponent<UITabContainer>();
            _tabstrip.tabPages.width = this.width;
            _tabstrip.tabPages.height = PageHeight;
            _tabstrip.tabPages.relativePosition = new Vector3(0, _titleBar.height);
            _tabstrip.tabPages.padding = new RectOffset(PagesPadding, PagesPadding, PagesPadding, PagesPadding);
            _tabstrip.padding.right = 0;

            // Add 4 tabs and 4 pages
            var keyMappingTabstrip = GameObject.Find("KeyMappingTabStrip").GetComponent<UITabstrip>();
            var buttonTemplate = keyMappingTabstrip.GetComponentInChildren<UIButton>();

            _netTypePages = new UIPanel[NetUtil.NET_TYPE_NAMES.Length];

            for (var i = 0; i < NetUtil.NET_TYPE_NAMES.Length; i++)
            {
                var tab = _tabstrip.AddTab(NetUtil.NET_TYPE_NAMES[i], buttonTemplate, true);
                tab.textPadding.top = 8;
                tab.textPadding.bottom = 8;
                tab.textPadding.left = 10;
                tab.textPadding.right = 10;
                tab.autoSize = true;
                tab.textScale = .9f;
                tab.playAudioEvents = buttonTemplate.playAudioEvents;

                tab.pressedTextColor = new Color32(255, 255, 255, 255);
                tab.focusedTextColor = new Color32(255, 255, 255, 255);
                tab.focusedColor = new Color32(205, 205, 205, 255);
                tab.disabledTextColor = buttonTemplate.disabledTextColor;

                var page = _tabstrip.tabPages.components.Last() as UIPanel;
                page.autoLayoutDirection = LayoutDirection.Vertical;
                page.autoLayoutPadding = new RectOffset(0, 0, 0, Padding);
                page.autoLayout = true;
                page.isVisible = false;

                // TODO add scrolling + autofitting

                _netTypePages[i] = page;
            }

            this.FitChildren();

            _netToolWrapper = NetUtil.GenerateNetToolWrapper();
            if (_netToolWrapper == null) throw new Exception("NetworkSkins Error: NetToolWrapper is null!");

            // Add some example options
            GetPage(NetType.Ground).AddUIComponent<UILightOption>();
            //GetPage(NetType.Ground).AddUIComponent<UILightDistanceOption>();
            GetPage(NetType.Ground).AddUIComponent<UITreeOption>().LanePosition = LanePosition.Left;
            //GetPage(NetType.Ground).AddUIComponent<UITreeDistanceOption>().LanePosition = LanePosition.Left;
            GetPage(NetType.Ground).AddUIComponent<UITreeOption>().LanePosition = LanePosition.Middle;
            //GetPage(NetType.Ground).AddUIComponent<UITreeDistanceOption>().LanePosition = LanePosition.Middle;
            GetPage(NetType.Ground).AddUIComponent<UITreeOption>().LanePosition = LanePosition.Right;
            //GetPage(NetType.Ground).AddUIComponent<UITreeDistanceOption>().LanePosition = LanePosition.Right;

            GetPage(NetType.Elevated).AddUIComponent<UILightOption>();
            //GetPage(NetType.Elevated).AddUIComponent<UILightDistanceOption>();
            GetPage(NetType.Elevated).AddUIComponent<UIPillarOption>().PillarType = PillarType.BridgePillar;
            //GetPage(NetType.ELEVATED).AddUIComponent<UIPillarOption>().PillarType = PillarType.MIDDLE_PILLAR;

            GetPage(NetType.Bridge).AddUIComponent<UILightOption>();
            //GetPage(NetType.Bridge).AddUIComponent<UILightDistanceOption>();
            GetPage(NetType.Bridge).AddUIComponent<UIPillarOption>().PillarType = PillarType.BridgePillar;
            //GetPage(NetType.BRIDGE).AddUIComponent<UIPillarOption>().PillarType = PillarType.MIDDLE_PILLAR;
            //GetPage(NetType.BRIDGE).AddUIComponent<UIBridgeTypeOption>();

            _tabstrip.startSelectedIndex = (int)NetType.Ground;

            Debug.Log("End UINetworkSkinsPanel.Awake");
        }
#pragma warning disable 108,114
        protected UIButton SpawnButtonEntry(UITabstrip strip, string name, string category, bool isDefaultCategory,
#pragma warning restore 108,114
            string localeID, string unlockText, string spriteBase, bool enabled, bool forceFillContainer)
        {
            int objectIndex = (int)typeof(GeneratedGroupPanel).GetField("m_ObjectIndex", BindingFlags.Instance | BindingFlags.NonPublic).GetValue(this);

            // TAM Edit Start
            Type type = typeof(GeneratedScrollPanel)
                .Assembly
                .GetTypes()
                .FirstOrDefault(t => string.Equals(t.Name, name + "Panel", StringComparison.InvariantCultureIgnoreCase));
            // TAM Edit End

            if (type != null && !type.IsSubclassOf(typeof(GeneratedScrollPanel)))
            {
                type = null;
            }

            UIButton uIButton;
            if (strip.childCount > objectIndex)
            {
                uIButton = (strip.components[objectIndex] as UIButton);
            }
            else
            {
                GameObject asGameObject = UITemplateManager.GetAsGameObject(kSubbarButtonTemplate);
                GameObject asGameObject2 = UITemplateManager.GetAsGameObject(kSubbarPanelTemplate);
                uIButton = (strip.AddTab(category, asGameObject, asGameObject2, type) as UIButton);
            }

            uIButton.isEnabled = enabled;
            uIButton.gameObject.GetComponent<TutorialUITag>().tutorialTag = category;
            GeneratedScrollPanel generatedScrollPanel = strip.GetComponentInContainer(uIButton, type) as GeneratedScrollPanel;
            if (generatedScrollPanel != null)
            {
                generatedScrollPanel.component.isInteractive = true;
                generatedScrollPanel.m_OptionsBar = this.m_OptionsBar;
                generatedScrollPanel.m_DefaultInfoTooltipAtlas = this.m_DefaultInfoTooltipAtlas;
                if (forceFillContainer || enabled)
                {
                    generatedScrollPanel.category = ((!isDefaultCategory) ? category : string.Empty);
                    generatedScrollPanel.RefreshPanel();
                }
            }

            // TAM Edit Start
            var customAtlas = AtlasManager.instance.GetAtlas(category);
            if (customAtlas != null)
            {
                uIButton.atlas = customAtlas;
            }
            // TAM Edit End

            string text = spriteBase + category;
            uIButton.normalFgSprite = text;
            uIButton.focusedFgSprite = text + "Focused";
            uIButton.hoveredFgSprite = text + "Hovered";
            uIButton.pressedFgSprite = text + "Pressed";
            uIButton.disabledFgSprite = text + "Disabled";

            if (!string.IsNullOrEmpty(localeID) && !string.IsNullOrEmpty(unlockText))
            {
                uIButton.tooltip = Locale.Get(localeID, category) + " - " + unlockText;
            }
            else if (!string.IsNullOrEmpty(localeID))
            {
                uIButton.tooltip = Locale.Get(localeID, category);
            }

            typeof(GeneratedGroupPanel).GetField("m_ObjectIndex", BindingFlags.Instance | BindingFlags.NonPublic).SetValue(this, objectIndex + 1);
            return uIButton;
        }
        private static UIButton AddButton(Type type, UITabstrip strip, string category, string[] editorCategories, string tooltip, bool enabled)
        {
            if (GameObject.Find($"{category}Panel") != null)
            {
                return null;
            }

            var subbarButtonTemplate = UITemplateManager.GetAsGameObject("SubbarButtonTemplate");
            var subbarPanelTemplate = UITemplateManager.GetAsGameObject("SubbarPanelTemplate");

            var button = (UIButton)strip.AddTab(category, subbarButtonTemplate, subbarPanelTemplate, type);
            button.isEnabled = enabled;

            var generatedScrollPanel = (GeneratedScrollPanel)strip.GetComponentInContainer(button, type);
            if (generatedScrollPanel != null)
            {
                generatedScrollPanel.component.isInteractive = true;
                generatedScrollPanel.m_OptionsBar = ToolsModifierControl.mainToolbar.m_OptionsBar;
                generatedScrollPanel.m_DefaultInfoTooltipAtlas = ToolsModifierControl.mainToolbar.m_DefaultInfoTooltipAtlas;

                var panel = generatedScrollPanel as EditorPropsPanel;
                if (panel != null)
                {
                    panel.m_editorCategories = editorCategories;
                    panel.category = category;
                }

                if (enabled)
                {
                    generatedScrollPanel.RefreshPanel();
                }
            }

            button.tooltip = tooltip;
            return button;
        }