public void Awake()
 {
     strip = (UITabstrip)ToolsModifierControl.mainToolbar.component;
     strip.eventComponentAdded += (container, child) => UpdatePosition();
     strip.eventComponentRemoved += (container, child) => UpdatePosition();
     Options.eventAutoCentreChanged += (value) => UpdatePosition();
     UpdatePosition();
 }
 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;
 }
Example #3
0
        public static void CreateTabsComponent(out UITabstrip tabstrip, out UITabContainer tabContainer, Transform parentStrip, Transform parentContainer, string namePrefix, Vector4 areaTabstrip, Vector4 areaContainer)
        {
            KlyteMonoUtils.CreateUIElement(out tabstrip, parentStrip, $"{namePrefix}_Tabstrip", areaTabstrip);

            KlyteMonoUtils.CreateUIElement(out tabContainer, parentContainer, $"{namePrefix}_TabContainer", areaContainer);
            tabstrip.tabPages      = tabContainer;
            tabstrip.selectedIndex = 0;
            tabstrip.selectedIndex = -1;
        }
 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;
 }
Example #5
0
        public static UITabstrip CreateTabStrip(UIComponent parent)
        {
            UITabstrip tabstrip = parent.AddUIComponent <UITabstrip>();

            tabstrip.name         = "TabStrip";
            tabstrip.clipChildren = true;

            return(tabstrip);
        }
Example #6
0
        /// <summary>
        /// Adds growable options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        internal ComplaintOptions(UITabstrip tabStrip, int tabIndex)
        {
            // Add tab and helper.
            UIPanel  panel  = PanelUtils.AddTab(tabStrip, Translations.Translate("PRR_OPTION_COM"), tabIndex, true);
            UIHelper helper = new UIHelper(panel);

            // Add 'ignore low value complaint' checkboxes.
            UIHelperBase valueGroup      = helper.AddGroup(Translations.Translate("PRR_OPTION_VAL"));
            UICheckBox   noValueRicoPlop = (UICheckBox)valueGroup.AddCheckbox(Translations.Translate("PRR_OPTION_RPL"), ModSettings.noValueRicoPlop, isChecked =>
            {
                ModSettings.noValueRicoPlop = isChecked;
                SettingsUtils.SaveSettings();
            });

            valueGroup.AddCheckbox(Translations.Translate("PRR_OPTION_RCO"), ModSettings.noValueRicoGrow, isChecked =>
            {
                ModSettings.noValueRicoGrow = isChecked;
                SettingsUtils.SaveSettings();

                // If this is active, then the checkbox above also needs to be checked if it isn't already.
                if (isChecked && !noValueRicoPlop.isChecked)
                {
                    noValueRicoPlop.isChecked = true;
                }
            });
            valueGroup.AddCheckbox(Translations.Translate("PRR_OPTION_OTH"), ModSettings.noValueOther, isChecked =>
            {
                ModSettings.noValueOther = isChecked;
                SettingsUtils.SaveSettings();
            });

            // Add 'ignore too few services complaint' checkboxes.
            UIHelperBase servicesGroup      = helper.AddGroup(Translations.Translate("PRR_OPTION_SVC"));
            UICheckBox   noServicesRicoPlop = (UICheckBox)servicesGroup.AddCheckbox(Translations.Translate("PRR_OPTION_RPL"), ModSettings.noServicesRicoPlop, isChecked =>
            {
                ModSettings.noServicesRicoPlop = isChecked;
                SettingsUtils.SaveSettings();
            });

            servicesGroup.AddCheckbox(Translations.Translate("PRR_OPTION_RCO"), ModSettings.noServicesRicoGrow, isChecked =>
            {
                ModSettings.noServicesRicoGrow = isChecked;
                SettingsUtils.SaveSettings();

                // If this is active, then the checkbox above also needs to be checked if it isn't already.
                if (isChecked && !noServicesRicoPlop.isChecked)
                {
                    noServicesRicoPlop.isChecked = true;
                }
            });
            servicesGroup.AddCheckbox(Translations.Translate("PRR_OPTION_OTH"), ModSettings.noServicesOther, isChecked =>
            {
                ModSettings.noServicesOther = isChecked;
                SettingsUtils.SaveSettings();
            });
        }
Example #7
0
        private IEnumerator CreateButtonCoroutine(UITabstrip tabstrip)
        {
            // This will delay the execution of this coroutine.
            yield return(null);

            if (CreateButton(null))
            {
                tabstrip.eventSelectedIndexChanged -= mainToolStrip_eventSelectedIndexChanged;
            }
        }
