diff --git a/Glamourer/Api/GlamourerIpc.Apply.cs b/Glamourer/Api/GlamourerIpc.Apply.cs index 94896f0..fecce92 100644 --- a/Glamourer/Api/GlamourerIpc.Apply.cs +++ b/Glamourer/Api/GlamourerIpc.Apply.cs @@ -88,6 +88,12 @@ public partial class GlamourerIpc public static ActionSubscriber ApplyByGuidOnceToCharacterSubscriber(DalamudPluginInterface pi) => new(pi, LabelApplyByGuidOnceToCharacter); + public static ActionSubscriber ApplyAllLockSubscriber(DalamudPluginInterface pi) + => new(pi, LabelApplyAllLock); + + public static ActionSubscriber ApplyAllToCharacterLockSubscriber(DalamudPluginInterface pi) + => new(pi, LabelApplyAllToCharacterLock); + public void ApplyAll(string base64, string characterName) => ApplyDesign(_designConverter.FromBase64(base64, true, true, out var version), FindActors(characterName), version, 0); diff --git a/Glamourer/Api/GlamourerIpc.GetCustomization.cs b/Glamourer/Api/GlamourerIpc.GetCustomization.cs index 0067db6..d6caf45 100644 --- a/Glamourer/Api/GlamourerIpc.GetCustomization.cs +++ b/Glamourer/Api/GlamourerIpc.GetCustomization.cs @@ -8,11 +8,15 @@ namespace Glamourer.Api; public partial class GlamourerIpc { - public const string LabelGetAllCustomization = "Glamourer.GetAllCustomization"; - public const string LabelGetAllCustomizationFromCharacter = "Glamourer.GetAllCustomizationFromCharacter"; + public const string LabelGetAllCustomization = "Glamourer.GetAllCustomization"; + public const string LabelGetAllCustomizationFromCharacter = "Glamourer.GetAllCustomizationFromCharacter"; + public const string LabelGetAllCustomizationLocked = "Glamourer.GetAllCustomizationLocked"; + public const string LabelGetAllCustomizationFromLockedCharacter = "Glamourer.GetAllCustomizationFromLockedCharacter"; - private readonly FuncProvider _getAllCustomizationProvider; - private readonly FuncProvider _getAllCustomizationFromCharacterProvider; + private readonly FuncProvider _getAllCustomizationProvider; + private readonly FuncProvider _getAllCustomizationLockedProvider; + private readonly FuncProvider _getAllCustomizationFromCharacterProvider; + private readonly FuncProvider _getAllCustomizationFromLockedCharacterProvider; public static FuncSubscriber GetAllCustomizationSubscriber(DalamudPluginInterface pi) => new(pi, LabelGetAllCustomization); @@ -20,13 +24,25 @@ public partial class GlamourerIpc public static FuncSubscriber GetAllCustomizationFromCharacterSubscriber(DalamudPluginInterface pi) => new(pi, LabelGetAllCustomizationFromCharacter); + public static FuncSubscriber GetAllCustomizationLockedSubscriber(DalamudPluginInterface pi) + => new(pi, LabelGetAllCustomizationLocked); + + public static FuncSubscriber GetAllCustomizationFromLockedCharacterSubscriber(DalamudPluginInterface pi) + => new(pi, LabelGetAllCustomizationFromLockedCharacter); + 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) - => GetCustomization(FindActors(character)); + => GetCustomization(FindActors(character), 0); - private string? GetCustomization(IEnumerable actors) + public string? GetAllCustomizationFromCharacter(Character? character, uint lockCode) + => GetCustomization(FindActors(character), lockCode); + + private string? GetCustomization(IEnumerable actors, uint lockCode) { var actor = actors.FirstOrDefault(ActorIdentifier.Invalid); if (!actor.IsValid) @@ -40,6 +56,8 @@ public partial class GlamourerIpc if (!_stateManager.GetOrCreate(actor, data.Objects[0], out state)) return null; } + if (!state.CanUnlock(lockCode)) + return null; return _designConverter.ShareBase64(state, ApplicationRules.AllWithConfig(_config)); } diff --git a/Glamourer/Api/GlamourerIpc.Revert.cs b/Glamourer/Api/GlamourerIpc.Revert.cs index c5e1005..50cc3c7 100644 --- a/Glamourer/Api/GlamourerIpc.Revert.cs +++ b/Glamourer/Api/GlamourerIpc.Revert.cs @@ -16,6 +16,7 @@ public partial class GlamourerIpc public const string LabelRevertToAutomationCharacter = "Glamourer.RevertToAutomationCharacter"; public const string LabelUnlock = "Glamourer.Unlock"; public const string LabelUnlockName = "Glamourer.UnlockName"; + public const string LabelUnlockAll = "Glamourer.UnlockAll"; private readonly ActionProvider _revertProvider; private readonly ActionProvider _revertCharacterProvider; @@ -29,6 +30,8 @@ public partial class GlamourerIpc private readonly FuncProvider _unlockNameProvider; private readonly FuncProvider _unlockProvider; + private readonly FuncProvider _unlockAllProvider; + public static ActionSubscriber RevertSubscriber(DalamudPluginInterface pi) => new(pi, LabelRevert); @@ -47,6 +50,9 @@ public partial class GlamourerIpc public static FuncSubscriber UnlockSubscriber(DalamudPluginInterface pi) => new(pi, LabelUnlock); + public static FuncSubscriber UnlockAllSubscriber(DalamudPluginInterface pi) + => new(pi, LabelUnlockAll); + public static FuncSubscriber RevertToAutomationSubscriber(DalamudPluginInterface pi) => new(pi, LabelRevertToAutomation); @@ -71,6 +77,15 @@ public partial class GlamourerIpc public bool Unlock(Character? character, uint 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) => RevertToAutomation(FindActorsRevert(characterName), lockCode); diff --git a/Glamourer/Api/GlamourerIpc.cs b/Glamourer/Api/GlamourerIpc.cs index 895a14f..24039b8 100644 --- a/Glamourer/Api/GlamourerIpc.cs +++ b/Glamourer/Api/GlamourerIpc.cs @@ -16,7 +16,7 @@ namespace Glamourer.Api; public sealed partial class GlamourerIpc : IDisposable { public const int CurrentApiVersionMajor = 0; - public const int CurrentApiVersionMinor = 4; + public const int CurrentApiVersionMinor = 5; private readonly StateManager _stateManager; private readonly ObjectManager _objects; @@ -47,6 +47,9 @@ public sealed partial class GlamourerIpc : IDisposable _getAllCustomizationProvider = new FuncProvider(pi, LabelGetAllCustomization, GetAllCustomization); _getAllCustomizationFromCharacterProvider = new FuncProvider(pi, LabelGetAllCustomizationFromCharacter, GetAllCustomizationFromCharacter); + _getAllCustomizationLockedProvider = new FuncProvider(pi, LabelGetAllCustomizationLocked, GetAllCustomization); + _getAllCustomizationFromLockedCharacterProvider = + new FuncProvider(pi, LabelGetAllCustomizationFromLockedCharacter, GetAllCustomizationFromCharacter); _applyAllProvider = new ActionProvider(pi, LabelApplyAll, ApplyAll); _applyAllOnceProvider = new ActionProvider(pi, LabelApplyAllOnce, ApplyAllOnce); @@ -82,6 +85,7 @@ public sealed partial class GlamourerIpc : IDisposable _revertCharacterProviderLock = new ActionProvider(pi, LabelRevertCharacterLock, RevertCharacterLock); _unlockNameProvider = new FuncProvider(pi, LabelUnlockName, Unlock); _unlockProvider = new FuncProvider(pi, LabelUnlock, Unlock); + _unlockAllProvider = new FuncProvider(pi, LabelUnlockAll, UnlockAll); _revertToAutomationProvider = new FuncProvider(pi, LabelRevertToAutomation, RevertToAutomation); _revertToAutomationCharacterProvider = new FuncProvider(pi, LabelRevertToAutomationCharacter, RevertToAutomation); @@ -111,7 +115,9 @@ public sealed partial class GlamourerIpc : IDisposable _apiVersionsProvider.Dispose(); _getAllCustomizationProvider.Dispose(); + _getAllCustomizationLockedProvider.Dispose(); _getAllCustomizationFromCharacterProvider.Dispose(); + _getAllCustomizationFromLockedCharacterProvider.Dispose(); _applyAllProvider.Dispose(); _applyAllOnceProvider.Dispose(); @@ -139,6 +145,7 @@ public sealed partial class GlamourerIpc : IDisposable _revertCharacterProviderLock.Dispose(); _unlockNameProvider.Dispose(); _unlockProvider.Dispose(); + _unlockAllProvider.Dispose(); _revertToAutomationProvider.Dispose(); _revertToAutomationCharacterProvider.Dispose(); @@ -158,7 +165,7 @@ public sealed partial class GlamourerIpc : IDisposable private IEnumerable FindActors(string actorName) { if (actorName.Length == 0 || !ByteString.FromString(actorName, out var byteString)) - return Array.Empty(); + return []; _objects.Update(); return _objects.Where(i => i.Key is { IsValid: true, Type: IdentifierType.Player } && i.Key.PlayerName == byteString) diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTesterPanel.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTesterPanel.cs index d447f9f..98fbcab 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTesterPanel.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTesterPanel.cs @@ -64,6 +64,14 @@ public class IpcTesterPanel(DalamudPluginInterface _pluginInterface, ObjectManag else 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); ImGui.TableNextColumn(); if (ImGui.Button("Revert##Name")) @@ -118,7 +126,6 @@ public class IpcTesterPanel(DalamudPluginInterface _pluginInterface, ObjectManag GlamourerIpc.ApplyOnlyCustomizationToCharacterSubscriber(_pluginInterface) .Invoke(_base64Apply, _objectManager.Objects[_gameObjectIndex] as Character); - ImGuiUtil.DrawTableColumn(GlamourerIpc.LabelApplyByGuid); ImGui.TableNextColumn(); if (ImGui.Button("Apply##ByGuidName") && Guid.TryParse(_designIdentifier, out var guid1)) @@ -141,6 +148,11 @@ public class IpcTesterPanel(DalamudPluginInterface _pluginInterface, ObjectManag GlamourerIpc.ApplyByGuidOnceToCharacterSubscriber(_pluginInterface) .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); ImGui.TableNextColumn(); @@ -148,6 +160,12 @@ public class IpcTesterPanel(DalamudPluginInterface _pluginInterface, ObjectManag GlamourerIpc.UnlockSubscriber(_pluginInterface) .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); ImGui.TableNextColumn(); if (ImGui.Button("Revert##CustomizeCharacter")) diff --git a/Penumbra.Api b/Penumbra.Api index 79ffdd6..34921fd 160000 --- a/Penumbra.Api +++ b/Penumbra.Api @@ -1 +1 @@ -Subproject commit 79ffdd69a28141a1ac93daa24d76573b2fa0d71e +Subproject commit 34921fd2c5a9aff5d34aef664bdb78331e8b9436