Add locking and color options and commands.

This commit is contained in:
Ottermandias 2023-10-12 16:56:12 +02:00
parent a84a66a344
commit 27c41cac49
5 changed files with 73 additions and 22 deletions

View file

@ -1,4 +1,5 @@
using System.Collections.Generic; using System.Collections.Generic;
using ImGuiNET;
namespace Glamourer.Gui; namespace Glamourer.Gui;
@ -21,6 +22,9 @@ public enum ColorId
FavoriteStarOn, FavoriteStarOn,
FavoriteStarHovered, FavoriteStarHovered,
FavoriteStarOff, FavoriteStarOff,
QuickDesignButton,
QuickDesignFrame,
QuickDesignBg,
} }
public static class Colors public static class Colors
@ -29,24 +33,27 @@ public static class Colors
=> color switch => color switch
{ {
// @formatter:off // @formatter:off
ColorId.NormalDesign => (0xFFFFFFFF, "Normal Design", "A design with no specific traits." ), 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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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.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 // @formatter:on
}; };

View file

@ -22,7 +22,7 @@ public class DesignQuickBar : Window, IDisposable
{ {
private ImGuiWindowFlags GetFlags private ImGuiWindowFlags GetFlags
=> _config.LockDesignQuickBar => _config.LockDesignQuickBar
? ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoBackground ? ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoFocusOnAppearing | ImGuiWindowFlags.NoMove
: ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoFocusOnAppearing; : ImGuiWindowFlags.NoDecoration | ImGuiWindowFlags.NoFocusOnAppearing;
private readonly Configuration _config; private readonly Configuration _config;
@ -32,6 +32,7 @@ public class DesignQuickBar : Window, IDisposable
private readonly ObjectManager _objects; private readonly ObjectManager _objects;
private readonly IKeyState _keyState; private readonly IKeyState _keyState;
private readonly ImRaii.Style _windowPadding = new(); private readonly ImRaii.Style _windowPadding = new();
private readonly ImRaii.Color _windowColor = new();
private DateTime _keyboardToggle = DateTime.UnixEpoch; private DateTime _keyboardToggle = DateTime.UnixEpoch;
public DesignQuickBar(Configuration config, DesignCombo designCombo, StateManager stateManager, IKeyState keyState, 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()); Size = new Vector2(12 * ImGui.GetFrameHeight(), ImGui.GetFrameHeight());
_windowPadding.Push(ImGuiStyleVar.WindowPadding, new Vector2(ImGuiHelpers.GlobalScale * 4)); _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() public override void PostDraw()
=> _windowPadding.Dispose(); {
_windowPadding.Dispose();
_windowColor.Dispose();
}
public override void Draw() public override void Draw()

View file

@ -79,6 +79,13 @@ public class MainWindow : Window, IDisposable
IsOpen = _config.DebugMode; IsOpen = _config.DebugMode;
} }
public override void PreDraw()
{
Flags = _config.LockMainWindow
? Flags | ImGuiWindowFlags.NoMove | ImGuiWindowFlags.NoResize
: Flags & ~(ImGuiWindowFlags.NoMove |ImGuiWindowFlags.NoResize);
}
public void Dispose() public void Dispose()
=> _event.Unsubscribe(OnTabSelected); => _event.Unsubscribe(OnTabSelected);

View file

@ -137,6 +137,8 @@ public class SettingsTab : ITab
_config.HideWindowInCutscene = v; _config.HideWindowInCutscene = v;
_uiBuilder.DisableCutsceneUiHide = !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.Dummy(Vector2.Zero);
ImGui.Separator(); ImGui.Separator();

View file

@ -35,10 +35,11 @@ public class CommandService : IDisposable
private readonly DesignManager _designManager; private readonly DesignManager _designManager;
private readonly DesignConverter _converter; private readonly DesignConverter _converter;
private readonly DesignFileSystem _designFileSystem; private readonly DesignFileSystem _designFileSystem;
private readonly Configuration _config;
public CommandService(ICommandManager commands, MainWindow mainWindow, IChatGui chat, ActorService actors, ObjectManager objects, public CommandService(ICommandManager commands, MainWindow mainWindow, IChatGui chat, ActorService actors, ObjectManager objects,
AutoDesignApplier autoDesignApplier, StateManager stateManager, DesignManager designManager, DesignConverter converter, AutoDesignApplier autoDesignApplier, StateManager stateManager, DesignManager designManager, DesignConverter converter,
DesignFileSystem designFileSystem, AutoDesignManager autoDesignManager) DesignFileSystem designFileSystem, AutoDesignManager autoDesignManager, Configuration config)
{ {
_commands = commands; _commands = commands;
_mainWindow = mainWindow; _mainWindow = mainWindow;
@ -51,6 +52,7 @@ public class CommandService : IDisposable
_converter = converter; _converter = converter;
_designFileSystem = designFileSystem; _designFileSystem = designFileSystem;
_autoDesignManager = autoDesignManager; _autoDesignManager = autoDesignManager;
_config = config;
_commands.AddHandler(MainCommandString, new CommandInfo(OnGlamourer) { HelpMessage = "Open or close the Glamourer window." }); _commands.AddHandler(MainCommandString, new CommandInfo(OnGlamourer) { HelpMessage = "Open or close the Glamourer window." });
_commands.AddHandler(ApplyCommandString, _commands.AddHandler(ApplyCommandString,
@ -64,7 +66,33 @@ public class CommandService : IDisposable
} }
private void OnGlamourer(string command, string arguments) 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) private void OnGlamour(string command, string arguments)
{ {