Example #8
0
        private static T CreateTabInternal <T>(this UITabstrip stripMain, string sprite, string text, string objectName, bool scroll = true, UITextureAtlas textureAtlas = null, Vector2?nullableSize = null, bool isHorizontal = true) where T : UICustomControl
        {
            GameObject go = CreateTabInternal(stripMain, sprite, text, objectName, scroll, textureAtlas, nullableSize, isHorizontal);

            if (typeof(T) != typeof(UICustomControl))
            {
                return(go.AddComponent <T>());
            }
            return(null);
        }
 private void AddMainToolbarProps(UITabstrip strip)
 {
     base.SpawnSubEntry(strip, "PropsBillboards", "DECORATIONEDITOR_TOOL", null, "ToolbarIcon", true);
     base.SpawnSubEntry(strip, "PropsSpecialBillboards", "DECORATIONEDITOR_TOOL", null, "ToolbarIcon", true);
     base.SpawnSubEntry(strip, "PropsIndustrial", "DECORATIONEDITOR_TOOL", null, "ToolbarIcon", true);
     base.SpawnSubEntry(strip, "PropsParks", "DECORATIONEDITOR_TOOL", null, "ToolbarIcon", true);
     base.SpawnSubEntry(strip, "PropsCommon", "DECORATIONEDITOR_TOOL", null, "ToolbarIcon", true);
     base.SpawnSubEntry(strip, "PropsResidential", "DECORATIONEDITOR_TOOL", null, "ToolbarIcon", true);
     base.SpawnSubEntry(strip, "PropsMarkers", "DECORATIONEDITOR_TOOL", null, "ToolbarIcon", true);
 }
        public bool CreateButtons(UIPanel uiPanel)
        {
            if (Object.op_Equality((Object)uiPanel, (Object)null))
            {
                uiPanel = UIUtils.Find <UIPanel>("RoadsOptionPanel(RoadsPanel)");
            }
            if (Object.op_Equality((Object)uiPanel, (Object)null))
            {
                Logger.Warning("Could not find RoadsOptionPanel");
                return(false);
            }
            this.roadsOptionPanel = uiPanel;
            this.builtinTabstrip  = (UITabstrip)((UIComponent)this.roadsOptionPanel).Find <UITabstrip>("ToolMode");
            this.RemoveButtons(new string[2]
            {
                "ZoningToggle",
                "ZoningUpdateToggle"
            });
            this.roadsOptionPanel.get_atlas().get_material();
            UIMultiStateButton button = UIUtils.AddToggle((UIComponent)this.roadsOptionPanel, "ZoningToggle", "togglezoning_icon.png", -38, 38, 36, 36, DeactivatableButtonWrapper.iconNames);

            this.TZWrapper = new DeactivatableButtonWrapper(button, "Toggle zoning\nRight click reset default", "Default zoning set\nRight click enable toggle");
            // ISSUE: method pointer
            this.TZWrapper.AddEventActiveStateIndexChanged(new PropertyChangedEventHandler <int>((object)this, __methodptr(handleActiveStateIndexChanged)));
            UIPanel uiPanel1 = UIUtils.Find <UIPanel>("NoPillarsPanel");

            if (Object.op_Inequality((Object)uiPanel1, (Object)null))
            {
                Logger.Info("NoPillarsPanel found");
                using (IEnumerator <UIComponent> enumerator = ((IEnumerable <UIComponent>)((UIComponent)uiPanel1).get_components()).GetEnumerator())
                {
                    while (((IEnumerator)enumerator).MoveNext())
                    {
                        UIDropDown current = enumerator.Current as UIDropDown;
                        Logger.Info("dropDown != null" + Object.op_Inequality((Object)current, (Object)null).ToString());
                        if (Object.op_Inequality((Object)current, (Object)null))
                        {
                            Logger.Info("dropDown.tooltip: '" + ((UIComponent)current).get_tooltip() + "'");
                        }
                        if (Object.op_Inequality((Object)current, (Object)null) && ((UIComponent)current).get_tooltip().Equals("Change zoning/collision mode"))
                        {
                            this.noPillarsDropDown = current;
                            // ISSUE: method pointer
                            current.add_eventSelectedIndexChanged(new PropertyChangedEventHandler <int>((object)this, __methodptr(\u003CCreateButtons\u003Eb__19_0)));
                        }
                    }
                }
            }
            Logger.Debug(string.Concat((object)OptionsWrapper.ToggleState));
            button.set_activeStateIndex((int)OptionsWrapper.ToggleState % 2);
            this.TZWrapper.active = OptionsWrapper.ToggleState != ToggleStates.deactivated;
            this.UpdateVisible(OptionsWrapper.Options.ToggleVisible);
            this.CreateUpdateButtons();
            return(true);
        }
        public static UIButton SpawnSubEntry(UITabstrip strip, string name, string localeID, string unlockText, string spriteBase, bool enabled,
            UIComponent m_OptionsBar, UITextureAtlas m_DefaultInfoTooltipAtlas)
        {
            if (strip.Find<UIButton>(name) != null)
            {
                return null;
            }

            Type type1 = Util.FindType(name + "Group" + "Panel");
            if (type1 != null && !type1.IsSubclassOf(typeof(GeneratedGroupPanel)))
                type1 = (Type)null;
            if (type1 == null)
                return (UIButton)null;
            UIButton button;

            GameObject asGameObject1 = UITemplateManager.GetAsGameObject(kMainToolbarButtonTemplate);
            GameObject asGameObject2 = UITemplateManager.GetAsGameObject(kScrollableSubPanelTemplate);
            UITabstrip uiTabstrip = strip;
            string name1 = name;
            GameObject strip1 = asGameObject1;
            GameObject page = asGameObject2;
            Type[] typeArray = new Type[1];
            int index = 0;
            Type type2 = type1;
            typeArray[index] = type2;
            button = uiTabstrip.AddTab(name1, strip1, page, typeArray) as UIButton;

            button.isEnabled = enabled;
            button.gameObject.GetComponent<TutorialUITag>().tutorialTag = name;
            GeneratedGroupPanel generatedGroupPanel = GameObject.FindObjectOfType(type1) as GeneratedGroupPanel;
            if ((Object)generatedGroupPanel != (Object)null)
            {
                generatedGroupPanel.component.isInteractive = true;
                generatedGroupPanel.m_OptionsBar = m_OptionsBar;
                generatedGroupPanel.m_DefaultInfoTooltipAtlas = m_DefaultInfoTooltipAtlas;
                if (enabled)
                    generatedGroupPanel.RefreshPanel();
            }
            button.normalBgSprite = GetBackgroundSprite(button, spriteBase, name, "Normal");
            button.focusedBgSprite = GetBackgroundSprite(button, spriteBase, name, "Focused");
            button.hoveredBgSprite = GetBackgroundSprite(button, spriteBase, name, "Hovered");
            button.pressedBgSprite = GetBackgroundSprite(button, spriteBase, name, "Pressed");
            button.disabledBgSprite = GetBackgroundSprite(button, spriteBase, name, "Disabled");
            string str = spriteBase + name;
            button.normalFgSprite = str;
            button.focusedFgSprite = str + "Focused";
            button.hoveredFgSprite = str + "Hovered";
            button.pressedFgSprite = str + "Pressed";
            button.disabledFgSprite = str + "Disabled";
            if (unlockText != null)
                button.tooltip = Locale.Get(localeID, name) + " - " + unlockText;
            else
                button.tooltip = Locale.Get(localeID, name);
            return button;
        }
Example #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));
        }
Example #13
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);
            }
        }
Example #14
0
        /// <summary>
        /// Creates the panel object in-game and displays it.
        /// </summary>
        private static void Create()
        {
            try
            {
                Logging.KeyMessage("creating options panels");

                // We're now visible - create our gameobject, and give it a unique name for easy finding with ModTools.
                optionsGameObject = new GameObject("PloppableRICOOptionsPanel");

                // Attach to game options panel.
                optionsGameObject.transform.parent = optionsPanel.transform;

                // Create a base panel attached to our game object, perfectly overlaying the game options panel.
                UIPanel basePanel = optionsGameObject.AddComponent <UIPanel>();
                basePanel.width        = optionsPanel.width - 10f;
                basePanel.height       = 725f;
                basePanel.clipChildren = false;

                // Needed to ensure position is consistent if we regenerate after initial opening (e.g. on language change).
                basePanel.relativePosition = new Vector2(10f, 10f);

                // Add tabstrip.
                UITabstrip tabStrip = basePanel.AddUIComponent <UITabstrip>();
                tabStrip.relativePosition = new Vector3(0, 0);
                tabStrip.width            = basePanel.width;
                tabStrip.height           = basePanel.height;
                tabStrip.clipChildren     = false;

                // Tab container (the panels underneath each tab).
                UITabContainer tabContainer = basePanel.AddUIComponent <UITabContainer>();
                tabContainer.relativePosition = new Vector3(0, 30f);
                tabContainer.width            = tabStrip.width;
                tabContainer.height           = tabStrip.height;
                tabContainer.clipChildren     = false;
                tabStrip.tabPages             = tabContainer;

                // Add tabs and panels.
                new ModOptions(tabStrip, 0);
                new GrowableOptions(tabStrip, 1);
                new PloppableOptions(tabStrip, 2);
                new ComplaintOptions(tabStrip, 3);

                // Change tab size and text scale (to fit them all in...).
                foreach (UIButton button in tabStrip.components)
                {
                    button.textScale = 0.8f;
                    button.width     = 175f;
                }
            }
            catch (Exception e)
            {
                Logging.LogException(e, "exception creating options panel");
            }
        }
        /// <summary>
        /// Creates a click handler delegate that opens the service menu with the specified index.
        /// </summary>
        /// <param name="menuIndex">The service menu index to open on click.</param>
        /// <returns>The created click handler delegate.</returns>
        private MouseEventHandler CreateServiceMenuClickHandler(int menuIndex)
        {
            return(delegate(UIComponent component, UIMouseEventParameter eventParam) {
                UITabstrip mainToolstrip = this.uiParent.FindUIComponent <UITabstrip>("MainToolstrip");

                if (mainToolstrip != null)
                {
                    mainToolstrip.selectedIndex = menuIndex;
                }
            });
        }
Example #16
0
        /// <summary>
        /// Constructor - adds default options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        internal GoodsPanelBase(UITabstrip tabStrip, int tabIndex) : base(tabStrip, tabIndex)
        {
            // Add title.
            float currentY = PanelUtils.TitleLabel(panel, TitleKey);

            // Add menus.
            currentY = SetUpMenus(panel, currentY);

            // Add buttons- add extra space.
            FooterButtons(currentY + Margin);
        }
