feat: add button to remove window from layout
This commit is contained in:
parent
6cbe5b24a7
commit
2daeb5603a
|
@ -935,14 +935,16 @@ namespace HUD_Manager {
|
||||||
|
|
||||||
foreach (var window in WindowKindExt.All) {
|
foreach (var window in WindowKindExt.All) {
|
||||||
var addon = this.Plugin.Interface.Framework.Gui.GetAddonByName(window, 1);
|
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)) {
|
if (!ImGui.Selectable(window, false, flags)) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
var pos = this.Plugin.GameFunctions.GetAddonPosition(window);
|
var pos = this.Plugin.GameFunctions.GetAddonPosition(window);
|
||||||
if (pos != null && !layout.Windows.ContainsKey(window)) {
|
if (pos != null) {
|
||||||
layout.Windows.Add(window, new Window(pos));
|
layout.Windows.Add(window, new Window(pos));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -954,6 +956,8 @@ namespace HUD_Manager {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
var toRemove = new HashSet<string>();
|
||||||
|
|
||||||
foreach (var entry in layout.Windows) {
|
foreach (var entry in layout.Windows) {
|
||||||
if (!ImGui.CollapsingHeader($"{entry.Key}##uimanager-window-{entry.Key}")) {
|
if (!ImGui.CollapsingHeader($"{entry.Key}##uimanager-window-{entry.Key}")) {
|
||||||
continue;
|
continue;
|
||||||
|
@ -967,6 +971,11 @@ namespace HUD_Manager {
|
||||||
this.Plugin.GameFunctions.SetAddonPosition(entry.Key, pos.X, pos.Y);
|
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;
|
var y = (int) pos.Y;
|
||||||
if (ImGui.InputInt($"Y##uimanager-window-{entry.Key}", ref y)) {
|
if (ImGui.InputInt($"Y##uimanager-window-{entry.Key}", ref y)) {
|
||||||
pos.Y = (short) y;
|
pos.Y = (short) y;
|
||||||
|
@ -974,6 +983,10 @@ namespace HUD_Manager {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
foreach (var remove in toRemove) {
|
||||||
|
layout.Windows.Remove(remove);
|
||||||
|
}
|
||||||
|
|
||||||
ImGui.EndChild();
|
ImGui.EndChild();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue