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
@ -46,6 +50,9 @@ public static class Colors
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." ),
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 ), _ => (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)
{ {