Exemple #1
0
 public static void InitCircledButtonText(UIComponent parent, out UIButton button, string text, MouseEventHandler onClicked, string tooltip, float size = 40)
 {
     KlyteMonoUtils.CreateUIElement(out button, parent.transform, tooltip, new UnityEngine.Vector4(0, 0, size, size));
     KlyteMonoUtils.InitButtonFull(button, false, "OptionBase");
     button.focusedBgSprite = "";
     button.text            = text;
     button.eventClicked   += onClicked;
     button.tooltip         = tooltip;
 }
Exemple #2
0
 public static void InitCircledButton(UIComponent parent, out UIButton button, string sprite, MouseEventHandler onClicked, string name, float size = 40)
 {
     KlyteMonoUtils.CreateUIElement(out button, parent.transform, name, new UnityEngine.Vector4(0, 0, size, size));
     KlyteMonoUtils.InitButtonFull(button, false, "OptionBase");
     button.focusedBgSprite = "";
     button.normalFgSprite  = sprite;
     button.scaleFactor     = 0.6f;
     button.eventClicked   += onClicked;
     button.tooltip         = name;
 }
        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);
        }