mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 10:17:23 +01:00
Add RevertToAutomation IPC.
This commit is contained in:
parent
ea55d9cb03
commit
c2b5064256
3 changed files with 56 additions and 7 deletions
|
|
@ -14,6 +14,7 @@ public partial class GlamourerIpc
|
|||
public const string LabelRevertLock = "Glamourer.RevertLock";
|
||||
public const string LabelRevertCharacterLock = "Glamourer.RevertCharacterLock";
|
||||
public const string LabelUnlock = "Glamourer.Unlock";
|
||||
public const string LabelRevertToAutomation = "Glamourer.RevertToAutomation";
|
||||
|
||||
private readonly ActionProvider<string> _revertProvider;
|
||||
private readonly ActionProvider<Character?> _revertCharacterProvider;
|
||||
|
|
@ -21,6 +22,8 @@ public partial class GlamourerIpc
|
|||
private readonly ActionProvider<string, uint> _revertProviderLock;
|
||||
private readonly ActionProvider<Character?, uint> _revertCharacterProviderLock;
|
||||
|
||||
private readonly FuncProvider<Character?, uint, bool> _revertToAutomationProvider;
|
||||
|
||||
private readonly FuncProvider<Character?, uint, bool> _unlockProvider;
|
||||
|
||||
public static ActionSubscriber<string> RevertSubscriber(DalamudPluginInterface pi)
|
||||
|
|
@ -29,6 +32,12 @@ public partial class GlamourerIpc
|
|||
public static ActionSubscriber<Character?> RevertCharacterSubscriber(DalamudPluginInterface pi)
|
||||
=> new(pi, LabelRevertCharacter);
|
||||
|
||||
public static FuncSubscriber<Character?, uint, bool> UnlockSubscriber(DalamudPluginInterface pi)
|
||||
=> new(pi, LabelUnlock);
|
||||
|
||||
public static FuncSubscriber<Character?, uint, bool> RevertToAutomationSubscriber(DalamudPluginInterface pi)
|
||||
=> new(pi, LabelRevertToAutomation);
|
||||
|
||||
public void Revert(string characterName)
|
||||
=> Revert(FindActors(characterName), 0);
|
||||
|
||||
|
|
@ -44,6 +53,9 @@ public partial class GlamourerIpc
|
|||
public bool Unlock(Character? character, uint lockCode)
|
||||
=> Unlock(FindActors(character), lockCode);
|
||||
|
||||
public bool RevertToAutomation(Character? character, uint lockCode)
|
||||
=> RevertToAutomation(FindActors(character), lockCode);
|
||||
|
||||
private void Revert(IEnumerable<ActorIdentifier> actors, uint lockCode)
|
||||
{
|
||||
foreach (var id in actors)
|
||||
|
|
@ -64,4 +76,24 @@ public partial class GlamourerIpc
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
private bool RevertToAutomation(IEnumerable<ActorIdentifier> actors, uint lockCode)
|
||||
{
|
||||
var ret = false;
|
||||
foreach (var id in actors)
|
||||
{
|
||||
if (_stateManager.TryGetValue(id, out var state))
|
||||
{
|
||||
ret |= state.Unlock(lockCode);
|
||||
if (_objects.TryGetValue(id, out var data))
|
||||
foreach (var obj in data.Objects)
|
||||
{
|
||||
_autoDesignApplier.ReapplyAutomation(obj, state.Identifier, state);
|
||||
_stateManager.ReapplyState(obj);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ using Dalamud.Plugin;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using Glamourer.Automation;
|
||||
using Glamourer.Designs;
|
||||
using Glamourer.Events;
|
||||
using Glamourer.Interop;
|
||||
|
|
@ -17,20 +18,22 @@ namespace Glamourer.Api;
|
|||
public partial class GlamourerIpc : IDisposable
|
||||
{
|
||||
public const int CurrentApiVersionMajor = 0;
|
||||
public const int CurrentApiVersionMinor = 3;
|
||||
public const int CurrentApiVersionMinor = 4;
|
||||
|
||||
private readonly StateManager _stateManager;
|
||||
private readonly ObjectManager _objects;
|
||||
private readonly ActorService _actors;
|
||||
private readonly DesignConverter _designConverter;
|
||||
private readonly AutoDesignApplier _autoDesignApplier;
|
||||
|
||||
public GlamourerIpc(DalamudPluginInterface pi, StateManager stateManager, ObjectManager objects, ActorService actors,
|
||||
DesignConverter designConverter, StateChanged stateChangedEvent, GPoseService gPose)
|
||||
DesignConverter designConverter, StateChanged stateChangedEvent, GPoseService gPose, AutoDesignApplier autoDesignApplier)
|
||||
{
|
||||
_stateManager = stateManager;
|
||||
_objects = objects;
|
||||
_actors = actors;
|
||||
_designConverter = designConverter;
|
||||
_autoDesignApplier = autoDesignApplier;
|
||||
_gPose = gPose;
|
||||
_stateChangedEvent = stateChangedEvent;
|
||||
_apiVersionProvider = new FuncProvider<int>(pi, LabelApiVersion, ApiVersion);
|
||||
|
|
@ -65,6 +68,7 @@ public partial class GlamourerIpc : IDisposable
|
|||
_revertProviderLock = new ActionProvider<string, uint>(pi, LabelRevertLock, RevertLock);
|
||||
_revertCharacterProviderLock = new ActionProvider<Character?, uint>(pi, LabelRevertCharacterLock, RevertCharacterLock);
|
||||
_unlockProvider = new FuncProvider<Character?, uint, bool>(pi, LabelUnlock, Unlock);
|
||||
_revertToAutomationProvider = new FuncProvider<Character?, uint, bool>(pi, LabelRevertToAutomation, RevertToAutomation);
|
||||
|
||||
_stateChangedProvider = new EventProvider<StateChanged.Type, nint, Lazy<string>>(pi, LabelStateChanged);
|
||||
_gPoseChangedProvider = new EventProvider<bool>(pi, LabelGPoseChanged);
|
||||
|
|
@ -99,6 +103,7 @@ public partial class GlamourerIpc : IDisposable
|
|||
_revertProviderLock.Dispose();
|
||||
_revertCharacterProviderLock.Dispose();
|
||||
_unlockProvider.Dispose();
|
||||
_revertToAutomationProvider.Dispose();
|
||||
|
||||
_stateChangedEvent.Unsubscribe(OnStateChanged);
|
||||
_stateChangedProvider.Dispose();
|
||||
|
|
|
|||
|
|
@ -1682,6 +1682,18 @@ public unsafe class DebugTab : ITab
|
|||
if (ImGui.Button("Apply##CustomizeCharacter"))
|
||||
GlamourerIpc.ApplyOnlyCustomizationToCharacterSubscriber(_pluginInterface)
|
||||
.Invoke(_base64Apply, _objectManager.Objects[_gameObjectIndex] as Character);
|
||||
|
||||
ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelUnlock);
|
||||
ImGui.TableNextColumn();
|
||||
if (ImGui.Button("Unlock##CustomizeCharacter"))
|
||||
GlamourerIpc.UnlockSubscriber(_pluginInterface)
|
||||
.Invoke(_objectManager.Objects[_gameObjectIndex] as Character, 1337);
|
||||
|
||||
ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelRevertToAutomation);
|
||||
ImGui.TableNextColumn();
|
||||
if (ImGui.Button("Revert##CustomizeCharacter"))
|
||||
GlamourerIpc.RevertToAutomationSubscriber(_pluginInterface)
|
||||
.Invoke(_objectManager.Objects[_gameObjectIndex] as Character, 1337);
|
||||
}
|
||||
|
||||
#endregion
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue