mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-18 14:44:31 +01:00
Add option to apply designs to player with doubl click.
This commit is contained in:
parent
64c1f75ee0
commit
bfe50f459d
5 changed files with 80 additions and 8 deletions
|
|
@ -44,6 +44,7 @@ public class Configuration : IPluginConfiguration, ISavable
|
||||||
public bool ShowColorConfig { get; set; } = true;
|
public bool ShowColorConfig { get; set; } = true;
|
||||||
public bool ChangeEntireItem { get; set; } = false;
|
public bool ChangeEntireItem { get; set; } = false;
|
||||||
public bool AlwaysApplyAssociatedMods { get; set; } = false;
|
public bool AlwaysApplyAssociatedMods { get; set; } = false;
|
||||||
|
public bool AllowDoubleClickToApply { get; set; } = false;
|
||||||
public ModifiableHotkey ToggleQuickDesignBar { get; set; } = new(VirtualKey.NO_KEY);
|
public ModifiableHotkey ToggleQuickDesignBar { get; set; } = new(VirtualKey.NO_KEY);
|
||||||
public DoubleModifier DeleteDesignModifier { get; set; } = new(ModifierHotkey.Control, ModifierHotkey.Shift);
|
public DoubleModifier DeleteDesignModifier { get; set; } = new(ModifierHotkey.Control, ModifierHotkey.Shift);
|
||||||
public ChangeLogDisplayType ChangeLogDisplayType { get; set; } = ChangeLogDisplayType.New;
|
public ChangeLogDisplayType ChangeLogDisplayType { get; set; } = ChangeLogDisplayType.New;
|
||||||
|
|
|
||||||
|
|
@ -3,6 +3,7 @@ using Dalamud.Interface.Internal.Notifications;
|
||||||
using Dalamud.Plugin.Services;
|
using Dalamud.Plugin.Services;
|
||||||
using Glamourer.Designs;
|
using Glamourer.Designs;
|
||||||
using Glamourer.Events;
|
using Glamourer.Events;
|
||||||
|
using Glamourer.Services;
|
||||||
using ImGuiNET;
|
using ImGuiNET;
|
||||||
using OtterGui;
|
using OtterGui;
|
||||||
using OtterGui.Classes;
|
using OtterGui.Classes;
|
||||||
|
|
@ -21,6 +22,7 @@ public sealed class DesignFileSystemSelector : FileSystemSelector<Design, Design
|
||||||
private readonly DesignConverter _converter;
|
private readonly DesignConverter _converter;
|
||||||
private readonly TabSelected _selectionEvent;
|
private readonly TabSelected _selectionEvent;
|
||||||
private readonly DesignColors _designColors;
|
private readonly DesignColors _designColors;
|
||||||
|
private readonly DesignApplier _designApplier;
|
||||||
|
|
||||||
private string? _clipboardText;
|
private string? _clipboardText;
|
||||||
private Design? _cloneDesign;
|
private Design? _cloneDesign;
|
||||||
|
|
@ -43,7 +45,8 @@ public sealed class DesignFileSystemSelector : FileSystemSelector<Design, Design
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
public DesignFileSystemSelector(DesignManager designManager, DesignFileSystem fileSystem, IKeyState keyState, DesignChanged @event,
|
public DesignFileSystemSelector(DesignManager designManager, DesignFileSystem fileSystem, IKeyState keyState, DesignChanged @event,
|
||||||
Configuration config, DesignConverter converter, TabSelected selectionEvent, Logger log, DesignColors designColors)
|
Configuration config, DesignConverter converter, TabSelected selectionEvent, Logger log, DesignColors designColors,
|
||||||
|
DesignApplier designApplier)
|
||||||
: base(fileSystem, keyState, log, allowMultipleSelection: true)
|
: base(fileSystem, keyState, log, allowMultipleSelection: true)
|
||||||
{
|
{
|
||||||
_designManager = designManager;
|
_designManager = designManager;
|
||||||
|
|
@ -52,6 +55,7 @@ public sealed class DesignFileSystemSelector : FileSystemSelector<Design, Design
|
||||||
_converter = converter;
|
_converter = converter;
|
||||||
_selectionEvent = selectionEvent;
|
_selectionEvent = selectionEvent;
|
||||||
_designColors = designColors;
|
_designColors = designColors;
|
||||||
|
_designApplier = designApplier;
|
||||||
_event.Subscribe(OnDesignChange, DesignChanged.Priority.DesignFileSystemSelector);
|
_event.Subscribe(OnDesignChange, DesignChanged.Priority.DesignFileSystemSelector);
|
||||||
_selectionEvent.Subscribe(OnTabSelected, TabSelected.Priority.DesignSelector);
|
_selectionEvent.Subscribe(OnTabSelected, TabSelected.Priority.DesignSelector);
|
||||||
_designColors.ColorChanged += SetFilterDirty;
|
_designColors.ColorChanged += SetFilterDirty;
|
||||||
|
|
@ -92,6 +96,8 @@ public sealed class DesignFileSystemSelector : FileSystemSelector<Design, Design
|
||||||
var name = IncognitoMode ? leaf.Value.Incognito : leaf.Value.Name.Text;
|
var name = IncognitoMode ? leaf.Value.Incognito : leaf.Value.Name.Text;
|
||||||
using var color = ImRaii.PushColor(ImGuiCol.Text, state.Color);
|
using var color = ImRaii.PushColor(ImGuiCol.Text, state.Color);
|
||||||
using var _ = ImRaii.TreeNode(name, flag);
|
using var _ = ImRaii.TreeNode(name, flag);
|
||||||
|
if (_config.AllowDoubleClickToApply && ImGui.IsItemHovered() && ImGui.IsMouseDoubleClicked(ImGuiMouseButton.Left))
|
||||||
|
_designApplier.ApplyToPlayer(leaf.Value);
|
||||||
}
|
}
|
||||||
|
|
||||||
public override void Dispose()
|
public override void Dispose()
|
||||||
|
|
|
||||||
|
|
@ -175,6 +175,9 @@ public class SettingsTab(
|
||||||
ImGui.Separator();
|
ImGui.Separator();
|
||||||
ImGui.Dummy(Vector2.Zero);
|
ImGui.Dummy(Vector2.Zero);
|
||||||
|
|
||||||
|
Checkbox("Allow Double-Clicking Designs to Apply",
|
||||||
|
"Tries to apply a design to the current player character When double-clicking it in the design selector.",
|
||||||
|
config.AllowDoubleClickToApply, v => config.AllowDoubleClickToApply = v);
|
||||||
Checkbox("Show all Application Rule Checkboxes for Automation",
|
Checkbox("Show all Application Rule Checkboxes for Automation",
|
||||||
"Show multiple separate application rule checkboxes for automated designs, instead of a single box for enabling or disabling.",
|
"Show multiple separate application rule checkboxes for automated designs, instead of a single box for enabling or disabling.",
|
||||||
config.ShowAllAutomatedApplicationRules, v => config.ShowAllAutomatedApplicationRules = v);
|
config.ShowAllAutomatedApplicationRules, v => config.ShowAllAutomatedApplicationRules = v);
|
||||||
|
|
@ -183,9 +186,6 @@ public class SettingsTab(
|
||||||
config.ShowUnlockedItemWarnings, v => config.ShowUnlockedItemWarnings = v);
|
config.ShowUnlockedItemWarnings, v => config.ShowUnlockedItemWarnings = v);
|
||||||
if (config.UseAdvancedParameters)
|
if (config.UseAdvancedParameters)
|
||||||
{
|
{
|
||||||
//Checkbox("Show Revert Advanced Customizations Button in Quick Design Bar",
|
|
||||||
// "Show a button to revert only advanced customizations on your character or a target in the quick design bar.",
|
|
||||||
// config.ShowRevertAdvancedParametersButton, v => config.ShowRevertAdvancedParametersButton = v);
|
|
||||||
Checkbox("Show Color Display Config", "Show the Color Display configuration options in the Advanced Customization panels.",
|
Checkbox("Show Color Display Config", "Show the Color Display configuration options in the Advanced Customization panels.",
|
||||||
config.ShowColorConfig, v => config.ShowColorConfig = v);
|
config.ShowColorConfig, v => config.ShowColorConfig = v);
|
||||||
Checkbox("Show Palette+ Import Button",
|
Checkbox("Show Palette+ Import Button",
|
||||||
|
|
@ -213,7 +213,8 @@ public class SettingsTab(
|
||||||
ImGui.NewLine();
|
ImGui.NewLine();
|
||||||
ImGui.TextUnformatted("Show the Following Buttons in the Quick Design Bar:");
|
ImGui.TextUnformatted("Show the Following Buttons in the Quick Design Bar:");
|
||||||
ImGui.Dummy(Vector2.Zero);
|
ImGui.Dummy(Vector2.Zero);
|
||||||
using var table = ImRaii.Table("##tableQdb", numColumns, ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.Borders | ImGuiTableFlags.NoHostExtendX);
|
using var table = ImRaii.Table("##tableQdb", numColumns,
|
||||||
|
ImGuiTableFlags.SizingFixedFit | ImGuiTableFlags.Borders | ImGuiTableFlags.NoHostExtendX);
|
||||||
if (!table)
|
if (!table)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
|
|
|
||||||
61
Glamourer/Services/DesignApplier.cs
Normal file
61
Glamourer/Services/DesignApplier.cs
Normal file
|
|
@ -0,0 +1,61 @@
|
||||||
|
using Glamourer.Designs;
|
||||||
|
using Glamourer.Interop;
|
||||||
|
using Glamourer.Interop.Structs;
|
||||||
|
using Glamourer.State;
|
||||||
|
using OtterGui.Services;
|
||||||
|
using Penumbra.GameData.Actors;
|
||||||
|
|
||||||
|
namespace Glamourer.Services;
|
||||||
|
|
||||||
|
public sealed class DesignApplier(StateManager stateManager, ObjectManager objects) : IService
|
||||||
|
{
|
||||||
|
public void ApplyToPlayer(DesignBase design)
|
||||||
|
{
|
||||||
|
var (player, data) = objects.PlayerData;
|
||||||
|
if (!data.Valid)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!stateManager.GetOrCreate(player, data.Objects[0], out var state))
|
||||||
|
return;
|
||||||
|
|
||||||
|
stateManager.ApplyDesign(state, design, ApplySettings.ManualWithLinks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void ApplyToTarget(DesignBase design)
|
||||||
|
{
|
||||||
|
var (player, data) = objects.TargetData;
|
||||||
|
if (!data.Valid)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!stateManager.GetOrCreate(player, data.Objects[0], out var state))
|
||||||
|
return;
|
||||||
|
|
||||||
|
stateManager.ApplyDesign(state, design, ApplySettings.ManualWithLinks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Apply(ActorIdentifier actor, DesignBase design)
|
||||||
|
{
|
||||||
|
objects.Update();
|
||||||
|
Apply(actor, objects.TryGetValue(actor, out var d) ? d : ActorData.Invalid, design, ApplySettings.ManualWithLinks);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Apply(ActorIdentifier actor, DesignBase design, ApplySettings settings)
|
||||||
|
{
|
||||||
|
objects.Update();
|
||||||
|
Apply(actor, objects.TryGetValue(actor, out var d) ? d : ActorData.Invalid, design, settings);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void Apply(ActorIdentifier actor, ActorData data, DesignBase design)
|
||||||
|
=> Apply(actor, data, design, ApplySettings.ManualWithLinks);
|
||||||
|
|
||||||
|
public void Apply(ActorIdentifier actor, ActorData data, DesignBase design, ApplySettings settings)
|
||||||
|
{
|
||||||
|
if (!actor.IsValid || !data.Valid)
|
||||||
|
return;
|
||||||
|
|
||||||
|
if (!stateManager.GetOrCreate(actor, data.Objects[0], out var state))
|
||||||
|
return;
|
||||||
|
|
||||||
|
stateManager.ApplyDesign(state, design, ApplySettings.ManualWithLinks);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
@ -68,6 +68,9 @@ public sealed class StateManager(
|
||||||
if (TryGetValue(identifier, out state))
|
if (TryGetValue(identifier, out state))
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
|
if (!actor.Valid)
|
||||||
|
return false;
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
// Initial Creation, use the actors data for the base data,
|
// Initial Creation, use the actors data for the base data,
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue