public override void OnInitialize() { this._panel = new DragableUIPanel(); this._panel.Left.Set(((Main.screenWidth - this.PanelWidth) / 2) + this.OffsetX, 0f); this._panel.Top.Set(((Main.screenHeight - this.PanelHeight) / 2) + this.OffsetY, 0f); this._panel.Width.Set(this.PanelWidth, 0f); this._panel.Height.Set(this.PanelHeight, 0f); this._panel.BorderColor = new Color(0, 0, 0, 0); var textbox = new UIInputTextField(this.Value, "Enter a value"); textbox.OnTextChange += (s, e) => { this.Value = textbox.Text; }; textbox.OnSave += (sender, args) => this.Save(); textbox.OnCancel += (sender, args) => this.Close(); var button = new UIClickableButton("Save", (evt, element) => this.Save()); this._panel.Append(textbox); button.Top.Set(50f, 0f); this._panel.Append(button); this.Append(this._panel); }
public override void OnInitialize() { this._panel = new DragableUIPanel(); this._panel.Left.Set(((Main.screenWidth - PanelWidth) / 2) + OffsetX, 0f); this._panel.Top.Set(((Main.screenHeight - PanelHeight) / 2) + OffsetY, 0f); this._panel.Width.Set(PanelWidth, 0f); this._panel.Height.Set(PanelHeight, 0f); this._panel.BorderColor = new Color(0, 0, 0, 0); var textHeight = ChatManager.GetStringSize(Main.fontMouseText, Constants.ToolCategories[0], new Vector2(0, 0)).Y; var currentY = 0f; var currentX = this.Padding; for (var cat = 0; cat < Constants.ToolCategories.Count; cat++) { var uiTitle = new UIText(Constants.ToolCategories[cat]); uiTitle.Height.Set(textHeight, 0f); uiTitle.Top.Set(currentY, 0f); this._panel.Append(uiTitle); var i = 0; foreach (var tool in Constants.Tools[cat]) { if (i % this.PerRow == 0) { currentY += this.ButtonSize + this.InnerPadding; currentX = 0; } else { currentX += this.ButtonSize + this.InnerPadding; } // TODO: Issue #6: Remove need for separate device icons var button = new ElectronicsManualButton(tool, WireMod.Instance.GetTexture($"Images/Icons/{tool}Icon")) { ToolCat = cat, Tool = i }; button.Height.Set(this.ButtonSize, 0f); button.Width.Set(this.ButtonSize, 0f); button.Left.Set(currentX, 0f); button.Top.Set(currentY - (this.ButtonSize / 2), 0f); button.SetVisibility(0f, 0.25f); this._panel.Append(button); i++; } currentY += this.Padding + this.InnerPadding; currentX = this.Padding; } this._panel.Height.Set(currentY + this.Padding, 0f); this.Append(this._panel); Recalculate(); }