feat: add button to remove window from layout

This commit is contained in:
Anna 2021-03-17 13:53:22 -04:00
parent 6cbe5b24a7
commit 2daeb5603a
1 changed files with 15 additions and 2 deletions

View File

@ -935,14 +935,16 @@ namespace HUD_Manager {
foreach (var window in WindowKindExt.All) {
var addon = this.Plugin.Interface.Framework.Gui.GetAddonByName(window, 1);
var flags = addon?.Visible == true ? ImGuiSelectableFlags.None : ImGuiSelectableFlags.Disabled;
var flags = addon?.Visible == true && !layout.Windows.ContainsKey(window)
? ImGuiSelectableFlags.None
: ImGuiSelectableFlags.Disabled;
if (!ImGui.Selectable(window, false, flags)) {
continue;
}
var pos = this.Plugin.GameFunctions.GetAddonPosition(window);
if (pos != null && !layout.Windows.ContainsKey(window)) {
if (pos != null) {
layout.Windows.Add(window, new Window(pos));
}
}
@ -954,6 +956,8 @@ namespace HUD_Manager {
return;
}
var toRemove = new HashSet<string>();
foreach (var entry in layout.Windows) {
if (!ImGui.CollapsingHeader($"{entry.Key}##uimanager-window-{entry.Key}")) {
continue;
@ -967,6 +971,11 @@ namespace HUD_Manager {
this.Plugin.GameFunctions.SetAddonPosition(entry.Key, pos.X, pos.Y);
}
ImGui.SameLine(ImGui.GetContentRegionAvail().X - ImGui.GetStyle().ItemSpacing.X * 3);
if (IconButton(FontAwesomeIcon.Trash, $"uimanager-remove-window-{entry.Key}")) {
toRemove.Add(entry.Key);
}
var y = (int) pos.Y;
if (ImGui.InputInt($"Y##uimanager-window-{entry.Key}", ref y)) {
pos.Y = (short) y;
@ -974,6 +983,10 @@ namespace HUD_Manager {
}
}
foreach (var remove in toRemove) {
layout.Windows.Remove(remove);
}
ImGui.EndChild();
}