diff --git a/BossMod/AI/AIManager.cs b/BossMod/AI/AIManager.cs index 167a690005..1635d2559f 100644 --- a/BossMod/AI/AIManager.cs +++ b/BossMod/AI/AIManager.cs @@ -2,9 +2,11 @@ using Dalamud.Game.Text; using Dalamud.Game.Text.SeStringHandling; using Dalamud.Game.Text.SeStringHandling.Payloads; +using Dalamud.Interface; using Dalamud.Interface.Utility.Raii; using FFXIVClientStructs.FFXIV.Client.Game.Group; using ImGuiNET; +using static Dalamud.Interface.Windowing.Window; namespace BossMod.AI; @@ -45,11 +47,13 @@ public AIManager(RotationModuleManager autorot, ActionManagerEx amex, MovementOv _autorot = autorot; _controller = new(amex, movement); _config = Service.Config.Get(); + List _titlebarButtons = [new() { Icon = FontAwesomeIcon.WindowClose, IconOffset = new(1, 1), Click = _ => _config.DrawUI = false }]; _ui = new("###AI", DrawOverlay, false, new(100, 100), ImGuiWindowFlags.NoScrollbar | ImGuiWindowFlags.NoScrollWithMouse | ImGuiWindowFlags.NoFocusOnAppearing) { RespectCloseHotkey = false, ShowCloseButton = false, - WindowName = $"AI: off###AI" + WindowName = $"AI: off###AI", + TitleBarButtons = _titlebarButtons }; Service.ChatGui.ChatMessage += OnChatMessage; Service.CommandManager.AddHandler("/vbmai", new Dalamud.Game.Command.CommandInfo(OnCommand) { HelpMessage = "Toggle AI mode" }); diff --git a/BossMod/Util/UIWindow.cs b/BossMod/Util/UIWindow.cs index eb5ec0de56..f14df6239a 100644 --- a/BossMod/Util/UIWindow.cs +++ b/BossMod/Util/UIWindow.cs @@ -1,5 +1,6 @@ using Dalamud.Interface.Windowing; using ImGuiNET; +using static Dalamud.Interface.Windowing.Window; namespace BossMod; @@ -17,13 +18,16 @@ public abstract class UIWindow : Window, IDisposable { public bool DisposeOnClose; // defaults to true for detached windows, false for normal windows - protected UIWindow(string name, bool detached, Vector2 initialSize, ImGuiWindowFlags flags = ImGuiWindowFlags.None) : base(name, flags) + protected UIWindow(string name, bool detached, Vector2 initialSize, ImGuiWindowFlags flags = ImGuiWindowFlags.None, List? titleBarButtons = null) : base(name, flags) { DisposeOnClose = detached; Size = initialSize; SizeCondition = ImGuiCond.FirstUseEver; AllowClickthrough = AllowPinning = false; // this breaks uidev - + if (titleBarButtons != null) + { + TitleBarButtons = titleBarButtons; + } var existingWindow = Service.WindowSystem!.Windows.FirstOrDefault(w => w.WindowName == WindowName); if (existingWindow == null) { @@ -61,8 +65,8 @@ public override void OnClose() } // utility: window that uses custom delegate to perform drawing - allows avoiding creating derived classes in simple cases -public class UISimpleWindow(string name, Action draw, bool detached, Vector2 initialSize, ImGuiWindowFlags flags = ImGuiWindowFlags.None) - : UIWindow(name, detached, initialSize, flags) +public class UISimpleWindow(string name, Action draw, bool detached, Vector2 initialSize, ImGuiWindowFlags flags = ImGuiWindowFlags.None, List? titleBarButtons = null) + : UIWindow(name, detached, initialSize, flags, titleBarButtons) { private readonly Action _draw = draw;