Example #17
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;
        }
        public void DestroyView() {
            if (tabstrip != null) {
                if (builtinTabstrip != null) {
                    builtinTabstrip.eventSelectedIndexChanged -= builtinModeChangedHandler;
                }

                UIView.Destroy(tabstrip);
                tabstrip = null;
            }
            isVisible = false;
        }
Example #19
0
 private void AddPropsPanels(UITabstrip tabstrip, EditorProps[] props)
 {
     foreach (EditorProps prop in props)
     {
         UIButton button = this.AddButton(typeof(EditorPropsPanel), tabstrip, prop.m_category, prop.m_categories, prop.m_tooltip, true);
         if (button == null)
         {
             continue;
         }
         this.SetButtonSprites(button, prop.m_icon, "SubBarButtonBase");
     }
 }
        /// <summary>
        /// Creates the panel object in-game and displays it.
        /// </summary>
        private static void Create()
        {
            try
            {
                // We're now visible - create our gameobject, and give it a unique name for easy finding with ModTools.
                optionsGameObject = new GameObject("RealPopOptionsPanel");

                // Attach to game options panel.
                optionsGameObject.transform.parent = optionsPanel.transform;

                // Create a base panel attached to our game object, perfectly overlaying the game options panel.
                UIPanel basePanel = optionsGameObject.AddComponent <UIPanel>();
                basePanel.absolutePosition = optionsPanel.absolutePosition;
                basePanel.width            = optionsPanel.width;
                basePanel.height           = 735f;
                basePanel.clipChildren     = false;

                // Add tabstrip.
                UITabstrip tabStrip = basePanel.AddUIComponent <UITabstrip>();
                tabStrip.relativePosition = new Vector3(0, 0);
                tabStrip.width            = basePanel.width;
                tabStrip.height           = basePanel.height;
                tabStrip.clipChildren     = false;

                // Tab container (the panels underneath each tab).
                UITabContainer tabContainer = basePanel.AddUIComponent <UITabContainer>();
                tabContainer.relativePosition = new Vector3(0, 30f);
                tabContainer.width            = tabStrip.width;
                tabContainer.height           = tabStrip.height;
                tabContainer.clipChildren     = false;
                tabStrip.tabPages             = tabContainer;

                // Initialize data.
                DataUtils.Setup();

                // Add tabs and panels.
                new ModOptionsPanel(tabStrip, 0);
                new CalculationsPanel(tabStrip, 1);
                new EducationPanel(tabStrip, 2);
                new CrimePanel(tabStrip, 3);

                /*// Change tab size and text scale (to fit them all in...).
                 * foreach (UIButton button in tabStrip.components)
                 * {
                 *  button.textScale = 0.8f;
                 *  button.width = 100f;
                 * }*/
            }
            catch (Exception e)
            {
                Logging.LogException(e, "exception creating options panel");
            }
        }
        private void InitSubTabstrip()
        {
            TLMUtils.doLog("INIT TLM_TABS");
            m_StripAsteriskTab        = m_prefixSelectorPanel.self.AddUIComponent <UITabstrip>();
            m_StripAsteriskTab.width  = 840;
            m_StripAsteriskTab.height = 50;

            m_StripAsteriskTab.tabPages = m_prefixSelectorPanel.self.AddUIComponent <UITabContainer>();

            m_StripAsteriskTab.tabPages.width  = 840;
            m_StripAsteriskTab.tabPages.height = 630;
        }
Example #22
0
        public static void MakeSettings(UIHelperBase helper)
        {
            LoadSetting();
            UIHelper    actualHelper = helper as UIHelper;
            UIComponent container    = actualHelper.self as UIComponent;

            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 tabIndex = 0;

            // Lane_ShortCut

            AddOptionTab(tabStrip, Localization.Get("BASIC_SETTING"));
            tabStrip.selectedIndex = tabIndex;

            UIPanel currentPanel = tabStrip.tabContainer.components[tabIndex] 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);

            UIHelperBase group = panelHelper.AddGroup(Localization.Get("BASIC_SETTING"));

            group.AddCheckbox(Localization.Get("SHOW_LACK_OF_RESOURCE"), RealCity.debugMode, (index) => debugModeEnable(index));
            group.AddCheckbox(Localization.Get("REDUCE_CARGO_ENABLE"), RealCity.reduceVehicle, (index) => reduceVehicleEnable(index));
            group.AddCheckbox(Localization.Get("NO_PASSENGERCAR"), RealCity.noPassengerCar, (index) => noPassengerCarEnable(index));
            group.AddCheckbox(Localization.Get("ENABLE_RANDOM_EVENT"), RealCity.randomEvent, (index) => randomEventEnable(index));
            group.AddButton(Localization.Get("RESET_VALUE"), Loader.InitData);

            if (Loader.isTransportLinesManagerRunning)
            {
                UIHelperBase group1 = panelHelper.AddGroup(Localization.Get("TLMRUNNING"));
            }
            else
            {
                UIHelperBase group1 = panelHelper.AddGroup(Localization.Get("TLMNOTRUNNING"));
            }

            SaveSetting();
        }
