From 9a52dddba3c21b667652da13305b949847e2dbaa Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Tue, 9 Apr 2024 15:21:07 +0200 Subject: [PATCH] Add design rename field to context. --- Glamourer/Configuration.cs | 2 + .../DesignTab/DesignFileSystemSelector.cs | 55 +++++++++++++++++++ Glamourer/Gui/Tabs/DesignTab/RenameField.cs | 26 +++++++++ Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs | 30 ++++++++++ 4 files changed, 113 insertions(+) create mode 100644 Glamourer/Gui/Tabs/DesignTab/RenameField.cs diff --git a/Glamourer/Configuration.cs b/Glamourer/Configuration.cs index 896b431..ce2ed08 100644 --- a/Glamourer/Configuration.cs +++ b/Glamourer/Configuration.cs @@ -3,6 +3,7 @@ using Dalamud.Game.ClientState.Keys; using Dalamud.Interface.Internal.Notifications; using Glamourer.Designs; using Glamourer.Gui; +using Glamourer.Gui.Tabs.DesignTab; using Glamourer.Services; using Newtonsoft.Json; using OtterGui; @@ -46,6 +47,7 @@ public class Configuration : IPluginConfiguration, ISavable public bool AlwaysApplyAssociatedMods { get; set; } = false; public bool AllowDoubleClickToApply { get; set; } = false; public bool RespectManualOnAutomationUpdate { get; set; } = false; + public RenameField ShowRename { get; set; } = RenameField.BothDataPrio; public ModifiableHotkey ToggleQuickDesignBar { get; set; } = new(VirtualKey.NO_KEY); public DoubleModifier DeleteDesignModifier { get; set; } = new(ModifierHotkey.Control, ModifierHotkey.Shift); public ChangeLogDisplayType ChangeLogDisplayType { get; set; } = ChangeLogDisplayType.New; diff --git a/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs b/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs index cfc3877..2608dd3 100644 --- a/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs +++ b/Glamourer/Gui/Tabs/DesignTab/DesignFileSystemSelector.cs @@ -64,6 +64,8 @@ public sealed class DesignFileSystemSelector : FileSystemSelector.Leaf? leaf, bool clear, in DesignState storage = default) { base.Select(leaf, clear, storage); diff --git a/Glamourer/Gui/Tabs/DesignTab/RenameField.cs b/Glamourer/Gui/Tabs/DesignTab/RenameField.cs new file mode 100644 index 0000000..d79fb2f --- /dev/null +++ b/Glamourer/Gui/Tabs/DesignTab/RenameField.cs @@ -0,0 +1,26 @@ +namespace Glamourer.Gui.Tabs.DesignTab; + +public enum RenameField +{ + None, + RenameSearchPath, + RenameData, + BothSearchPathPrio, + BothDataPrio, +} + +public static class RenameFieldExtensions +{ + public static (string Name, string Desc) GetData(this RenameField value) + => value switch + { + RenameField.None => ("None", "Show no rename fields in the context menu for designs."), + RenameField.RenameSearchPath => ("Search Path", "Show only the search path / move field in the context menu for designs."), + RenameField.RenameData => ("Design Name", "Show only the design name field in the context menu for designs."), + RenameField.BothSearchPathPrio => ("Both (Focus Search Path)", + "Show both rename fields in the context menu for designs, but put the keyboard cursor on the search path field."), + RenameField.BothDataPrio => ("Both (Focus Design Name)", + "Show both rename fields in the context menu for designs, but put the keyboard cursor on the design name field"), + _ => (string.Empty, string.Empty), + }; +} diff --git a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs index 223a0a8..67ecda7 100644 --- a/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs +++ b/Glamourer/Gui/Tabs/SettingsTab/SettingsTab.cs @@ -168,6 +168,7 @@ public class SettingsTab( "A modifier you need to hold while clicking the Delete Design button for it to take effect.", 100 * ImGuiHelpers.GlobalScale, config.DeleteDesignModifier, v => config.DeleteDesignModifier = v)) config.Save(); + DrawRenameSettings(); Checkbox("Auto-Open Design Folders", "Have design folders open or closed as their default state after launching.", config.OpenFoldersByDefault, v => config.OpenFoldersByDefault = v); @@ -411,4 +412,33 @@ public class SettingsTab( ImGuiUtil.LabeledHelpMarker("Sort Mode", "Choose the sort mode for the mod selector in the designs tab."); } + + private void DrawRenameSettings() + { + ImGui.SetNextItemWidth(300 * ImGuiHelpers.GlobalScale); + using (var combo = ImRaii.Combo("##renameSettings", config.ShowRename.GetData().Name)) + { + if (combo) + foreach (var value in Enum.GetValues()) + { + var (name, desc) = value.GetData(); + if (ImGui.Selectable(name, config.ShowRename == value)) + { + config.ShowRename = value; + selector.SetRenameSearchPath(value); + config.Save(); + } + + ImGuiUtil.HoverTooltip(desc); + } + } + + ImGui.SameLine(); + const string tt = + "Select which of the two renaming input fields are visible when opening the right-click context menu of a design in the design selector."; + ImGuiComponents.HelpMarker(tt); + ImGui.SameLine(); + ImGui.TextUnformatted("Rename Fields in Design Context Menu"); + ImGuiUtil.HoverTooltip(tt); + } }