From 18dcdea6b4a9f21be2554993780d12cc8619b9c2 Mon Sep 17 00:00:00 2001 From: Zacharie Day Date: Tue, 15 Sep 2020 20:15:09 -0400 Subject: [PATCH] feat: rename interface cleanup Move the rename input to below the layouts list and give it a fixed width. Fix "delete" button not having correct height. --- HudSwap/PluginUI.cs | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/HudSwap/PluginUI.cs b/HudSwap/PluginUI.cs index 13cc5dc..968d045 100644 --- a/HudSwap/PluginUI.cs +++ b/HudSwap/PluginUI.cs @@ -120,12 +120,21 @@ namespace HudSwap { } ImGui.PopItemWidth(); - ImGui.NewLine(); + ImGui.PushItemWidth(200); + ImGui.InputText("##rename-input", ref this.renameName, 100); + ImGui.PopItemWidth(); + ImGui.SameLine(); + if (ImGui.Button("Rename") && this.renameName.Length != 0 && this.selectedLayoutId != null) { + Layout layout = this.plugin.Config.Layouts2[this.selectedLayoutId]; + Layout newLayout = new Layout(this.renameName, layout.Hud, layout.Positions); + this.plugin.Config.Layouts2[this.selectedLayoutId] = newLayout; + this.plugin.Config.Save(); + } const int deleteButtonWidth = 30; ImGui.SameLine(ImGui.GetWindowContentRegionWidth() - deleteButtonWidth); ImGui.PushFont(UiBuilder.IconFont); - if (ImGui.Button(FontAwesomeIcon.Trash.ToIconString(), new Vector2(deleteButtonWidth, ImGui.GetTextLineHeight())) && + if (ImGui.Button(FontAwesomeIcon.Trash.ToIconString(), new Vector2(deleteButtonWidth, 0)) && this.selectedLayoutId != null) { this.plugin.Config.Layouts2.Remove(this.selectedLayoutId); this.plugin.Config.HudConditionMatches.RemoveAll(m => m.LayoutId == this.selectedLayoutId); @@ -135,7 +144,7 @@ namespace HudSwap { } ImGui.PopFont(); - ImGui.Text("Copy onto slot..."); + ImGui.Text("Copy to..."); Vector2 slotButtonSize = new Vector2(40, 0); foreach (HudSlot slot in Enum.GetValues(typeof(HudSlot))) { // Surround the button with parentheses if this is the current slot @@ -157,14 +166,6 @@ namespace HudSwap { } } - ImGui.InputText("##rename-input", ref this.renameName, 100); - ImGui.SameLine(); - if (ImGui.Button("Rename") && this.renameName.Length != 0 && this.selectedLayoutId != null) { - Layout layout = this.plugin.Config.Layouts2[this.selectedLayoutId]; - Layout newLayout = new Layout(this.renameName, layout.Hud, layout.Positions); - this.plugin.Config.Layouts2[this.selectedLayoutId] = newLayout; - this.plugin.Config.Save(); - } } ImGui.Separator();