Example #23
0
        public void SetupControls()
        {
            //  Title Bar:
            m_title       = AddUIComponent <UIMainTitleBar>();
            m_title.title = "American RoadSigns " + Mod.version;

            //  Tabs:
            panelTabs                  = AddUIComponent <UITabstrip>();
            panelTabs.size             = new Vector2(UIUtils.c_modPanelInnerWidth, UIUtils.c_tabButtonHeight);
            panelTabs.relativePosition = new Vector2(UIUtils.c_spacing, UIUtils.c_titleBarHeight + UIUtils.c_spacing);

            //  Tab Buttons:
            //  Road signs:
            roadSignsButton           = UIUtils.CreateTab(panelTabs, "Road signs", true);
            roadSignsButton.tooltip   = "";
            roadSignsButton.width     = UIUtils.c_tabButtonWidth;
            roadSignsButton.height    = UIUtils.c_tabButtonHeight;
            roadSignsButton.textScale = 0.9f;
            //  Roadside props:
            roadPropsButton           = UIUtils.CreateTab(panelTabs, "Road props");
            roadPropsButton.tooltip   = "";
            roadPropsButton.width     = UIUtils.c_tabButtonWidth;
            roadPropsButton.height    = UIUtils.c_tabButtonHeight;
            roadPropsButton.textScale = 0.9f;
            //  Tab Button Events:
            roadSignsButton.eventClick += (c, e) => TabClicked(c, e);
            roadPropsButton.eventClick += (c, e) => TabClicked(c, e);

            //  Main Panel:
            UIPanel body = AddUIComponent <UIPanel>();

            body.width  = UIUtils.c_modPanelInnerWidth;
            body.height = UIUtils.c_modPanelInnerHeight;
            //  ScrollRect
            body.relativePosition = new Vector3(5, 36 + 28 + 5);

            //  Section Panels:
            //  Road signs Panel:
            roadSignsPanel                  = body.AddUIComponent <UIRoadSignsPanel>();
            roadSignsPanel.name             = "roadSignsPanel";
            roadSignsPanel.width            = UIUtils.c_modPanelInnerWidth;
            roadSignsPanel.height           = UIUtils.c_modPanelInnerHeight;
            roadSignsPanel.relativePosition = Vector3.zero;
            roadSignsPanel.isVisible        = true;
            //  Roadside props Panel:
            roadPropsPanel                  = body.AddUIComponent <UIRoadPropsPanel>();
            roadPropsPanel.name             = "roadPropsPanel";
            roadPropsPanel.width            = UIUtils.c_modPanelInnerWidth;
            roadPropsPanel.height           = UIUtils.c_modPanelInnerHeight;
            roadPropsPanel.relativePosition = Vector3.zero;
            roadPropsPanel.isVisible        = false;
        }
        private IEnumerator <object> GetRoadOptionsPanel(UITabstrip tabstrip)
        {
            yield return((object)null);

            UIPanel roadsOptionsPanel = this.getRoadsOptionsPanel();

            if (Object.op_Inequality((Object)roadsOptionsPanel, (Object)null))
            {
                // ISSUE: method pointer
                tabstrip.remove_eventSelectedIndexChanged(new PropertyChangedEventHandler <int>((object)this, __methodptr(mainToolStrip_eventSelectedIndexChanged)));
                this.onWaitComplete(roadsOptionsPanel);
            }
        }
Example #25
0
        public override void Awake()
        {
            title        = AddUIComponent <UILabel>();
            dragHandle   = AddUIComponent <UIDragHandle>();
            tabStrip     = AddUIComponent <UITabstrip>();
            tabContainer = AddUIComponent <UITabContainer>();
            closeButton  = AddUIComponent <UIButton>();

            initPanel    = tabContainer.AddUIComponent <TerrainUIInitPanel>();
            terrainPanel = tabContainer.AddUIComponent <TerrainUITerrainPanel>();
            resPanel     = tabContainer.AddUIComponent <TerrainUIResourcePanel>();
            treePanel    = tabContainer.AddUIComponent <TerrainUITreePanel>();
        }
Example #26
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);
        }
Example #27
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);
        }
