public override void OnInitialize() { area = new UIElement(); area.Width.Set(0f, 0.8f); area.Top.Set(200f, 0f); area.Height.Set(-210f, 1f); area.HAlign = 0.5f; message.Width.Set(0f, 1f); message.Height.Set(-110f, 1f); message.HAlign = 0.5f; area.Append(message); continueButton.Width.Set(-10f, 0.5f); continueButton.Height.Set(50f, 0f); continueButton.Top.Set(-108f, 1f); continueButton.OnMouseOver += UICommon.FadedMouseOver; continueButton.OnMouseOut += UICommon.FadedMouseOut; continueButton.OnClick += ContinueClick; area.Append(continueButton); UITextPanel <string> button2 = new UITextPanel <string>(Language.GetTextValue("tModLoader.OpenLogs"), 0.7f, true); button2.CopyStyle(continueButton); button2.HAlign = 1f; button2.OnMouseOver += UICommon.FadedMouseOver; button2.OnMouseOut += UICommon.FadedMouseOut; button2.OnClick += OpenFile; area.Append(button2); webHelpButton = new UITextPanel <string>(Language.GetTextValue("tModLoader.OpenWebHelp"), 0.7f, true); webHelpButton.CopyStyle(button2); webHelpButton.Top.Set(-55f, 1f); webHelpButton.OnMouseOver += UICommon.FadedMouseOver; webHelpButton.OnMouseOut += UICommon.FadedMouseOut; webHelpButton.OnClick += VisitRegisterWebpage; area.Append(webHelpButton); Append(area); }
public UINumberSetting(StoredVariable variable) { this.storedVar = variable; Width.Set(0, 1f); Height.Set(60f, 0f); UIText title = new UIText(storedVar.DisplayName, 0.9f, false); title.MaxWidth.Set(-10f, 1f); numberBox = new UITextPanel <string>("000000", 0.8f, false); numberBox.Top.Set(-18, 0.5f); numberBox.Left.Set(-110, 1f); numberBox.Width.Set(120f, 0f); _defaultBackground = numberBox.BackgroundColor; _defaultBorder = numberBox.BorderColor; numberBox.OnMouseOver += BoxMouseOver; numberBox.OnClick += BoxOnClick; useDecimalSystem = false; int min = (int)(storedVar.valMin - 0.5f); int max = (int)storedVar.valMax; if (min - max < 200 && storedVar.IsDecimalNumbers) { // set up to allow normalised increments useDecimalSystem = true; min = (int)(min * decimalIncrement - 0.5f); max = (int)(max * decimalIncrement); } numberBar = new UIValueBar(min, max); numberBar.Top.Set(-20f, 1f); numberBar.Left.Set(-6f, 0f); numberBar.OnMouseUp += BarMouseUp; base.Append(numberBar); base.Append(numberBox); base.Append(title); }
public UISettingsItem(string name) { fileName = name; this.BorderColor = new Color(89, 116, 213) * 0.7f; this.dividerTexture = TextureManager.Load("Images/UI/Divider"); this.innerPanelTexture = TextureManager.Load("Images/UI/InnerPanelBackground"); this.Height.Set(90f, 0f); this.Width.Set(0f, 1f); base.SetPadding(6f); this.listName = new UIText(name, 1f, false); this.listName.Left.Set(10f, 0f); this.listName.Top.Set(5f, 0f); base.Append(this.listName); loadThisSettingButton = new UITextPanel <string>(TerraCustomUtils.TCText("EnableThisList"), 1f, false); loadThisSettingButton.Width.Set(100f, 0f); loadThisSettingButton.Height.Set(30f, 0f); loadThisSettingButton.Left.Set(75f, 0f); loadThisSettingButton.Top.Set(40f, 0f); loadThisSettingButton.PaddingTop -= 2f; loadThisSettingButton.PaddingBottom -= 2f; loadThisSettingButton.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver); loadThisSettingButton.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut); loadThisSettingButton.OnClick += new UIElement.MouseEvent(LoadThisSetting); base.Append(loadThisSettingButton); deleteThisSettingButton = new UITextPanel <string>(TerraCustomUtils.TCText("DeleteThisList"), 1f, false); deleteThisSettingButton.Width.Set(100f, 0f); deleteThisSettingButton.Height.Set(30f, 0f); deleteThisSettingButton.Left.Set(275f, 0f); deleteThisSettingButton.Top.Set(40f, 0f); deleteThisSettingButton.PaddingTop -= 2f; deleteThisSettingButton.PaddingBottom -= 2f; deleteThisSettingButton.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver); deleteThisSettingButton.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut); deleteThisSettingButton.OnClick += new UIElement.MouseEvent(DeleteThisSetting); base.Append(deleteThisSettingButton); }
public override void OnInitialize() { loadProgress = new UILoadProgress { Width = { Percent = 0.8f }, MaxWidth = UICommon.MaxPanelWidth, Height = { Pixels = 150 }, HAlign = 0.5f, VAlign = 0.5f, Top = { Pixels = 10 } }; Append(loadProgress); var cancel = new UITextPanel <string>(Language.GetTextValue("UI.Cancel"), 0.75f, true) { VAlign = 0.5f, HAlign = 0.5f, Top = { Pixels = 170 } }.WithFadedMouseOver(); cancel.OnClick += CancelClick; Append(cancel); }
public DraggableUIPanel(float width, float height) { // Set the width and height to the passed parameters Width.Set(width, 0); Height.Set(height, 0); SetPadding(0); // Create a new header, with custom OnMouse events header = new UIPanel(); header.SetPadding(0); header.Width = Width; header.Height = new StyleDimension(30, 0); header.BackgroundColor.A = 255; header.OnMouseDown += Header_OnMouseDown; header.OnMouseUp += Header_OnMouseUp; Append(header); // Create a close button var closeBtn = new UITextPanel <char>('X'); closeBtn.SetPadding(7); closeBtn.Width = new StyleDimension(40, 0); closeBtn.Left = new StyleDimension(-40, 1); closeBtn.BackgroundColor.A = 255; closeBtn.OnClick += (evt, elm) => OnCloseBtnClicked?.Invoke(); header.Append(closeBtn); // Create a lock button var lockBtn = new UIImageButton(ModContent.GetTexture("Terraria/Lock_" + (isDraggable ? 1 : 0))); lockBtn.Width = new StyleDimension(24, 0); lockBtn.Height = new StyleDimension(24, 0); lockBtn.Left = new StyleDimension(width - 65, 0); lockBtn.Top = new StyleDimension(5, 0); lockBtn.SetPadding(0); lockBtn.OnClick += UpdateLock; header.Append(lockBtn); }
public UIModSourceItem(string mod) { this.mod = mod; BorderColor = new Color(89, 116, 213) * 0.7f; dividerTexture = Main.Assets.Request <Texture2D>("Images/UI/Divider").Value; Height.Set(90f, 0f); Width.Set(0f, 1f); SetPadding(6f); modName = new UIText(Path.GetFileName(mod), 1f, false); modName.Left.Set(10f, 0f); modName.Top.Set(5f, 0f); Append(modName); UITextPanel <string> button = new UITextPanel <string>("Build", 1f, false); button.Width.Set(100f, 0f); button.Height.Set(30f, 0f); button.Left.Set(10f, 0f); button.Top.Set(40f, 0f); button.PaddingTop -= 2f; button.PaddingBottom -= 2f; button.OnMouseOver += new MouseEvent(FadedMouseOver); button.OnMouseOut += new MouseEvent(FadedMouseOut); button.OnClick += new MouseEvent(BuildMod); Append(button); UITextPanel <string> button2 = new UITextPanel <string>("Build + Reload", 1f, false); button2.CopyStyle(button); button2.Width.Set(200f, 0f); button2.Left.Set(150f, 0f); button2.OnMouseOver += new MouseEvent(FadedMouseOver); button2.OnMouseOut += new MouseEvent(FadedMouseOut); button2.OnClick += new MouseEvent(BuildAndReload); Append(button2); OnDoubleClick += new MouseEvent(BuildAndReload); }
public override void OnInitialize() { var area = new UIElement { Width = { Percent = 0.8f }, Top = { Pixels = 60 }, Height = { Pixels = -60, Percent = 1f }, HAlign = 0.5f }; _backPanel = new UIPanel { Width = { Percent = 1f }, Height = { Pixels = -70, Percent = 1f }, BackgroundColor = UICommon.MainPanelBackground }.WithPadding(6); area.Append(_backPanel); var heading = new UITextPanel <string>(Language.GetTextValue("tModLoader.MenuEnableDeveloperMode"), 0.8f, true) { HAlign = 0.5f, Top = { Pixels = -45 }, BackgroundColor = UICommon.DefaultUIBlue }.WithPadding(15); area.Append(heading); _bottomButton = new UITextPanel <string>(Language.GetTextValue("UI.Back"), 0.7f, true) { Width = { Percent = 0.5f }, Height = { Pixels = 50 }, HAlign = 0.5f, VAlign = 1f, Top = { Pixels = -20 } }.WithFadedMouseOver(); _bottomButton.OnClick += BackClick; area.Append(_bottomButton); Append(area); }
public override void OnInitialize() { loadProgress = new UILoadProgress(); loadProgress.Width.Set(0f, 0.8f); loadProgress.MaxWidth.Set(600f, 0f); loadProgress.Height.Set(150f, 0f); loadProgress.HAlign = 0.5f; loadProgress.VAlign = 0.5f; loadProgress.Top.Set(10f, 0f); base.Append(loadProgress); var cancel = new UITextPanel <string>(Language.GetTextValue("UI.Cancel"), 0.75f, true) { VAlign = 0.5f, HAlign = 0.5f }; cancel.Top.Set(170f, 0f); cancel.OnMouseOver += UICommon.FadedMouseOver; cancel.OnMouseOut += UICommon.FadedMouseOut; cancel.OnClick += CancelClick; base.Append(cancel); }
public UIModManageItem(string displayname, string name, string version, string author, string downloads, string downloadsversion, string modloaderversion) { this.displayname = displayname; this.version = version; this.author = author; this.name = name; this.BorderColor = new Color(89, 116, 213) * 0.7f; this.dividerTexture = TextureManager.Load("Images/UI/Divider"); this.Height.Set(90f, 0f); this.Width.Set(0f, 1f); base.SetPadding(6f); string text = displayname + " " + version + " - by " + author + " - " + modloaderversion; this.modName = new UIText(text, 1f, false); this.modName.Left.Set(10f, 0f); this.modName.Top.Set(5f, 0f); base.Append(this.modName); UITextPanel button = new UITextPanel(downloads + " downloads (" + downloadsversion + " latest version)", 1f, false); button.Width.Set(260f, 0f); button.Height.Set(30f, 0f); button.Left.Set(10f, 0f); button.Top.Set(40f, 0f); button.PaddingTop -= 2f; button.PaddingBottom -= 2f; // button.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver); // button.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut); base.Append(button); button2 = new UITextPanel("Unpublish", 1f, false); button2.CopyStyle(button); button2.Width.Set(150f, 0f); button2.Left.Set(360f, 0f); button2.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver); button2.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut); button2.OnClick += new UIElement.MouseEvent(this.Unpublish); base.Append(button2); }
internal void Populate() { int i = 0; foreach (var item in ConfigManager.Configs) { foreach (var config in item.Value) { //if (config.Mode == ConfigScope.ClientSide) { string configDisplayName = ((LabelAttribute)Attribute.GetCustomAttribute(config.GetType(), typeof(LabelAttribute)))?.Label ?? config.Name; UITextPanel <string> t = new UITextPanel <string>(item.Key.DisplayName + ": " + configDisplayName); //UIText t = new UIText(item.Key.DisplayName + ": " + item.Value.Count); t.OnClick += (a, b) => { Interface.modConfig.SetMod(item.Key, config); Main.InGameUI.SetState(Interface.modConfig); }; t.WithFadedMouseOver(); t.HAlign = 0.5f; UIElement container = new UISortableElement(i++); container.Width.Set(0f, 1f); container.Height.Set(40f, 0f); container.HAlign = 1f; container.Append(t); modList.Add(container); if (config.Mode == ConfigScope.ServerSide) { t.BackgroundColor = Color.Pink * 0.7f; t.OnMouseOver += (a, b) => t.BackgroundColor = Color.Pink; t.OnMouseOut += (a, b) => t.BackgroundColor = Color.Pink * 0.7f; } } } } }
public UIModManageItem(string displayname, string name, string version, string author, string downloads, string downloadsversion, string modloaderversion) { this.displayname = displayname; this.version = version; this.author = author; this.name = name; this.BorderColor = new Color(89, 116, 213) * 0.7f; this.dividerTexture = TextureManager.Load("Images/UI/Divider"); this.Height.Set(90f, 0f); this.Width.Set(0f, 1f); base.SetPadding(6f); string text = displayname + " " + version + " - by " + author + " - " + modloaderversion; this.modName = new UIText(text, 1f, false); this.modName.Left.Set(10f, 0f); this.modName.Top.Set(5f, 0f); base.Append(this.modName); UITextPanel <string> button = new UITextPanel <string>(Language.GetTextValue("tModLoader.MBMyPublishedModsStats", downloads, downloadsversion), 1f, false); button.Width.Set(260f, 0f); button.Height.Set(30f, 0f); button.Left.Set(10f, 0f); button.Top.Set(40f, 0f); button.PaddingTop -= 2f; button.PaddingBottom -= 2f; // button.OnMouseOver += UICommon.FadedMouseOver; // button.OnMouseOut += UICommon.FadedMouseOut; base.Append(button); button2 = new UITextPanel <string>(Language.GetTextValue("tModLoader.MBUnpublish"), 1f, false); button2.CopyStyle(button); button2.Width.Set(150f, 0f); button2.Left.Set(360f, 0f); button2.OnMouseOver += UICommon.FadedMouseOver; button2.OnMouseOut += UICommon.FadedMouseOut; button2.OnClick += this.Unpublish; base.Append(button2); }
public override void OnInitialize() { //Panel backPanel = new UIPanel(); backPanel.SetPadding(0); backPanel.Left.Set(Terraria.Main.instance.GraphicsDevice.Viewport.Bounds.Width / 2 - panelWidth / 2, 0f); backPanel.Top.Set(Terraria.Main.instance.GraphicsDevice.Viewport.Bounds.Height / 2 - panelHeight / 2, 0f); backPanel.Width.Set(panelWidth, 0f); backPanel.Height.Set(panelHeight, 0f); base.Append(backPanel); //Text lockMouseText = new UIText("Lock mouse?", 1.15f, false) { VAlign = 0.07f, HAlign = 0.07f }; backPanel.Append(lockMouseText); //Yes button yesButton = new UITextPanel <string>("Yes", 0.7f, true) { VAlign = 0.85f, HAlign = 0.06f }; yesButton.OnClick += YesButtonClicked; backPanel.Append(yesButton); //No button noButton = new UITextPanel <string>("No", 0.7f, true) { VAlign = 0.85f, HAlign = 0.7f }; noButton.OnClick += NoButtonClicked; backPanel.Append(noButton); }
public override void OnInitialize() { //Panel backPanel = new UIPanel(); backPanel.SetPadding(0); backPanel.Left.Set(Terraria.Main.instance.GraphicsDevice.Viewport.Bounds.Width / 2 - panelWidth / 2, 0f); backPanel.Top.Set(Terraria.Main.instance.GraphicsDevice.Viewport.Bounds.Height / 2 - panelHeight / 2, 0f); backPanel.Width.Set(panelWidth, 0f); backPanel.Height.Set(panelHeight, 0f); base.Append(backPanel); //Change gamepad button changeGamepadButton = new UITextPanel <string>("Next", 0.5f, true) { VAlign = 0.05f, HAlign = 0.03f }; changeGamepadButton.OnClick += new UIElement.MouseEvent(this.ChangedButtonClicked); backPanel.Append(changeGamepadButton); //Player index display playerIndexDisplay = new UIText("", 1.15f, false) { VAlign = 0.07f, HAlign = 0.6f }; backPanel.Append(playerIndexDisplay); //Finished button finishButton = new UITextPanel <string>("OK", 0.5f, true) { VAlign = 0.9f, HAlign = 0.9f }; finishButton.OnClick += FinishButtonClicked; backPanel.Append(finishButton); }
public override void OnInitialize() { UIElement uIElement = new UIElement(); uIElement.Width.Set(0f, 0.8f); uIElement.MaxWidth.Set(600f, 0f); uIElement.Top.Set(220f, 0f); uIElement.Height.Set(-220f, 1f); uIElement.HAlign = 0.5f; UIPanel uIPanel = new UIPanel(); uIPanel.Width.Set(0f, 1f); uIPanel.Height.Set(-110f, 1f); uIPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f; uIElement.Append(uIPanel); modInfo = new UIMessageBox("This is a test of mod info here."); modInfo.Width.Set(0f, 1f); modInfo.Height.Set(0f, 1f); uIPanel.Append(modInfo); uITextPanel = new UITextPanel("Mod Info", 0.8f, true); uITextPanel.HAlign = 0.5f; uITextPanel.Top.Set(-35f, 0f); uITextPanel.SetPadding(15f); uITextPanel.BackgroundColor = new Color(73, 94, 171); uIElement.Append(uITextPanel); UITextPanel button3 = new UITextPanel("Back", 1f, false); button3.Width.Set(-10f, 0.5f); button3.Height.Set(25f, 0f); button3.VAlign = 1f; button3.Top.Set(-20f, 0f); button3.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver); button3.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut); button3.OnClick += new UIElement.MouseEvent(BackClick); uIElement.Append(button3); base.Append(uIElement); }
public UIBoolSetting(StoredVariable variable) { this.storedVar = variable; Width.Set(0, 1f); Height.Set(40f, 0f); UIText title = new UIText(storedVar.DisplayName, 0.9f, false); title.MaxWidth.Set(-10f, 1f); booleanSetting = new UITextPanel <string>("FILLER", 0.8f, false); booleanSetting.Top.Set(-18, 0.5f); booleanSetting.Left.Set(-46, 1f); booleanSetting.MinWidth.Set(60f, 0f); _defaultBackground = booleanSetting.BackgroundColor; _defaultBorder = booleanSetting.BorderColor; booleanSetting.OnMouseOver += boxOnMouseOver; booleanSetting.OnClick += boxOnClick; booleanSetting.OnMouseUp += boxOnMouseUpOut; booleanSetting.OnMouseOut += boxOnMouseUpOut; base.Append(booleanSetting); base.Append(title); }
public UIVirtualKeyboard(string labelText, string startingText, UIVirtualKeyboard.KeyboardSubmitEvent submitAction, Action cancelAction, int inputMode = 0, bool allowEmpty = false) { this._keyboardContext = inputMode; this._allowEmpty = allowEmpty; UIVirtualKeyboard.OffsetDown = 0; this._lastOffsetDown = 0; this._edittingSign = this._keyboardContext == 1; this._edittingChest = this._keyboardContext == 2; UIVirtualKeyboard._currentInstance = this; this._submitAction = submitAction; this._cancelAction = cancelAction; this._textureShift = TextureManager.Load("Images/UI/VK_Shift"); this._textureBackspace = TextureManager.Load("Images/UI/VK_Backspace"); this.Top.Pixels = (float)this._lastOffsetDown; float num1 = (float)(-5000 * this._edittingSign.ToInt()); float maxValue = (float)byte.MaxValue; float num2 = 0.0f; float num3 = 516f; UIElement element = new UIElement(); element.Width.Pixels = (float)((double)num3 + 8.0 + 16.0); element.Top.Precent = num2; element.Top.Pixels = maxValue; element.Height.Pixels = 266f; element.HAlign = 0.5f; element.SetPadding(0.0f); this.outerLayer1 = element; UIElement uiElement = new UIElement(); uiElement.Width.Pixels = (float)((double)num3 + 8.0 + 16.0); uiElement.Top.Precent = num2; uiElement.Top.Pixels = maxValue; uiElement.Height.Pixels = 266f; uiElement.HAlign = 0.5f; uiElement.SetPadding(0.0f); this.outerLayer2 = uiElement; UIPanel mainPanel = new UIPanel(); mainPanel.Width.Precent = 1f; mainPanel.Height.Pixels = 225f; mainPanel.BackgroundColor = new Color(23, 33, 69) * 0.7f; element.Append((UIElement)mainPanel); float num4 = -79f; this._textBox = new UITextBox("", 0.78f, true); this._textBox.BackgroundColor = Color.Transparent; this._textBox.BorderColor = Color.Transparent; this._textBox.HAlign = 0.5f; this._textBox.Width.Pixels = num3; this._textBox.Top.Pixels = (float)((double)num4 + (double)maxValue - 10.0) + num1; this._textBox.Top.Precent = num2; this._textBox.Height.Pixels = 37f; this.Append((UIElement)this._textBox); for (int x = 0; x < 10; ++x) { for (int y = 0; y < 4; ++y) { UITextPanel <object> keyboardButton = this.CreateKeyboardButton((object)"1234567890qwertyuiopasdfghjkl'zxcvbnm,.?"[y * 10 + x].ToString(), x, y, 1, true); keyboardButton.OnClick += new UIElement.MouseEvent(this.TypeText); mainPanel.Append((UIElement)keyboardButton); } } this._shiftButton = this.CreateKeyboardButton((object)"", 0, 4, 1, false); this._shiftButton.PaddingLeft = 0.0f; this._shiftButton.PaddingRight = 0.0f; this._shiftButton.PaddingBottom = this._shiftButton.PaddingTop = 0.0f; this._shiftButton.BackgroundColor = new Color(63, 82, 151) * 0.7f; this._shiftButton.BorderColor = this._internalBorderColor * 0.7f; this._shiftButton.OnMouseOver += (UIElement.MouseEvent)((evt, listeningElement) => { this._shiftButton.BorderColor = this._internalBorderColorSelected; if (this._keyState == UIVirtualKeyboard.KeyState.Shift) { return; } this._shiftButton.BackgroundColor = new Color(73, 94, 171); }); this._shiftButton.OnMouseOut += (UIElement.MouseEvent)((evt, listeningElement) => { this._shiftButton.BorderColor = this._internalBorderColor * 0.7f; if (this._keyState == UIVirtualKeyboard.KeyState.Shift) { return; } this._shiftButton.BackgroundColor = new Color(63, 82, 151) * 0.7f; }); this._shiftButton.OnClick += (UIElement.MouseEvent)((evt, listeningElement) => { Main.PlaySound(12, -1, -1, 1, 1f, 0.0f); this.SetKeyState(this._keyState == UIVirtualKeyboard.KeyState.Shift ? UIVirtualKeyboard.KeyState.Default : UIVirtualKeyboard.KeyState.Shift); }); UIImage uiImage1 = new UIImage(this._textureShift); uiImage1.HAlign = 0.5f; uiImage1.VAlign = 0.5f; uiImage1.ImageScale = 0.85f; this._shiftButton.Append((UIElement)uiImage1); mainPanel.Append((UIElement)this._shiftButton); this._symbolButton = this.CreateKeyboardButton((object)"@%", 1, 4, 1, false); this._symbolButton.PaddingLeft = 0.0f; this._symbolButton.PaddingRight = 0.0f; this._symbolButton.BackgroundColor = new Color(63, 82, 151) * 0.7f; this._symbolButton.BorderColor = this._internalBorderColor * 0.7f; this._symbolButton.OnMouseOver += (UIElement.MouseEvent)((evt, listeningElement) => { this._symbolButton.BorderColor = this._internalBorderColorSelected; if (this._keyState == UIVirtualKeyboard.KeyState.Symbol) { return; } this._symbolButton.BackgroundColor = new Color(73, 94, 171); }); this._symbolButton.OnMouseOut += (UIElement.MouseEvent)((evt, listeningElement) => { this._symbolButton.BorderColor = this._internalBorderColor * 0.7f; if (this._keyState == UIVirtualKeyboard.KeyState.Symbol) { return; } this._symbolButton.BackgroundColor = new Color(63, 82, 151) * 0.7f; }); this._symbolButton.OnClick += (UIElement.MouseEvent)((evt, listeningElement) => { Main.PlaySound(12, -1, -1, 1, 1f, 0.0f); this.SetKeyState(this._keyState == UIVirtualKeyboard.KeyState.Symbol ? UIVirtualKeyboard.KeyState.Default : UIVirtualKeyboard.KeyState.Symbol); }); mainPanel.Append((UIElement)this._symbolButton); this.BuildSpaceBarArea(mainPanel); this._submitButton = new UITextPanel <LocalizedText>(this._edittingSign || this._edittingChest ? Language.GetText("UI.Save") : Language.GetText("UI.Submit"), 0.4f, true); this._submitButton.Height.Pixels = 37f; this._submitButton.Width.Precent = 0.4f; this._submitButton.HAlign = 1f; this._submitButton.VAlign = 1f; this._submitButton.PaddingLeft = 0.0f; this._submitButton.PaddingRight = 0.0f; this.ValidateText(); this._submitButton.OnMouseOver += (UIElement.MouseEvent)((evt, listeningElement) => this.ValidateText()); this._submitButton.OnMouseOut += (UIElement.MouseEvent)((evt, listeningElement) => this.ValidateText()); this._submitButton.OnClick += (UIElement.MouseEvent)((evt, listeningElement) => { string text = this.Text.Trim(); if (text.Length <= 0 && !this._edittingSign && (!this._edittingChest && !this._allowEmpty)) { return; } Main.PlaySound(10, -1, -1, 1, 1f, 0.0f); this._submitAction(text); }); element.Append((UIElement)this._submitButton); this._cancelButton = new UITextPanel <LocalizedText>(Language.GetText("UI.Cancel"), 0.4f, true); this.StyleKey <LocalizedText>(this._cancelButton, true); this._cancelButton.Height.Pixels = 37f; this._cancelButton.Width.Precent = 0.4f; this._cancelButton.VAlign = 1f; this._cancelButton.OnClick += (UIElement.MouseEvent)((evt, listeningElement) => { Main.PlaySound(11, -1, -1, 1, 1f, 0.0f); this._cancelAction(); }); element.Append((UIElement)this._cancelButton); this._submitButton2 = new UITextPanel <LocalizedText>(this._edittingSign || this._edittingChest ? Language.GetText("UI.Save") : Language.GetText("UI.Submit"), 0.72f, true); this._submitButton2.TextColor = Color.Silver; this._submitButton2.DrawPanel = false; this._submitButton2.Height.Pixels = 60f; this._submitButton2.Width.Precent = 0.4f; this._submitButton2.HAlign = 0.5f; this._submitButton2.VAlign = 0.0f; this._submitButton2.OnMouseOver += (UIElement.MouseEvent)((a, b) => { ((UITextPanel <LocalizedText>)b).TextScale = 0.85f; ((UITextPanel <LocalizedText>)b).TextColor = Color.White; }); this._submitButton2.OnMouseOut += (UIElement.MouseEvent)((a, b) => { ((UITextPanel <LocalizedText>)b).TextScale = 0.72f; ((UITextPanel <LocalizedText>)b).TextColor = Color.Silver; }); this._submitButton2.Top.Pixels = 50f; this._submitButton2.PaddingLeft = 0.0f; this._submitButton2.PaddingRight = 0.0f; this.ValidateText(); this._submitButton2.OnMouseOver += (UIElement.MouseEvent)((evt, listeningElement) => this.ValidateText()); this._submitButton2.OnMouseOut += (UIElement.MouseEvent)((evt, listeningElement) => this.ValidateText()); this._submitButton2.OnClick += (UIElement.MouseEvent)((evt, listeningElement) => { string text = this.Text.Trim(); if (text.Length <= 0 && !this._edittingSign && (!this._edittingChest && !this._allowEmpty)) { return; } Main.PlaySound(10, -1, -1, 1, 1f, 0.0f); this._submitAction(text); }); this.outerLayer2.Append((UIElement)this._submitButton2); this._cancelButton2 = new UITextPanel <LocalizedText>(Language.GetText("UI.Cancel"), 0.72f, true); this._cancelButton2.TextColor = Color.Silver; this._cancelButton2.DrawPanel = false; this._cancelButton2.OnMouseOver += (UIElement.MouseEvent)((a, b) => { ((UITextPanel <LocalizedText>)b).TextScale = 0.85f; ((UITextPanel <LocalizedText>)b).TextColor = Color.White; }); this._cancelButton2.OnMouseOut += (UIElement.MouseEvent)((a, b) => { ((UITextPanel <LocalizedText>)b).TextScale = 0.72f; ((UITextPanel <LocalizedText>)b).TextColor = Color.Silver; }); this._cancelButton2.Height.Pixels = 60f; this._cancelButton2.Width.Precent = 0.4f; this._cancelButton2.Top.Pixels = 114f; this._cancelButton2.VAlign = 0.0f; this._cancelButton2.HAlign = 0.5f; this._cancelButton2.OnClick += (UIElement.MouseEvent)((evt, listeningElement) => { Main.PlaySound(11, -1, -1, 1, 1f, 0.0f); this._cancelAction(); }); this.outerLayer2.Append((UIElement)this._cancelButton2); UITextPanel <object> keyboardButton1 = this.CreateKeyboardButton((object)"", 8, 4, 2, true); keyboardButton1.OnClick += (UIElement.MouseEvent)((evt, listeningElement) => { Main.PlaySound(12, -1, -1, 1, 1f, 0.0f); this._textBox.Backspace(); this.ValidateText(); }); keyboardButton1.PaddingLeft = 0.0f; keyboardButton1.PaddingRight = 0.0f; keyboardButton1.PaddingBottom = keyboardButton1.PaddingTop = 0.0f; UIImage uiImage2 = new UIImage(this._textureBackspace); uiImage2.HAlign = 0.5f; uiImage2.VAlign = 0.5f; uiImage2.ImageScale = 0.92f; keyboardButton1.Append((UIElement)uiImage2); mainPanel.Append((UIElement)keyboardButton1); UIText uiText = new UIText(labelText, 0.75f, true); uiText.HAlign = 0.5f; uiText.Width.Pixels = num3; uiText.Top.Pixels = (float)((double)num4 - 37.0 - 4.0) + maxValue + num1; uiText.Top.Precent = num2; uiText.Height.Pixels = 37f; this.Append((UIElement)uiText); this._label = uiText; this.Append(element); this._textBox.SetTextMaxLength(this._edittingSign ? 99999 : 20); this.Text = startingText; if (this.Text.Length == 0) { this.SetKeyState(UIVirtualKeyboard.KeyState.Shift); } UIVirtualKeyboard.OffsetDown = 9999; this.UpdateOffsetDown(); }
private void BuildPage() { this.RemoveAllChildren(); UIElement uiElement = new UIElement(); uiElement.Width.Set(0.0f, 0.8f); uiElement.MaxWidth.Set(800f, 0.0f); uiElement.MinWidth.Set(600f, 0.0f); uiElement.Top.Set(240f, 0.0f); uiElement.Height.Set(-240f, 1f); uiElement.HAlign = 0.5f; this.Append(uiElement); UIPanel uiPanel1 = new UIPanel(); uiPanel1.Width = StyleDimension.Fill; uiPanel1.Height = new StyleDimension(-110f, 1f); uiPanel1.BackgroundColor = new Color(33, 43, 79) * 0.8f; uiPanel1.PaddingRight = 0.0f; uiPanel1.PaddingLeft = 0.0f; UIPanel uiPanel2 = uiPanel1; uiElement.Append((UIElement)uiPanel2); int num1 = 35; int num2 = num1; int num3 = 30; UIElement element1 = new UIElement() { Width = StyleDimension.Fill, Height = StyleDimension.FromPixelsAndPercent((float)-(num3 + 4 + 5), 1f), VAlign = 1f }; element1.SetPadding(0.0f); uiPanel2.Append(element1); UIElement element2 = new UIElement() { Width = new StyleDimension(-20f, 0.5f), Height = new StyleDimension(0.0f, 1f), Left = new StyleDimension(10f, 0.0f) }; element2.SetPadding(0.0f); element1.Append(element2); UIElement element3 = new UIElement() { Width = new StyleDimension(-20f, 0.5f), Height = new StyleDimension(0.0f, 1f), Left = new StyleDimension(-10f, 0.0f), HAlign = 1f }; element3.SetPadding(0.0f); element1.Append(element3); UIList uiList1 = new UIList(); uiList1.Width = new StyleDimension(-25f, 1f); uiList1.Height = new StyleDimension(0.0f, 1f); uiList1.ListPadding = 5f; uiList1.HAlign = 1f; UIList uiList2 = uiList1; element2.Append((UIElement)uiList2); this._availablePacksList = uiList2; UIList uiList3 = new UIList(); uiList3.Width = new StyleDimension(-25f, 1f); uiList3.Height = new StyleDimension(0.0f, 1f); uiList3.ListPadding = 5f; uiList3.HAlign = 0.0f; uiList3.Left = new StyleDimension(0.0f, 0.0f); UIList uiList4 = uiList3; element3.Append((UIElement)uiList4); this._enabledPacksList = uiList4; UIText uiText1 = new UIText(Language.GetText("UI.AvailableResourcePacksTitle"), 1f, false); uiText1.HAlign = 0.0f; uiText1.Left = new StyleDimension(25f, 0.0f); uiText1.Width = new StyleDimension(-25f, 0.5f); uiText1.VAlign = 0.0f; uiText1.Top = new StyleDimension(10f, 0.0f); UIText uiText2 = uiText1; this._titleAvailable = uiText2; uiPanel2.Append((UIElement)uiText2); UIText uiText3 = new UIText(Language.GetText("UI.EnabledResourcePacksTitle"), 1f, false); uiText3.HAlign = 1f; uiText3.Left = new StyleDimension(-25f, 0.0f); uiText3.Width = new StyleDimension(-25f, 0.5f); uiText3.VAlign = 0.0f; uiText3.Top = new StyleDimension(10f, 0.0f); UIText uiText4 = uiText3; this._titleEnabled = uiText4; uiPanel2.Append((UIElement)uiText4); UITextPanel <LocalizedText> uiTextPanel1 = new UITextPanel <LocalizedText>(Language.GetText("UI.ResourcePacks"), 1f, true); uiTextPanel1.HAlign = 0.5f; uiTextPanel1.VAlign = 0.0f; uiTextPanel1.Top = new StyleDimension(-44f, 0.0f); uiTextPanel1.BackgroundColor = new Color(73, 94, 171); UITextPanel <LocalizedText> uiTextPanel2 = uiTextPanel1; uiTextPanel2.SetPadding(13f); uiElement.Append((UIElement)uiTextPanel2); UIScrollbar uiScrollbar1 = new UIScrollbar(); uiScrollbar1.Height = new StyleDimension(0.0f, 1f); uiScrollbar1.HAlign = 0.0f; uiScrollbar1.Left = new StyleDimension(0.0f, 0.0f); UIScrollbar scrollbar1 = uiScrollbar1; element2.Append((UIElement)scrollbar1); this._availablePacksList.SetScrollbar(scrollbar1); UIVerticalSeparator verticalSeparator1 = new UIVerticalSeparator(); verticalSeparator1.Height = new StyleDimension(-12f, 1f); verticalSeparator1.HAlign = 0.5f; verticalSeparator1.VAlign = 1f; verticalSeparator1.Color = new Color(89, 116, 213, (int)byte.MaxValue) * 0.9f; UIVerticalSeparator verticalSeparator2 = verticalSeparator1; uiPanel2.Append((UIElement)verticalSeparator2); UIHorizontalSeparator horizontalSeparator1 = new UIHorizontalSeparator(2, true); horizontalSeparator1.Width = new StyleDimension((float)-num2, 0.5f); horizontalSeparator1.VAlign = 0.0f; horizontalSeparator1.HAlign = 0.0f; horizontalSeparator1.Color = new Color(89, 116, 213, (int)byte.MaxValue) * 0.9f; horizontalSeparator1.Top = new StyleDimension((float)num3, 0.0f); horizontalSeparator1.Left = new StyleDimension((float)num1, 0.0f); UIHorizontalSeparator horizontalSeparator2 = new UIHorizontalSeparator(2, true); horizontalSeparator2.Width = new StyleDimension((float)-num2, 0.5f); horizontalSeparator2.VAlign = 0.0f; horizontalSeparator2.HAlign = 1f; horizontalSeparator2.Color = new Color(89, 116, 213, (int)byte.MaxValue) * 0.9f; horizontalSeparator2.Top = new StyleDimension((float)num3, 0.0f); horizontalSeparator2.Left = new StyleDimension((float)-num1, 0.0f); UIScrollbar uiScrollbar2 = new UIScrollbar(); uiScrollbar2.Height = new StyleDimension(0.0f, 1f); uiScrollbar2.HAlign = 1f; UIScrollbar scrollbar2 = uiScrollbar2; element3.Append((UIElement)scrollbar2); this._enabledPacksList.SetScrollbar(scrollbar2); this.AddBackAndFolderButtons(uiElement); }
internal static UIPanel MakeSeparateListPanel(object item, object subitem, PropertyFieldWrapper memberInfo, IList array, int index, Func <string> AbridgedTextDisplayFunction) { UIPanel uIPanel = new UIPanel(); uIPanel.CopyStyle(Interface.modConfig.uIPanel); uIPanel.BackgroundColor = UICommon.MainPanelBackground; BackgroundColorAttribute bca = ConfigManager.GetCustomAttribute <BackgroundColorAttribute>(memberInfo, subitem, null); if (bca != null) { uIPanel.BackgroundColor = bca.color; } //uIElement.Append(uIPanel); UIList separateList = new UIList(); separateList.CopyStyle(Interface.modConfig.mainConfigList); separateList.Height.Set(-40f, 1f); separateList.Top.Set(40f, 0f); uIPanel.Append(separateList); int i = 0; int top = 0; UIScrollbar uIScrollbar = new UIScrollbar(); uIScrollbar.SetView(100f, 1000f); uIScrollbar.Height.Set(-40f, 1f); uIScrollbar.Top.Set(40f, 0f); uIScrollbar.HAlign = 1f; uIPanel.Append(uIScrollbar); separateList.SetScrollbar(uIScrollbar); string name = ConfigManager.GetCustomAttribute <LabelAttribute>(memberInfo, subitem, null)?.Label ?? memberInfo.Name; if (index != -1) { name = name + " #" + (index + 1); } Interface.modConfig.subPageStack.Push(name); //UIPanel heading = new UIPanel(); //UIText headingText = new UIText(name); name = string.Join(" > ", Interface.modConfig.subPageStack.Reverse()); //.Aggregate((current, next) => current + "/" + next); UITextPanel <string> heading = new UITextPanel <string>(name); // TODO: ToString as well. Separate label? heading.HAlign = 0f; //heading.Width.Set(-10, 0.5f); //heading.Left.Set(60, 0f); heading.Top.Set(-6, 0); heading.Height.Set(40, 0); //var headingContainer = GetContainer(heading, i++); //headingContainer.Height.Pixels = 40; uIPanel.Append(heading); //headingText.Top.Set(6, 0); //headingText.Left.Set(0, .5f); //headingText.HAlign = .5f; //uIPanel.Append(headingText); //top += 40; UITextPanel <string> back = new UITextPanel <string>("Back"); back.HAlign = 1f; back.Width.Set(50, 0f); back.Top.Set(-6, 0); //top += 40; //var capturedCurrent = Interface.modConfig.currentConfigList; back.OnClick += (a, c) => { Interface.modConfig.uIElement.RemoveChild(uIPanel); Interface.modConfig.configPanelStack.Pop(); Interface.modConfig.uIElement.Append(Interface.modConfig.configPanelStack.Peek()); //Interface.modConfig.configPanelStack.Peek().SetScrollbar(Interface.modConfig.uIScrollbar); //Interface.modConfig.currentConfigList = capturedCurrent; }; back.WithFadedMouseOver(); //var backContainer = GetContainer(back, i++); //backContainer.Height.Pixels = 40; uIPanel.Append(back); //var b = new UIText("Test"); //separateList.Add(b); // Make rest of list // load all mod config options into UIList // TODO: Inheritance with ModConfig? DeclaredOnly? if (true) { int order = 0; bool hasToString = false; if (array != null) { var listType = memberInfo.Type.GetGenericArguments()[0]; hasToString = listType.GetMethod("ToString", new Type[0]).DeclaringType != typeof(object); } else { hasToString = memberInfo.Type.GetMethod("ToString", new Type[0]).DeclaringType != typeof(object); } if (AbridgedTextDisplayFunction != null) { var display = new UITextPanel <FuncStringWrapper>(new FuncStringWrapper() { func = AbridgedTextDisplayFunction, }) { DrawPanel = true }; display.Recalculate(); var container = GetContainer(display, order++); container.Height.Pixels = (int)display.GetOuterDimensions().Height; separateList.Add(container); } //if (hasToString) // _TextDisplayFunction = () => index + 1 + ": " + (array[index]?.ToString() ?? "null"); foreach (PropertyFieldWrapper variable in ConfigManager.GetFieldsAndProperties(subitem)) { if (Attribute.IsDefined(variable.MemberInfo, typeof(JsonIgnoreAttribute)) && !Attribute.IsDefined(variable.MemberInfo, typeof(LabelAttribute))) // TODO, appropriately named attribute { continue; } HeaderAttribute header = ConfigManager.GetCustomAttribute <HeaderAttribute>(variable, null, null); if (header != null) { var wrapper = new PropertyFieldWrapper(typeof(HeaderAttribute).GetProperty(nameof(HeaderAttribute.Header))); WrapIt(separateList, ref top, wrapper, header, order++); } WrapIt(separateList, ref top, variable, subitem, order++); } } else { //ignoreSeparatePage just to simplify ToString label--> had some issues. //WrapIt(separateList, ref top, memberInfo, item, 1, ignoreSeparatePage: true); } Interface.modConfig.subPageStack.Pop(); return(uIPanel); }
public override void OnInitialize() { uIElement = new UIElement(); uIElement.Width.Set(0f, 0.8f); uIElement.MaxWidth.Set(600f, 0f); uIElement.Top.Set(160f, 0f); uIElement.Height.Set(-180f, 1f); uIElement.HAlign = 0.5f; uIPanel = new UIPanel(); uIPanel.Width.Set(0f, 1f); uIPanel.Height.Set(-140f, 1f); uIPanel.Top.Set(30f, 0f); uIPanel.BackgroundColor = UICommon.MainPanelBackground; uIElement.Append(uIPanel); UIPanel textBoxBackground = new UIPanel(); textBoxBackground.SetPadding(0); filterTextField = new UIFocusInputTextField("Filter Options"); textBoxBackground.Top.Set(2f, 0f); textBoxBackground.Left.Set(-190, 1f); textBoxBackground.Width.Set(180, 0f); textBoxBackground.Height.Set(30, 0f); uIElement.Append(textBoxBackground); filterTextField.SetText(""); filterTextField.Top.Set(5, 0f); filterTextField.Left.Set(10, 0f); filterTextField.Width.Set(-20, 1f); filterTextField.Height.Set(20, 0); filterTextField.OnTextChange += (a, b) => { updateNeeded = true; }; filterTextField.OnRightClick += (a, b) => { filterTextField.SetText(""); }; textBoxBackground.Append(filterTextField); // TODO: ModConfig Localization support message = new UITextPanel <string>("Notification: "); message.Width.Set(-80f, 1f); message.Height.Set(20f, 0f); message.HAlign = 0.5f; message.VAlign = 1f; message.Top.Set(-65f, 0f); uIElement.Append(message); mainConfigList = new UIList(); mainConfigList.Width.Set(-25f, 1f); mainConfigList.Height.Set(0f, 1f); //mainConfigList.Top.Set(40f, 0f); mainConfigList.ListPadding = 5f; uIPanel.Append(mainConfigList); configPanelStack.Push(uIPanel); //currentConfigList = mainConfigList; uIScrollbar = new UIScrollbar(); uIScrollbar.SetView(100f, 1000f); uIScrollbar.Height.Set(0f, 1f); uIScrollbar.HAlign = 1f; uIPanel.Append(uIScrollbar); mainConfigList.SetScrollbar(uIScrollbar); headerTextPanel = new UITextPanel <string>("Mod Config", 0.8f, true); headerTextPanel.HAlign = 0.5f; headerTextPanel.Top.Set(-50f, 0f); headerTextPanel.SetPadding(15f); headerTextPanel.BackgroundColor = UICommon.DefaultUIBlue; uIElement.Append(headerTextPanel); previousConfigButton = new UITextPanel <string>("<", 1f, false); previousConfigButton.Width.Set(25f, 0); previousConfigButton.Height.Set(25f, 0f); previousConfigButton.VAlign = 1f; previousConfigButton.Top.Set(-65f, 0f); previousConfigButton.HAlign = 0f; previousConfigButton.WithFadedMouseOver(); previousConfigButton.OnClick += PreviousConfig; //uIElement.Append(previousConfigButton); nextConfigButton = new UITextPanel <string>(">", 1f, false); nextConfigButton.CopyStyle(previousConfigButton); nextConfigButton.WithFadedMouseOver(); nextConfigButton.HAlign = 1f; nextConfigButton.OnClick += NextConfig; //uIElement.Append(nextConfigButton); saveConfigButton = new UITextPanel <string>("Save Config", 1f, false); saveConfigButton.Width.Set(-10f, 1f / 4f); saveConfigButton.Height.Set(25f, 0f); saveConfigButton.Top.Set(-20f, 0f); saveConfigButton.WithFadedMouseOver(); saveConfigButton.HAlign = 0.33f; saveConfigButton.VAlign = 1f; saveConfigButton.OnClick += SaveConfig; //uIElement.Append(saveConfigButton); backButton = new UITextPanel <string>("Back", 1f, false); backButton.CopyStyle(saveConfigButton); backButton.HAlign = 0; backButton.WithFadedMouseOver(); backButton.OnMouseOver += (a, b) => { if (pendingChanges) { backButton.BackgroundColor = Color.Red; } }; backButton.OnMouseOut += (a, b) => { if (pendingChanges) { backButton.BackgroundColor = Color.Red * 0.7f; } }; backButton.OnClick += BackClick; uIElement.Append(backButton); revertConfigButton = new UITextPanel <string>("Revert Changes", 1f, false); revertConfigButton.CopyStyle(saveConfigButton); revertConfigButton.WithFadedMouseOver(); revertConfigButton.HAlign = 0.66f; revertConfigButton.OnClick += RevertConfig; //uIElement.Append(revertConfigButton); //float scale = Math.Min(1f, 130f/Main.fontMouseText.MeasureString("Restore Defaults").X); restoreDefaultsConfigButton = new UITextPanel <string>("Restore Defaults", 1f, false); restoreDefaultsConfigButton.CopyStyle(saveConfigButton); restoreDefaultsConfigButton.WithFadedMouseOver(); restoreDefaultsConfigButton.HAlign = 1f; restoreDefaultsConfigButton.OnClick += RestoreDefaults; uIElement.Append(restoreDefaultsConfigButton); uIPanel.BackgroundColor = UICommon.MainPanelBackground; Append(uIElement); }
public override void OnInitialize() { area = new UIElement { Width = { Percent = 0.8f }, Top = { Pixels = 200 }, Height = { Pixels = -210, Percent = 1f }, HAlign = 0.5f }; messageBox = new UIMessageBox("") { Width = { Percent = 1f }, Height = { Pixels = -110, Percent = 1f }, HAlign = 0.5f }; area.Append(messageBox); continueButton = new UITextPanel <string>("", 0.7f, true) { Width = { Pixels = -10, Percent = 0.5f }, Height = { Pixels = 50 }, Top = { Pixels = -108, Percent = 1f } }; continueButton.WithFadedMouseOver(); continueButton.OnClick += ContinueClick; area.Append(continueButton); var openLogsButton = new UITextPanel <string>(Language.GetTextValue("tModLoader.OpenLogs"), 0.7f, true); openLogsButton.CopyStyle(continueButton); openLogsButton.HAlign = 1f; openLogsButton.WithFadedMouseOver(); openLogsButton.OnClick += OpenFile; area.Append(openLogsButton); webHelpButton = new UITextPanel <string>(Language.GetTextValue("tModLoader.OpenWebHelp"), 0.7f, true); webHelpButton.CopyStyle(openLogsButton); webHelpButton.Top.Set(-55f, 1f); webHelpButton.WithFadedMouseOver(); webHelpButton.OnClick += VisitRegisterWebpage; area.Append(webHelpButton); skipLoadButton = new UITextPanel <string>(Language.GetTextValue("tModLoader.SkipToMainMenu"), 0.7f, true); skipLoadButton.CopyStyle(continueButton); skipLoadButton.Top.Set(-55f, 1f); skipLoadButton.WithFadedMouseOver(); skipLoadButton.OnClick += SkipLoad; area.Append(skipLoadButton); exitAndDisableAllButton = new UITextPanel <string>(Language.GetTextValue("tModLoader.ExitAndDisableAll"), 0.7f, true); exitAndDisableAllButton.CopyStyle(skipLoadButton); exitAndDisableAllButton.TextColor = Color.Red; exitAndDisableAllButton.WithFadedMouseOver(); exitAndDisableAllButton.OnClick += ExitAndDisableAll; retryButton = new UITextPanel <string>("Retry", 0.7f, true); retryButton.CopyStyle(continueButton); retryButton.Top.Set(-50f, 1f); retryButton.WithFadedMouseOver(); retryButton.OnClick += (evt, elem) => retryAction(); Append(area); }
public override void OnInitialize() { UIElement uIElement = new UIElement(); uIElement.Width.Set(0f, 0.8f); uIElement.MaxWidth.Set(600f, 0f); uIElement.Top.Set(220f, 0f); uIElement.Height.Set(-220f, 1f); uIElement.HAlign = 0.5f; UIPanel uIPanel = new UIPanel(); uIPanel.Width.Set(0f, 1f); uIPanel.Height.Set(-110f, 1f); uIPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f; uIElement.Append(uIPanel); modList = new UIList(); modList.Width.Set(-25f, 1f); modList.Height.Set(0f, 1f); modList.ListPadding = 5f; uIPanel.Append(modList); UIScrollbar uIScrollbar = new UIScrollbar(); uIScrollbar.SetView(100f, 1000f); uIScrollbar.Height.Set(0f, 1f); uIScrollbar.HAlign = 1f; uIPanel.Append(uIScrollbar); modList.SetScrollbar(uIScrollbar); UITextPanel uITextPanel = new UITextPanel("Mod Sources", 0.8f, true); uITextPanel.HAlign = 0.5f; uITextPanel.Top.Set(-35f, 0f); uITextPanel.SetPadding(15f); uITextPanel.BackgroundColor = new Color(73, 94, 171); uIElement.Append(uITextPanel); UITextPanel button = new UITextPanel("Build All", 1f, false); button.Width.Set(-10f, 0.5f); button.Height.Set(25f, 0f); button.VAlign = 1f; button.Top.Set(-65f, 0f); button.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver); button.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut); button.OnClick += new UIElement.MouseEvent(BuildMods); uIElement.Append(button); UITextPanel button2 = new UITextPanel("Build + Reload All", 1f, false); button2.CopyStyle(button); button2.HAlign = 1f; button2.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver); button2.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut); button2.OnClick += new UIElement.MouseEvent(BuildAndReload); uIElement.Append(button2); UITextPanel button3 = new UITextPanel("Back", 1f, false); button3.CopyStyle(button); button3.Width.Set(-10f, 1f / 3f); button3.Top.Set(-20f, 0f); button3.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver); button3.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut); button3.OnClick += new UIElement.MouseEvent(BackClick); uIElement.Append(button3); UITextPanel button4 = new UITextPanel("Open Sources", 1f, false); button4.CopyStyle(button3); button4.HAlign = .5f; button4.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver); button4.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut); button4.OnClick += new UIElement.MouseEvent(OpenSources); uIElement.Append(button4); UITextPanel button5 = new UITextPanel("Manage Published", 1f, false); button5.CopyStyle(button3); button5.HAlign = 1f; button5.OnMouseOver += new UIElement.MouseEvent(FadedMouseOver); button5.OnMouseOut += new UIElement.MouseEvent(FadedMouseOut); button5.OnClick += new UIElement.MouseEvent(ManagePublished); uIElement.Append(button5); base.Append(uIElement); }
public override void OnInitialize() { uIElement = new UIElement { Width = { Percent = 0.8f }, MaxWidth = UICommon.MaxPanelWidth, Top = { Pixels = 220 }, Height = { Pixels = -220, Percent = 1f }, HAlign = 0.5f }; uIPanel = new UIPanel { Width = { Percent = 1f }, Height = { Pixels = -110, Percent = 1f }, BackgroundColor = UICommon.mainPanelBackground, PaddingTop = 0f }; uIElement.Append(uIPanel); uiLoader = new UILoaderAnimatedImage(0.5f, 0.5f, 1f); modList = new UIList { Width = { Pixels = -25, Percent = 1f }, Height = { Pixels = -50, Percent = 1f }, Top = { Pixels = 50 }, ListPadding = 5f }; uIPanel.Append(modList); var uIScrollbar = new UIScrollbar { Height = { Pixels = -50, Percent = 1f }, Top = { Pixels = 50 }, HAlign = 1f }.WithView(100f, 1000f); uIPanel.Append(uIScrollbar); modList.SetScrollbar(uIScrollbar); var uIHeaderTexTPanel = new UITextPanel <string>(Language.GetTextValue("tModLoader.ModsModsList"), 0.8f, true) { HAlign = 0.5f, Top = { Pixels = -35 }, BackgroundColor = UICommon.defaultUIBlue }.WithPadding(15f); uIElement.Append(uIHeaderTexTPanel); buttonEA = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsEnableAll")) { TextColor = Color.Green, Width = new StyleDimension(-10f, 1f / 3f), Height = { Pixels = 40 }, VAlign = 1f, Top = { Pixels = -65 } }.WithFadedMouseOver(); buttonEA.OnClick += EnableAll; uIElement.Append(buttonEA); // TODO CopyStyle doesn't capture all the duplication here, consider an inner method buttonDA = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsDisableAll")); buttonDA.CopyStyle(buttonEA); buttonDA.TextColor = Color.Red; buttonDA.HAlign = 0.5f; buttonDA.WithFadedMouseOver(); buttonDA.OnClick += DisableAll; uIElement.Append(buttonDA); buttonRM = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsReloadMods")); buttonRM.CopyStyle(buttonEA); buttonRM.HAlign = 1f; buttonDA.WithFadedMouseOver(); buttonRM.OnClick += ReloadMods; uIElement.Append(buttonRM); buttonB = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("UI.Back")); buttonB.CopyStyle(buttonEA); buttonB.Top.Pixels = -20; buttonB.WithFadedMouseOver(); buttonB.OnClick += BackClick; uIElement.Append(buttonB); buttonOMF = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsOpenModsFolder")); buttonOMF.CopyStyle(buttonB); buttonOMF.HAlign = 0.5f; buttonOMF.WithFadedMouseOver(); buttonOMF.OnClick += OpenModsFolder; uIElement.Append(buttonOMF); var texture = Texture2D.FromStream(Main.instance.GraphicsDevice, Assembly.GetExecutingAssembly().GetManifestResourceStream("Terraria.ModLoader.UI.UIModBrowserIcons.png")); var upperMenuContainer = new UIElement { Width = { Percent = 1f }, Height = { Pixels = 32 }, Top = { Pixels = 10 } }; UICycleImage toggleImage; for (int j = 0; j < 3; j++) { if (j == 0) //TODO: ouch, at least there's a loop but these click events look quite similar { toggleImage = new UICycleImage(texture, 3, 32, 32, 34 * 3, 0); toggleImage.setCurrentState((int)sortMode); toggleImage.OnClick += (a, b) => { sortMode = sortMode.NextEnum(); updateNeeded = true; }; toggleImage.OnRightClick += (a, b) => { sortMode = sortMode.PreviousEnum(); updateNeeded = true; }; } else if (j == 1) { toggleImage = new UICycleImage(texture, 3, 32, 32, 34 * 4, 0); toggleImage.setCurrentState((int)enabledFilterMode); toggleImage.OnClick += (a, b) => { enabledFilterMode = enabledFilterMode.NextEnum(); updateNeeded = true; }; toggleImage.OnRightClick += (a, b) => { enabledFilterMode = enabledFilterMode.PreviousEnum(); updateNeeded = true; }; } else { toggleImage = new UICycleImage(texture, 5, 32, 32, 34 * 5, 0); toggleImage.setCurrentState((int)modSideFilterMode); toggleImage.OnClick += (a, b) => { modSideFilterMode = modSideFilterMode.NextEnum(); updateNeeded = true; }; toggleImage.OnRightClick += (a, b) => { modSideFilterMode = modSideFilterMode.PreviousEnum(); updateNeeded = true; }; } toggleImage.Left.Pixels = j * 36 + 8; _categoryButtons.Add(toggleImage); upperMenuContainer.Append(toggleImage); } var filterTextBoxBackground = new UIPanel { Top = { Percent = 0f }, Left = { Pixels = -170, Percent = 1f }, Width = { Pixels = 135 }, Height = { Pixels = 40 } }; filterTextBoxBackground.OnRightClick += (a, b) => filterTextBox.Text = ""; upperMenuContainer.Append(filterTextBoxBackground); filterTextBox = new UIInputTextField(Language.GetTextValue("tModLoader.ModsTypeToSearch")) { Top = { Pixels = 5 }, Left = { Pixels = -160, Percent = 1f }, Width = { Pixels = 120 }, Height = { Pixels = 20 } }; filterTextBox.OnTextChange += (a, b) => updateNeeded = true; upperMenuContainer.Append(filterTextBox); SearchFilterToggle = new UICycleImage(texture, 2, 32, 32, 34 * 2, 0) { Left = { Pixels = 545 } }; SearchFilterToggle.setCurrentState((int)searchFilterMode); SearchFilterToggle.OnClick += (a, b) => { searchFilterMode = searchFilterMode.NextEnum(); updateNeeded = true; }; SearchFilterToggle.OnRightClick += (a, b) => { searchFilterMode = searchFilterMode.PreviousEnum(); updateNeeded = true; }; _categoryButtons.Add(SearchFilterToggle); upperMenuContainer.Append(SearchFilterToggle); buttonMP = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModsModPacks")); buttonMP.CopyStyle(buttonOMF); buttonMP.HAlign = 1f; buttonMP.WithFadedMouseOver(); buttonMP.OnClick += GotoModPacksMenu; uIElement.Append(buttonMP); uIPanel.Append(upperMenuContainer); Append(uIElement); }
public override void OnInitialize() { UIElement uIElement = new UIElement(); uIElement.Width.Set(0f, 0.8f); uIElement.MaxWidth.Set(600f, 0f); uIElement.Top.Set(220f, 0f); uIElement.Height.Set(-220f, 1f); uIElement.HAlign = 0.5f; uiLoader = new UILoaderAnimatedImage(0.5f, 0.5f, 1f); scrollPanel = new UIPanel(); scrollPanel.Width.Set(0f, 1f); scrollPanel.Height.Set(-65f, 1f); scrollPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f; uIElement.Append(scrollPanel); modListList = new UIList(); modListList.Width.Set(-25f, 1f); modListList.Height.Set(0f, 1f); modListList.ListPadding = 5f; scrollPanel.Append(modListList); UIScrollbar uIScrollbar = new UIScrollbar(); uIScrollbar.SetView(100f, 1000f); uIScrollbar.Height.Set(0f, 1f); uIScrollbar.HAlign = 1f; scrollPanel.Append(uIScrollbar); modListList.SetScrollbar(uIScrollbar); UITextPanel <string> titleTextPanel = new UITextPanel <string>(Language.GetTextValue("tModLoader.ModPacksHeader"), 0.8f, true); titleTextPanel.HAlign = 0.5f; titleTextPanel.Top.Set(-35f, 0f); titleTextPanel.SetPadding(15f); titleTextPanel.BackgroundColor = new Color(73, 94, 171); uIElement.Append(titleTextPanel); UIAutoScaleTextTextPanel <string> backButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("UI.Back"), 1f, false); backButton.Width.Set(-10f, 1f / 2f); backButton.Height.Set(40f, 0f); backButton.VAlign = 1f; backButton.Top.Set(-20f, 0f); backButton.OnMouseOver += UICommon.FadedMouseOver; backButton.OnMouseOut += UICommon.FadedMouseOut; backButton.OnClick += BackClick; uIElement.Append(backButton); UIAutoScaleTextTextPanel <string> saveNewButton = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.ModPacksSaveEnabledAsNewPack"), 1f, false); saveNewButton.TextColor = Color.Green; saveNewButton.CopyStyle(backButton); saveNewButton.HAlign = 1f; saveNewButton.OnMouseOver += UICommon.FadedMouseOver; saveNewButton.OnMouseOut += UICommon.FadedMouseOut; saveNewButton.OnClick += SaveNewModList; uIElement.Append(saveNewButton); base.Append(uIElement); }
public override void OnInitialize() { UIElement uIElement = new UIElement(); uIElement.Width.Set(0f, 0.8f); uIElement.MaxWidth.Set(600f, 0f); uIElement.Top.Set(220f, 0f); uIElement.Height.Set(-220f, 1f); uIElement.HAlign = 0.5f; UIPanel uIPanel = new UIPanel(); uIPanel.Width.Set(0f, 1f); uIPanel.Height.Set(-110f, 1f); uIPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f; uIPanel.PaddingTop = 0f; uIElement.Append(uIPanel); modListAll = new UIList(); modList = new UIList(); modList.Width.Set(-25f, 1f); modList.Height.Set(-50f, 1f); modList.Top.Set(50f, 0f); modList.ListPadding = 5f; uIPanel.Append(modList); UIScrollbar uIScrollbar = new UIScrollbar(); uIScrollbar.SetView(100f, 1000f); uIScrollbar.Height.Set(-50f, 1f); uIScrollbar.Top.Set(50f, 0f); uIScrollbar.HAlign = 1f; uIPanel.Append(uIScrollbar); modList.SetScrollbar(uIScrollbar); uITextPanel = new UITextPanel <string>("Mod Browser", 0.8f, true); uITextPanel.HAlign = 0.5f; uITextPanel.Top.Set(-35f, 0f); uITextPanel.SetPadding(15f); uITextPanel.BackgroundColor = new Color(73, 94, 171); uIElement.Append(uITextPanel); reloadButton = new UITextPanel <string>("Loading...", 1f, false); reloadButton.Width.Set(-10f, 0.5f); reloadButton.Height.Set(25f, 0f); reloadButton.VAlign = 1f; reloadButton.Top.Set(-65f, 0f); reloadButton.OnMouseOver += UICommon.FadedMouseOver; reloadButton.OnMouseOut += UICommon.FadedMouseOut; reloadButton.OnClick += ReloadList; uIElement.Append(reloadButton); UITextPanel <string> backButton = new UITextPanel <string>("Back", 1f, false); backButton.Width.Set(-10f, 0.5f); backButton.Height.Set(25f, 0f); backButton.VAlign = 1f; backButton.Top.Set(-20f, 0f); backButton.OnMouseOver += UICommon.FadedMouseOver; backButton.OnMouseOut += UICommon.FadedMouseOut; backButton.OnClick += BackClick; uIElement.Append(backButton); base.Append(uIElement); UIElement uIElement2 = new UIElement(); uIElement2.Width.Set(0f, 1f); uIElement2.Height.Set(32f, 0f); uIElement2.Top.Set(10f, 0f); Texture2D texture = Texture2D.FromStream(Main.instance.GraphicsDevice, Assembly.GetExecutingAssembly().GetManifestResourceStream("Terraria.ModLoader.UI.UIModBrowserIcons.png")); UICycleImage uIToggleImage; for (int j = 0; j < 2; j++) { if (j == 0) { uIToggleImage = new UICycleImage(texture, 5, 32, 32, 0, 0); uIToggleImage.setCurrentState((int)sortMode); uIToggleImage.OnClick += (a, b) => { sortMode = sortMode.Next(); SortList(); }; } else { uIToggleImage = new UICycleImage(texture, 3, 32, 32, 34, 0); uIToggleImage.setCurrentState((int)updateFilterMode); uIToggleImage.OnClick += (a, b) => { updateFilterMode = updateFilterMode.Next(); SortList(); }; } uIToggleImage.Left.Set((float)(j * 36 + 8), 0f); _categoryButtons.Add(uIToggleImage); uIElement2.Append(uIToggleImage); } filterTextBox = new UIInputTextField("Type to search"); filterTextBox.Top.Set(5, 0f); filterTextBox.Left.Set(-150, 1f); filterTextBox.OnTextChange += (sender, e) => SortList(); uIElement2.Append(filterTextBox); UICycleImage SearchFilterToggle = new UICycleImage(texture, 2, 32, 32, 68, 0); SearchFilterToggle.setCurrentState((int)searchFilterMode); SearchFilterToggle.OnClick += (a, b) => { searchFilterMode = searchFilterMode.Next(); SortList(); }; SearchFilterToggle.Left.Set(545f, 0f); _categoryButtons.Add(SearchFilterToggle); uIElement2.Append(SearchFilterToggle); uIPanel.Append(uIElement2); PopulateModBrowser(); }
public override void OnInitialize() { _uIElement = new UIElement { Width = { Percent = 0.8f }, MaxWidth = UICommon.MaxPanelWidth, Top = { Pixels = 220 }, Height = { Pixels = -220, Percent = 1f }, HAlign = 0.5f }; _uIPanel = new UIPanel { Width = { Percent = 1f }, Height = { Pixels = -110, Percent = 1f }, BackgroundColor = UICommon.MainPanelBackground }; _uIElement.Append(_uIPanel); _uiLoader = new UILoaderAnimatedImage(0.5f, 0.5f, 1f); _modList = new UIList { Width = { Pixels = -25, Percent = 1f }, Height = { Percent = 1f }, ListPadding = 5f }; _uIPanel.Append(_modList); var uIScrollbar = new UIScrollbar { Height = { Percent = 1f }, HAlign = 1f }.WithView(100f, 1000f); _uIPanel.Append(uIScrollbar); _modList.SetScrollbar(uIScrollbar); var uIHeaderTextPanel = new UITextPanel <string>(Language.GetTextValue("tModLoader.MenuModSources"), 0.8f, true) { HAlign = 0.5f, Top = { Pixels = -35 }, BackgroundColor = UICommon.DefaultUIBlue }.WithPadding(15f); _uIElement.Append(uIHeaderTextPanel); var buttonBA = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSBuildAll")) { Width = { Pixels = -10, Percent = 1f / 3f }, Height = { Pixels = 40 }, VAlign = 1f, Top = { Pixels = -65 } }; buttonBA.WithFadedMouseOver(); buttonBA.OnClick += BuildMods; _uIElement.Append(buttonBA); var buttonBRA = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSBuildReloadAll")); buttonBRA.CopyStyle(buttonBA); buttonBRA.HAlign = 0.5f; buttonBRA.WithFadedMouseOver(); buttonBRA.OnClick += BuildAndReload; _uIElement.Append(buttonBRA); var buttonCreateMod = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSCreateMod")); buttonCreateMod.CopyStyle(buttonBA); buttonCreateMod.HAlign = 1f; buttonCreateMod.WithFadedMouseOver(); buttonCreateMod.OnClick += ButtonCreateMod_OnClick; _uIElement.Append(buttonCreateMod); var buttonB = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("UI.Back")); buttonB.CopyStyle(buttonBA); //buttonB.Width.Set(-10f, 1f / 3f); buttonB.Top.Pixels = -20; buttonB.WithFadedMouseOver(); buttonB.OnClick += BackClick; _uIElement.Append(buttonB); var buttonOS = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSOpenSources")); buttonOS.CopyStyle(buttonB); buttonOS.HAlign = .5f; buttonOS.WithFadedMouseOver(); buttonOS.OnClick += OpenSources; _uIElement.Append(buttonOS); var buttonMP = new UIAutoScaleTextTextPanel <string>(Language.GetTextValue("tModLoader.MSManagePublished")); buttonMP.CopyStyle(buttonB); buttonMP.HAlign = 1f; buttonMP.WithFadedMouseOver(); buttonMP.OnClick += ManagePublished; _uIElement.Append(buttonMP); Append(_uIElement); }
public override void OnInitialize() { base.OnInitialize(); mainPanel = new UIPanel(); width = 310; height = 610; mainPanel.SetPadding(6); mainPanel.BackgroundColor = Color.Orange * 0.7f; int top = 0; UIText text = new UIText("Projectiles:", 0.85f); text.Top.Set(top, 0f); mainPanel.Append(text); UITextPanel <string> clearProjectilesButton = new UITextPanel <string>("Clear Projectiles"); clearProjectilesButton.OnClick += (a, b) => { for (int i = 0; i < Main.maxProjectiles; i++) { if (Main.projectile[i].active) { Main.projectile[i].Kill(); if (Main.netMode == 1) { NetMessage.SendData(27, -1, -1, null, i, 0f, 0f, 0f, 0); } } } }; clearProjectilesButton.Top.Set(top, 0f); clearProjectilesButton.Width.Set(-10, 0.5f); clearProjectilesButton.HAlign = 1; clearProjectilesButton.SetPadding(4); mainPanel.Append(clearProjectilesButton); top += 20; UIText text2 = new UIText("Filter:", 0.85f); text2.Top.Set(top, 0f); mainPanel.Append(text2); searchFilter = new NewUITextBox("Search", 0.85f); searchFilter.SetPadding(0); searchFilter.OnTextChanged += () => { ValidateInput(); updateNeeded = true; }; searchFilter.Top.Set(top, 0f); searchFilter.Left.Set(text2.GetInnerDimensions().Width, 0f); searchFilter.Width.Set(-text2.GetInnerDimensions().Width, 1f); searchFilter.Height.Set(20, 0f); //searchFilter.VAlign = 0.5f; mainPanel.Append(searchFilter); top += 20; speedXDataProperty = new UIFloatRangedDataValue("SpeedX:", 0, -10, 10); speedYDataProperty = new UIFloatRangedDataValue("SpeedY:", 0, -10, 10); var ui2DRange = new UI2DRange <float>(speedXDataProperty, speedYDataProperty); ui2DRange.Top.Set(top, 0f); mainPanel.Append(ui2DRange); top += 30; ai0DataProperty = new UIFloatRangedDataValue("ai0:", 0, -10, 10); var uiRange = new UIRange <float>(ai0DataProperty); uiRange.Top.Set(top, 0f); uiRange.Width.Set(0, 1f); mainPanel.Append(uiRange); top += 30; ai1DataProperty = new UIFloatRangedDataValue("ai1:", 0, -10, 10); uiRange = new UIRange <float>(ai1DataProperty); uiRange.Top.Set(top, 0f); uiRange.Width.Set(0, 1f); mainPanel.Append(uiRange); top += 30; knockbackDataProperty = new UIFloatRangedDataValue("Knockback:", 0, 0, 20); uiRange = new UIRange <float>(knockbackDataProperty); uiRange.Top.Set(top, 0f); uiRange.Width.Set(0, 1f); mainPanel.Append(uiRange); top += 30; damageDataProperty = new UIIntRangedDataValue("Damage:", 20, 0, 200); var uiRangeI = new UIRange <int>(damageDataProperty); uiRangeI.Top.Set(top, 0f); uiRangeI.Width.Set(0, 1f); mainPanel.Append(uiRangeI); top += 30; aiStyleDataProperty = new UIIntRangedDataValue("AIStyle:", -1, -1, 145); uiRangeI = new UIRange <int>(aiStyleDataProperty); uiRangeI.Top.Set(top, 0f); uiRangeI.Width.Set(0, 1f); mainPanel.Append(uiRangeI); top += 30; drawOffsetXDataProperty = new UIIntRangedDataValue("drawOffsetX:", 0, -30, 30); uiRangeI = new UIRange <int>(drawOffsetXDataProperty); uiRangeI.Top.Set(top, 0f); uiRangeI.Width.Set(0, 1f); mainPanel.Append(uiRangeI); top += 30; drawOriginOffsetXDataProperty = new UIIntRangedDataValue("drawOriginOffsetX:", 0, -30, 30); uiRangeI = new UIRange <int>(drawOriginOffsetXDataProperty); uiRangeI.Top.Set(top, 0f); uiRangeI.Width.Set(0, 1f); mainPanel.Append(uiRangeI); top += 30; drawOriginOffsetYDataProperty = new UIIntRangedDataValue("drawOriginOffsetY:", 0, -30, 30); uiRangeI = new UIRange <int>(drawOriginOffsetYDataProperty); uiRangeI.Top.Set(top, 0f); uiRangeI.Width.Set(0, 1f); mainPanel.Append(uiRangeI); top += 30; hostile = new UIBoolNDataValue("Hostile"); var hostileCheckbox = new UITriStateCheckbox(hostile); hostileCheckbox.Top.Set(top, 0f); mainPanel.Append(hostileCheckbox); top += 30; friendly = new UIBoolNDataValue("Friendly"); var friendlyCheckbox = new UITriStateCheckbox(friendly); friendlyCheckbox.Top.Set(top, 0f); mainPanel.Append(friendlyCheckbox); top += 25; pause = new UICheckbox("Pause", "Pauses All Projectiles (Prevent AI from running)"); pause.Top.Set(top, 0f); mainPanel.Append(pause); UIHoverImageButton stepButton = new UIHoverImageButton(ModdersToolkit.Instance.GetTexture("UIElements/next"), "Step"); stepButton.OnClick += (s, e) => step = true; stepButton.Top.Set(top - 6, 0f); stepButton.Left.Set(80, 0f); mainPanel.Append(stepButton); top += 25; freeze = new UICheckbox("Freeze", "Zero out velocity during PreAI for All Projectiles"); freeze.Top.Set(top, 0f); mainPanel.Append(freeze); top += 25; projectileGrid = new UIGrid(7); projectileGrid.Top.Pixels = top; //autoTrashGrid.Left.Pixels = spacing; projectileGrid.Width.Set(-25f, 1f); // leave space for scroll? projectileGrid.Height.Set(-top, 1f); projectileGrid.ListPadding = 6f; mainPanel.Append(projectileGrid); // this will initialize grid updateNeeded = true; var projectileGridScrollbar = new UIElements.FixedUIScrollbar(_userInterface); projectileGridScrollbar.SetView(100f, 1000f); projectileGridScrollbar.Top.Pixels = top; // + spacing; projectileGridScrollbar.Height.Set(-top /*- spacing*/, 1f); projectileGridScrollbar.HAlign = 1f; mainPanel.Append(projectileGridScrollbar); projectileGrid.SetScrollbar(projectileGridScrollbar); AdjustMainPanelDimensions(mainPanel); Append(mainPanel); }
public override void OnInitialize() { UIElement uIElement = new UIElement(); uIElement.Width.Set(0f, 0.8f); uIElement.MaxWidth.Set(600f, 0f); uIElement.Top.Set(220f, 0f); uIElement.Height.Set(-220f, 1f); uIElement.HAlign = 0.5f; UIPanel uIPanel = new UIPanel(); uIPanel.Width.Set(0f, 1f); uIPanel.Height.Set(-110f, 1f); uIPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f; uIPanel.PaddingTop = 0f; uIElement.Append(uIPanel); uITextPanel = new UITextPanel <string>(Language.GetTextValue("tModLoader.EnterSteamID"), 0.8f, true) { HAlign = 0.5f }; uITextPanel.Top.Set(-35f, 0f); uITextPanel.SetPadding(15f); uITextPanel.BackgroundColor = new Color(73, 94, 171); uIElement.Append(uITextPanel); UITextPanel <string> button = new UITextPanel <string>(Language.GetTextValue("UI.Back"), 1f, false); button.Width.Set(-10f, 0.5f); button.Height.Set(25f, 0f); button.VAlign = 1f; button.Top.Set(-65f, 0f); button.OnMouseOver += UICommon.FadedMouseOver; button.OnMouseOut += UICommon.FadedMouseOut; button.OnClick += BackClick; uIElement.Append(button); UITextPanel <string> button2 = new UITextPanel <string>(Language.GetTextValue("UI.Submit"), 1f, false); button2.CopyStyle(button); button2.HAlign = 1f; button2.OnMouseOver += UICommon.FadedMouseOver; button2.OnMouseOut += UICommon.FadedMouseOut; button2.OnClick += OKClick; uIElement.Append(button2); //UITextPanel<string> button3 = new UITextPanel<string>("Visit Website to Generate Passphrase", 1f, false); //button3.CopyStyle(button); //button3.Width.Set(0f, 1f); //button3.Top.Set(-20f, 0f); //button3.OnMouseOver += UICommon.FadedMouseOver; //button3.OnMouseOut += UICommon.FadedMouseOut; //button3.OnClick += VisitRegisterWebpage; //uIElement.Append(button3); steamIDTextField = new UIInputTextField(Language.GetTextValue("tModLoader.PasteSteamID")) { HAlign = 0.5f, VAlign = 0.5f }; steamIDTextField.Left.Set(-100, 0); steamIDTextField.OnTextChange += new UIInputTextField.EventHandler(OnTextChange); uIPanel.Append(steamIDTextField); base.Append(uIElement); }
public void InitializePage() { this.RemoveAllChildren(); this._categoryButtons.Clear(); this._achievementElements.Clear(); this._achievementsList = (UIList)null; bool largeForOtherLanguages = true; int num = largeForOtherLanguages.ToInt() * 100; UIElement element1 = new UIElement(); element1.Width.Set(0.0f, 0.8f); element1.MaxWidth.Set(800f + (float)num, 0.0f); element1.MinWidth.Set(600f + (float)num, 0.0f); element1.Top.Set(220f, 0.0f); element1.Height.Set(-220f, 1f); element1.HAlign = 0.5f; this._outerContainer = element1; this.Append(element1); UIPanel uiPanel = new UIPanel(); uiPanel.Width.Set(0.0f, 1f); uiPanel.Height.Set(-110f, 1f); uiPanel.BackgroundColor = new Color(33, 43, 79) * 0.8f; uiPanel.PaddingTop = 0.0f; element1.Append((UIElement)uiPanel); this._achievementsList = new UIList(); this._achievementsList.Width.Set(-25f, 1f); this._achievementsList.Height.Set(-50f, 1f); this._achievementsList.Top.Set(50f, 0.0f); this._achievementsList.ListPadding = 5f; uiPanel.Append((UIElement)this._achievementsList); UITextPanel <LocalizedText> uiTextPanel1 = new UITextPanel <LocalizedText>(Language.GetText("UI.Achievements"), 1f, true); uiTextPanel1.HAlign = 0.5f; uiTextPanel1.Top.Set(-33f, 0.0f); uiTextPanel1.SetPadding(13f); uiTextPanel1.BackgroundColor = new Color(73, 94, 171); element1.Append((UIElement)uiTextPanel1); UITextPanel <LocalizedText> uiTextPanel2 = new UITextPanel <LocalizedText>(Language.GetText("UI.Back"), 0.7f, true); uiTextPanel2.Width.Set(-10f, 0.5f); uiTextPanel2.Height.Set(50f, 0.0f); uiTextPanel2.VAlign = 1f; uiTextPanel2.HAlign = 0.5f; uiTextPanel2.Top.Set(-45f, 0.0f); uiTextPanel2.OnMouseOver += new UIElement.MouseEvent(this.FadedMouseOver); uiTextPanel2.OnMouseOut += new UIElement.MouseEvent(this.FadedMouseOut); uiTextPanel2.OnClick += new UIElement.MouseEvent(this.GoBackClick); element1.Append((UIElement)uiTextPanel2); this._backpanel = (UIElement)uiTextPanel2; List <Achievement> achievementsList = Main.Achievements.CreateAchievementsList(); for (int index = 0; index < achievementsList.Count; ++index) { UIAchievementListItem achievementListItem = new UIAchievementListItem(achievementsList[index], largeForOtherLanguages); this._achievementsList.Add((UIElement)achievementListItem); this._achievementElements.Add(achievementListItem); } UIScrollbar scrollbar = new UIScrollbar(); scrollbar.SetView(100f, 1000f); scrollbar.Height.Set(-50f, 1f); scrollbar.Top.Set(50f, 0.0f); scrollbar.HAlign = 1f; uiPanel.Append((UIElement)scrollbar); this._achievementsList.SetScrollbar(scrollbar); UIElement element2 = new UIElement(); element2.Width.Set(0.0f, 1f); element2.Height.Set(32f, 0.0f); element2.Top.Set(10f, 0.0f); Asset <Texture2D> texture = (Asset <Texture2D>)Main.Assets.Request <Texture2D>("Images/UI/Achievement_Categories", (AssetRequestMode)1); for (int index = 0; index < 4; ++index) { UIToggleImage uiToggleImage = new UIToggleImage(texture, 32, 32, new Point(34 * index, 0), new Point(34 * index, 34)); uiToggleImage.Left.Set((float)(index * 36 + 8), 0.0f); uiToggleImage.SetState(true); uiToggleImage.OnClick += new UIElement.MouseEvent(this.FilterList); this._categoryButtons.Add(uiToggleImage); element2.Append((UIElement)uiToggleImage); } uiPanel.Append(element2); }
public override void Update(GameTime gameTime) { base.Update(gameTime); if (watchedFileChanged) { if (watcherCooldown > 0) { watcherCooldown--; } if (watcherCooldown == 0) { Texture2D file; using (Stream stream = File.OpenRead(path)) { file = Texture2D.FromStream(Main.instance.GraphicsDevice, stream); } if (file.Width != selectedTexture2D.Width || file.Height != selectedTexture2D.Height) { Main.NewText("Width or height changed, aborting."); } else { Color[] c = new Color[file.Width * file.Height]; file.GetData <Color>(c, 0, c.Length); selectedTexture2D.SetData <Color>(c); Main.NewText("Texture updated from watch file."); } watchedFileChanged = false; } } if (watchedFileChangedSources) { if (watcherCooldownSources > 0) { watcherCooldownSources--; } if (watcherCooldownSources == 0) { watchedFileChangedSources = false; string dir = ModLoader.ModSourcePath + Path.DirectorySeparatorChar + selectedMod.Name + Path.DirectorySeparatorChar; string innername = watchedFileChangedSourcesFileName.Substring(dir.Length); string innernamenoext = System.IO.Path.ChangeExtension(innername, null); innernamenoext = innernamenoext.Replace("\\", "/"); FieldInfo texturesField = typeof(Mod).GetField("textures", BindingFlags.Instance | BindingFlags.NonPublic); var textures = (Dictionary <string, Texture2D>)texturesField.GetValue(selectedMod); if (!textures.ContainsKey(innernamenoext)) { Main.NewText("Detected png change, but file not present at load: " + innername); return; } Texture2D modTexture = textures[innernamenoext]; Texture2D file; using (Stream stream = File.OpenRead(watchedFileChangedSourcesFileName)) { file = Texture2D.FromStream(Main.instance.GraphicsDevice, stream); } if (file.Width != modTexture.Width || file.Height != modTexture.Height) { Main.NewText("Width or height changed, aborting."); } else { Color[] c = new Color[file.Width * file.Height]; file.GetData <Color>(c, 0, c.Length); modTexture.SetData <Color>(c); Main.NewText("Texture updated from watch mod sources folder."); } } } if (!updateneeded) { return; } updateneeded = false; if (modList.Count == 0) { foreach (var otherMod in ModLoader.LoadedMods) { UITextPanel <string> button = new UITextPanel <string>(otherMod.DisplayName); button.OnClick += (a, b) => { selectedMod = otherMod; updateneeded = true; watchModSources.Selected = false; watchModSources.Clickable = Directory.Exists(ModLoader.ModSourcePath + Path.DirectorySeparatorChar + otherMod.Name); if (watchModSources.Clickable) { watchModSources.Selected = true; } }; modList.Add(button); } } if (selectedMod != null) { textureList.Clear(); FieldInfo texturesField = typeof(Mod).GetField("textures", BindingFlags.Instance | BindingFlags.NonPublic); var textures = (Dictionary <string, Texture2D>)texturesField.GetValue(selectedMod); foreach (var textureEntry in textures) { if (searchFilter.Text.Length > 0) { if (textureEntry.Key.ToLower().IndexOf(searchFilter.Text, StringComparison.OrdinalIgnoreCase) == -1) { continue; } } UIImage image = new UIHoverImage(textureEntry.Value, textureEntry.Key); //image.ImageScale = Math.Min(1f, 60f/textureEntry.Value.Height); image.OnClick += (a, b) => { selectedTexture2D = textureEntry.Value; currentTexture.SetText("Current: " + textureEntry.Key); SelectedTexture2DChanged(); }; textureList.Add(image); } } }
public override void OnInitialize() { base.OnInitialize(); mainPanel = new UIPanel(); mainPanel.SetPadding(6); mainPanel.BackgroundColor = new Color(173, 94, 171); UIText text = new UIText("Miscellaneous:", 0.85f); AppendToAndAdjustWidthHeight(mainPanel, text, ref height, ref width); // checkboxes UICheckbox npcInfoCheckbox = new UICheckbox("NPC Info", "Show NPC ai values and other variables."); npcInfoCheckbox.OnSelectedChanged += () => MiscellaneousTool.showNPCInfo = npcInfoCheckbox.Selected; AppendToAndAdjustWidthHeight(mainPanel, npcInfoCheckbox, ref height, ref width); UICheckbox tileGridCheckbox = new UICheckbox("Tile Grid", "Show grid lines between tiles."); tileGridCheckbox.OnSelectedChanged += () => MiscellaneousTool.showTileGrid = tileGridCheckbox.Selected; AppendToAndAdjustWidthHeight(mainPanel, tileGridCheckbox, ref height, ref width); UITextPanel <string> calculateChunkData = new UITextPanel <string>("Calculate Chunk Size"); calculateChunkData.SetPadding(4); //calculateChunkData.Width.Set(-10, 0.5f); calculateChunkData.OnClick += CalculateButton_OnClick; AppendToAndAdjustWidthHeight(mainPanel, calculateChunkData, ref height, ref width); UITextPanel <string> generateTownSprite = new UITextPanel <string>("Generate Town Sprite (WIP)"); generateTownSprite.SetPadding(4); generateTownSprite.OnClick += GenerateTownSprite_OnClick; AppendToAndAdjustWidthHeight(mainPanel, generateTownSprite, ref height, ref width); UICheckbox collisionCircleCheckbox = new UICheckbox("Collision Circle", "Show a circle of Collision.CanHit"); collisionCircleCheckbox.OnSelectedChanged += () => MiscellaneousTool.showCollisionCircle = collisionCircleCheckbox.Selected; AppendToAndAdjustWidthHeight(mainPanel, collisionCircleCheckbox, ref height, ref width); UICheckbox logSoundsCheckbox = new UICheckbox("Log Sounds", "Log Sound Styles and Types"); logSoundsCheckbox.OnSelectedChanged += () => MiscellaneousTool.logSounds = logSoundsCheckbox.Selected; AppendToAndAdjustWidthHeight(mainPanel, logSoundsCheckbox, ref height, ref width); UITextPanel <string> takeWorldSnapshot = new UITextPanel <string>("Take World Snapshot (WIP)"); takeWorldSnapshot.SetPadding(4); takeWorldSnapshot.OnClick += TakeWorldSnapshot_OnClick; ; AppendToAndAdjustWidthHeight(mainPanel, takeWorldSnapshot, ref height, ref width); UITextPanel <string> restoreWorldSnapshot = new UITextPanel <string>("Restore World Snapshot (WIP)"); restoreWorldSnapshot.SetPadding(4); restoreWorldSnapshot.OnClick += RestoreWorldSnapshot_OnClick; ; AppendToAndAdjustWidthHeight(mainPanel, restoreWorldSnapshot, ref height, ref width); AdjustMainPanelDimensions(mainPanel); Append(mainPanel); }