mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 10:17:23 +01:00
Add design rename field to context.
This commit is contained in:
parent
e35f2816e2
commit
9a52dddba3
4 changed files with 113 additions and 0 deletions
|
|
@ -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;
|
||||
|
|
|
|||
|
|
@ -64,6 +64,8 @@ public sealed class DesignFileSystemSelector : FileSystemSelector<Design, Design
|
|||
AddButton(ImportDesignButton, 10);
|
||||
AddButton(CloneDesignButton, 20);
|
||||
AddButton(DeleteButton, 1000);
|
||||
UnsubscribeRightClickLeaf(RenameLeaf);
|
||||
SetRenameSearchPath(_config.ShowRename);
|
||||
SetFilterTooltip();
|
||||
|
||||
if (_config.Ephemeral.SelectedDesign == Guid.Empty)
|
||||
|
|
@ -74,6 +76,59 @@ public sealed class DesignFileSystemSelector : FileSystemSelector<Design, Design
|
|||
SelectByValue(design);
|
||||
}
|
||||
|
||||
public void SetRenameSearchPath(RenameField value)
|
||||
{
|
||||
switch (value)
|
||||
{
|
||||
case RenameField.RenameSearchPath:
|
||||
SubscribeRightClickLeaf(RenameLeafDesign, 1000);
|
||||
UnsubscribeRightClickLeaf(RenameDesign);
|
||||
break;
|
||||
case RenameField.RenameData:
|
||||
UnsubscribeRightClickLeaf(RenameLeafDesign);
|
||||
SubscribeRightClickLeaf(RenameDesign, 1000);
|
||||
break;
|
||||
case RenameField.BothSearchPathPrio:
|
||||
UnsubscribeRightClickLeaf(RenameLeafDesign);
|
||||
UnsubscribeRightClickLeaf(RenameDesign);
|
||||
SubscribeRightClickLeaf(RenameLeafDesign, 1001);
|
||||
SubscribeRightClickLeaf(RenameDesign, 1000);
|
||||
break;
|
||||
case RenameField.BothDataPrio:
|
||||
UnsubscribeRightClickLeaf(RenameLeafDesign);
|
||||
UnsubscribeRightClickLeaf(RenameDesign);
|
||||
SubscribeRightClickLeaf(RenameLeafDesign, 1000);
|
||||
SubscribeRightClickLeaf(RenameDesign, 1001);
|
||||
break;
|
||||
default:
|
||||
UnsubscribeRightClickLeaf(RenameLeafDesign);
|
||||
UnsubscribeRightClickLeaf(RenameDesign);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
private void RenameLeafDesign(DesignFileSystem.Leaf leaf)
|
||||
{
|
||||
ImGui.Separator();
|
||||
RenameLeaf(leaf);
|
||||
}
|
||||
|
||||
private void RenameDesign(DesignFileSystem.Leaf leaf)
|
||||
{
|
||||
ImGui.Separator();
|
||||
var currentName = leaf.Value.Name.Text;
|
||||
if (ImGui.IsWindowAppearing())
|
||||
ImGui.SetKeyboardFocusHere(0);
|
||||
ImGui.TextUnformatted("Rename Design:");
|
||||
if (ImGui.InputText("##RenameDesign", ref currentName, 256, ImGuiInputTextFlags.EnterReturnsTrue))
|
||||
{
|
||||
_designManager.Rename(leaf.Value, currentName);
|
||||
ImGui.CloseCurrentPopup();
|
||||
}
|
||||
|
||||
ImGuiUtil.HoverTooltip("Enter a new name here to rename the changed design.");
|
||||
}
|
||||
|
||||
protected override void Select(FileSystem<Design>.Leaf? leaf, bool clear, in DesignState storage = default)
|
||||
{
|
||||
base.Select(leaf, clear, storage);
|
||||
|
|
|
|||
26
Glamourer/Gui/Tabs/DesignTab/RenameField.cs
Normal file
26
Glamourer/Gui/Tabs/DesignTab/RenameField.cs
Normal file
|
|
@ -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),
|
||||
};
|
||||
}
|
||||
|
|
@ -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<RenameField>())
|
||||
{
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue