From 27c41cac4971d6063b602f013b4d5b07f003c691 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Thu, 12 Oct 2023 16:56:12 +0200 Subject: [PATCH] Add locking and color options and commands. --- Glamourer/Gui/Colors.cs | 43 ++++++++++++++++------------ Glamourer/Gui/DesignQuickBar.cs | 11 +++++-- Glamourer/Gui/MainWindow.cs | 7 +++++ Glamourer/Gui/Tabs/SettingsTab.cs | 2 ++ Glamourer/Services/CommandService.cs | 32 +++++++++++++++++++-- 5 files changed, 73 insertions(+), 22 deletions(-) diff --git a/Glamourer/Gui/Colors.cs b/Glamourer/Gui/Colors.cs index a665eee..4b163f9 100644 --- a/Glamourer/Gui/Colors.cs +++ b/Glamourer/Gui/Colors.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using ImGuiNET; namespace Glamourer.Gui; @@ -21,6 +22,9 @@ public enum ColorId FavoriteStarOn, FavoriteStarHovered, FavoriteStarOff, + QuickDesignButton, + QuickDesignFrame, + QuickDesignBg, } public static class Colors @@ -29,24 +33,27 @@ public static class Colors => color switch { // @formatter:off - ColorId.NormalDesign => (0xFFFFFFFF, "Normal Design", "A design with no specific traits." ), - ColorId.CustomizationDesign => (0xFFC000C0, "Customization Design", "A design that only changes customizations on a character." ), - ColorId.StateDesign => (0xFF00C0C0, "State Design", "A design that does not change equipment or customizations on a character." ), - ColorId.EquipmentDesign => (0xFF00C000, "Equipment Design", "A design that only changes equipment on a character." ), - ColorId.ActorAvailable => (0xFF18C018, "Actor Available", "The header in the Actor tab panel if the currently selected actor exists in the game world at least once." ), - ColorId.ActorUnavailable => (0xFF1818C0, "Actor Unavailable", "The Header in the Actor tab panel if the currently selected actor does not exist in the game world." ), - ColorId.FolderExpanded => (0xFFFFF0C0, "Expanded Design Folder", "A design folder that is currently expanded." ), - ColorId.FolderCollapsed => (0xFFFFF0C0, "Collapsed Design Folder", "A design folder that is currently collapsed." ), - ColorId.FolderLine => (0xFFFFF0C0, "Expanded Design Folder Line", "The line signifying which descendants belong to an expanded design folder." ), - ColorId.EnabledAutoSet => (0xFFA0F0A0, "Enabled Automation Set", "An automation set that is currently enabled. Only one set can be enabled for each identifier at once." ), - ColorId.DisabledAutoSet => (0xFF808080, "Disabled Automation Set", "An automation set that is currently disabled." ), - ColorId.AutomationActorAvailable => (0xFFFFFFFF, "Automation Actor Available", "A character associated with the given automated design set is currently visible." ), - ColorId.AutomationActorUnavailable => (0xFF808080, "Automation Actor Unavailable", "No character associated with the given automated design set is currently visible." ), - ColorId.HeaderButtons => (0xFFFFF0C0, "Header Buttons", "The text and border color of buttons in the header, like the Incognito toggle." ), - ColorId.FavoriteStarOn => (0xFF40D0D0, "Favored Item", "The color of the star for favored items and of the border in the unlock overview tab." ), - ColorId.FavoriteStarHovered => (0xFFD040D0, "Favorite Star Hovered", "The color of the star for favored items when it is hovered." ), - ColorId.FavoriteStarOff => (0x20808080, "Favorite Star Outline", "The color of the star for items that are not favored when it is not hovered." ), - _ => (0x00000000, string.Empty, string.Empty ), + ColorId.NormalDesign => (0xFFFFFFFF, "Normal Design", "A design with no specific traits." ), + ColorId.CustomizationDesign => (0xFFC000C0, "Customization Design", "A design that only changes customizations on a character." ), + ColorId.StateDesign => (0xFF00C0C0, "State Design", "A design that does not change equipment or customizations on a character." ), + ColorId.EquipmentDesign => (0xFF00C000, "Equipment Design", "A design that only changes equipment on a character." ), + ColorId.ActorAvailable => (0xFF18C018, "Actor Available", "The header in the Actor tab panel if the currently selected actor exists in the game world at least once." ), + ColorId.ActorUnavailable => (0xFF1818C0, "Actor Unavailable", "The Header in the Actor tab panel if the currently selected actor does not exist in the game world." ), + ColorId.FolderExpanded => (0xFFFFF0C0, "Expanded Design Folder", "A design folder that is currently expanded." ), + ColorId.FolderCollapsed => (0xFFFFF0C0, "Collapsed Design Folder", "A design folder that is currently collapsed." ), + ColorId.FolderLine => (0xFFFFF0C0, "Expanded Design Folder Line", "The line signifying which descendants belong to an expanded design folder." ), + ColorId.EnabledAutoSet => (0xFFA0F0A0, "Enabled Automation Set", "An automation set that is currently enabled. Only one set can be enabled for each identifier at once." ), + ColorId.DisabledAutoSet => (0xFF808080, "Disabled Automation Set", "An automation set that is currently disabled." ), + ColorId.AutomationActorAvailable => (0xFFFFFFFF, "Automation Actor Available", "A character associated with the given automated design set is currently visible." ), + ColorId.AutomationActorUnavailable => (0xFF808080, "Automation Actor Unavailable", "No character associated with the given automated design set is currently visible." ), + ColorId.HeaderButtons => (0xFFFFF0C0, "Header Buttons", "The text and border color of buttons in the header, like the Incognito toggle." ), + ColorId.FavoriteStarOn => (0xFF40D0D0, "Favored Item", "The color of the star for favored items and of the border in the unlock overview tab." ), + ColorId.FavoriteStarHovered => (0xFFD040D0, "Favorite Star Hovered", "The color of the star for favored items when it is hovered." ), + ColorId.FavoriteStarOff => (0x20808080, "Favorite Star Outline", "The color of the star for items that are not favored when it is not hovered." ), + ColorId.QuickDesignButton => (0x900A0A0A, "Quick Design Bar Button Background", "The color of button frames in the quick design bar." ), + ColorId.QuickDesignFrame => (0x90383838, "Quick Design Bar Combo Background", "The color of the combo background in the quick design bar." ), + ColorId.QuickDesignBg => (0x00F0F0F0, "Quick Design Bar Window Background", "The color of the window background in the quick design bar." ), + _ => (0x00000000, string.Empty, string.Empty ), // @formatter:on }; diff --git a/Glamourer/Gui/DesignQuickBar.cs b/Glamourer/Gui/DesignQuickBar.cs index fd9976f..3a0fe3f 100644 --- a/Glamourer/Gui/DesignQuickBar.cs +++ b/Glamourer/Gui/DesignQuickBar.cs @@ -22,7 +22,7 @@ public class DesignQuickBar : Window, IDisposable { private ImGuiWindowFlags GetFlags => _config.LockDesignQuickBar - ? ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoBackground + ? ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoMove : ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoFocusOnAppearing; private readonly Configuration _config; @@ -32,6 +32,7 @@ public class DesignQuickBar : Window, IDisposable private readonly ObjectManager _objects; private readonly IKeyState _keyState; private readonly ImRaii.Style _windowPadding = new(); + private readonly ImRaii.Color _windowColor = new(); private DateTime _keyboardToggle = DateTime.UnixEpoch; public DesignQuickBar(Configuration config, DesignCombo designCombo, StateManager stateManager, IKeyState keyState, @@ -64,10 +65,16 @@ public class DesignQuickBar : Window, IDisposable Size = new Vector2(12 * ImGui.GetFrameHeight(), ImGui.GetFrameHeight()); _windowPadding.Push(ImGuiStyleVar.WindowPadding, new Vector2(ImGuiHelpers.GlobalScale * 4)); + _windowColor.Push(ImGuiCol.WindowBg, ColorId.QuickDesignBg.Value()) + .Push(ImGuiCol.Button, ColorId.QuickDesignButton.Value()) + .Push(ImGuiCol.FrameBg, ColorId.QuickDesignFrame.Value()); } public override void PostDraw() - => _windowPadding.Dispose(); + { + _windowPadding.Dispose(); + _windowColor.Dispose(); + } public override void Draw() diff --git a/Glamourer/Gui/MainWindow.cs b/Glamourer/Gui/MainWindow.cs index 4b58979..415fc89 100644 --- a/Glamourer/Gui/MainWindow.cs +++ b/Glamourer/Gui/MainWindow.cs @@ -79,6 +79,13 @@ public class MainWindow : Window, IDisposable IsOpen = _config.DebugMode; } + public override void PreDraw() + { + Flags = _config.LockMainWindow + ? Flags | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoResize + : Flags & ~(ImGuiWindowFlags.NoMove |ImGuiWindowFlags.NoResize); + } + public void Dispose() => _event.Unsubscribe(OnTabSelected); diff --git a/Glamourer/Gui/Tabs/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab.cs index a604860..142b48b 100644 --- a/Glamourer/Gui/Tabs/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab.cs @@ -137,6 +137,8 @@ public class SettingsTab : ITab _config.HideWindowInCutscene = v; _uiBuilder.DisableCutsceneUiHide = !v; }); + Checkbox("Lock Main Window", "Prevent the main window from being moved and lock it in place.", _config.LockMainWindow, + v => _config.LockMainWindow = v); ImGui.Dummy(Vector2.Zero); ImGui.Separator(); diff --git a/Glamourer/Services/CommandService.cs b/Glamourer/Services/CommandService.cs index 924d091..02d4185 100644 --- a/Glamourer/Services/CommandService.cs +++ b/Glamourer/Services/CommandService.cs @@ -35,10 +35,11 @@ public class CommandService : IDisposable private readonly DesignManager _designManager; private readonly DesignConverter _converter; private readonly DesignFileSystem _designFileSystem; + private readonly Configuration _config; public CommandService(ICommandManager commands, MainWindow mainWindow, IChatGui chat, ActorService actors, ObjectManager objects, AutoDesignApplier autoDesignApplier, StateManager stateManager, DesignManager designManager, DesignConverter converter, - DesignFileSystem designFileSystem, AutoDesignManager autoDesignManager) + DesignFileSystem designFileSystem, AutoDesignManager autoDesignManager, Configuration config) { _commands = commands; _mainWindow = mainWindow; @@ -51,6 +52,7 @@ public class CommandService : IDisposable _converter = converter; _designFileSystem = designFileSystem; _autoDesignManager = autoDesignManager; + _config = config; _commands.AddHandler(MainCommandString, new CommandInfo(OnGlamourer) { HelpMessage = "Open or close the Glamourer window." }); _commands.AddHandler(ApplyCommandString, @@ -64,7 +66,33 @@ public class CommandService : IDisposable } private void OnGlamourer(string command, string arguments) - => _mainWindow.Toggle(); + { + if (arguments.Length > 0) + switch (arguments) + { + case "qdb": + case "quick": + case "bar": + case "designs": + case "design": + case "design bar": + _config.ShowDesignQuickBar = !_config.ShowDesignQuickBar; + _config.Save(); + return; + case "lock": + case "unlock": + _config.LockMainWindow = !_config.LockMainWindow; + _config.Save(); + return; + default: + _chat.Print("Use without argument to toggle the main window."); + _chat.Print(new SeStringBuilder().AddCommand("qdb", "Toggles the quick design bar on or off.").BuiltString); + _chat.Print(new SeStringBuilder().AddCommand("lock", "Toggles the lock of the main window on or off.").BuiltString); + return; + } + + _mainWindow.Toggle(); + } private void OnGlamour(string command, string arguments) {