Example #28
0
        public void SetupControls()
        {
            //  Title Bar:
            m_title       = AddUIComponent <UIMainTitleBar>();
            m_title.title = "American RoadSigns " + Mod.version;

            //  Tabs:
            panelTabs = AddUIComponent <UITabstrip>();
            panelTabs.relativePosition = new Vector2(10, AmericanRoadsignsTool.TITLE_HEIGHT + AmericanRoadsignsTool.SPACING);
            panelTabs.size             = new Vector2(AmericanRoadsignsTool.WIDTH - (3 * AmericanRoadsignsTool.SPACING), AmericanRoadsignsTool.TABS_HEIGHT);

            //  Tab Buttons:
            //  Road signs:
            roadSignsButton           = UIUtils.CreateTab(panelTabs, "Road signs", true);
            roadSignsButton.tooltip   = "";
            roadSignsButton.textScale = 0.8f;
            roadSignsButton.width     = 130f;
            //  Roadside props:
            roadPropsButton           = UIUtils.CreateTab(panelTabs, "Road props");
            roadPropsButton.tooltip   = "";
            roadPropsButton.textScale = 0.8f;
            roadPropsButton.width     = 130f;
            //  Tab Button Events:
            roadSignsButton.eventClick += (c, e) => TabClicked(c, e);
            roadPropsButton.eventClick += (c, e) => TabClicked(c, e);

            //  Main Panel:
            UIPanel body = AddUIComponent <UIPanel>();

            body.width  = AmericanRoadsignsTool.WIDTH;
            body.height = AmericanRoadsignsTool.HEIGHT;
            //  ScrollRect
            body.relativePosition = new Vector3(5, 36 + 28 + 5);

            //  Section Panels:
            //  Road signs Panel:
            roadSignsPanel                  = body.AddUIComponent <UIRoadSignsPanel>();
            roadSignsPanel.name             = "roadSignsPanel";
            roadSignsPanel.width            = AmericanRoadsignsTool.WIDTH - (3 * AmericanRoadsignsTool.SPACING);
            roadSignsPanel.height           = AmericanRoadsignsTool.HEIGHT;
            roadSignsPanel.relativePosition = new Vector3(5, 0);
            roadSignsPanel.isVisible        = true;
            //  Roadside props Panel:
            roadPropsPanel                  = body.AddUIComponent <UIRoadPropsPanel>();
            roadPropsPanel.name             = "roadPropsPanel";
            roadPropsPanel.width            = AmericanRoadsignsTool.WIDTH - 3 * AmericanRoadsignsTool.SPACING;
            roadPropsPanel.height           = AmericanRoadsignsTool.HEIGHT;
            roadPropsPanel.relativePosition = new Vector3(5, 0);
            roadPropsPanel.isVisible        = false;
        }
Example #29
0
        /// <summary>
        /// Creates the panel object in-game and displays it.
        /// </summary>
        private static void Create()
        {
            try
            {
                // Load settings.
                OptionsPanel.settings = Configuration <SettingsFile> .Load();

                // We're now visible - create our gameobject, and give it a unique name for easy finding with ModTools.
                optionsGameObject = new GameObject("RealPopOptionsPanel");

                // Attach to game options panel.
                optionsGameObject.transform.parent = optionsPanel.transform;

                // Create a base panel attached to our game object, perfectly overlaying the game options panel.
                UIPanel basePanel = optionsGameObject.AddComponent <UIPanel>();
                basePanel.absolutePosition = optionsPanel.absolutePosition;
                basePanel.size             = optionsPanel.size;

                // Add tabstrip.
                UITabstrip tabStrip = basePanel.AddUIComponent <UITabstrip>();
                tabStrip.relativePosition = new Vector3(0, 0);
                tabStrip.size             = new Vector2(744, 713);

                // Tab container (the panels underneath each tab).
                UITabContainer tabContainer = basePanel.AddUIComponent <UITabContainer>();
                tabContainer.relativePosition = new Vector3(0, 40);
                tabContainer.size             = new Vector3(744, 713);
                tabStrip.tabPages             = tabContainer;

                // Add tabs and panels.
                new CalculationOptions(tabStrip, 0);
                new SpeedOptions(tabStrip, 1);
                new DeathOptions(tabStrip, 2);
                new HealthOptions(tabStrip, 3);
                new TransportOptions(tabStrip, 4);
                new ImmigrationOptions(tabStrip, 5);
                new ModOptions(tabStrip, 6);

                // Change tab size and text scale (to fit them all in...).
                foreach (UIButton button in tabStrip.components)
                {
                    button.textScale = 0.8f;
                    button.width     = 100f;
                }
            }
            catch (Exception e)
            {
                Logging.LogException(e, "exception creating options panel");
            }
        }
Example #30
0
        public void DestroyView()
        {
            if (tabstrip != null)
            {
                if (builtinTabstrip != null)
                {
                    builtinTabstrip.eventSelectedIndexChanged -= builtinModeChangedHandler;
                }

                UIView.Destroy(tabstrip);
                tabstrip = null;
            }
            isVisible = false;
        }
        /// <summary>
        /// Creates the panel object in-game and displays it.
        /// </summary>
        private static void Create()
        {
            try
            {
                Logging.KeyMessage("creating options panels");

                // We're now visible - create our gameobject, and give it a unique name for easy finding with ModTools.
                optionsGameObject = new GameObject("PloppableRICOOptionsPanel");

                // Attach to game options panel.
                optionsGameObject.transform.parent = optionsPanel.transform;

                // Create a base panel attached to our game object, perfectly overlaying the game options panel.
                UIPanel basePanel = optionsGameObject.AddComponent <UIPanel>();
                basePanel.absolutePosition = optionsPanel.absolutePosition;
                basePanel.size             = optionsPanel.size;

                // Add tabstrip.
                UITabstrip tabStrip = basePanel.AddUIComponent <UITabstrip>();
                tabStrip.relativePosition = new Vector3(0, 0);
                tabStrip.size             = new Vector2(744, 713);

                // Tab container (the panels underneath each tab).
                UITabContainer tabContainer = basePanel.AddUIComponent <UITabContainer>();
                tabContainer.relativePosition = new Vector3(0, 40);
                tabContainer.size             = new Vector3(744, 713);
                tabStrip.tabPages             = tabContainer;

                // Add tabs and panels.
                Logging.KeyMessage("adding GrowableOptions");
                new GrowableOptions(tabStrip, 0);
                Logging.KeyMessage("adding PloppableOptions");
                new PloppableOptions(tabStrip, 1);
                Logging.KeyMessage("adding ComplaintOptions");
                new ComplaintOptions(tabStrip, 2);
                Logging.KeyMessage("adding ModOptions");
                new ModOptions(tabStrip, 3);

                // Change tab size and text scale (to fit them all in...).
                foreach (UIButton button in tabStrip.components)
                {
                    button.textScale = 0.8f;
                    button.width     = 175f;
                }
            }
            catch (Exception e)
            {
                Logging.LogException(e, "exception creating options panel");
            }
        }
