public override void OnLevelLoaded(LoadMode mode)
        {
            var toolController = ToolsModifierControl.toolController;

            if (toolController == null)
            {
                Debug.LogError("ExtraTools#OnLevelLoaded(): ToolContoller not found");
                return;
            }
            try
            {
                var extraTools = NaturalResourcesBrush.SetUpExtraTools(mode, toolController);
                NaturalResourcesBrush.AddExtraToolsToController(toolController, extraTools);
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }
            finally
            {
                if (toolController.Tools.Length > 0)
                {
                    toolController.Tools[0].enabled = true;
                }
            }
            if (OptionsWrapper <Options> .Options.terrainTool && GetPanels().ContainsKey(LandscapingInfoPanel))
            {
                landscapingPanel = GetPanels()[LandscapingInfoPanel];
                if (landscapingPanel != null)
                {
                    GetPanels().Remove(LandscapingInfoPanel);
                }
                LandscapingPanelDetour.Initialize();
            }
        }
 public override void OnLevelUnloading()
 {
     base.OnLevelUnloading();
     if (landscapingPanel != null)
     {
         GetPanels().Add(LandscapingInfoPanel, landscapingPanel);
     }
     landscapingPanel = null;
 }
Esempio n. 3
0
        public override void OnLevelUnloading()
        {
            base.OnLevelUnloading();
            if (landscapingPanel != null)
            {
                GetPanels().Add(LandscapingInfoPanel, landscapingPanel);
            }
            landscapingPanel = null;
            beautificationPanelsCachedVisible.Clear();
            var beautificationPanels = Object.FindObjectsOfType <BeautificationPanel>();

            beautificationPanels.ForEach(p =>
            {
                p.component.eventVisibilityChanged -= HideBrushOptionsPanel();
            });
        }
Esempio n. 4
0
        public override void OnLevelLoaded(LoadMode mode)
        {
            var toolController = ToolsModifierControl.toolController;

            if (toolController == null)
            {
                Debug.LogError("ExtraTools#OnLevelLoaded(): ToolContoller not found");
                return;
            }
            try
            {
                var extraTools = NaturalResourcesBrush.SetUpExtraTools(mode, toolController);
                NaturalResourcesBrush.AddExtraToolsToController(toolController, extraTools);
            }
            catch (Exception e)
            {
                Debug.LogError(e);
            }
            finally
            {
                if (toolController.Tools.Length > 0)
                {
                    toolController.Tools[0].enabled = true;
                }
            }
            if (OptionsWrapper <Options> .Options.terrainTool && GetPanels().ContainsKey(LandscapingInfoPanel))
            {
                landscapingPanel = GetPanels()[LandscapingInfoPanel];
                if (landscapingPanel != null)
                {
                    GetPanels().Remove(LandscapingInfoPanel);
                }
                LandscapingPanelDetour.Initialize();
            }
            var beautificationPanels = Object.FindObjectsOfType <BeautificationPanel>();

            beautificationPanels.ForEach(p =>
            {
                p.component.eventVisibilityChanged -= HideBrushOptionsPanel();
                p.component.eventVisibilityChanged += HideBrushOptionsPanel();
            });
        }
        public virtual bool InitPanel()
        {
            try
            {
                // Get Title
                _title = transform.Find("Caption").GetComponent<UILabel>();

                // Get Description
                _description = transform.Find("Scrollable Panel/Message").GetComponent<UILabel>();

                // Remove Close Button
                GameObject.Destroy(transform.Find("Caption/Close").gameObject);

                // Hide scrollbar
                _scrollbar = transform.Find("Scrollbar").GetComponent<UIScrollbar>();
                _scrollbar.opacity = 0;

                // Change Dont show text
                _dontShowAgainCheckbox = transform.Find("DontShow").GetComponent<UICheckBox>();
                transform.Find("DontShow/OnOff").GetComponent<UILabel>().text = "Don't show on future updates";

                // Change ok to Options
                _okButton = transform.Find("Ok").GetComponent<UIButton>();
                GameObject.Destroy(_okButton.GetComponent<BindEvent>());

                // Change cancel to Later
                _cancelButton = transform.Find("Cancel").GetComponent<UIButton>();
                GameObject.Destroy(_cancelButton.GetComponent<BindEvent>());

                // Get fireworks
                ParadoxUnlockPanel paradoxPanel = UIView.GetAView().GetComponentInChildren<ParadoxUnlockPanel>();
                if (paradoxPanel != null)
                {
                    m_fireworks = paradoxPanel.m_Fireworks;
                    if (m_fireworks != null)
                    {
                        Renderer[] componentsInChildren = this.m_fireworks.GetComponentsInChildren<Renderer>();
                        m_fireworkMaterials = new Material[componentsInChildren.Length];
                        for (int i = 0; i < componentsInChildren.Length; ++i)
                        {
                            m_fireworkMaterials[i] = componentsInChildren[i].material;
                        }
                    }
                }

                // Add panel to dynamic panels library
                this.name = this.GetType().Name;
                UIDynamicPanels.DynamicPanelInfo panelInfo = new UIDynamicPanels.DynamicPanelInfo();
                typeof(UIDynamicPanels.DynamicPanelInfo).GetFieldByName("m_Name").SetValue(panelInfo, this.name);
                typeof(UIDynamicPanels.DynamicPanelInfo).GetFieldByName("m_PanelRoot").SetValue(panelInfo, this.GetComponent<UIPanel>());
                typeof(UIDynamicPanels.DynamicPanelInfo).GetFieldByName("m_IsModal").SetValue(panelInfo, true);
                panelInfo.viewOwner = UIView.GetAView();
                panelInfo.AddInstance(this.GetComponent<UIPanel>());

                Dictionary<string, UIDynamicPanels.DynamicPanelInfo> cachedPanels = typeof(UIDynamicPanels).GetFieldByName("m_CachedPanels").GetValue(UIView.library) as Dictionary<string, UIDynamicPanels.DynamicPanelInfo>;
                if (!cachedPanels.ContainsKey(panelInfo.name))
                    cachedPanels.Add(panelInfo.name, panelInfo);

                return true;
            }
            catch (Exception)
            {
                // TODO: log error
                return false;
            }
        }
