Beispiel #1
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;
        }
        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();
                                                          }
            };
        }
Beispiel #3
0
 internal void OpenAt(ServiceSystemDefinition ssd)
 {
     m_StripMain.selectedIndex = 0;
     if (ssd != null)
     {
         m_StripBuilings.selectedIndex = m_StripBuilings.Find <UIComponent>(ssd.GetDefType().Name)?.zOrder ?? 0;
     }
     SVMController.instance.OpenSVMPanel();
 }
        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;
        }
        public static bool initCustomEducationGroupPanel()
        {
            // Get the Tab Strip, but fetching it before it's initlized can throw an exception
            UITabstrip strip = null;

            try {
                if (ToolsModifierControl.mainToolbar != null)
                {
                    strip = ToolsModifierControl.mainToolbar.component as UITabstrip;
                }
            } catch {
                // Do nothing
            }

            // Get the other needed components
            UIComponent         education           = null;
            UIComponent         educationPanelComp  = null;
            EducationGroupPanel educationGroupPanel = null;

            if (strip != null)
            {
                education = strip.Find(CustomEducationGroupPanel.EDUCATION_NAME);
                if (strip.tabPages != null)
                {
                    educationPanelComp = strip.tabPages.Find(CustomEducationGroupPanel.EDUCATION_PANEL_NAME);
                }
                if (educationPanelComp != null)
                {
                    educationGroupPanel = educationPanelComp.GetComponent <EducationGroupPanel>();
                }
            }

            // Ensure the Education Components are available before initilization
            if (education == null || educationPanelComp == null || educationGroupPanel == null || !education.isActiveAndEnabled || !education.isVisible)
            {
                Logger.logInfo(LOG_CUSTOM_PANELS, "PanelHelper.initCustomEducationGroupPanel -- Waiting to initilize Education Menu because the components aren't ready");
                return(false);
            }

            // Can start initilization
            Logger.logInfo(LOG_CUSTOM_PANELS, "PanelHelper.initCustomEducationGroupPanel -- Initilizing Education Menu");

            // Check the Education Group Panel and replace it with a Custom Education Group Panel
            if (!(educationGroupPanel is CustomEducationGroupPanel))
            {
                if (replacedEducationGroupPanel)
                {
                    Logger.logInfo(LOG_CUSTOM_PANELS, "PanelHelper.initCustomEducationGroupPanel -- Waiting to continue initilization of the Education Menu because the Custom Panel isn't fully initilized yet");
                    return(false);
                }

                // Destroy the existing group panel
                Logger.logInfo(LOG_CUSTOM_PANELS, "PanelHelper.initCustomEducationGroupPanel -- Destroying the existing Education Group Panel: {0}", educationGroupPanel);
                UnityEngine.Object.Destroy(educationGroupPanel);

                // Create a new custom group panel
                Logger.logInfo(LOG_CUSTOM_PANELS, "PanelHelper.initCustomEducationGroupPanel -- Creating the new Custom Education Group Panel");
                educationPanelComp.gameObject.AddComponent(typeof(CustomEducationGroupPanel));

                // Mark this step as complete and bail to give this step a chance to complete
                replacedEducationGroupPanel = true;
                return(false);
            }

            // Attempt initilization of the Custom Education Group Panel -- Will take multiple attempts to completely initilize
            Logger.logInfo(LOG_CUSTOM_PANELS, "PanelHelper.initCustomEducationGroupPanel -- Attempting initilization of the Custom Education Group Panel");
            return(((CustomEducationGroupPanel)educationGroupPanel).initDormitories());
        }
        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());
            }
        }
        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 ());
            }
        }
Beispiel #8
0
        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);
        }