Example #32
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;
        }
Example #34
0
        private UIButton[] AllButtons(UITabstrip s)
        {
            List <UIButton> buttons = new List <UIButton>();

            foreach (UIComponent component in s.components)
            {
                if (component != null && component is UIButton)
                {
                    UIButton button = (UIButton)component;
                    buttons.Add(button);
                }
            }
            return(buttons.ToArray());
        }
        /// <summary>
        /// Adds editing options tab to tabstrip.
        /// </summary>
        /// <param name="tabStrip">Tab strip to add to</param>
        /// <param name="tabIndex">Index number of tab</param>
        internal FloorPanel(UITabstrip tabStrip, int tabIndex) : base(tabStrip, tabIndex)
        {
            // Add title.
            float currentY = PanelUtils.TitleLabel(panel, TabTooltipKey);

            // Initialise arrays
            floorHeightField = new UITextField();
            firstMinField = new UITextField();
            firstExtraField = new UITextField();
            firstEmptyCheck = new UICheckBox();

            // Pack selection dropdown.
            packDropDown = UIControls.AddPlainDropDown(panel, Translations.Translate("RPR_OPT_CPK"), new string[0], -1);
            packDropDown.parent.relativePosition = new Vector3(20f, currentY);
            packDropDown.eventSelectedIndexChanged += PackChanged;

            // Headings.
            currentY += 140f;
            PanelUtils.ColumnLabel(panel, FloorHeightX, currentY, ColumnWidth, Translations.Translate("RPR_CAL_VOL_FLH"), Translations.Translate("RPR_CAL_VOL_FLH_TIP"), 1.0f);
            PanelUtils.ColumnLabel(panel, FirstMinX, currentY, ColumnWidth, Translations.Translate("RPR_CAL_VOL_FMN"), Translations.Translate("RPR_CAL_VOL_FMN_TIP"), 1.0f);
            PanelUtils.ColumnLabel(panel, FirstMaxX, currentY, ColumnWidth, Translations.Translate("RPR_CAL_VOL_FMX"), Translations.Translate("RPR_CAL_VOL_FMX_TIP"), 1.0f);
            PanelUtils.ColumnLabel(panel, FirstEmptyX, currentY, ColumnWidth, Translations.Translate("RPR_CAL_VOL_IGF"), Translations.Translate("RPR_CAL_VOL_IGF_TIP"), 1.0f);

            // Add level textfields.
            currentY += RowHeight;
            floorHeightField = UIControls.AddTextField(panel, FloorHeightX + Margin, currentY, width: TextFieldWidth, tooltip: Translations.Translate("RPR_CAL_VOL_FLH_TIP"));
            floorHeightField.eventTextChanged += (control, value) => PanelUtils.FloatTextFilter((UITextField)control, value);
            floorHeightField.tooltipBox = TooltipUtils.TooltipBox;

            firstMinField = UIControls.AddTextField(panel, FirstMinX + Margin, currentY, width: TextFieldWidth, tooltip: Translations.Translate("RPR_CAL_VOL_FMN_TIP"));
            firstMinField.eventTextChanged += (control, value) => PanelUtils.FloatTextFilter((UITextField)control, value);
            firstMinField.tooltipBox = TooltipUtils.TooltipBox;

            firstExtraField = UIControls.AddTextField(panel, FirstMaxX + Margin, currentY, width: TextFieldWidth, tooltip: Translations.Translate("RPR_CAL_VOL_FMX_TIP"));
            firstExtraField.eventTextChanged += (control, value) => PanelUtils.FloatTextFilter((UITextField)control, value);
            firstExtraField.tooltipBox = TooltipUtils.TooltipBox;

            firstEmptyCheck = UIControls.AddCheckBox(panel, FirstEmptyX + (ColumnWidth / 2), currentY, tooltip: Translations.Translate("RPR_CAL_VOL_IGF_TIP"));
            firstEmptyCheck.tooltipBox = TooltipUtils.TooltipBox;

            // Move to next row.
            currentY += RowHeight;

            // Add footer controls.
            PanelFooter(currentY);

            // Populate pack menu and set onitial pack selection.
            packDropDown.items = PackList();
            packDropDown.selectedIndex = 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;
    }
        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;
        }
        private static UITabstrip BeautificationTabstrip(UITabstrip s)
        {
            var button = FindButton(s, "Landscaping");
            if (button == null)
            {
                return null;
            }

            var groupPanelType = typeof(LandscapingGroupPanel);
            var groupPanel = (GeneratedGroupPanel)s.GetComponentInContainer(button, groupPanelType);

            var strip = groupPanel?.Find<UITabstrip>("GroupToolstrip");
            return strip;
        }
        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");
        }
 private static UIButton[] AllButtons(UITabstrip s)
 {
     return s.components.OfType<UIButton>().ToArray();
 }
        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());
        }
 private static void AddPropsPanels(UITabstrip tabstrip, EditorProps[] props)
 {
     foreach (var prop in props)
     {
         var button = AddButton(typeof(EditorPropsPanel), tabstrip, prop.m_category, prop.m_categories, prop.m_tooltip, true);
         if (button == null)
         {
             continue;
         }
         SetButtonSprites(button, prop.m_icon, "SubBarButtonBase");
     }
 }
        internal void CreateGraphics()
        {
            try {

                var uiView = UIView.GetAView();
                TextureDB.LoadFavCimsTextures();
                Atlas.LoadAtlasIcons();

                ////////////////////////////////////////////////
                ///////////Favorite Button Manu Panel/////////
                ///////////////////////////////////////////////

                //MainMenuPos = UIView.GetAView().FindUIComponent<UITabstrip> ("MainToolstrip");
                MainMenuPos = UIView.Find<UITabstrip> ("MainToolstrip");

                if(MainMenuPos.Find<FavoritesCimsButton>("FavCimsMenuPanel") != null) {
                    FavCimsMenuPanel = MainMenuPos.Find<FavoritesCimsButton>("FavCimsMenuPanel");
                }else{
                    FavCimsMenuPanel = MainMenuPos.AddUIComponent(typeof(FavoritesCimsButton)) as FavoritesCimsButton;
                }

                ////////////////////////////////////////////////
                ////////////////Favorite Panel////////////////
                ///////////////////////////////////////////////

                FullScreenContainer = UIView.Find<UIPanel> ("FullScreenContainer");
                FavCimsPanel = FullScreenContainer.AddUIComponent<FavoriteCimsMainPanel> ();
                FavCimsPanel.Hide ();

                FullScreenContainer.eventMouseDown += delegate {
                    if (!FavCimsPanel.containsMouse) {
                        FavCimsPanel.SendToBack ();
                    } else {
                        FavCimsPanel.BringToFront ();
                    }
                };

                ////////////////////////////////////////////////
                ////////////Humans Button & Subscribe///////////
                ///////////////////////////////////////////////

                FavCimsHumanPanel = FullScreenContainer.Find<UIPanel> ("(Library) CitizenWorldInfoPanel");

                if (FavCimsHumanPanel != null) {
                    if(FavCimsHumanPanel.GetComponentInChildren<AddToFavButton>() != null) {
                        FavStarButton = FavCimsHumanPanel.GetComponentInChildren<AddToFavButton>();
                    }else{
                        FavStarButton = FavCimsHumanPanel.AddUIComponent(typeof(AddToFavButton)) as AddToFavButton;
                    }
                }

                GenerateFamilyDetailsTpl();

            } catch (Exception e) {
                Debug.Error ("OnLoad List Error : " + e.ToString ());
            }
        }