Esempio n. 6
0
        public virtual bool InitPanel()
        {
            try
            {
                // Get Title
                _title = transform.Find("Caption").GetComponent <UILabel>();

                // Get Description
                _description = transform.Find("Scrollable Panel/Message").GetComponent <UILabel>();

                // Remove Close Button
                GameObject.Destroy(transform.Find("Caption/Close").gameObject);

                // Hide scrollbar
                _scrollbar         = transform.Find("Scrollbar").GetComponent <UIScrollbar>();
                _scrollbar.opacity = 0;

                // Change Dont show text
                _dontShowAgainCheckbox = transform.Find("DontShow").GetComponent <UICheckBox>();
                transform.Find("DontShow/OnOff").GetComponent <UILabel>().text = "Don't show on future updates";

                // Change ok to Options
                _okButton = transform.Find("Ok").GetComponent <UIButton>();
                GameObject.Destroy(_okButton.GetComponent <BindEvent>());

                // Change cancel to Later
                _cancelButton = transform.Find("Cancel").GetComponent <UIButton>();
                GameObject.Destroy(_cancelButton.GetComponent <BindEvent>());

                // Get fireworks
                UnlockingPanel paradoxPanel = UIView.GetAView().GetComponentInChildren <UnlockingPanel>();
                if (paradoxPanel != null)
                {
                    m_fireworks = paradoxPanel.m_Fireworks;
                    if (m_fireworks != null)
                    {
                        Renderer[] componentsInChildren = this.m_fireworks.GetComponentsInChildren <Renderer>();
                        m_fireworkMaterials = new Material[componentsInChildren.Length];
                        for (int i = 0; i < componentsInChildren.Length; ++i)
                        {
                            m_fireworkMaterials[i] = componentsInChildren[i].material;
                        }
                    }
                }

                // Add panel to dynamic panels library
                this.name = this.GetType().Name;
                UIDynamicPanels.DynamicPanelInfo panelInfo = new UIDynamicPanels.DynamicPanelInfo();
                typeof(UIDynamicPanels.DynamicPanelInfo).GetFieldByName("m_Name").SetValue(panelInfo, this.name);
                typeof(UIDynamicPanels.DynamicPanelInfo).GetFieldByName("m_PanelRoot").SetValue(panelInfo, this.GetComponent <UIPanel>());
                typeof(UIDynamicPanels.DynamicPanelInfo).GetFieldByName("m_IsModal").SetValue(panelInfo, true);
                panelInfo.viewOwner = UIView.GetAView();
                panelInfo.AddInstance(this.GetComponent <UIPanel>());

                Dictionary <string, UIDynamicPanels.DynamicPanelInfo> cachedPanels = typeof(UIDynamicPanels).GetFieldByName("m_CachedPanels").GetValue(UIView.library) as Dictionary <string, UIDynamicPanels.DynamicPanelInfo>;
                if (!cachedPanels.ContainsKey(panelInfo.name))
                {
                    cachedPanels.Add(panelInfo.name, panelInfo);
                }

                return(true);
            }
            catch (Exception)
            {
                // TODO: log error
                return(false);
            }
        }
        public static UIDynamicPanels.DynamicPanelInfo CreatePanelInfo(UIView view)
        {
            KlyteMonoUtils.CreateUIElement(out UIPanel mainPanel, null, PANEL_ID);
            mainPanel.enabled                   = false;
            mainPanel.maximumSize               = new Vector2(0, view.fixedHeight);
            mainPanel.minimumSize               = new Vector2(800, 70);
            mainPanel.backgroundSprite          = "MenuPanel2";
            mainPanel.anchor                    = UIAnchorStyle.CenterHorizontal | UIAnchorStyle.CenterVertical;
            mainPanel.autoLayout                = true;
            mainPanel.autoFitChildrenVertically = true;
            mainPanel.autoLayoutDirection       = LayoutDirection.Vertical;
            mainPanel.autoLayoutStart           = LayoutStart.TopLeft;
            mainPanel.padding                   = new RectOffset(5, 5, 0, 0);
            mainPanel.autoLayoutPadding         = new RectOffset(0, 0, 0, 10);


            #region Title
            KlyteMonoUtils.CreateUIElement(out UIPanel titleContainer, mainPanel.transform, "TitleContainer");
            titleContainer.size = new Vector2(mainPanel.width, 40);


            KlyteMonoUtils.CreateUIElement(out UILabel title, titleContainer.transform, "Title");
            title.text          = "<k45symbol K45_HexagonIcon_NOBORDER,5e35b1,K> Klyte45";
            title.anchor        = UIAnchorStyle.CenterHorizontal | UIAnchorStyle.CenterVertical;
            title.minimumSize   = new Vector3(titleContainer.width - 100, 0);
            title.textScale     = 2;
            title.textAlignment = UIHorizontalAlignment.Center;



            KlyteMonoUtils.CreateUIElement(out UISprite modIcon, titleContainer.transform, "ModIcon", new Vector4(5, 5, 32, 32));
            modIcon.tooltip = $"v{VERSION}{CommonProperties.Acronym}";

            KlyteMonoUtils.CreateUIElement(out UIButton closeButton, titleContainer.transform, "CloseButton");
            closeButton.area            = new Vector4(mainPanel.width - 37, 3, 32, 32);
            closeButton.normalBgSprite  = "buttonclose";
            closeButton.hoveredBgSprite = "buttonclosehover";
            closeButton.pressedBgSprite = "buttonclosepressed";


            #endregion

            #region Texture area
            KlyteMonoUtils.CreateUIElement(out UIPanel textureContainer, mainPanel.transform, "TextureSupContainer");
            textureContainer.size = new Vector2(800, 0);
            textureContainer.autoFitChildrenVertically = true;

            KlyteMonoUtils.CreateUIElement(out UIPanel textureSubContainer, textureContainer.transform, "TextureContainer");
            textureSubContainer.anchor = UIAnchorStyle.CenterHorizontal | UIAnchorStyle.Top;
            textureSubContainer.pivot  = UIPivotPoint.TopCenter;
            textureSubContainer.autoFitChildrenVertically   = true;
            textureSubContainer.autoFitChildrenHorizontally = true;
            textureSubContainer.autoLayout       = true;
            textureSubContainer.relativePosition = new Vector3(0, 0);

            KlyteMonoUtils.CreateUIElement(out UITextureSprite textureSprite, textureSubContainer.transform, "TextureSprite");
            textureSprite.size = default;
            #endregion

            #region Text area
            KlyteMonoUtils.CreateUIElement(out UILabel boxText, mainPanel.transform, "BoxText");
            boxText.minimumSize       = new Vector2(800, 60);
            boxText.maximumSize       = new Vector2(0, view.fixedHeight * 0.8f);
            boxText.clipChildren      = true;
            boxText.wordWrap          = true;
            boxText.autoSize          = false;
            boxText.autoHeight        = true;
            boxText.processMarkup     = true;
            boxText.padding           = new RectOffset(10, 10, 5, 5);
            boxText.textAlignment     = UIHorizontalAlignment.Center;
            boxText.verticalAlignment = UIVerticalAlignment.Middle;
            #endregion

            #region Inputs
            CreateInputs(mainPanel, boxText);
            #endregion

            #region Action Buttons
            KlyteMonoUtils.CreateUIElement(out UIPanel buttonContainer, mainPanel.transform, "ButtonSupContainer");
            buttonContainer.size = new Vector2(800, 70);
            buttonContainer.autoFitChildrenVertically = true;

            KlyteMonoUtils.CreateUIElement(out UIPanel buttonSubContainer, buttonContainer.transform, "ButtonContainer");
            buttonSubContainer.anchor = UIAnchorStyle.CenterHorizontal | UIAnchorStyle.Top;
            buttonSubContainer.pivot  = UIPivotPoint.TopCenter;
            buttonSubContainer.autoFitChildrenVertically   = true;
            buttonSubContainer.autoFitChildrenHorizontally = true;
            buttonSubContainer.autoLayout        = true;
            buttonSubContainer.autoLayoutPadding = new RectOffset(5, 5, 0, 0);
            buttonSubContainer.relativePosition  = new Vector3(0, 0);

            KlyteMonoUtils.CreateUIElement(out UIButton button1, buttonSubContainer.transform, "ButtonAction1");
            button1.anchor   = UIAnchorStyle.CenterHorizontal | UIAnchorStyle.Top;
            button1.size     = new Vector2(150, 60);
            button1.text     = "AAAAA";
            button1.wordWrap = true;
            KlyteMonoUtils.InitButtonFull(button1, false, "ButtonMenu");
            KlyteMonoUtils.CreateUIElement(out UIButton button2, buttonSubContainer.transform, "ButtonAction2");
            button2.anchor   = UIAnchorStyle.CenterHorizontal | UIAnchorStyle.Top;
            button2.size     = new Vector2(150, 60);
            button2.text     = "BBBBB";
            button2.wordWrap = true;
            KlyteMonoUtils.InitButtonFull(button2, false, "ButtonMenu");
            KlyteMonoUtils.CreateUIElement(out UIButton button3, buttonSubContainer.transform, "ButtonAction3");
            button3.anchor   = UIAnchorStyle.CenterHorizontal | UIAnchorStyle.Top;
            button3.size     = new Vector2(150, 60);
            button3.text     = "CCCCC";
            button3.wordWrap = true;
            KlyteMonoUtils.InitButtonFull(button3, false, "ButtonMenu");
            KlyteMonoUtils.CreateUIElement(out UIButton button4, buttonSubContainer.transform, "ButtonAction4");
            button4.anchor   = UIAnchorStyle.CenterHorizontal | UIAnchorStyle.Top;
            button4.size     = new Vector2(150, 60);
            button4.text     = "DDDDD";
            button4.wordWrap = true;
            KlyteMonoUtils.InitButtonFull(button4, false, "ButtonMenu");
            KlyteMonoUtils.CreateUIElement(out UIButton button5, buttonSubContainer.transform, "ButtonAction5");
            button5.anchor   = UIAnchorStyle.CenterHorizontal | UIAnchorStyle.Top;
            button5.size     = new Vector2(150, 60);
            button5.text     = "EEEEE";
            button5.wordWrap = true;
            KlyteMonoUtils.InitButtonFull(button5, false, "ButtonMenu");
            #endregion

            #region Bindings creation
            mainPanel.gameObject.AddComponent <K45DialogControl>();
            BindPropertyByKey bindByKey = mainPanel.gameObject.AddComponent <BindPropertyByKey>();
            bindByKey.m_Bindings.AddRange(new List <BindPropertyByKey.BindingInfo>()
            {
                CreateBind("title", title, "text"),
                CreateBind("icon", modIcon, "spriteName"),
                CreateBind("showClose", closeButton, "isVisible"),
                CreateBind("message", boxText, "text"),
                CreateBind("messageAlign", boxText, "textAlignment"),
                CreateBind("showButton1", button1, "isVisible"),
                CreateBind("showButton2", button2, "isVisible"),
                CreateBind("showButton3", button3, "isVisible"),
                CreateBind("showButton4", button4, "isVisible"),
                CreateBind("showButton5", button5, "isVisible"),
                CreateBind("textButton1", button1, "text"),
                CreateBind("textButton2", button2, "text"),
                CreateBind("textButton3", button3, "text"),
                CreateBind("textButton4", button4, "text"),
                CreateBind("textButton5", button5, "text"),
            });
            #endregion

            #region Declare Dynamic Panel Info
            var panelTestInfo = new UIDynamicPanels.DynamicPanelInfo();
            panelTestInfo.GetType().GetField("m_Name", RedirectorUtils.allFlags).SetValue(panelTestInfo, PANEL_ID);
            panelTestInfo.GetType().GetField("m_PanelRoot", RedirectorUtils.allFlags).SetValue(panelTestInfo, mainPanel);
            panelTestInfo.GetType().GetField("m_IsModal", RedirectorUtils.allFlags).SetValue(panelTestInfo, true);
            #endregion

            return(panelTestInfo);
        }