Beispiel #9
0
        public void OnLevelLoaded(LoadMode mode)
        {
            try
            {
                Log.Message("ModCorral.OnLevelLoaded() " + mode.ToString());

                if (mode == LoadMode.LoadGame || mode == LoadMode.NewGame)
                {
                    if (mcButton == null) // if not created yet
                    {
                        // add button to the end of the TSBar MainToolstrip (UITabStrip)
                        UIView uiv = UIView.GetAView();

                        if (uiv != null)
                        {
                            UITabstrip ts = uiv.FindUIComponent <UITabstrip>("MainToolstrip");

                            if (ts != null)
                            {
                                UIButton policiesButton = ts.Find <UIButton>("Policies"); // we use this as a template to get 'most' of what we need set up
                                mcButton = ts.AddTab("ModCorral", policiesButton, false);

                                // find the panel added in the ts tabcontainer
                                foreach (UIComponent c in ts.tabContainer.components)
                                {
                                    if (c.name.Contains("ModCorral"))
                                    {
                                        TabPanel       = c as UIPanel;
                                        c.clipChildren = false;
                                        c.opacity      = 0; // otherwise our panel gets clicks obscured when it's in the same place...

                                        break;
                                    }
                                }

                                // initial position info
                                StartingAbsPosY = ts.absolutePosition.y - 20; // get rid of hardcoded 20...

                                ts.eventSelectedIndexChanged += ts_eventSelectedIndexChanged;

                                if (mcButton != null)
                                {
                                    StartingAbsPosX = mcButton.absolutePosition.x;

                                    mcButton.tooltip              = "Open Mod Corral";
                                    mcButton.eventTooltipShow    += (component, param) => { param.tooltip.relativePosition = new Vector3(param.tooltip.relativePosition.x + 25, param.tooltip.relativePosition.y + 10, param.tooltip.relativePosition.z); };
                                    mcButton.foregroundSpriteMode = UIForegroundSpriteMode.Scale;
                                    mcButton.scaleFactor          = 0.6f; // to fit a little better when using options sprites
                                    mcButton.normalFgSprite       = "Options";
                                    mcButton.hoveredFgSprite      = "OptionsHovered";
                                    mcButton.focusedFgSprite      = "OptionsFocused";
                                    mcButton.pressedFgSprite      = "OptionsPressed";
                                    mcButton.disabledFgSprite     = "OptionsDisabled";
                                    mcButton.eventClick          += mcButton_eventClick;
                                    mcButton.clipChildren         = false;

                                    UIPanel fscont = uiv.FindUIComponent <UIPanel>("FullScreenContainer");

                                    if (fscont != null)
                                    {
                                        // create our ui panel
                                        mcPanel = (ModCorralUI)fscont.AddUIComponent(typeof(ModCorralUI));
                                    }
                                    else
                                    {
                                        Log.Message("no fullscreencontainer");
                                    }

                                    if (mcPanel != null)
                                    {
                                        mcPanel.transform.parent = fscont.transform;
                                        mcPanel.initialize();
                                        //mcPanel.anchor = UIAnchorStyle.All;

                                        mcPanel.isVisible = false;
                                    }

                                    ModCorralConfigDialog             = (ConfigDialog)uiv.AddUIComponent(typeof(ConfigDialog));
                                    ModCorralConfigDialog.ParentPanel = mcPanel;
                                    ModCorralConfigDialog.isVisible   = false;
                                }
                            }
                            else
                            {
                                Log.Message("failed to find maintoolstrip");
                            }
                        }
                    }

                    // add any buttons that might have been registered before we got created
                    if (CorralRegistration.RegisteredMods != null)
                    {
                        foreach (ModRegistrationInfo mri in CorralRegistration.RegisteredMods)
                        {
                            if (!mri.IsButtonInitialized())
                            {
                                if (mri is ToggleModRegistrationInfo)
                                {
                                    ToggleModRegistrationInfo tmri = mri as ToggleModRegistrationInfo;

                                    tmri.ToggleButton = mcPanel.ScrollPanel.AddAToggleButton(tmri);
                                }
                                else
                                {
                                    mri.ModButton = mcPanel.ScrollPanel.AddAButton(mri);
                                }
                            }
                        }

                        UpdateNewCount();
                    }
                }
            }
            catch (Exception ex)
            {
                Log.Error("ModCorral.OnLevelLoaded() Exception: " + ex.Message);
            }
        }
Beispiel #10
0
 internal void OpenAt(TransportSystemDefinition tsd)
 {
     m_stripMain.selectedIndex = m_stripMain.Find <UIComponent>(tsd.GetDefType().Name)?.zOrder ?? -1;
     TLMController.instance.OpenTLMPanel();
 }