public bool showVersionInfoPopup(bool force = false) { if (needShowPopup || force) { try { UIComponent uIComponent = UIView.library.ShowModal("ExceptionPanel"); if (uIComponent != null) { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; BindPropertyByKey component = uIComponent.GetComponent <BindPropertyByKey>(); if (component != null) { string title = "Transport Lines Manager v" + version; string notes = ResourceLoader.loadResourceString("UI.VersionNotes.txt"); string text = "Transport Lines Manager was updated! Release notes:\r\n\r\n" + notes; string img = "IconMessage"; component.SetProperties(TooltipHelper.Format(new string[] { "title", title, "message", text, "img", img })); needShowPopup = false; currentSaveVersion.value = fullVersion; return(true); } return(false); } else { if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("PANEL NOT FOUND!!!!"); } return(false); } } catch (Exception e) { if (TransportLinesManagerMod.instance != null && TransportLinesManagerMod.debugMode) { TLMUtils.doLog("showVersionInfoPopup ERROR {0} {1}", e.GetType(), e.Message); } } } return(false); }
public bool showVersionInfoPopup(bool force = false) { if (needShowPopup || force) { try { UIComponent uIComponent = UIView.library.ShowModal("ExceptionPanel"); if (uIComponent != null) { Cursor.lockState = CursorLockMode.None; Cursor.visible = true; BindPropertyByKey component = uIComponent.GetComponent <BindPropertyByKey>(); if (component != null) { string title = $"{SimpleName.Replace("&", "and")} v{version}"; string notes = Singleton <R> .instance.loadResourceString("UI.VersionNotes.txt"); string text = $"{SimpleName.Replace("&", "and")} was updated! Release notes:\r\n\r\n" + notes; string img = "IconMessage"; component.SetProperties(TooltipHelper.Format(new string[] { "title", title, "message", text, "img", img })); needShowPopup = false; currentSaveVersion.value = fullVersion; return(true); } return(false); } else { doLog("PANEL NOT FOUND!!!!"); return(false); } } catch (Exception e) { doErrorLog("showVersionInfoPopup ERROR {0} {1}", e.GetType(), e.Message); } } 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); }