Example #44
0
        bool Initialize()
        {
            ModDebug.Log("Initializing UI");

            if (UIUtils.Instance == null) return false;

            roadsOptionPanel = UIUtils.Instance.FindComponent<UIComponent>("RoadsOptionPanel", null, UIUtils.FindOptions.NameContains);
            if (roadsOptionPanel == null || !roadsOptionPanel.gameObject.activeInHierarchy) return false;

            builtinTabstrip = UIUtils.Instance.FindComponent<UITabstrip>("ToolMode", roadsOptionPanel);
            if (builtinTabstrip == null || !builtinTabstrip.gameObject.activeInHierarchy) return false;

            tabstrip = UIUtils.Instance.FindComponent<UITabstrip>(panelName);
            if (tabstrip != null) {
                DestroyView();
            }

            CreateView();
            if (tabstrip == null) return false;

            return true;
        }
Example #45
0
        void CreateView()
        {
            ModDebug.Log("Creating view");

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

            CreateButtons();

            roadsOptionPanel.AttachUIComponent(tabstrip.gameObject);
            tabstrip.relativePosition = new Vector3(90, 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());
        }
        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;
        }
 private static UIButton FindButton(UITabstrip s, string name)
 {
     var buttons = AllButtons(s);
     return Array.Find(buttons, b => b.name == name);
 }
#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 UIButton AddButton(Type type, UITabstrip strip, string category, string tooltip, bool enabled)
 {
     return AddButton(type, strip, category, null, tooltip, enabled);
 }
 private static bool IsCreated(UITabstrip strip)
 {
     var button = FindButton(strip, "TerrainDefault");
     return button != null;
 }