From 21aa3e8efc73e9843aa503893c1a99d5caf36573 Mon Sep 17 00:00:00 2001 From: Ottermandias Date: Sun, 14 Apr 2024 15:30:39 +0200 Subject: [PATCH] Extract API to own project. --- Glamourer.Api | 1 + Glamourer.sln | 6 + Glamourer/Api/Api/IGlamourerApi.cs | 8 - Glamourer/Api/Api/IGlamourerApiBase.cs | 6 - Glamourer/Api/Api/IGlamourerApiDesigns.cs | 12 - Glamourer/Api/Api/IGlamourerApiItems.cs | 9 - Glamourer/Api/Api/IGlamourerApiState.cs | 28 --- Glamourer/Api/Enums/ApplyFlag.cs | 34 --- Glamourer/Api/Enums/GlamourerApiEc.cs | 13 - Glamourer/Api/GlamourerApi.cs | 12 +- Glamourer/Api/IpcProviders.cs | 2 +- Glamourer/Api/IpcSubscribers/Designs.cs | 52 ---- Glamourer/Api/IpcSubscribers/Items.cs | 39 --- Glamourer/Api/IpcSubscribers/PluginState.cs | 51 ---- Glamourer/Api/IpcSubscribers/State.cs | 235 ------------------ Glamourer/Glamourer.csproj | 1 + .../Tabs/DebugTab/IpcTester/ItemsIpcTester.cs | 22 +- .../Tabs/DebugTab/IpcTester/StateIpcTester.cs | 2 +- 18 files changed, 28 insertions(+), 505 deletions(-) create mode 160000 Glamourer.Api delete mode 100644 Glamourer/Api/Api/IGlamourerApi.cs delete mode 100644 Glamourer/Api/Api/IGlamourerApiBase.cs delete mode 100644 Glamourer/Api/Api/IGlamourerApiDesigns.cs delete mode 100644 Glamourer/Api/Api/IGlamourerApiItems.cs delete mode 100644 Glamourer/Api/Api/IGlamourerApiState.cs delete mode 100644 Glamourer/Api/Enums/ApplyFlag.cs delete mode 100644 Glamourer/Api/Enums/GlamourerApiEc.cs delete mode 100644 Glamourer/Api/IpcSubscribers/Designs.cs delete mode 100644 Glamourer/Api/IpcSubscribers/Items.cs delete mode 100644 Glamourer/Api/IpcSubscribers/PluginState.cs delete mode 100644 Glamourer/Api/IpcSubscribers/State.cs diff --git a/Glamourer.Api b/Glamourer.Api new file mode 160000 index 0000000..0c8578c --- /dev/null +++ b/Glamourer.Api @@ -0,0 +1 @@ +Subproject commit 0c8578cfa12bf0591ed204fd89b30b66719f678f diff --git a/Glamourer.sln b/Glamourer.sln index 9acdd6c..254f8e4 100644 --- a/Glamourer.sln +++ b/Glamourer.sln @@ -19,6 +19,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Penumbra.String", "Penumbra EndProject Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "OtterGui", "OtterGui\OtterGui.csproj", "{EF233CE2-F243-449E-BE05-72B9D110E419}" EndProject +Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Glamourer.Api", "Glamourer.Api\Glamourer.Api.csproj", "{9B46691B-FAB2-4CC3-9B89-C8B91A590F47}" +EndProject Global GlobalSection(SolutionConfigurationPlatforms) = preSolution Debug|Any CPU = Debug|Any CPU @@ -45,6 +47,10 @@ Global {EF233CE2-F243-449E-BE05-72B9D110E419}.Debug|Any CPU.Build.0 = Debug|Any CPU {EF233CE2-F243-449E-BE05-72B9D110E419}.Release|Any CPU.ActiveCfg = Release|Any CPU {EF233CE2-F243-449E-BE05-72B9D110E419}.Release|Any CPU.Build.0 = Release|Any CPU + {9B46691B-FAB2-4CC3-9B89-C8B91A590F47}.Debug|Any CPU.ActiveCfg = Debug|Any CPU + {9B46691B-FAB2-4CC3-9B89-C8B91A590F47}.Debug|Any CPU.Build.0 = Debug|Any CPU + {9B46691B-FAB2-4CC3-9B89-C8B91A590F47}.Release|Any CPU.ActiveCfg = Release|Any CPU + {9B46691B-FAB2-4CC3-9B89-C8B91A590F47}.Release|Any CPU.Build.0 = Release|Any CPU EndGlobalSection GlobalSection(SolutionProperties) = preSolution HideSolutionNode = FALSE diff --git a/Glamourer/Api/Api/IGlamourerApi.cs b/Glamourer/Api/Api/IGlamourerApi.cs deleted file mode 100644 index c28410b..0000000 --- a/Glamourer/Api/Api/IGlamourerApi.cs +++ /dev/null @@ -1,8 +0,0 @@ -namespace Glamourer.Api.Api; - -public interface IGlamourerApi : IGlamourerApiBase -{ - public IGlamourerApiDesigns Designs { get; } - public IGlamourerApiItems Items { get; } - public IGlamourerApiState State { get; } -} \ No newline at end of file diff --git a/Glamourer/Api/Api/IGlamourerApiBase.cs b/Glamourer/Api/Api/IGlamourerApiBase.cs deleted file mode 100644 index b52db45..0000000 --- a/Glamourer/Api/Api/IGlamourerApiBase.cs +++ /dev/null @@ -1,6 +0,0 @@ -namespace Glamourer.Api.Api; - -public interface IGlamourerApiBase -{ - public (int Major, int Minor) ApiVersion { get; } -} diff --git a/Glamourer/Api/Api/IGlamourerApiDesigns.cs b/Glamourer/Api/Api/IGlamourerApiDesigns.cs deleted file mode 100644 index f4d7184..0000000 --- a/Glamourer/Api/Api/IGlamourerApiDesigns.cs +++ /dev/null @@ -1,12 +0,0 @@ -using Glamourer.Api.Enums; - -namespace Glamourer.Api.Api; - -public interface IGlamourerApiDesigns -{ - public Dictionary GetDesignList(); - - public GlamourerApiEc ApplyDesign(Guid designId, int objectIndex, uint key, ApplyFlag flags); - - public GlamourerApiEc ApplyDesignName(Guid designId, string objectName, uint key, ApplyFlag flags); -} diff --git a/Glamourer/Api/Api/IGlamourerApiItems.cs b/Glamourer/Api/Api/IGlamourerApiItems.cs deleted file mode 100644 index 25bdcee..0000000 --- a/Glamourer/Api/Api/IGlamourerApiItems.cs +++ /dev/null @@ -1,9 +0,0 @@ -using Glamourer.Api.Enums; - -namespace Glamourer.Api.Api; - -public interface IGlamourerApiItems -{ - public GlamourerApiEc SetItem(int objectIndex, ApiEquipSlot apiSlot, ulong itemId, byte stain, uint key, ApplyFlag flags); - public GlamourerApiEc SetItemName(string objectName, ApiEquipSlot slot, ulong itemId, byte stain, uint key, ApplyFlag flags); -} diff --git a/Glamourer/Api/Api/IGlamourerApiState.cs b/Glamourer/Api/Api/IGlamourerApiState.cs deleted file mode 100644 index 2443701..0000000 --- a/Glamourer/Api/Api/IGlamourerApiState.cs +++ /dev/null @@ -1,28 +0,0 @@ -using Glamourer.Api.Enums; -using Newtonsoft.Json.Linq; - -namespace Glamourer.Api.Api; - -public interface IGlamourerApiState -{ - public (GlamourerApiEc, JObject?) GetState(int objectIndex, uint key); - public (GlamourerApiEc, JObject?) GetStateName(string objectName, uint key); - - public GlamourerApiEc ApplyState(object applyState, int objectIndex, uint key, ApplyFlag flags); - - public GlamourerApiEc ApplyStateName(object state, string objectName, uint key, ApplyFlag flags); - - public GlamourerApiEc RevertState(int objectIndex, uint key, ApplyFlag flags); - public GlamourerApiEc RevertStateName(string objectName, uint key, ApplyFlag flags); - - public GlamourerApiEc UnlockState(int objectIndex, uint key); - public GlamourerApiEc UnlockStateName(string objectName, uint key); - public int UnlockAll(uint key); - - public GlamourerApiEc RevertToAutomation(int objectIndex, uint key, ApplyFlag flags); - public GlamourerApiEc RevertToAutomationName(string objectName, uint key, ApplyFlag flags); - - public event Action? StateChanged; - - public event Action? GPoseChanged; -} diff --git a/Glamourer/Api/Enums/ApplyFlag.cs b/Glamourer/Api/Enums/ApplyFlag.cs deleted file mode 100644 index 0008e96..0000000 --- a/Glamourer/Api/Enums/ApplyFlag.cs +++ /dev/null @@ -1,34 +0,0 @@ -namespace Glamourer.Api.Enums; - -[Flags] -public enum ApplyFlag : ulong -{ - Once = 0x01, - Equipment = 0x02, - Customization = 0x04, - Lock = 0x08, -} - -public static class ApplyFlagEx -{ - public const ApplyFlag DesignDefault = ApplyFlag.Once | ApplyFlag.Equipment | ApplyFlag.Customization; - public const ApplyFlag StateDefault = ApplyFlag.Equipment | ApplyFlag.Customization | ApplyFlag.Lock; - public const ApplyFlag RevertDefault = ApplyFlag.Equipment | ApplyFlag.Customization; -} - -public enum ApiEquipSlot : byte -{ - Unknown = 0, - MainHand = 1, - OffHand = 2, - Head = 3, - Body = 4, - Hands = 5, - Legs = 7, - Feet = 8, - Ears = 9, - Neck = 10, - Wrists = 11, - RFinger = 12, - LFinger = 14, // Not officially existing, means "weapon could be equipped in either hand" for the game. -} \ No newline at end of file diff --git a/Glamourer/Api/Enums/GlamourerApiEc.cs b/Glamourer/Api/Enums/GlamourerApiEc.cs deleted file mode 100644 index 086a2a5..0000000 --- a/Glamourer/Api/Enums/GlamourerApiEc.cs +++ /dev/null @@ -1,13 +0,0 @@ -namespace Glamourer.Api.Enums; - -public enum GlamourerApiEc -{ - Success, - ActorNotFound, - ActorNotHuman, - DesignNotFound, - ItemInvalid, - InvalidKey, - InvalidState, - NothingDone, -} diff --git a/Glamourer/Api/GlamourerApi.cs b/Glamourer/Api/GlamourerApi.cs index 98461c6..4be328c 100644 --- a/Glamourer/Api/GlamourerApi.cs +++ b/Glamourer/Api/GlamourerApi.cs @@ -1,8 +1,8 @@ -using Glamourer.Api.Api; -using OtterGui.Services; - -namespace Glamourer.Api; - +using Glamourer.Api.Api; +using OtterGui.Services; + +namespace Glamourer.Api; + public class GlamourerApi(DesignsApi designs, StateApi state, ItemsApi items) : IGlamourerApi, IApiService { public const int CurrentApiVersionMajor = 1; @@ -19,4 +19,4 @@ public class GlamourerApi(DesignsApi designs, StateApi state, ItemsApi items) : public IGlamourerApiState State => state; -} +} diff --git a/Glamourer/Api/IpcProviders.cs b/Glamourer/Api/IpcProviders.cs index 115142b..c2a674c 100644 --- a/Glamourer/Api/IpcProviders.cs +++ b/Glamourer/Api/IpcProviders.cs @@ -1,7 +1,7 @@ using Dalamud.Plugin; using Glamourer.Api.Api; +using Glamourer.Api.Helpers; using OtterGui.Services; -using Penumbra.Api.Helpers; namespace Glamourer.Api; diff --git a/Glamourer/Api/IpcSubscribers/Designs.cs b/Glamourer/Api/IpcSubscribers/Designs.cs deleted file mode 100644 index 8b31f6e..0000000 --- a/Glamourer/Api/IpcSubscribers/Designs.cs +++ /dev/null @@ -1,52 +0,0 @@ -using Dalamud.Plugin; -using Glamourer.Api.Api; -using Glamourer.Api.Enums; -using Penumbra.Api.Helpers; - -namespace Glamourer.Api.IpcSubscribers; - -/// -public sealed class GetDesignList(DalamudPluginInterface pi) - : FuncSubscriber>(pi, Label) -{ - /// The label. - public const string Label = $"Glamourer.{nameof(GetDesignList)}"; - - /// - public new Dictionary Invoke() - => base.Invoke(); - - /// Create a provider. - public static FuncProvider> Provider(DalamudPluginInterface pi, IGlamourerApiDesigns api) - => new(pi, Label, api.GetDesignList); -} - -/// -public sealed class ApplyDesign(DalamudPluginInterface pi) : FuncSubscriber(pi, Label) -{ - /// The label. - public const string Label = $"Glamourer.{nameof(ApplyDesign)}"; - - /// - public GlamourerApiEc Invoke(Guid designId, int objectIndex, uint key = 0, ApplyFlag flags = ApplyFlagEx.DesignDefault) - => (GlamourerApiEc)Invoke(designId, objectIndex, key, (ulong)flags); - - /// Create a provider. - public static FuncProvider Provider(DalamudPluginInterface pi, IGlamourerApiDesigns api) - => new(pi, Label, (a, b, c, d) => (int)api.ApplyDesign(a, b, c, (ApplyFlag)d)); -} - -/// -public sealed class ApplyDesignName(DalamudPluginInterface pi) : FuncSubscriber(pi, Label) -{ - /// The label. - public const string Label = $"Glamourer.{nameof(ApplyDesignName)}"; - - /// - public GlamourerApiEc Invoke(Guid designId, string objectName, uint key = 0, ApplyFlag flags = ApplyFlagEx.DesignDefault) - => (GlamourerApiEc)Invoke(designId, objectName, key, (ulong)flags); - - /// Create a provider. - public static FuncProvider Provider(DalamudPluginInterface pi, IGlamourerApiDesigns api) - => new(pi, Label, (a, b, c, d) => (int)api.ApplyDesignName(a, b, c, (ApplyFlag)d)); -} diff --git a/Glamourer/Api/IpcSubscribers/Items.cs b/Glamourer/Api/IpcSubscribers/Items.cs deleted file mode 100644 index 2c9139c..0000000 --- a/Glamourer/Api/IpcSubscribers/Items.cs +++ /dev/null @@ -1,39 +0,0 @@ -using Dalamud.Plugin; -using Glamourer.Api.Api; -using Glamourer.Api.Enums; -using Penumbra.Api.Helpers; -using Penumbra.GameData.Enums; - -namespace Glamourer.Api.IpcSubscribers; - -/// -public sealed class SetItem(DalamudPluginInterface pi) - : FuncSubscriber(pi, Label) -{ - /// The label. - public const string Label = $"Glamourer.{nameof(SetItem)}"; - - /// - public GlamourerApiEc Invoke(int objectIndex, EquipSlot slot, ulong itemId, byte stain, uint key = 0, ApplyFlag flags = ApplyFlag.Once) - => (GlamourerApiEc)Invoke(objectIndex, (byte)slot, itemId, stain, key, (ulong)flags); - - /// Create a provider. - public static FuncProvider Provider(DalamudPluginInterface pi, IGlamourerApiItems api) - => new(pi, Label, (a, b, c, d, e, f) => (int)api.SetItem(a, (ApiEquipSlot)b, c, d, e, (ApplyFlag)f)); -} - -/// -public sealed class SetItemName(DalamudPluginInterface pi) - : FuncSubscriber(pi, Label) -{ - /// The label. - public const string Label = $"Glamourer.{nameof(SetItemName)}"; - - /// - public GlamourerApiEc Invoke(string objectName, EquipSlot slot, ulong itemId, byte stain, uint key = 0, ApplyFlag flags = ApplyFlag.Once) - => (GlamourerApiEc)Invoke(objectName, (byte)slot, itemId, stain, key, (ulong)flags); - - /// Create a provider. - public static FuncProvider Provider(DalamudPluginInterface pi, IGlamourerApiItems api) - => new(pi, Label, (a, b, c, d, e, f) => (int)api.SetItemName(a, (ApiEquipSlot)b, c, d, e, (ApplyFlag)f)); -} diff --git a/Glamourer/Api/IpcSubscribers/PluginState.cs b/Glamourer/Api/IpcSubscribers/PluginState.cs deleted file mode 100644 index 107c51a..0000000 --- a/Glamourer/Api/IpcSubscribers/PluginState.cs +++ /dev/null @@ -1,51 +0,0 @@ -using Dalamud.Plugin; -using Glamourer.Api.Api; -using Penumbra.Api.Helpers; - -namespace Glamourer.Api.IpcSubscribers; - -/// -public sealed class ApiVersion(DalamudPluginInterface pi) - : FuncSubscriber<(int, int)>(pi, Label) -{ - /// The label. - public const string Label = $"Glamourer.{nameof(ApiVersion)}"; - - /// - public new (int Major, int Minor) Invoke() - => base.Invoke(); - - /// Create a provider. - public static FuncProvider<(int, int)> Provider(DalamudPluginInterface pi, IGlamourerApiBase api) - => new(pi, Label, () => api.ApiVersion); -} - -/// Triggered when the Glamourer API is initialized and ready. -public static class Initialized -{ - /// The label. - public const string Label = $"Glamourer.{nameof(Initialized)}"; - - /// Create a new event subscriber. - public static EventSubscriber Subscriber(DalamudPluginInterface pi, params Action[] actions) - => new(pi, Label, actions); - - /// Create a provider. - public static EventProvider Provider(DalamudPluginInterface pi) - => new(pi, Label); -} - -/// Triggered when the Glamourer API is fully disposed and unavailable. -public static class Disposed -{ - /// The label. - public const string Label = $"Glamourer.{nameof(Disposed)}"; - - /// Create a new event subscriber. - public static EventSubscriber Subscriber(DalamudPluginInterface pi, params Action[] actions) - => new(pi, Label, actions); - - /// Create a provider. - public static EventProvider Provider(DalamudPluginInterface pi) - => new(pi, Label); -} diff --git a/Glamourer/Api/IpcSubscribers/State.cs b/Glamourer/Api/IpcSubscribers/State.cs deleted file mode 100644 index e523c10..0000000 --- a/Glamourer/Api/IpcSubscribers/State.cs +++ /dev/null @@ -1,235 +0,0 @@ -using Dalamud.Plugin; -using Glamourer.Api.Api; -using Glamourer.Api.Enums; -using Newtonsoft.Json.Linq; -using Penumbra.Api.Helpers; - -namespace Glamourer.Api.IpcSubscribers; - -/// -public sealed class GetState(DalamudPluginInterface pi) - : FuncSubscriber(pi, Label) -{ - /// The label. - public const string Label = $"Glamourer.{nameof(GetState)}"; - - /// - public new (GlamourerApiEc, JObject?) Invoke(int objectIndex, uint key = 0) - { - var (ec, data) = base.Invoke(objectIndex, key); - return ((GlamourerApiEc)ec, data); - } - - /// Create a provider. - public static FuncProvider Provider(DalamudPluginInterface pi, IGlamourerApiState api) - => new(pi, Label, (a, b) => - { - var (ec, data) = api.GetState(a, b); - return ((int)ec, data); - }); -} - -/// -public sealed class GetStateName(DalamudPluginInterface pi) - : FuncSubscriber(pi, Label) -{ - /// The label. - public const string Label = $"Glamourer.{nameof(GetStateName)}"; - - /// - public new (GlamourerApiEc, JObject?) Invoke(string objectName, uint key = 0) - { - var (ec, data) = base.Invoke(objectName, key); - return ((GlamourerApiEc)ec, data); - } - - /// Create a provider. - public static FuncProvider Provider(DalamudPluginInterface pi, IGlamourerApiState api) - => new(pi, Label, (i, k) => - { - var (ec, data) = api.GetStateName(i, k); - return ((int)ec, data); - }); -} - -/// -public sealed class ApplyState(DalamudPluginInterface pi) - : FuncSubscriber(pi, Label) -{ - /// The label. - public const string Label = $"Glamourer.{nameof(ApplyState)}"; - - /// - public GlamourerApiEc Invoke(JObject state, int objectIndex, uint key = 0, ApplyFlag flags = ApplyFlagEx.StateDefault) - => (GlamourerApiEc)Invoke(state, objectIndex, key, (ulong)flags); - - /// - public GlamourerApiEc Invoke(string base64State, int objectIndex, uint key = 0, ApplyFlag flags = ApplyFlagEx.StateDefault) - => (GlamourerApiEc)Invoke(base64State, objectIndex, key, (ulong)flags); - - /// Create a provider. - public static FuncProvider Provider(DalamudPluginInterface pi, IGlamourerApiState api) - => new(pi, Label, (a, b, c, d) => (int)api.ApplyState(a, b, c, (ApplyFlag)d)); -} - -/// -public sealed class ApplyStateName(DalamudPluginInterface pi) - : FuncSubscriber(pi, Label) -{ - /// The label. - public const string Label = $"Glamourer.{nameof(ApplyStateName)}"; - - /// - public GlamourerApiEc Invoke(JObject state, string objectName, uint key = 0, ApplyFlag flags = ApplyFlagEx.StateDefault) - => (GlamourerApiEc)Invoke(state, objectName, key, (ulong)flags); - - /// - public GlamourerApiEc Invoke(string base64State, string objectName, uint key = 0, ApplyFlag flags = ApplyFlagEx.StateDefault) - => (GlamourerApiEc)Invoke(base64State, objectName, key, (ulong)flags); - - /// Create a provider. - public static FuncProvider Provider(DalamudPluginInterface pi, IGlamourerApiState api) - => new(pi, Label, (a, b, c, d) => (int)api.ApplyStateName(a, b, c, (ApplyFlag)d)); -} - -/// -public sealed class RevertState(DalamudPluginInterface pi) - : FuncSubscriber(pi, Label) -{ - /// The label. - public const string Label = $"Glamourer.{nameof(RevertState)}"; - - /// - public GlamourerApiEc Invoke(int objectIndex, uint key = 0, ApplyFlag flags = ApplyFlagEx.RevertDefault) - => (GlamourerApiEc)Invoke(objectIndex, key, (ulong)flags); - - /// Create a provider. - public static FuncProvider Provider(DalamudPluginInterface pi, IGlamourerApiState api) - => new(pi, Label, (a, b, c) => (int)api.RevertState(a, b, (ApplyFlag)c)); -} - -/// -public sealed class RevertStateName(DalamudPluginInterface pi) - : FuncSubscriber(pi, Label) -{ - /// The label. - public const string Label = $"Glamourer.{nameof(RevertStateName)}"; - - /// - public GlamourerApiEc Invoke(string objectName, uint key = 0, ApplyFlag flags = ApplyFlagEx.RevertDefault) - => (GlamourerApiEc)Invoke(objectName, key, (ulong)flags); - - /// Create a provider. - public static FuncProvider Provider(DalamudPluginInterface pi, IGlamourerApiState api) - => new(pi, Label, (a, b, c) => (int)api.RevertStateName(a, b, (ApplyFlag)c)); -} - -/// -public sealed class UnlockState(DalamudPluginInterface pi) - : FuncSubscriber(pi, Label) -{ - /// The label. - public const string Label = $"Glamourer.{nameof(UnlockState)}"; - - /// - public new GlamourerApiEc Invoke(int objectIndex, uint key = 0) - => (GlamourerApiEc)base.Invoke(objectIndex, key); - - /// Create a provider. - public static FuncProvider Provider(DalamudPluginInterface pi, IGlamourerApiState api) - => new(pi, Label, (a, b) => (int)api.UnlockState(a, b)); -} - -/// -public sealed class UnlockStateName(DalamudPluginInterface pi) - : FuncSubscriber(pi, Label) -{ - /// The label. - public const string Label = $"Glamourer.{nameof(UnlockStateName)}"; - - /// - public new GlamourerApiEc Invoke(string objectName, uint key = 0) - => (GlamourerApiEc)base.Invoke(objectName, key); - - /// Create a provider. - public static FuncProvider Provider(DalamudPluginInterface pi, IGlamourerApiState api) - => new(pi, Label, (a, b) => (int)api.UnlockStateName(a, b)); -} - -/// -public sealed class UnlockAll(DalamudPluginInterface pi) - : FuncSubscriber(pi, Label) -{ - /// The label. - public const string Label = $"Glamourer.{nameof(UnlockAll)}"; - - /// - public new int Invoke(uint key) - => base.Invoke(key); - - /// Create a provider. - public static FuncProvider Provider(DalamudPluginInterface pi, IGlamourerApiState api) - => new(pi, Label, api.UnlockAll); -} - -/// -public sealed class RevertToAutomation(DalamudPluginInterface pi) - : FuncSubscriber(pi, Label) -{ - /// The label. - public const string Label = $"Glamourer.{nameof(RevertToAutomation)}"; - - /// - public GlamourerApiEc Invoke(int objectIndex, uint key = 0, ApplyFlag flags = ApplyFlagEx.RevertDefault) - => (GlamourerApiEc)Invoke(objectIndex, key, (ulong)flags); - - /// Create a provider. - public static FuncProvider Provider(DalamudPluginInterface pi, IGlamourerApiState api) - => new(pi, Label, (a, b, c) => (int)api.RevertToAutomation(a, b, (ApplyFlag)c)); -} - -/// -public sealed class RevertToAutomationName(DalamudPluginInterface pi) - : FuncSubscriber(pi, Label) -{ - /// The label. - public const string Label = $"Glamourer.{nameof(RevertToAutomationName)}"; - - /// - public GlamourerApiEc Invoke(string objectName, uint key = 0, ApplyFlag flags = ApplyFlagEx.RevertDefault) - => (GlamourerApiEc)Invoke(objectName, key, (ulong)flags); - - /// Create a provider. - public static FuncProvider Provider(DalamudPluginInterface pi, IGlamourerApiState api) - => new(pi, Label, (a, b, c) => (int)api.RevertToAutomationName(a, b, (ApplyFlag)c)); -} - -/// -public static class StateChanged -{ - /// The label. - public const string Label = $"Penumbra.{nameof(StateChanged)}"; - - /// Create a new event subscriber. - public static EventSubscriber Subscriber(DalamudPluginInterface pi, params Action[] actions) - => new(pi, Label, actions); - - /// Create a provider. - public static EventProvider Provider(DalamudPluginInterface pi, IGlamourerApiState api) - => new(pi, Label, (t => api.StateChanged += t, t => api.StateChanged -= t)); -} - -/// -public static class GPoseChanged -{ - /// The label. - public const string Label = $"Penumbra.{nameof(GPoseChanged)}"; - - /// Create a new event subscriber. - public static EventSubscriber Subscriber(DalamudPluginInterface pi, params Action[] actions) - => new(pi, Label, actions); - - /// Create a provider. - public static EventProvider Provider(DalamudPluginInterface pi, IGlamourerApiState api) - => new(pi, Label, (t => api.GPoseChanged += t, t => api.GPoseChanged -= t)); -} diff --git a/Glamourer/Glamourer.csproj b/Glamourer/Glamourer.csproj index d50c24e..9a1b95b 100644 --- a/Glamourer/Glamourer.csproj +++ b/Glamourer/Glamourer.csproj @@ -83,6 +83,7 @@ + diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/ItemsIpcTester.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/ItemsIpcTester.cs index ec75998..3d61df7 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/ItemsIpcTester.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/ItemsIpcTester.cs @@ -13,14 +13,14 @@ namespace Glamourer.Gui.Tabs.DebugTab.IpcTester; public class ItemsIpcTester(DalamudPluginInterface pluginInterface) : IUiService { - private int _gameObjectIndex; - private string _gameObjectName = string.Empty; - private uint _key; - private ApplyFlag _flags = ApplyFlagEx.DesignDefault; - private CustomItemId _customItemId; - private StainId _stainId; - private EquipSlot _slot = EquipSlot.Head; - private GlamourerApiEc _lastError; + private int _gameObjectIndex; + private string _gameObjectName = string.Empty; + private uint _key; + private ApplyFlag _flags = ApplyFlagEx.DesignDefault; + private CustomItemId _customItemId; + private StainId _stainId; + private EquipSlot _slot = EquipSlot.Head; + private GlamourerApiEc _lastError; public void Draw() { @@ -40,11 +40,13 @@ public class ItemsIpcTester(DalamudPluginInterface pluginInterface) : IUiService IpcTesterHelpers.DrawIntro(SetItem.Label); if (ImGui.Button("Set##Idx")) - _lastError = new SetItem(pluginInterface).Invoke(_gameObjectIndex, _slot, _customItemId.Id, _stainId.Id, _key, _flags); + _lastError = new SetItem(pluginInterface).Invoke(_gameObjectIndex, (ApiEquipSlot)_slot, _customItemId.Id, _stainId.Id, _key, + _flags); IpcTesterHelpers.DrawIntro(SetItemName.Label); if (ImGui.Button("Set##Name")) - _lastError = new SetItemName(pluginInterface).Invoke(_gameObjectName, _slot, _customItemId.Id, _stainId.Id, _key, _flags); + _lastError = new SetItemName(pluginInterface).Invoke(_gameObjectName, (ApiEquipSlot)_slot, _customItemId.Id, _stainId.Id, _key, + _flags); } private void DrawItemInput() diff --git a/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs b/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs index 5898177..bcf7454 100644 --- a/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs +++ b/Glamourer/Gui/Tabs/DebugTab/IpcTester/StateIpcTester.cs @@ -2,6 +2,7 @@ using Dalamud.Interface.Utility; using Dalamud.Plugin; using Glamourer.Api.Enums; +using Glamourer.Api.Helpers; using Glamourer.Api.IpcSubscribers; using Glamourer.Designs; using ImGuiNET; @@ -10,7 +11,6 @@ using Newtonsoft.Json.Linq; using OtterGui; using OtterGui.Raii; using OtterGui.Services; -using Penumbra.Api.Helpers; using Penumbra.GameData.Interop; using Penumbra.String;