mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-13 12:14:18 +01:00
Add some IPC stuff.
This commit is contained in:
parent
78b15c085f
commit
fdd74c0514
6 changed files with 75 additions and 11 deletions
|
|
@ -88,6 +88,12 @@ public partial class GlamourerIpc
|
||||||
public static ActionSubscriber<Guid, Character?> ApplyByGuidOnceToCharacterSubscriber(DalamudPluginInterface pi)
|
public static ActionSubscriber<Guid, Character?> ApplyByGuidOnceToCharacterSubscriber(DalamudPluginInterface pi)
|
||||||
=> new(pi, LabelApplyByGuidOnceToCharacter);
|
=> new(pi, LabelApplyByGuidOnceToCharacter);
|
||||||
|
|
||||||
|
public static ActionSubscriber<string, string, uint> ApplyAllLockSubscriber(DalamudPluginInterface pi)
|
||||||
|
=> new(pi, LabelApplyAllLock);
|
||||||
|
|
||||||
|
public static ActionSubscriber<string, Character?, uint> ApplyAllToCharacterLockSubscriber(DalamudPluginInterface pi)
|
||||||
|
=> new(pi, LabelApplyAllToCharacterLock);
|
||||||
|
|
||||||
public void ApplyAll(string base64, string characterName)
|
public void ApplyAll(string base64, string characterName)
|
||||||
=> ApplyDesign(_designConverter.FromBase64(base64, true, true, out var version), FindActors(characterName), version, 0);
|
=> ApplyDesign(_designConverter.FromBase64(base64, true, true, out var version), FindActors(characterName), version, 0);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -8,11 +8,15 @@ namespace Glamourer.Api;
|
||||||
|
|
||||||
public partial class GlamourerIpc
|
public partial class GlamourerIpc
|
||||||
{
|
{
|
||||||
public const string LabelGetAllCustomization = "Glamourer.GetAllCustomization";
|
public const string LabelGetAllCustomization = "Glamourer.GetAllCustomization";
|
||||||
public const string LabelGetAllCustomizationFromCharacter = "Glamourer.GetAllCustomizationFromCharacter";
|
public const string LabelGetAllCustomizationFromCharacter = "Glamourer.GetAllCustomizationFromCharacter";
|
||||||
|
public const string LabelGetAllCustomizationLocked = "Glamourer.GetAllCustomizationLocked";
|
||||||
|
public const string LabelGetAllCustomizationFromLockedCharacter = "Glamourer.GetAllCustomizationFromLockedCharacter";
|
||||||
|
|
||||||
private readonly FuncProvider<string, string?> _getAllCustomizationProvider;
|
private readonly FuncProvider<string, string?> _getAllCustomizationProvider;
|
||||||
private readonly FuncProvider<Character?, string?> _getAllCustomizationFromCharacterProvider;
|
private readonly FuncProvider<string, uint, string?> _getAllCustomizationLockedProvider;
|
||||||
|
private readonly FuncProvider<Character?, string?> _getAllCustomizationFromCharacterProvider;
|
||||||
|
private readonly FuncProvider<Character?, uint, string?> _getAllCustomizationFromLockedCharacterProvider;
|
||||||
|
|
||||||
public static FuncSubscriber<string, string?> GetAllCustomizationSubscriber(DalamudPluginInterface pi)
|
public static FuncSubscriber<string, string?> GetAllCustomizationSubscriber(DalamudPluginInterface pi)
|
||||||
=> new(pi, LabelGetAllCustomization);
|
=> new(pi, LabelGetAllCustomization);
|
||||||
|
|
@ -20,13 +24,25 @@ public partial class GlamourerIpc
|
||||||
public static FuncSubscriber<Character?, string?> GetAllCustomizationFromCharacterSubscriber(DalamudPluginInterface pi)
|
public static FuncSubscriber<Character?, string?> GetAllCustomizationFromCharacterSubscriber(DalamudPluginInterface pi)
|
||||||
=> new(pi, LabelGetAllCustomizationFromCharacter);
|
=> new(pi, LabelGetAllCustomizationFromCharacter);
|
||||||
|
|
||||||
|
public static FuncSubscriber<string, uint, string?> GetAllCustomizationLockedSubscriber(DalamudPluginInterface pi)
|
||||||
|
=> new(pi, LabelGetAllCustomizationLocked);
|
||||||
|
|
||||||
|
public static FuncSubscriber<Character?, uint, string?> GetAllCustomizationFromLockedCharacterSubscriber(DalamudPluginInterface pi)
|
||||||
|
=> new(pi, LabelGetAllCustomizationFromLockedCharacter);
|
||||||
|
|
||||||
public string? GetAllCustomization(string characterName)
|
public string? GetAllCustomization(string characterName)
|
||||||
=> GetCustomization(FindActors(characterName));
|
=> GetCustomization(FindActors(characterName), 0);
|
||||||
|
|
||||||
|
public string? GetAllCustomization(string characterName, uint lockCode)
|
||||||
|
=> GetCustomization(FindActors(characterName), lockCode);
|
||||||
|
|
||||||
public string? GetAllCustomizationFromCharacter(Character? character)
|
public string? GetAllCustomizationFromCharacter(Character? character)
|
||||||
=> GetCustomization(FindActors(character));
|
=> GetCustomization(FindActors(character), 0);
|
||||||
|
|
||||||
private string? GetCustomization(IEnumerable<ActorIdentifier> actors)
|
public string? GetAllCustomizationFromCharacter(Character? character, uint lockCode)
|
||||||
|
=> GetCustomization(FindActors(character), lockCode);
|
||||||
|
|
||||||
|
private string? GetCustomization(IEnumerable<ActorIdentifier> actors, uint lockCode)
|
||||||
{
|
{
|
||||||
var actor = actors.FirstOrDefault(ActorIdentifier.Invalid);
|
var actor = actors.FirstOrDefault(ActorIdentifier.Invalid);
|
||||||
if (!actor.IsValid)
|
if (!actor.IsValid)
|
||||||
|
|
@ -40,6 +56,8 @@ public partial class GlamourerIpc
|
||||||
if (!_stateManager.GetOrCreate(actor, data.Objects[0], out state))
|
if (!_stateManager.GetOrCreate(actor, data.Objects[0], out state))
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
if (!state.CanUnlock(lockCode))
|
||||||
|
return null;
|
||||||
|
|
||||||
return _designConverter.ShareBase64(state, ApplicationRules.AllWithConfig(_config));
|
return _designConverter.ShareBase64(state, ApplicationRules.AllWithConfig(_config));
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -16,6 +16,7 @@ public partial class GlamourerIpc
|
||||||
public const string LabelRevertToAutomationCharacter = "Glamourer.RevertToAutomationCharacter";
|
public const string LabelRevertToAutomationCharacter = "Glamourer.RevertToAutomationCharacter";
|
||||||
public const string LabelUnlock = "Glamourer.Unlock";
|
public const string LabelUnlock = "Glamourer.Unlock";
|
||||||
public const string LabelUnlockName = "Glamourer.UnlockName";
|
public const string LabelUnlockName = "Glamourer.UnlockName";
|
||||||
|
public const string LabelUnlockAll = "Glamourer.UnlockAll";
|
||||||
|
|
||||||
private readonly ActionProvider<string> _revertProvider;
|
private readonly ActionProvider<string> _revertProvider;
|
||||||
private readonly ActionProvider<Character?> _revertCharacterProvider;
|
private readonly ActionProvider<Character?> _revertCharacterProvider;
|
||||||
|
|
@ -29,6 +30,8 @@ public partial class GlamourerIpc
|
||||||
private readonly FuncProvider<string, uint, bool> _unlockNameProvider;
|
private readonly FuncProvider<string, uint, bool> _unlockNameProvider;
|
||||||
private readonly FuncProvider<Character?, uint, bool> _unlockProvider;
|
private readonly FuncProvider<Character?, uint, bool> _unlockProvider;
|
||||||
|
|
||||||
|
private readonly FuncProvider<uint, int> _unlockAllProvider;
|
||||||
|
|
||||||
public static ActionSubscriber<string> RevertSubscriber(DalamudPluginInterface pi)
|
public static ActionSubscriber<string> RevertSubscriber(DalamudPluginInterface pi)
|
||||||
=> new(pi, LabelRevert);
|
=> new(pi, LabelRevert);
|
||||||
|
|
||||||
|
|
@ -47,6 +50,9 @@ public partial class GlamourerIpc
|
||||||
public static FuncSubscriber<Character?, uint, bool> UnlockSubscriber(DalamudPluginInterface pi)
|
public static FuncSubscriber<Character?, uint, bool> UnlockSubscriber(DalamudPluginInterface pi)
|
||||||
=> new(pi, LabelUnlock);
|
=> new(pi, LabelUnlock);
|
||||||
|
|
||||||
|
public static FuncSubscriber<uint, int> UnlockAllSubscriber(DalamudPluginInterface pi)
|
||||||
|
=> new(pi, LabelUnlockAll);
|
||||||
|
|
||||||
public static FuncSubscriber<string, uint, bool> RevertToAutomationSubscriber(DalamudPluginInterface pi)
|
public static FuncSubscriber<string, uint, bool> RevertToAutomationSubscriber(DalamudPluginInterface pi)
|
||||||
=> new(pi, LabelRevertToAutomation);
|
=> new(pi, LabelRevertToAutomation);
|
||||||
|
|
||||||
|
|
@ -71,6 +77,15 @@ public partial class GlamourerIpc
|
||||||
public bool Unlock(Character? character, uint lockCode)
|
public bool Unlock(Character? character, uint lockCode)
|
||||||
=> Unlock(FindActors(character), lockCode);
|
=> Unlock(FindActors(character), lockCode);
|
||||||
|
|
||||||
|
public int UnlockAll(uint lockCode)
|
||||||
|
{
|
||||||
|
var count = 0;
|
||||||
|
foreach (var state in _stateManager.Values)
|
||||||
|
if (state.Unlock(lockCode))
|
||||||
|
++count;
|
||||||
|
return count;
|
||||||
|
}
|
||||||
|
|
||||||
public bool RevertToAutomation(string characterName, uint lockCode)
|
public bool RevertToAutomation(string characterName, uint lockCode)
|
||||||
=> RevertToAutomation(FindActorsRevert(characterName), lockCode);
|
=> RevertToAutomation(FindActorsRevert(characterName), lockCode);
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -16,7 +16,7 @@ namespace Glamourer.Api;
|
||||||
public sealed partial class GlamourerIpc : IDisposable
|
public sealed partial class GlamourerIpc : IDisposable
|
||||||
{
|
{
|
||||||
public const int CurrentApiVersionMajor = 0;
|
public const int CurrentApiVersionMajor = 0;
|
||||||
public const int CurrentApiVersionMinor = 4;
|
public const int CurrentApiVersionMinor = 5;
|
||||||
|
|
||||||
private readonly StateManager _stateManager;
|
private readonly StateManager _stateManager;
|
||||||
private readonly ObjectManager _objects;
|
private readonly ObjectManager _objects;
|
||||||
|
|
@ -47,6 +47,9 @@ public sealed partial class GlamourerIpc : IDisposable
|
||||||
_getAllCustomizationProvider = new FuncProvider<string, string?>(pi, LabelGetAllCustomization, GetAllCustomization);
|
_getAllCustomizationProvider = new FuncProvider<string, string?>(pi, LabelGetAllCustomization, GetAllCustomization);
|
||||||
_getAllCustomizationFromCharacterProvider =
|
_getAllCustomizationFromCharacterProvider =
|
||||||
new FuncProvider<Character?, string?>(pi, LabelGetAllCustomizationFromCharacter, GetAllCustomizationFromCharacter);
|
new FuncProvider<Character?, string?>(pi, LabelGetAllCustomizationFromCharacter, GetAllCustomizationFromCharacter);
|
||||||
|
_getAllCustomizationLockedProvider = new FuncProvider<string, uint, string?>(pi, LabelGetAllCustomizationLocked, GetAllCustomization);
|
||||||
|
_getAllCustomizationFromLockedCharacterProvider =
|
||||||
|
new FuncProvider<Character?, uint, string?>(pi, LabelGetAllCustomizationFromLockedCharacter, GetAllCustomizationFromCharacter);
|
||||||
|
|
||||||
_applyAllProvider = new ActionProvider<string, string>(pi, LabelApplyAll, ApplyAll);
|
_applyAllProvider = new ActionProvider<string, string>(pi, LabelApplyAll, ApplyAll);
|
||||||
_applyAllOnceProvider = new ActionProvider<string, string>(pi, LabelApplyAllOnce, ApplyAllOnce);
|
_applyAllOnceProvider = new ActionProvider<string, string>(pi, LabelApplyAllOnce, ApplyAllOnce);
|
||||||
|
|
@ -82,6 +85,7 @@ public sealed partial class GlamourerIpc : IDisposable
|
||||||
_revertCharacterProviderLock = new ActionProvider<Character?, uint>(pi, LabelRevertCharacterLock, RevertCharacterLock);
|
_revertCharacterProviderLock = new ActionProvider<Character?, uint>(pi, LabelRevertCharacterLock, RevertCharacterLock);
|
||||||
_unlockNameProvider = new FuncProvider<string, uint, bool>(pi, LabelUnlockName, Unlock);
|
_unlockNameProvider = new FuncProvider<string, uint, bool>(pi, LabelUnlockName, Unlock);
|
||||||
_unlockProvider = new FuncProvider<Character?, uint, bool>(pi, LabelUnlock, Unlock);
|
_unlockProvider = new FuncProvider<Character?, uint, bool>(pi, LabelUnlock, Unlock);
|
||||||
|
_unlockAllProvider = new FuncProvider<uint, int>(pi, LabelUnlockAll, UnlockAll);
|
||||||
_revertToAutomationProvider = new FuncProvider<string, uint, bool>(pi, LabelRevertToAutomation, RevertToAutomation);
|
_revertToAutomationProvider = new FuncProvider<string, uint, bool>(pi, LabelRevertToAutomation, RevertToAutomation);
|
||||||
_revertToAutomationCharacterProvider =
|
_revertToAutomationCharacterProvider =
|
||||||
new FuncProvider<Character?, uint, bool>(pi, LabelRevertToAutomationCharacter, RevertToAutomation);
|
new FuncProvider<Character?, uint, bool>(pi, LabelRevertToAutomationCharacter, RevertToAutomation);
|
||||||
|
|
@ -111,7 +115,9 @@ public sealed partial class GlamourerIpc : IDisposable
|
||||||
_apiVersionsProvider.Dispose();
|
_apiVersionsProvider.Dispose();
|
||||||
|
|
||||||
_getAllCustomizationProvider.Dispose();
|
_getAllCustomizationProvider.Dispose();
|
||||||
|
_getAllCustomizationLockedProvider.Dispose();
|
||||||
_getAllCustomizationFromCharacterProvider.Dispose();
|
_getAllCustomizationFromCharacterProvider.Dispose();
|
||||||
|
_getAllCustomizationFromLockedCharacterProvider.Dispose();
|
||||||
|
|
||||||
_applyAllProvider.Dispose();
|
_applyAllProvider.Dispose();
|
||||||
_applyAllOnceProvider.Dispose();
|
_applyAllOnceProvider.Dispose();
|
||||||
|
|
@ -139,6 +145,7 @@ public sealed partial class GlamourerIpc : IDisposable
|
||||||
_revertCharacterProviderLock.Dispose();
|
_revertCharacterProviderLock.Dispose();
|
||||||
_unlockNameProvider.Dispose();
|
_unlockNameProvider.Dispose();
|
||||||
_unlockProvider.Dispose();
|
_unlockProvider.Dispose();
|
||||||
|
_unlockAllProvider.Dispose();
|
||||||
_revertToAutomationProvider.Dispose();
|
_revertToAutomationProvider.Dispose();
|
||||||
_revertToAutomationCharacterProvider.Dispose();
|
_revertToAutomationCharacterProvider.Dispose();
|
||||||
|
|
||||||
|
|
@ -158,7 +165,7 @@ public sealed partial class GlamourerIpc : IDisposable
|
||||||
private IEnumerable<ActorIdentifier> FindActors(string actorName)
|
private IEnumerable<ActorIdentifier> FindActors(string actorName)
|
||||||
{
|
{
|
||||||
if (actorName.Length == 0 || !ByteString.FromString(actorName, out var byteString))
|
if (actorName.Length == 0 || !ByteString.FromString(actorName, out var byteString))
|
||||||
return Array.Empty<ActorIdentifier>();
|
return [];
|
||||||
|
|
||||||
_objects.Update();
|
_objects.Update();
|
||||||
return _objects.Where(i => i.Key is { IsValid: true, Type: IdentifierType.Player } && i.Key.PlayerName == byteString)
|
return _objects.Where(i => i.Key is { IsValid: true, Type: IdentifierType.Player } && i.Key.PlayerName == byteString)
|
||||||
|
|
|
||||||
|
|
@ -64,6 +64,14 @@ public class IpcTesterPanel(DalamudPluginInterface _pluginInterface, ObjectManag
|
||||||
else
|
else
|
||||||
ImGui.TextUnformatted("Error");
|
ImGui.TextUnformatted("Error");
|
||||||
|
|
||||||
|
ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelGetAllCustomizationFromLockedCharacter);
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
var base64Locked = GlamourerIpc.GetAllCustomizationFromLockedCharacterSubscriber(_pluginInterface).Invoke(_objectManager.Objects[_gameObjectIndex] as Character, 1337);
|
||||||
|
if (base64Locked != null)
|
||||||
|
ImGuiUtil.CopyOnClickSelectable(base64Locked);
|
||||||
|
else
|
||||||
|
ImGui.TextUnformatted("Error");
|
||||||
|
|
||||||
ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelRevert);
|
ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelRevert);
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
if (ImGui.Button("Revert##Name"))
|
if (ImGui.Button("Revert##Name"))
|
||||||
|
|
@ -118,7 +126,6 @@ public class IpcTesterPanel(DalamudPluginInterface _pluginInterface, ObjectManag
|
||||||
GlamourerIpc.ApplyOnlyCustomizationToCharacterSubscriber(_pluginInterface)
|
GlamourerIpc.ApplyOnlyCustomizationToCharacterSubscriber(_pluginInterface)
|
||||||
.Invoke(_base64Apply, _objectManager.Objects[_gameObjectIndex] as Character);
|
.Invoke(_base64Apply, _objectManager.Objects[_gameObjectIndex] as Character);
|
||||||
|
|
||||||
|
|
||||||
ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyByGuid);
|
ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyByGuid);
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
if (ImGui.Button("Apply##ByGuidName") && Guid.TryParse(_designIdentifier, out var guid1))
|
if (ImGui.Button("Apply##ByGuidName") && Guid.TryParse(_designIdentifier, out var guid1))
|
||||||
|
|
@ -141,6 +148,11 @@ public class IpcTesterPanel(DalamudPluginInterface _pluginInterface, ObjectManag
|
||||||
GlamourerIpc.ApplyByGuidOnceToCharacterSubscriber(_pluginInterface)
|
GlamourerIpc.ApplyByGuidOnceToCharacterSubscriber(_pluginInterface)
|
||||||
.Invoke(guid2Once, _objectManager.Objects[_gameObjectIndex] as Character);
|
.Invoke(guid2Once, _objectManager.Objects[_gameObjectIndex] as Character);
|
||||||
|
|
||||||
|
ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyAllLock);
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
if (ImGui.Button("Apply With Lock##CustomizeCharacter"))
|
||||||
|
GlamourerIpc.ApplyAllToCharacterLockSubscriber(_pluginInterface)
|
||||||
|
.Invoke(_base64Apply, _objectManager.Objects[_gameObjectIndex] as Character, 1337);
|
||||||
|
|
||||||
ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelUnlock);
|
ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelUnlock);
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
|
|
@ -148,6 +160,12 @@ public class IpcTesterPanel(DalamudPluginInterface _pluginInterface, ObjectManag
|
||||||
GlamourerIpc.UnlockSubscriber(_pluginInterface)
|
GlamourerIpc.UnlockSubscriber(_pluginInterface)
|
||||||
.Invoke(_objectManager.Objects[_gameObjectIndex] as Character, 1337);
|
.Invoke(_objectManager.Objects[_gameObjectIndex] as Character, 1337);
|
||||||
|
|
||||||
|
ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelUnlockAll);
|
||||||
|
ImGui.TableNextColumn();
|
||||||
|
if (ImGui.Button("Unlock All##CustomizeCharacter"))
|
||||||
|
GlamourerIpc.UnlockAllSubscriber(_pluginInterface)
|
||||||
|
.Invoke(1337);
|
||||||
|
|
||||||
ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelRevertToAutomation);
|
ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelRevertToAutomation);
|
||||||
ImGui.TableNextColumn();
|
ImGui.TableNextColumn();
|
||||||
if (ImGui.Button("Revert##CustomizeCharacter"))
|
if (ImGui.Button("Revert##CustomizeCharacter"))
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit 79ffdd69a28141a1ac93daa24d76573b2fa0d71e
|
Subproject commit 34921fd2c5a9aff5d34aef664bdb78331e8b9436
|
||||||
Loading…
Add table
Add a link
Reference in a new issue