Initial
This commit is contained in:
3625
Glamourer.Api/.editorconfig
Normal file
3625
Glamourer.Api/.editorconfig
Normal file
File diff suppressed because it is too large
Load Diff
3
Glamourer.Api/.gitignore
vendored
Normal file
3
Glamourer.Api/.gitignore
vendored
Normal file
@@ -0,0 +1,3 @@
|
||||
bin/
|
||||
obj/
|
||||
.vs/
|
14
Glamourer.Api/Api/IGlamourerApi.cs
Normal file
14
Glamourer.Api/Api/IGlamourerApi.cs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace Glamourer.Api.Api;
|
||||
|
||||
/// <summary> The full API available. </summary>
|
||||
public interface IGlamourerApi : IGlamourerApiBase
|
||||
{
|
||||
/// <inheritdoc cref="IGlamourerApiDesigns"/>
|
||||
public IGlamourerApiDesigns Designs { get; }
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiItems"/>
|
||||
public IGlamourerApiItems Items { get; }
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState"/>
|
||||
public IGlamourerApiState State { get; }
|
||||
}
|
11
Glamourer.Api/Api/IGlamourerApiBase.cs
Normal file
11
Glamourer.Api/Api/IGlamourerApiBase.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Glamourer.Api.Api;
|
||||
|
||||
/// <summary> Basic API functions. </summary>
|
||||
public interface IGlamourerApiBase
|
||||
{
|
||||
/// <summary>
|
||||
/// Get the current API version of the Glamourer available in this installation.
|
||||
/// Major version changes indicate incompatibilities, minor version changes are backward-compatible additions.
|
||||
/// </summary>
|
||||
public (int Major, int Minor) ApiVersion { get; }
|
||||
}
|
33
Glamourer.Api/Api/IGlamourerApiDesigns.cs
Normal file
33
Glamourer.Api/Api/IGlamourerApiDesigns.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Glamourer.Api.Enums;
|
||||
|
||||
namespace Glamourer.Api.Api;
|
||||
|
||||
/// <summary> All functions related to Glamourer designs. </summary>
|
||||
public interface IGlamourerApiDesigns
|
||||
{
|
||||
/// <summary> Obtain a list of all available designs. </summary>
|
||||
/// <returns> A dictionary of all designs from their GUID to their current display name. </returns>
|
||||
public Dictionary<Guid, string> GetDesignList();
|
||||
|
||||
/// <summary> Apply an existing design to an actor. </summary>
|
||||
/// <param name="designId"> The GUID of the design to apply. </param>
|
||||
/// <param name="objectIndex"> The game object index of the actor to be manipulated. </param>
|
||||
/// <param name="key"> A key to unlock or lock the state if necessary. </param>
|
||||
/// <param name="flags"> The flags used for the reversion. Respects Once, Equipment, Customization, Lock (see <see cref="ApplyFlag"/>.)</param>
|
||||
/// <returns> DesignNotFound, ActorNotFound, InvalidKey, Success. </returns>
|
||||
public GlamourerApiEc ApplyDesign(Guid designId, int objectIndex, uint key, ApplyFlag flags);
|
||||
|
||||
/// <summary> Apply an existing design to an actor. </summary>
|
||||
/// <param name="designId"> The GUID of the design to apply. </param>
|
||||
/// <param name="playerName"> The name of the players to be manipulated. </param>
|
||||
/// <param name="key"> A key to unlock or lock the state if necessary. </param>
|
||||
/// <param name="flags"> The flags used for the reversion. Respects Once, Equipment, Customization, Lock (see <see cref="ApplyFlag"/>.)</param>
|
||||
/// <returns> DesignNotFound, ActorNotFound, InvalidKey, Success. </returns>
|
||||
/// /// <remarks>
|
||||
/// The player does not have to be currently available as long as he has a persisted Glamourer state.<br/>
|
||||
/// Only players are checked for name equality, no NPCs.<br/>
|
||||
/// If multiple players of the same name are found, all of them are reverted.<br/>
|
||||
/// Prefer to use the index-based function unless you need to get the state of someone currently unavailable.
|
||||
/// </remarks>
|
||||
public GlamourerApiEc ApplyDesignName(Guid designId, string playerName, uint key, ApplyFlag flags);
|
||||
}
|
80
Glamourer.Api/Api/IGlamourerApiItems.cs
Normal file
80
Glamourer.Api/Api/IGlamourerApiItems.cs
Normal file
@@ -0,0 +1,80 @@
|
||||
using Glamourer.Api.Enums;
|
||||
|
||||
namespace Glamourer.Api.Api;
|
||||
|
||||
/// <summary> All functions related to items. </summary>
|
||||
public interface IGlamourerApiItems
|
||||
{
|
||||
/// <summary> Set a single item on an actor. </summary>
|
||||
/// <param name="objectIndex"> The game object index of the actor to be manipulated. </param>
|
||||
/// <param name="slot"> The slot to apply the item to. </param>
|
||||
/// <param name="itemId"> The (Custom) ID of the item to apply. </param>
|
||||
/// <param name="stains"> The IDs of the stains to apply to the item. </param>
|
||||
/// <param name="key"> A key to unlock or lock the state if necessary. </param>
|
||||
/// <param name="flags"> The flags used for the reversion. Respects Once (see <see cref="ApplyFlag"/>.)</param>
|
||||
/// <returns> ItemInvalid, ActorNotFound, ActorNotHuman, InvalidKey, Success. </returns>
|
||||
/// <remarks> The item ID can be a custom item ID in Glamourer's format for models without an associated item, or a normal game item ID. </remarks>
|
||||
public GlamourerApiEc SetItem(int objectIndex, ApiEquipSlot slot, ulong itemId, IReadOnlyList<byte> stains, uint key, ApplyFlag flags);
|
||||
|
||||
/// <summary> Set a single item on players. </summary>
|
||||
/// <param name="playerName"> The name of the players to be manipulated. </param>
|
||||
/// <param name="slot"> The slot to apply the item to. </param>
|
||||
/// <param name="itemId"> The (Custom) ID of the item to apply. </param>
|
||||
/// <param name="stains"> The IDs of the stains to apply to the item. </param>
|
||||
/// <param name="key"> A key to unlock or lock the state if necessary. </param>
|
||||
/// <param name="flags"> The flags used for the reversion. Respects Once (see <see cref="ApplyFlag"/>.)</param>
|
||||
/// <returns> ItemInvalid, ActorNotFound, ActorNotHuman, InvalidKey, Success. </returns>
|
||||
/// <remarks>
|
||||
/// The item ID can be a custom item ID in Glamourer's format for models without an associated item, or a normal game item ID.<br/>
|
||||
/// The player does not have to be currently available as long as he has a persisted Glamourer state.<br/>
|
||||
/// Only players are checked for name equality, no NPCs.<br/>
|
||||
/// If multiple players of the same name are found, all of them are modified.<br/>
|
||||
/// Prefer to use the index-based function unless you need to get the state of someone currently unavailable.
|
||||
/// </remarks>
|
||||
public GlamourerApiEc SetItemName(string playerName, ApiEquipSlot slot, ulong itemId, IReadOnlyList<byte> stains, uint key,
|
||||
ApplyFlag flags);
|
||||
|
||||
/// <summary> Set a single bonus item on an actor. </summary>
|
||||
/// <param name="objectIndex"> The game object index of the actor to be manipulated. </param>
|
||||
/// <param name="slot"> The bonus slot to apply the item to. </param>
|
||||
/// <param name="bonusItemId"> The bonus item sheet ID of the item to apply (including stain). </param>
|
||||
/// <param name="key"> A key to unlock or lock the state if necessary. </param>
|
||||
/// <param name="flags"> The flags used for the reversion. Respects Once (see <see cref="ApplyFlag"/>.)</param>
|
||||
/// <returns> ItemInvalid, ActorNotFound, ActorNotHuman, InvalidKey, Success. </returns>
|
||||
/// <remarks> The bonus item ID can currently not be a custom item ID in Glamourer's format for models without an associated item. Use 0 to remove the bonus item. </remarks>
|
||||
public GlamourerApiEc SetBonusItem(int objectIndex, ApiBonusSlot slot, ulong bonusItemId, uint key, ApplyFlag flags);
|
||||
|
||||
/// <summary> Set a single bonus item on an actor. </summary>
|
||||
/// <param name="playerName"> The game object index of the actor to be manipulated. </param>
|
||||
/// <param name="slot"> The bonus slot to apply the item to. </param>
|
||||
/// <param name="bonusItemId"> The bonus item sheet ID of the item to apply (including stain). </param>
|
||||
/// <param name="key"> A key to unlock or lock the state if necessary. </param>
|
||||
/// <param name="flags"> The flags used for the reversion. Respects Once (see <see cref="ApplyFlag"/>.)</param>
|
||||
/// <returns> ItemInvalid, ActorNotFound, ActorNotHuman, InvalidKey, Success. </returns>
|
||||
/// <remarks>
|
||||
/// The bonus item ID can currently not be a custom item ID in Glamourer's format for models without an associated item. Use 0 to remove the bonus item. <br/>
|
||||
/// The player does not have to be currently available as long as he has a persisted Glamourer state.<br/>
|
||||
/// Only players are checked for name equality, no NPCs.<br/>
|
||||
/// If multiple players of the same name are found, all of them are modified.<br/>
|
||||
/// Prefer to use the index-based function unless you need to get the state of someone currently unavailable.
|
||||
/// </remarks>
|
||||
public GlamourerApiEc SetBonusItemName(string playerName, ApiBonusSlot slot, ulong bonusItemId, uint key, ApplyFlag flags);
|
||||
|
||||
/// <summary> Set the defined Meta State flags to the active or inactive state on actor. </summary>
|
||||
/// <param name="objectIndex"> The game object index of the actor to be manipulated. </param>
|
||||
/// <param name="types"> The flags defining which meta states to update to the new value. This can be multiple at once. </param>
|
||||
/// <param name="newValue"> The new value to update to. </param>
|
||||
/// <param name="key"> A key to unlock or lock the state if necessary. </param>
|
||||
/// <param name="flags"> The flags used for the reversion. Respects Once (see <see cref="ApplyFlag.Once"/>.)</param>
|
||||
/// <returns> ItemInvalid, ActorNotFound, ActorNotHuman, InvalidKey, Success. </returns>
|
||||
public GlamourerApiEc SetMetaState(int objectIndex, MetaFlag types, bool newValue, uint key, ApplyFlag flags);
|
||||
|
||||
/// <summary> Set the defined Meta State flags to the active or inactive state on actor (by name) </summary>
|
||||
/// <param name="playerName"> The name of the players to be manipulated. </param>
|
||||
/// <param name="types"> The flags defining which meta states to update to the new value. This can be multiple at once. </param>
|
||||
/// <param name="newValue"> The new value to update to. </param>
|
||||
/// <param name="key"> A key to unlock or lock the state if necessary. </param>
|
||||
/// <param name="flags"> The flags used for the reversion. Respects Once (see <see cref="ApplyFlag.Once"/>.)</param>
|
||||
/// <returns> ItemInvalid, ActorNotFound, ActorNotHuman, InvalidKey, Success. </returns>
|
||||
public GlamourerApiEc SetMetaStateName(string playerName, MetaFlag types, bool newValue, uint key, ApplyFlag flags);
|
||||
}
|
124
Glamourer.Api/Api/IGlamourerApiState.cs
Normal file
124
Glamourer.Api/Api/IGlamourerApiState.cs
Normal file
@@ -0,0 +1,124 @@
|
||||
using Glamourer.Api.Enums;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Glamourer.Api.Api;
|
||||
|
||||
/// <summary> Any functions related to Glamourer's state tracking. </summary>
|
||||
public interface IGlamourerApiState
|
||||
{
|
||||
/// <summary> Get the current Glamourer state of an actor. </summary>
|
||||
/// <param name="objectIndex"> The game object index of the desired actor. </param>
|
||||
/// <param name="key"> A key to unlock the state if necessary. </param>
|
||||
/// <returns> ActorNotFound, InvalidKey or Success, and the state on success. </returns>
|
||||
/// <remarks> The actor does not need to have a prior Glamourer state as long as it can be found. </remarks>
|
||||
public (GlamourerApiEc, JObject?) GetState(int objectIndex, uint key);
|
||||
|
||||
/// <summary> Get the current Glamourer state of a player character. </summary>
|
||||
/// <param name="playerName"> The name of the desired player. </param>
|
||||
/// <param name="key"> A key to unlock the state if necessary. </param>
|
||||
/// <returns> ActorNotFound, InvalidKey or Success, and the state on success. </returns>
|
||||
/// <remarks>
|
||||
/// The player does not have to be currently available as long as he has a persisted Glamourer state.
|
||||
/// Only players are checked for name equality, no NPCs.
|
||||
/// If multiple players of the same name are found, the first is returned.
|
||||
/// Prefer to use the index-based function unless you need to get the state of someone currently unavailable.
|
||||
/// </remarks>
|
||||
public (GlamourerApiEc, JObject?) GetStateName(string playerName, uint key);
|
||||
|
||||
/// <inheritdoc cref="GetState"/>
|
||||
public (GlamourerApiEc, string?) GetStateBase64(int objectIndex, uint key);
|
||||
|
||||
/// <inheritdoc cref="GetStateName"/>
|
||||
public (GlamourerApiEc, string?) GetStateBase64Name(string objectName, uint key);
|
||||
|
||||
/// <summary> Apply a supplied state to an actor. </summary>
|
||||
/// <param name="applyState"> The state, which can be either a Glamourer-supplied JObject or a Base64 string. </param>
|
||||
/// <param name="objectIndex"> The game object index of the actor to be manipulated. </param>
|
||||
/// <param name="key"> A key to unlock or lock the state if necessary. </param>
|
||||
/// <param name="flags"> The flags used for the application. Respects Once, Equipment, Customization and Lock (see <see cref="ApplyFlag"/>.) </param>
|
||||
/// <returns> ActorNotFound, InvalidKey, ActorNotHuman, Success. </returns>
|
||||
public GlamourerApiEc ApplyState(object applyState, int objectIndex, uint key, ApplyFlag flags);
|
||||
|
||||
/// <summary> Apply a supplied state to players. </summary>
|
||||
/// <param name="applyState"> The state, which can be either a Glamourer-supplied JObject or a Base64 string. </param>
|
||||
/// <param name="playerName"> The name of the player to be manipulated. </param>
|
||||
/// <param name="key"> A key to unlock or lock the state if necessary. </param>
|
||||
/// <param name="flags"> The flags used for the application. Respects Once, Equipment, Customization and Lock (see <see cref="ApplyFlag"/>.) </param>
|
||||
/// <returns> ActorNotFound, InvalidKey, ActorNotHuman, Success. </returns>
|
||||
/// <remarks>
|
||||
/// The player does not have to be currently available as long as he has a persisted Glamourer state.<br/>
|
||||
/// Only players are checked for name equality, no NPCs.<br/>
|
||||
/// If multiple players of the same name are found, all of them are manipulated.<br/>
|
||||
/// Prefer to use the index-based function unless you need to get the state of someone currently unavailable.
|
||||
/// </remarks>
|
||||
public GlamourerApiEc ApplyStateName(object applyState, string playerName, uint key, ApplyFlag flags);
|
||||
|
||||
/// <summary> Revert the Glamourer state of an actor to Game state. </summary>
|
||||
/// <param name="objectIndex"> The game object index of the actor to be manipulated. </param>
|
||||
/// <param name="key"> A key to unlock the state if necessary. </param>
|
||||
/// <param name="flags"> The flags used for the reversion. Respects Equipment and Customization (see <see cref="ApplyFlag"/>.) </param>
|
||||
/// <returns> ActorNotFound, InvalidKey, Success, NothingDone. </returns>
|
||||
public GlamourerApiEc RevertState(int objectIndex, uint key, ApplyFlag flags);
|
||||
|
||||
/// <summary> Revert the Glamourer state of players to game state. </summary>
|
||||
/// <param name="playerName"> The name of the players to be reverted. </param>
|
||||
/// <param name="key"> A key to unlock the state if necessary. </param>
|
||||
/// <param name="flags"> The flags used for the reversion. Respects Equipment and Customization (see <see cref="ApplyFlag"/>.) </param>
|
||||
/// <returns> ActorNotFound, InvalidKey, Success, NothingDone. </returns>
|
||||
/// /// <remarks>
|
||||
/// The player does not have to be currently available as long as he has a persisted Glamourer state.<br/>
|
||||
/// Only players are checked for name equality, no NPCs.<br/>
|
||||
/// If multiple players of the same name are found, all of them are reverted.<br/>
|
||||
/// Prefer to use the index-based function unless you need to get the state of someone currently unavailable.
|
||||
/// </remarks>
|
||||
public GlamourerApiEc RevertStateName(string playerName, uint key, ApplyFlag flags);
|
||||
|
||||
/// <summary> Unlock the Glamourer state of an actor with a key. </summary>
|
||||
/// <param name="objectIndex"> The game object index of the actor to be manipulated. </param>
|
||||
/// <param name="key"> A key to unlock the state. </param>
|
||||
/// <returns> ActorNotFound, InvalidKey, Success, NothingDone. </returns>
|
||||
public GlamourerApiEc UnlockState(int objectIndex, uint key);
|
||||
|
||||
/// <summary> Unlock the Glamourer state of players with a key. </summary>
|
||||
/// <param name="playerName"> The name of the players to be unlocked. </param>
|
||||
/// <param name="key"> A key to unlock the state. </param>
|
||||
/// <returns> InvalidKey, Success, NothingDone. </returns>
|
||||
public GlamourerApiEc UnlockStateName(string playerName, uint key);
|
||||
|
||||
/// <summary> Unlock all active glamourer states with a key. </summary>
|
||||
/// <param name="key"> The key to unlock states with. </param>
|
||||
/// <returns> The number of unlocked states. </returns>
|
||||
public int UnlockAll(uint key);
|
||||
|
||||
/// <summary> Revert the Glamourer state of an actor to automation state. </summary>
|
||||
/// <param name="objectIndex"> The game object index of the actor to be manipulated. </param>
|
||||
/// <param name="key"> A key to unlock the state if necessary. </param>
|
||||
/// <param name="flags"> The flags used for the reversion. Respects Once and Lock (see <see cref="ApplyFlag"/>.) </param>
|
||||
/// <returns> ActorNotFound, InvalidKey, Success, NothingDone. </returns>
|
||||
public GlamourerApiEc RevertToAutomation(int objectIndex, uint key, ApplyFlag flags);
|
||||
|
||||
/// <summary> Revert the Glamourer state of players to automation state. </summary>
|
||||
/// <param name="playerName"> The name of the players to be reverted. </param>
|
||||
/// <param name="key"> A key to unlock the state if necessary. </param>
|
||||
/// <param name="flags"> The flags used for the reversion. Respects Once and Lock (see <see cref="ApplyFlag"/>.) </param>
|
||||
/// <returns> ActorNotFound, InvalidKey, Success, NothingDone. </returns>
|
||||
/// /// <remarks>
|
||||
/// The player does not have to be currently available as long as he has a persisted Glamourer state.<br/>
|
||||
/// Only players are checked for name equality, no NPCs.<br/>
|
||||
/// If multiple players of the same name are found, all of them are reverted.<br/>
|
||||
/// Prefer to use the index-based function unless you need to get the state of someone currently unavailable.
|
||||
/// </remarks>
|
||||
public GlamourerApiEc RevertToAutomationName(string playerName, uint key, ApplyFlag flags);
|
||||
|
||||
/// <summary> Invoked with the game object pointer (if available) whenever an actors tracked state changes. </summary>
|
||||
public event Action<nint> StateChanged;
|
||||
|
||||
/// <summary> Invoked with the game object pointer (if available) whenever an actors tracked state changes, with the type of change. </summary>
|
||||
public event Action<nint, StateChangeType> StateChangedWithType;
|
||||
|
||||
/// <summary> Invoked with the game object pointer (if available) whenever an actors tracked state finalizes a grouped change consisting of multiple smaller changes. </summary>
|
||||
public event Action<nint, StateFinalizationType> StateFinalized;
|
||||
|
||||
/// <summary> Invoked when the player enters or leaves GPose (true => entered GPose, false => left GPose). </summary>
|
||||
public event Action<bool>? GPoseChanged;
|
||||
}
|
11
Glamourer.Api/Enums/ApiBonusSlot.cs
Normal file
11
Glamourer.Api/Enums/ApiBonusSlot.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Glamourer.Api.Enums;
|
||||
|
||||
/// <summary> Bonus item slots restricted to API-relevant slots. </summary>
|
||||
public enum ApiBonusSlot : byte
|
||||
{
|
||||
/// <summary> No slot. </summary>
|
||||
Unknown = 0,
|
||||
|
||||
/// <summary> The Glasses slot. </summary>
|
||||
Glasses = 1,
|
||||
}
|
45
Glamourer.Api/Enums/ApiEquipSlot.cs
Normal file
45
Glamourer.Api/Enums/ApiEquipSlot.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
namespace Glamourer.Api.Enums;
|
||||
|
||||
/// <summary> Equip slots restricted to API-relevant slots, but compatible with GameData.EquipSlots. </summary>
|
||||
public enum ApiEquipSlot : byte
|
||||
{
|
||||
/// <summary> No slot. </summary>
|
||||
Unknown = 0,
|
||||
|
||||
/// <summary> Mainhand, also used for both-handed weapons. </summary>
|
||||
MainHand = 1,
|
||||
|
||||
/// <summary> Offhand, used for shields or if you want to apply the offhand component of certain weapons. </summary>
|
||||
OffHand = 2,
|
||||
|
||||
/// <summary> Head. </summary>
|
||||
Head = 3,
|
||||
|
||||
/// <summary> Body. </summary>
|
||||
Body = 4,
|
||||
|
||||
/// <summary> Hands. </summary>
|
||||
Hands = 5,
|
||||
|
||||
/// <summary> Legs. </summary>
|
||||
Legs = 7,
|
||||
|
||||
/// <summary> Feet. </summary>
|
||||
Feet = 8,
|
||||
|
||||
/// <summary> Ears. </summary>
|
||||
Ears = 9,
|
||||
|
||||
/// <summary> Neck. </summary>
|
||||
Neck = 10,
|
||||
|
||||
/// <summary> Wrists. </summary>
|
||||
Wrists = 11,
|
||||
|
||||
/// <summary> Right Finger. </summary>
|
||||
RFinger = 12,
|
||||
|
||||
/// <summary> Left Finger. </summary>
|
||||
/// <remarks> Not officially existing, means "weapon could be equipped in either hand" for the game. </remarks>
|
||||
LFinger = 14,
|
||||
}
|
31
Glamourer.Api/Enums/ApplyFlag.cs
Normal file
31
Glamourer.Api/Enums/ApplyFlag.cs
Normal file
@@ -0,0 +1,31 @@
|
||||
namespace Glamourer.Api.Enums;
|
||||
|
||||
/// <summary> Application flags that can be used in different situations. </summary>
|
||||
[Flags]
|
||||
public enum ApplyFlag : ulong
|
||||
{
|
||||
/// <summary> Apply the selected manipulation only once, without forcing the state into automation. </summary>
|
||||
Once = 0x01,
|
||||
|
||||
/// <summary> Apply the selected manipulation on the equipment (might be more or less supported). </summary>
|
||||
Equipment = 0x02,
|
||||
|
||||
/// <summary> Apply the selected manipulation on the customizations (might be more or less supported). </summary>
|
||||
Customization = 0x04,
|
||||
|
||||
/// <summary> Lock the state with the given key after applying the selected manipulation </summary>
|
||||
Lock = 0x08,
|
||||
}
|
||||
|
||||
/// <summary> Extensions for apply flags. </summary>
|
||||
public static class ApplyFlagEx
|
||||
{
|
||||
/// <summary> The default application flags for design-based manipulations. </summary>
|
||||
public const ApplyFlag DesignDefault = ApplyFlag.Once | ApplyFlag.Equipment | ApplyFlag.Customization;
|
||||
|
||||
/// <summary> The default application flags for state-based manipulations. </summary>
|
||||
public const ApplyFlag StateDefault = ApplyFlag.Equipment | ApplyFlag.Customization | ApplyFlag.Lock;
|
||||
|
||||
/// <summary> The default application flags for reverse manipulations. </summary>
|
||||
public const ApplyFlag RevertDefault = ApplyFlag.Equipment | ApplyFlag.Customization;
|
||||
}
|
29
Glamourer.Api/Enums/GlamourerApiEc.cs
Normal file
29
Glamourer.Api/Enums/GlamourerApiEc.cs
Normal file
@@ -0,0 +1,29 @@
|
||||
namespace Glamourer.Api.Enums;
|
||||
|
||||
/// <summary> Return codes for API functions. </summary>
|
||||
public enum GlamourerApiEc
|
||||
{
|
||||
/// <summary> The function succeeded. </summary>
|
||||
Success = 0,
|
||||
|
||||
/// <summary> The function did not encounter a problem, but also did not do anything. </summary>
|
||||
NothingDone = 1,
|
||||
|
||||
/// <summary> The requested actor was not found. </summary>
|
||||
ActorNotFound = 2,
|
||||
|
||||
/// <summary> The requested actor was not human, but should have been. </summary>
|
||||
ActorNotHuman,
|
||||
|
||||
/// <summary> The requested design was not found. </summary>
|
||||
DesignNotFound,
|
||||
|
||||
/// <summary> The requested item was not found or could not be applied to the requested slot. </summary>
|
||||
ItemInvalid,
|
||||
|
||||
/// <summary> The state of an actor could not be manipulated because it was locked and the provided key could not unlock it. </summary>
|
||||
InvalidKey,
|
||||
|
||||
/// <summary> The provided object could not be converted into a valid Glamourer state to apply. </summary>
|
||||
InvalidState,
|
||||
}
|
11
Glamourer.Api/Enums/SetMetaFlag.cs
Normal file
11
Glamourer.Api/Enums/SetMetaFlag.cs
Normal file
@@ -0,0 +1,11 @@
|
||||
namespace Glamourer.Api.Enums;
|
||||
|
||||
/// <summary> Application flags for setting the meta state of an actor. </summary>
|
||||
[Flags]
|
||||
public enum MetaFlag : ulong
|
||||
{
|
||||
Wetness = 0x01,
|
||||
HatState = 0x02,
|
||||
VisorState = 0x04,
|
||||
WeaponState = 0x08,
|
||||
}
|
47
Glamourer.Api/Enums/StateChangeType.cs
Normal file
47
Glamourer.Api/Enums/StateChangeType.cs
Normal file
@@ -0,0 +1,47 @@
|
||||
namespace Glamourer.Api.Enums;
|
||||
|
||||
/// <summary> What type of information changed in a state. </summary>
|
||||
public enum StateChangeType
|
||||
{
|
||||
/// <summary> A characters saved state had the model id changed. This means everything may have changed. </summary>
|
||||
Model = 0,
|
||||
|
||||
/// <summary> A characters saved state had multiple customization values changed. </summary>
|
||||
EntireCustomize = 1,
|
||||
|
||||
/// <summary> A characters saved state had a customization value changed. </summary>
|
||||
Customize = 2,
|
||||
|
||||
/// <summary> A characters saved state had an equipment piece changed. </summary>
|
||||
Equip = 3,
|
||||
|
||||
/// <summary> A characters saved state had its weapons changed. </summary>
|
||||
Weapon = 4,
|
||||
|
||||
/// <summary> A characters saved state had a stain changed. </summary>
|
||||
Stains = 5,
|
||||
|
||||
/// <summary> A characters saved state had a crest visibility changed. </summary>
|
||||
Crest = 6,
|
||||
|
||||
/// <summary> A characters saved state had its customize parameter changed. </summary>
|
||||
Parameter = 7,
|
||||
|
||||
/// <summary> A characters saved state had a material color table value changed. </summary>
|
||||
MaterialValue = 8,
|
||||
|
||||
/// <summary> A characters saved state had a design applied. This means everything may have changed. </summary>
|
||||
Design = 9,
|
||||
|
||||
/// <summary> A characters saved state had its state reset to its game values. </summary>
|
||||
Reset = 10,
|
||||
|
||||
/// <summary> A characters saved state had a meta toggle changed. </summary>
|
||||
Other = 11,
|
||||
|
||||
/// <summary> A characters state was reapplied. Data is null. </summary>
|
||||
Reapply = 12,
|
||||
|
||||
/// <summary> A characters saved state had a bonus item changed. </summary>
|
||||
BonusItem = 13,
|
||||
}
|
36
Glamourer.Api/Enums/StateFinalizationType.cs
Normal file
36
Glamourer.Api/Enums/StateFinalizationType.cs
Normal file
@@ -0,0 +1,36 @@
|
||||
namespace Glamourer.Api.Enums;
|
||||
|
||||
/// <summary> What type of Glamourer process was performed on the actors state to update it. </summary>
|
||||
public enum StateFinalizationType
|
||||
{
|
||||
/// <summary> A characters saved state had the model id altered. </summary>
|
||||
ModelChange = 0,
|
||||
|
||||
/// <summary> A singular Design was applied to an actors state. </summary>
|
||||
DesignApplied = 1,
|
||||
|
||||
/// <summary> A characters saved state had been reset to game values. </summary>
|
||||
Revert = 2,
|
||||
|
||||
/// <summary> A characters saved state had only its customization data reset to game state. </summary>
|
||||
RevertCustomize = 3,
|
||||
|
||||
/// <summary> A characters saved state had only its equipment data reset to game state. </summary>
|
||||
RevertEquipment = 4,
|
||||
|
||||
/// <summary> A characters saved state had its advanced values reverted to game state. </summary>
|
||||
RevertAdvanced = 5,
|
||||
|
||||
/// <summary> A characters saved state was reverted to automation state on top of their game state </summary>
|
||||
RevertAutomation = 6,
|
||||
|
||||
/// <summary> A characters saved state had a generic reapply as a single operation. </summary>
|
||||
Reapply = 7,
|
||||
|
||||
/// <summary> A characters saved state had their automation state reapplied over their existing state. </summary>
|
||||
ReapplyAutomation = 8,
|
||||
|
||||
/// <summary> A characters save state finished applying all updated slots for game state on gearset change or initial load. </summary>
|
||||
Gearset = 9,
|
||||
}
|
||||
|
34
Glamourer.Api/Glamourer.Api.csproj
Normal file
34
Glamourer.Api/Glamourer.Api.csproj
Normal file
@@ -0,0 +1,34 @@
|
||||
<Project Sdk="Dalamud.NET.Sdk/13.0.0">
|
||||
<PropertyGroup>
|
||||
<AssemblyTitle>Glamourer.Api</AssemblyTitle>
|
||||
<Product>Glamourer</Product>
|
||||
<Copyright>Copyright © 2025</Copyright>
|
||||
<FileVersion>2.4.1.0</FileVersion>
|
||||
<AssemblyVersion>2.4.1.0</AssemblyVersion>
|
||||
<PackageVersion>2.4.1</PackageVersion>
|
||||
<PackageReadmeFile>README.md</PackageReadmeFile>
|
||||
<OutputPath>bin\$(Configuration)\</OutputPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<GeneratePackageOnBuild>true</GeneratePackageOnBuild>
|
||||
<GenerateDocumentationFile>true</GenerateDocumentationFile>
|
||||
<Title>Glamourer.Api</Title>
|
||||
<Authors>Ottermandias</Authors>
|
||||
<RepositoryUrl>https://github.com/Ottermandias/Glamourer</RepositoryUrl>
|
||||
<Description>Auxiliary functions for Glamourers external API.</Description>
|
||||
<PackageLicenseExpression>MIT</PackageLicenseExpression>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<Use_DalamudPackager>false</Use_DalamudPackager>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup>
|
||||
<NoWarn>1591</NoWarn>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<None Include="README.md" Pack="true" PackagePath="\" />
|
||||
</ItemGroup>
|
||||
</Project>
|
2
Glamourer.Api/Glamourer.Api.csproj.DotSettings
Normal file
2
Glamourer.Api/Glamourer.Api.csproj.DotSettings
Normal file
@@ -0,0 +1,2 @@
|
||||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation">
|
||||
<s:Boolean x:Key="/Default/CodeInspection/NamespaceProvider/NamespaceFoldersToSkip/=ipc/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary>
|
4
Glamourer.Api/GlobalUsings.cs
Normal file
4
Glamourer.Api/GlobalUsings.cs
Normal file
@@ -0,0 +1,4 @@
|
||||
// Global using directives
|
||||
|
||||
global using System;
|
||||
global using System.Collections.Generic;
|
114
Glamourer.Api/Helpers/ActionSubscriber.cs
Normal file
114
Glamourer.Api/Helpers/ActionSubscriber.cs
Normal file
@@ -0,0 +1,114 @@
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Ipc;
|
||||
|
||||
namespace Glamourer.Api.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// Specialized subscriber only allowing to invoke actions.
|
||||
/// </summary>
|
||||
public class ActionSubscriber
|
||||
{
|
||||
private readonly ICallGateSubscriber<object?>? _subscriber;
|
||||
|
||||
/// <summary> Whether the subscriber could successfully be created. </summary>
|
||||
public bool Valid
|
||||
=> _subscriber != null;
|
||||
|
||||
protected ActionSubscriber(IDalamudPluginInterface pi, string label)
|
||||
{
|
||||
try
|
||||
{
|
||||
_subscriber = pi.GetIpcSubscriber<object?>(label);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
PluginLogHelper.WriteError(pi, $"Error registering IPC Subscriber for {label}\n{e}");
|
||||
_subscriber = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Invoke the action. See the source of the subscriber for details.</summary>
|
||||
protected void Invoke()
|
||||
=> _subscriber?.InvokeAction();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ActionSubscriber"/>
|
||||
public class ActionSubscriber<T1>
|
||||
{
|
||||
private readonly ICallGateSubscriber<T1, object?>? _subscriber;
|
||||
|
||||
/// <summary> Whether the subscriber could successfully be created. </summary>
|
||||
public bool Valid
|
||||
=> _subscriber != null;
|
||||
|
||||
protected ActionSubscriber(IDalamudPluginInterface pi, string label)
|
||||
{
|
||||
try
|
||||
{
|
||||
_subscriber = pi.GetIpcSubscriber<T1, object?>(label);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
PluginLogHelper.WriteError(pi, $"Error registering IPC Subscriber for {label}\n{e}");
|
||||
_subscriber = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Invoke the action. See the source of the subscriber for details.</summary>
|
||||
protected void Invoke(T1 a)
|
||||
=> _subscriber?.InvokeAction(a);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ActionSubscriber"/>
|
||||
public class ActionSubscriber<T1, T2>
|
||||
{
|
||||
private readonly ICallGateSubscriber<T1, T2, object?>? _subscriber;
|
||||
|
||||
/// <inheritdoc cref="ActionSubscriber{T1}.Valid"/>
|
||||
public bool Valid
|
||||
=> _subscriber != null;
|
||||
|
||||
protected ActionSubscriber(IDalamudPluginInterface pi, string label)
|
||||
{
|
||||
try
|
||||
{
|
||||
_subscriber = pi.GetIpcSubscriber<T1, T2, object?>(label);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
PluginLogHelper.WriteError(pi, $"Error registering IPC Subscriber for {label}\n{e}");
|
||||
_subscriber = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ActionSubscriber.Invoke"/>
|
||||
protected void Invoke(T1 a, T2 b)
|
||||
=> _subscriber?.InvokeAction(a, b);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ActionSubscriber"/>
|
||||
public class ActionSubscriber<T1, T2, T3>
|
||||
{
|
||||
private readonly ICallGateSubscriber<T1, T2, T3, object?>? _subscriber;
|
||||
|
||||
/// <inheritdoc cref="ActionSubscriber{T1}.Valid"/>
|
||||
public bool Valid
|
||||
=> _subscriber != null;
|
||||
|
||||
protected ActionSubscriber(IDalamudPluginInterface pi, string label)
|
||||
{
|
||||
try
|
||||
{
|
||||
_subscriber = pi.GetIpcSubscriber<T1, T2, T3, object?>(label);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
PluginLogHelper.WriteError(pi, $"Error registering IPC Subscriber for {label}\n{e}");
|
||||
_subscriber = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="ActionSubscriber.Invoke"/>
|
||||
protected void Invoke(T1 a, T2 b, T3 c)
|
||||
=> _subscriber?.InvokeAction(a, b, c);
|
||||
}
|
234
Glamourer.Api/Helpers/EventProvider.cs
Normal file
234
Glamourer.Api/Helpers/EventProvider.cs
Normal file
@@ -0,0 +1,234 @@
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Ipc;
|
||||
using Dalamud.Plugin.Services;
|
||||
|
||||
namespace Glamourer.Api.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// Specialized disposable Provider for Events.<para />
|
||||
/// Will execute the unsubscriber action on dispose if any is provided.<para />
|
||||
/// Can only be invoked and disposed.
|
||||
/// </summary>
|
||||
public sealed class EventProvider : IDisposable
|
||||
{
|
||||
private readonly IPluginLog _log;
|
||||
private ICallGateProvider<object?>? _provider;
|
||||
private Delegate? _unsubscriber;
|
||||
|
||||
public EventProvider(IDalamudPluginInterface pi, string label, (Action<Action> Add, Action<Action> Del)? subscribe = null)
|
||||
{
|
||||
_unsubscriber = null;
|
||||
_log = PluginLogHelper.GetLog(pi);
|
||||
try
|
||||
{
|
||||
_provider = pi.GetIpcProvider<object?>(label);
|
||||
subscribe?.Add(Invoke);
|
||||
_unsubscriber = subscribe?.Del;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.Error($"Error registering IPC Provider for {label}\n{e}");
|
||||
_provider = null;
|
||||
}
|
||||
}
|
||||
|
||||
public EventProvider(IDalamudPluginInterface pi, string label, Action<EventProvider> add, Action<EventProvider> del)
|
||||
{
|
||||
_unsubscriber = null;
|
||||
_log = PluginLogHelper.GetLog(pi);
|
||||
try
|
||||
{
|
||||
_provider = pi.GetIpcProvider<object?>(label);
|
||||
add(this);
|
||||
_unsubscriber = del;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.Error($"Error registering IPC Provider for {label}\n{e}");
|
||||
_provider = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Invoke the event.</summary>
|
||||
public void Invoke()
|
||||
{
|
||||
try
|
||||
{
|
||||
_provider?.SendMessage();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.Error($"Exception thrown on IPC event:\n{e}");
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
switch (_unsubscriber)
|
||||
{
|
||||
case Action<Action> a:
|
||||
a(Invoke);
|
||||
break;
|
||||
case Action<EventProvider> b:
|
||||
b(this);
|
||||
break;
|
||||
}
|
||||
|
||||
_unsubscriber = null;
|
||||
_provider = null;
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
~EventProvider()
|
||||
=> Dispose();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="EventProvider"/>
|
||||
public sealed class EventProvider<T1> : IDisposable
|
||||
{
|
||||
private readonly IPluginLog _log;
|
||||
private ICallGateProvider<T1, object?>? _provider;
|
||||
private Delegate? _unsubscriber;
|
||||
|
||||
public EventProvider(IDalamudPluginInterface pi, string label, (Action<Action<T1>> Add, Action<Action<T1>> Del)? subscribe = null)
|
||||
{
|
||||
_unsubscriber = null;
|
||||
_log = PluginLogHelper.GetLog(pi);
|
||||
try
|
||||
{
|
||||
_provider = pi.GetIpcProvider<T1, object?>(label);
|
||||
subscribe?.Add(Invoke);
|
||||
_unsubscriber = subscribe?.Del;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.Error($"Error registering IPC Provider for {label}\n{e}");
|
||||
_provider = null;
|
||||
}
|
||||
}
|
||||
|
||||
public EventProvider(IDalamudPluginInterface pi, string label, Action<EventProvider<T1>> add, Action<EventProvider<T1>> del)
|
||||
{
|
||||
_unsubscriber = null;
|
||||
_log = PluginLogHelper.GetLog(pi);
|
||||
try
|
||||
{
|
||||
_provider = pi.GetIpcProvider<T1, object?>(label);
|
||||
add(this);
|
||||
_unsubscriber = del;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.Error($"Error registering IPC Provider for {label}\n{e}");
|
||||
_provider = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="EventProvider.Invoke"/>
|
||||
public void Invoke(T1 a)
|
||||
{
|
||||
try
|
||||
{
|
||||
_provider?.SendMessage(a);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.Error($"Exception thrown on IPC event:\n{e}");
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
switch (_unsubscriber)
|
||||
{
|
||||
case Action<Action<T1>> a:
|
||||
a(Invoke);
|
||||
break;
|
||||
case Action<EventProvider<T1>> b:
|
||||
b(this);
|
||||
break;
|
||||
}
|
||||
|
||||
_unsubscriber = null;
|
||||
_provider = null;
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
~EventProvider()
|
||||
=> Dispose();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="EventProvider"/>
|
||||
public sealed class EventProvider<T1, T2> : IDisposable
|
||||
{
|
||||
private readonly IPluginLog _log;
|
||||
private ICallGateProvider<T1, T2, object?>? _provider;
|
||||
private Delegate? _unsubscriber;
|
||||
|
||||
public EventProvider(IDalamudPluginInterface pi, string label, (Action<Action<T1, T2>> Add, Action<Action<T1, T2>> Del)? subscribe = null)
|
||||
{
|
||||
_unsubscriber = null;
|
||||
_log = PluginLogHelper.GetLog(pi);
|
||||
try
|
||||
{
|
||||
_provider = pi.GetIpcProvider<T1, T2, object?>(label);
|
||||
subscribe?.Add(Invoke);
|
||||
_unsubscriber = subscribe?.Del;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.Error($"Error registering IPC Provider for {label}\n{e}");
|
||||
_provider = null;
|
||||
}
|
||||
}
|
||||
|
||||
public EventProvider(IDalamudPluginInterface pi, string label, Action<EventProvider<T1, T2>> add, Action<EventProvider<T1, T2>> del)
|
||||
{
|
||||
_unsubscriber = null;
|
||||
_log = PluginLogHelper.GetLog(pi);
|
||||
try
|
||||
{
|
||||
_provider = pi.GetIpcProvider<T1, T2, object?>(label);
|
||||
add(this);
|
||||
_unsubscriber = del;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.Error($"Error registering IPC Provider for {label}\n{e}");
|
||||
_provider = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="EventProvider.Invoke"/>
|
||||
public void Invoke(T1 a, T2 b)
|
||||
{
|
||||
try
|
||||
{
|
||||
_provider?.SendMessage(a, b);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.Error($"Exception thrown on IPC event:\n{e}");
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
switch (_unsubscriber)
|
||||
{
|
||||
case Action<Action<T1, T2>> a:
|
||||
a(Invoke);
|
||||
break;
|
||||
case Action<EventProvider<T1, T2>> b:
|
||||
b(this);
|
||||
break;
|
||||
}
|
||||
|
||||
_unsubscriber = null;
|
||||
_provider = null;
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
~EventProvider()
|
||||
=> Dispose();
|
||||
}
|
394
Glamourer.Api/Helpers/EventSubscriber.cs
Normal file
394
Glamourer.Api/Helpers/EventSubscriber.cs
Normal file
@@ -0,0 +1,394 @@
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Ipc;
|
||||
using Dalamud.Plugin.Services;
|
||||
|
||||
namespace Glamourer.Api.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// Specialized disposable Subscriber for Events.<para />
|
||||
/// Subscriptions are wrapped to be individually exception-safe.<para/>
|
||||
/// Can be enabled and disabled.<para/>
|
||||
/// </summary>
|
||||
public sealed class EventSubscriber : IDisposable
|
||||
{
|
||||
private readonly string _label;
|
||||
private readonly IPluginLog _log;
|
||||
private readonly Dictionary<Action, Action> _delegates = new();
|
||||
private ICallGateSubscriber<object?>? _subscriber;
|
||||
private bool _disabled;
|
||||
|
||||
public EventSubscriber(IDalamudPluginInterface pi, string label, params Action[] actions)
|
||||
{
|
||||
_label = label;
|
||||
_log = PluginLogHelper.GetLog(pi);
|
||||
try
|
||||
{
|
||||
_subscriber = pi.GetIpcSubscriber<object?>(label);
|
||||
foreach (var action in actions)
|
||||
Event += action;
|
||||
|
||||
_disabled = false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.Error($"Error registering IPC Subscriber for {label}\n{e}");
|
||||
_subscriber = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Enable all currently subscribed actions registered with this EventSubscriber.
|
||||
/// Does nothing if it is already enabled.
|
||||
/// </summary>
|
||||
public void Enable()
|
||||
{
|
||||
if (_disabled && _subscriber != null)
|
||||
{
|
||||
foreach (var action in _delegates.Values)
|
||||
_subscriber.Subscribe(action);
|
||||
|
||||
_disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Disable all subscribed actions registered with this EventSubscriber.
|
||||
/// Does nothing if it is already disabled.
|
||||
/// Does not forget the actions, only disables them.
|
||||
/// </summary>
|
||||
public void Disable()
|
||||
{
|
||||
if (!_disabled)
|
||||
{
|
||||
if (_subscriber != null)
|
||||
foreach (var action in _delegates.Values)
|
||||
_subscriber.Unsubscribe(action);
|
||||
|
||||
_disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Add or remove an action to the IPC event, if it is valid.
|
||||
/// </summary>
|
||||
public event Action Event
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_subscriber != null && !_delegates.ContainsKey(value))
|
||||
{
|
||||
void Action()
|
||||
{
|
||||
try
|
||||
{
|
||||
value();
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.Error($"Exception invoking IPC event {_label}:\n{e}");
|
||||
}
|
||||
}
|
||||
|
||||
if (_delegates.TryAdd(value, Action) && !_disabled)
|
||||
_subscriber.Subscribe(Action);
|
||||
}
|
||||
}
|
||||
remove
|
||||
{
|
||||
if (_subscriber != null && _delegates.Remove(value, out var action))
|
||||
_subscriber.Unsubscribe(action);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Disable();
|
||||
_subscriber = null;
|
||||
_delegates.Clear();
|
||||
}
|
||||
|
||||
~EventSubscriber()
|
||||
=> Dispose();
|
||||
}
|
||||
|
||||
/// <summary><inheritdoc cref="EventSubscriber"/> </summary>
|
||||
public sealed class EventSubscriber<T1> : IDisposable
|
||||
{
|
||||
private readonly string _label;
|
||||
private readonly IPluginLog _log;
|
||||
private readonly Dictionary<Action<T1>, Action<T1>> _delegates = new();
|
||||
private ICallGateSubscriber<T1, object?>? _subscriber;
|
||||
private bool _disabled;
|
||||
|
||||
public EventSubscriber(IDalamudPluginInterface pi, string label, params Action<T1>[] actions)
|
||||
{
|
||||
_label = label;
|
||||
_log = PluginLogHelper.GetLog(pi);
|
||||
try
|
||||
{
|
||||
_subscriber = pi.GetIpcSubscriber<T1, object?>(label);
|
||||
foreach (var action in actions)
|
||||
Event += action;
|
||||
|
||||
_disabled = false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.Error($"Error registering IPC Subscriber for {label}\n{e}");
|
||||
_subscriber = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary><inheritdoc cref="EventSubscriber.Enable"/> </summary>
|
||||
public void Enable()
|
||||
{
|
||||
if (_disabled && _subscriber != null)
|
||||
{
|
||||
foreach (var action in _delegates.Values)
|
||||
_subscriber.Subscribe(action);
|
||||
|
||||
_disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary><inheritdoc cref="EventSubscriber.Disable"/> </summary>
|
||||
public void Disable()
|
||||
{
|
||||
if (!_disabled)
|
||||
{
|
||||
if (_subscriber != null)
|
||||
foreach (var action in _delegates.Values)
|
||||
_subscriber.Unsubscribe(action);
|
||||
|
||||
_disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary><inheritdoc cref="EventSubscriber.Event"/> </summary>
|
||||
public event Action<T1> Event
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_subscriber != null && !_delegates.ContainsKey(value))
|
||||
{
|
||||
void Action(T1 a)
|
||||
{
|
||||
try
|
||||
{
|
||||
value(a);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.Error($"Exception invoking IPC event {_label}:\n{e}");
|
||||
}
|
||||
}
|
||||
|
||||
if (_delegates.TryAdd(value, Action) && !_disabled)
|
||||
_subscriber.Subscribe(Action);
|
||||
}
|
||||
}
|
||||
remove
|
||||
{
|
||||
if (_subscriber != null && _delegates.Remove(value, out var action))
|
||||
_subscriber.Unsubscribe(action);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Disable();
|
||||
_subscriber = null;
|
||||
_delegates.Clear();
|
||||
}
|
||||
|
||||
~EventSubscriber()
|
||||
=> Dispose();
|
||||
}
|
||||
|
||||
/// <summary><inheritdoc cref="EventSubscriber"/> </summary>
|
||||
public sealed class EventSubscriber<T1, T2> : IDisposable
|
||||
{
|
||||
private readonly string _label;
|
||||
private readonly IPluginLog _log;
|
||||
private readonly Dictionary<Action<T1, T2>, Action<T1, T2>> _delegates = new();
|
||||
private ICallGateSubscriber<T1, T2, object?>? _subscriber;
|
||||
private bool _disabled;
|
||||
|
||||
public EventSubscriber(IDalamudPluginInterface pi, string label, params Action<T1, T2>[] actions)
|
||||
{
|
||||
_label = label;
|
||||
_log = PluginLogHelper.GetLog(pi);
|
||||
try
|
||||
{
|
||||
_subscriber = pi.GetIpcSubscriber<T1, T2, object?>(label);
|
||||
foreach (var action in actions)
|
||||
Event += action;
|
||||
|
||||
_disabled = false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.Error($"Error registering IPC Subscriber for {label}\n{e}");
|
||||
_subscriber = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary><inheritdoc cref="EventSubscriber.Enable"/> </summary>
|
||||
public void Enable()
|
||||
{
|
||||
if (_disabled && _subscriber != null)
|
||||
{
|
||||
foreach (var action in _delegates.Values)
|
||||
_subscriber.Subscribe(action);
|
||||
|
||||
_disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary><inheritdoc cref="EventSubscriber.Disable"/> </summary>
|
||||
public void Disable()
|
||||
{
|
||||
if (!_disabled)
|
||||
{
|
||||
if (_subscriber != null)
|
||||
foreach (var action in _delegates.Values)
|
||||
_subscriber.Unsubscribe(action);
|
||||
|
||||
_disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary><inheritdoc cref="EventSubscriber.Event"/> </summary>
|
||||
public event Action<T1, T2> Event
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_subscriber != null && !_delegates.ContainsKey(value))
|
||||
{
|
||||
void Action(T1 a, T2 b)
|
||||
{
|
||||
try
|
||||
{
|
||||
value(a, b);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.Error($"Exception invoking IPC event {_label}:\n{e}");
|
||||
}
|
||||
}
|
||||
|
||||
if (_delegates.TryAdd(value, Action) && !_disabled)
|
||||
_subscriber.Subscribe(Action);
|
||||
}
|
||||
}
|
||||
remove
|
||||
{
|
||||
if (_subscriber != null && _delegates.Remove(value, out var action))
|
||||
_subscriber.Unsubscribe(action);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Disable();
|
||||
_subscriber = null;
|
||||
_delegates.Clear();
|
||||
}
|
||||
|
||||
~EventSubscriber()
|
||||
=> Dispose();
|
||||
}
|
||||
|
||||
/// <summary><inheritdoc cref="EventSubscriber"/> </summary>
|
||||
public sealed class EventSubscriber<T1, T2, T3> : IDisposable
|
||||
{
|
||||
private readonly string _label;
|
||||
private readonly IPluginLog _log;
|
||||
private readonly Dictionary<Action<T1, T2, T3>, Action<T1, T2, T3>> _delegates = new();
|
||||
private ICallGateSubscriber<T1, T2, T3, object?>? _subscriber;
|
||||
private bool _disabled;
|
||||
|
||||
public EventSubscriber(IDalamudPluginInterface pi, string label, params Action<T1, T2, T3>[] actions)
|
||||
{
|
||||
_label = label;
|
||||
_log = PluginLogHelper.GetLog(pi);
|
||||
try
|
||||
{
|
||||
_subscriber = pi.GetIpcSubscriber<T1, T2, T3, object?>(label);
|
||||
foreach (var action in actions)
|
||||
Event += action;
|
||||
|
||||
_disabled = false;
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.Error($"Error registering IPC Subscriber for {label}\n{e}");
|
||||
_subscriber = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary><inheritdoc cref="EventSubscriber.Enable"/> </summary>
|
||||
public void Enable()
|
||||
{
|
||||
if (_disabled && _subscriber != null)
|
||||
{
|
||||
foreach (var action in _delegates.Values)
|
||||
_subscriber.Subscribe(action);
|
||||
|
||||
_disabled = false;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary><inheritdoc cref="EventSubscriber.Disable"/> </summary>
|
||||
public void Disable()
|
||||
{
|
||||
if (!_disabled)
|
||||
{
|
||||
if (_subscriber != null)
|
||||
foreach (var action in _delegates.Values)
|
||||
_subscriber.Unsubscribe(action);
|
||||
|
||||
_disabled = true;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary><inheritdoc cref="EventSubscriber.Event"/> </summary>
|
||||
public event Action<T1, T2, T3> Event
|
||||
{
|
||||
add
|
||||
{
|
||||
if (_subscriber != null && !_delegates.ContainsKey(value))
|
||||
{
|
||||
void Action(T1 a, T2 b, T3 c)
|
||||
{
|
||||
try
|
||||
{
|
||||
value(a, b, c);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
_log.Error($"Exception invoking IPC event {_label}:\n{e}");
|
||||
}
|
||||
}
|
||||
|
||||
if (_delegates.TryAdd(value, Action) && !_disabled)
|
||||
_subscriber.Subscribe(Action);
|
||||
}
|
||||
}
|
||||
remove
|
||||
{
|
||||
if (_subscriber != null && _delegates.Remove(value, out var action))
|
||||
_subscriber.Unsubscribe(action);
|
||||
}
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
Disable();
|
||||
_subscriber = null;
|
||||
_delegates.Clear();
|
||||
}
|
||||
|
||||
~EventSubscriber()
|
||||
=> Dispose();
|
||||
}
|
224
Glamourer.Api/Helpers/FuncProvider.cs
Normal file
224
Glamourer.Api/Helpers/FuncProvider.cs
Normal file
@@ -0,0 +1,224 @@
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Ipc;
|
||||
|
||||
namespace Glamourer.Api.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// Specialized disposable Provider for Funcs.
|
||||
/// </summary>
|
||||
public sealed class FuncProvider<TRet> : IDisposable
|
||||
{
|
||||
private ICallGateProvider<TRet>? _provider;
|
||||
|
||||
public FuncProvider(IDalamudPluginInterface pi, string label, Func<TRet> func)
|
||||
{
|
||||
try
|
||||
{
|
||||
_provider = pi.GetIpcProvider<TRet>(label);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
PluginLogHelper.WriteError(pi, $"Error registering IPC Provider for {label}\n{e}");
|
||||
_provider = null;
|
||||
}
|
||||
|
||||
_provider?.RegisterFunc(func);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_provider?.UnregisterFunc();
|
||||
_provider = null;
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
~FuncProvider()
|
||||
=> Dispose();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="FuncProvider{TRet}"/>
|
||||
public sealed class FuncProvider<T1, TRet> : IDisposable
|
||||
{
|
||||
private ICallGateProvider<T1, TRet>? _provider;
|
||||
|
||||
public FuncProvider(IDalamudPluginInterface pi, string label, Func<T1, TRet> func)
|
||||
{
|
||||
try
|
||||
{
|
||||
_provider = pi.GetIpcProvider<T1, TRet>(label);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
PluginLogHelper.WriteError(pi, $"Error registering IPC Provider for {label}\n{e}");
|
||||
_provider = null;
|
||||
}
|
||||
|
||||
_provider?.RegisterFunc(func);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_provider?.UnregisterFunc();
|
||||
_provider = null;
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
~FuncProvider()
|
||||
=> Dispose();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="FuncProvider{TRet}"/>
|
||||
public sealed class FuncProvider<T1, T2, TRet> : IDisposable
|
||||
{
|
||||
private ICallGateProvider<T1, T2, TRet>? _provider;
|
||||
|
||||
public FuncProvider(IDalamudPluginInterface pi, string label, Func<T1, T2, TRet> func)
|
||||
{
|
||||
try
|
||||
{
|
||||
_provider = pi.GetIpcProvider<T1, T2, TRet>(label);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
PluginLogHelper.WriteError(pi, $"Error registering IPC Provider for {label}\n{e}");
|
||||
_provider = null;
|
||||
}
|
||||
|
||||
_provider?.RegisterFunc(func);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_provider?.UnregisterFunc();
|
||||
_provider = null;
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
~FuncProvider()
|
||||
=> Dispose();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="FuncProvider{TRet}"/>
|
||||
public sealed class FuncProvider<T1, T2, T3, TRet> : IDisposable
|
||||
{
|
||||
private ICallGateProvider<T1, T2, T3, TRet>? _provider;
|
||||
|
||||
public FuncProvider(IDalamudPluginInterface pi, string label, Func<T1, T2, T3, TRet> func)
|
||||
{
|
||||
try
|
||||
{
|
||||
_provider = pi.GetIpcProvider<T1, T2, T3, TRet>(label);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
PluginLogHelper.WriteError(pi, $"Error registering IPC Provider for {label}\n{e}");
|
||||
_provider = null;
|
||||
}
|
||||
|
||||
_provider?.RegisterFunc(func);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_provider?.UnregisterFunc();
|
||||
_provider = null;
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
~FuncProvider()
|
||||
=> Dispose();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="FuncProvider{TRet}"/>
|
||||
public sealed class FuncProvider<T1, T2, T3, T4, TRet> : IDisposable
|
||||
{
|
||||
private ICallGateProvider<T1, T2, T3, T4, TRet>? _provider;
|
||||
|
||||
public FuncProvider(IDalamudPluginInterface pi, string label, Func<T1, T2, T3, T4, TRet> func)
|
||||
{
|
||||
try
|
||||
{
|
||||
_provider = pi.GetIpcProvider<T1, T2, T3, T4, TRet>(label);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
PluginLogHelper.WriteError(pi, $"Error registering IPC Provider for {label}\n{e}");
|
||||
_provider = null;
|
||||
}
|
||||
|
||||
_provider?.RegisterFunc(func);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_provider?.UnregisterFunc();
|
||||
_provider = null;
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
~FuncProvider()
|
||||
=> Dispose();
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="FuncProvider{TRet}"/>
|
||||
public sealed class FuncProvider<T1, T2, T3, T4, T5, TRet> : IDisposable
|
||||
{
|
||||
private ICallGateProvider<T1, T2, T3, T4, T5, TRet>? _provider;
|
||||
|
||||
public FuncProvider(IDalamudPluginInterface pi, string label, Func<T1, T2, T3, T4, T5, TRet> func)
|
||||
{
|
||||
try
|
||||
{
|
||||
_provider = pi.GetIpcProvider<T1, T2, T3, T4, T5, TRet>(label);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
PluginLogHelper.WriteError(pi, $"Error registering IPC Provider for {label}\n{e}");
|
||||
_provider = null;
|
||||
}
|
||||
|
||||
_provider?.RegisterFunc(func);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_provider?.UnregisterFunc();
|
||||
_provider = null;
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
~FuncProvider()
|
||||
=> Dispose();
|
||||
}
|
||||
|
||||
|
||||
/// <inheritdoc cref="FuncProvider{TRet}"/>
|
||||
public sealed class FuncProvider<T1, T2, T3, T4, T5, T6, TRet> : IDisposable
|
||||
{
|
||||
private ICallGateProvider<T1, T2, T3, T4, T5, T6, TRet>? _provider;
|
||||
|
||||
public FuncProvider(IDalamudPluginInterface pi, string label, Func<T1, T2, T3, T4, T5, T6, TRet> func)
|
||||
{
|
||||
try
|
||||
{
|
||||
_provider = pi.GetIpcProvider<T1, T2, T3, T4, T5, T6, TRet>(label);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
PluginLogHelper.WriteError(pi, $"Error registering IPC Provider for {label}\n{e}");
|
||||
_provider = null;
|
||||
}
|
||||
|
||||
_provider?.RegisterFunc(func);
|
||||
}
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
_provider?.UnregisterFunc();
|
||||
_provider = null;
|
||||
GC.SuppressFinalize(this);
|
||||
}
|
||||
|
||||
~FuncProvider()
|
||||
=> Dispose();
|
||||
}
|
217
Glamourer.Api/Helpers/FuncSubscriber.cs
Normal file
217
Glamourer.Api/Helpers/FuncSubscriber.cs
Normal file
@@ -0,0 +1,217 @@
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Ipc;
|
||||
using Dalamud.Plugin.Ipc.Exceptions;
|
||||
|
||||
namespace Glamourer.Api.Helpers;
|
||||
|
||||
/// <summary>
|
||||
/// Specialized subscriber only allowing to invoke functions with a return.
|
||||
/// </summary>
|
||||
public class FuncSubscriber<TRet>
|
||||
{
|
||||
private readonly string _label;
|
||||
private readonly ICallGateSubscriber<TRet>? _subscriber;
|
||||
|
||||
/// <summary> Whether the subscriber could successfully be created. </summary>
|
||||
public bool Valid
|
||||
=> _subscriber != null;
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}"/>
|
||||
protected FuncSubscriber(IDalamudPluginInterface pi, string label)
|
||||
{
|
||||
_label = label;
|
||||
try
|
||||
{
|
||||
_subscriber = pi.GetIpcSubscriber<TRet>(label);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
PluginLogHelper.WriteError(pi, $"Error registering IPC Subscriber for {label}\n{e}");
|
||||
_subscriber = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary> Invoke the function. See the source of the subscriber for details.</summary>
|
||||
protected TRet Invoke()
|
||||
=> _subscriber != null ? _subscriber.InvokeFunc() : throw new IpcNotReadyError(_label);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}"/>
|
||||
public class FuncSubscriber<T1, TRet>
|
||||
{
|
||||
private readonly string _label;
|
||||
private readonly ICallGateSubscriber<T1, TRet>? _subscriber;
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}.Valid"/>
|
||||
public bool Valid
|
||||
=> _subscriber != null;
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}"/>
|
||||
protected FuncSubscriber(IDalamudPluginInterface pi, string label)
|
||||
{
|
||||
_label = label;
|
||||
try
|
||||
{
|
||||
_subscriber = pi.GetIpcSubscriber<T1, TRet>(label);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
PluginLogHelper.WriteError(pi, $"Error registering IPC Subscriber for {label}\n{e}");
|
||||
_subscriber = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}.Invoke"/>
|
||||
protected TRet Invoke(T1 a)
|
||||
=> _subscriber != null ? _subscriber.InvokeFunc(a) : throw new IpcNotReadyError(_label);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}"/>
|
||||
public class FuncSubscriber<T1, T2, TRet>
|
||||
{
|
||||
private readonly string _label;
|
||||
private readonly ICallGateSubscriber<T1, T2, TRet>? _subscriber;
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}.Valid"/>
|
||||
public bool Valid
|
||||
=> _subscriber != null;
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}"/>
|
||||
protected FuncSubscriber(IDalamudPluginInterface pi, string label)
|
||||
{
|
||||
_label = label;
|
||||
try
|
||||
{
|
||||
_subscriber = pi.GetIpcSubscriber<T1, T2, TRet>(label);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
PluginLogHelper.WriteError(pi, $"Error registering IPC Subscriber for {label}\n{e}");
|
||||
_subscriber = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}.Invoke"/>
|
||||
protected TRet Invoke(T1 a, T2 b)
|
||||
=> _subscriber != null ? _subscriber.InvokeFunc(a, b) : throw new IpcNotReadyError(_label);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}"/>
|
||||
public class FuncSubscriber<T1, T2, T3, TRet>
|
||||
{
|
||||
private readonly string _label;
|
||||
private readonly ICallGateSubscriber<T1, T2, T3, TRet>? _subscriber;
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}.Valid"/>
|
||||
public bool Valid
|
||||
=> _subscriber != null;
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}"/>
|
||||
protected FuncSubscriber(IDalamudPluginInterface pi, string label)
|
||||
{
|
||||
_label = label;
|
||||
try
|
||||
{
|
||||
_subscriber = pi.GetIpcSubscriber<T1, T2, T3, TRet>(label);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
PluginLogHelper.WriteError(pi, $"Error registering IPC Subscriber for {label}\n{e}");
|
||||
_subscriber = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}.Invoke"/>
|
||||
protected TRet Invoke(T1 a, T2 b, T3 c)
|
||||
=> _subscriber != null ? _subscriber.InvokeFunc(a, b, c) : throw new IpcNotReadyError(_label);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}"/>
|
||||
public class FuncSubscriber<T1, T2, T3, T4, TRet>
|
||||
{
|
||||
private readonly string _label;
|
||||
private readonly ICallGateSubscriber<T1, T2, T3, T4, TRet>? _subscriber;
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}.Valid"/>
|
||||
public bool Valid
|
||||
=> _subscriber != null;
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}"/>
|
||||
protected FuncSubscriber(IDalamudPluginInterface pi, string label)
|
||||
{
|
||||
_label = label;
|
||||
try
|
||||
{
|
||||
_subscriber = pi.GetIpcSubscriber<T1, T2, T3, T4, TRet>(label);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
PluginLogHelper.WriteError(pi, $"Error registering IPC Subscriber for {label}\n{e}");
|
||||
_subscriber = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}.Invoke"/>
|
||||
protected TRet Invoke(T1 a, T2 b, T3 c, T4 d)
|
||||
=> _subscriber != null ? _subscriber.InvokeFunc(a, b, c, d) : throw new IpcNotReadyError(_label);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}"/>
|
||||
public class FuncSubscriber<T1, T2, T3, T4, T5, TRet>
|
||||
{
|
||||
private readonly string _label;
|
||||
private readonly ICallGateSubscriber<T1, T2, T3, T4, T5, TRet>? _subscriber;
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}.Valid"/>
|
||||
public bool Valid
|
||||
=> _subscriber != null;
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}"/>
|
||||
protected FuncSubscriber(IDalamudPluginInterface pi, string label)
|
||||
{
|
||||
_label = label;
|
||||
try
|
||||
{
|
||||
_subscriber = pi.GetIpcSubscriber<T1, T2, T3, T4, T5, TRet>(label);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
PluginLogHelper.WriteError(pi, $"Error registering IPC Subscriber for {label}\n{e}");
|
||||
_subscriber = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}.Invoke"/>
|
||||
protected TRet Invoke(T1 a, T2 b, T3 c, T4 d, T5 e)
|
||||
=> _subscriber != null ? _subscriber.InvokeFunc(a, b, c, d, e) : throw new IpcNotReadyError(_label);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}"/>
|
||||
public class FuncSubscriber<T1, T2, T3, T4, T5, T6, TRet>
|
||||
{
|
||||
private readonly string _label;
|
||||
private readonly ICallGateSubscriber<T1, T2, T3, T4, T5, T6, TRet>? _subscriber;
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}.Valid"/>
|
||||
public bool Valid
|
||||
=> _subscriber != null;
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}"/>
|
||||
protected FuncSubscriber(IDalamudPluginInterface pi, string label)
|
||||
{
|
||||
_label = label;
|
||||
try
|
||||
{
|
||||
_subscriber = pi.GetIpcSubscriber<T1, T2, T3, T4, T5, T6, TRet>(label);
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
PluginLogHelper.WriteError(pi, $"Error registering IPC Subscriber for {label}\n{e}");
|
||||
_subscriber = null;
|
||||
}
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="FuncSubscriber{TRet}.Invoke"/>
|
||||
protected TRet Invoke(T1 a, T2 b, T3 c, T4 d, T5 e, T6 f)
|
||||
=> _subscriber != null ? _subscriber.InvokeFunc(a, b, c, d, e, f) : throw new IpcNotReadyError(_label);
|
||||
}
|
26
Glamourer.Api/Helpers/PluginLogHelper.cs
Normal file
26
Glamourer.Api/Helpers/PluginLogHelper.cs
Normal file
@@ -0,0 +1,26 @@
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.Plugin;
|
||||
using Dalamud.Plugin.Services;
|
||||
|
||||
namespace Glamourer.Api.Helpers;
|
||||
|
||||
internal class PluginLogHelper
|
||||
{
|
||||
[PluginService]
|
||||
private static IPluginLog? _log { get; set; }
|
||||
|
||||
private PluginLogHelper(IDalamudPluginInterface pi)
|
||||
=> pi.Inject(this);
|
||||
|
||||
public static void WriteError(IDalamudPluginInterface pi, string errorMessage)
|
||||
=> GetLog(pi).Error(errorMessage);
|
||||
|
||||
public static IPluginLog GetLog(IDalamudPluginInterface pi)
|
||||
{
|
||||
if (_log != null)
|
||||
return _log;
|
||||
|
||||
_ = new PluginLogHelper(pi);
|
||||
return _log!;
|
||||
}
|
||||
}
|
52
Glamourer.Api/IpcSubscribers/Designs.cs
Normal file
52
Glamourer.Api/IpcSubscribers/Designs.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Dalamud.Plugin;
|
||||
using Glamourer.Api.Api;
|
||||
using Glamourer.Api.Enums;
|
||||
using Glamourer.Api.Helpers;
|
||||
|
||||
namespace Glamourer.Api.IpcSubscribers;
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiDesigns.GetDesignList"/>
|
||||
public sealed class GetDesignList(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<Dictionary<Guid, string>>(pi, Label)
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(GetDesignList)}.V2";
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiDesigns.GetDesignList"/>
|
||||
public new Dictionary<Guid, string> Invoke()
|
||||
=> base.Invoke();
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static FuncProvider<Dictionary<Guid, string>> Provider(IDalamudPluginInterface pi, IGlamourerApiDesigns api)
|
||||
=> new(pi, Label, api.GetDesignList);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiDesigns.ApplyDesign"/>
|
||||
public sealed class ApplyDesign(IDalamudPluginInterface pi) : FuncSubscriber<Guid, int, uint, ulong, int>(pi, Label)
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(ApplyDesign)}";
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiDesigns.ApplyDesign"/>
|
||||
public GlamourerApiEc Invoke(Guid designId, int objectIndex, uint key = 0, ApplyFlag flags = ApplyFlagEx.DesignDefault)
|
||||
=> (GlamourerApiEc)Invoke(designId, objectIndex, key, (ulong)flags);
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static FuncProvider<Guid, int, uint, ulong, int> Provider(IDalamudPluginInterface pi, IGlamourerApiDesigns api)
|
||||
=> new(pi, Label, (a, b, c, d) => (int)api.ApplyDesign(a, b, c, (ApplyFlag)d));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiDesigns.ApplyDesignName"/>
|
||||
public sealed class ApplyDesignName(IDalamudPluginInterface pi) : FuncSubscriber<Guid, string, uint, ulong, int>(pi, Label)
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(ApplyDesignName)}";
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiDesigns.ApplyDesignName"/>
|
||||
public GlamourerApiEc Invoke(Guid designId, string objectName, uint key = 0, ApplyFlag flags = ApplyFlagEx.DesignDefault)
|
||||
=> (GlamourerApiEc)Invoke(designId, objectName, key, (ulong)flags);
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static FuncProvider<Guid, string, uint, ulong, int> Provider(IDalamudPluginInterface pi, IGlamourerApiDesigns api)
|
||||
=> new(pi, Label, (a, b, c, d) => (int)api.ApplyDesignName(a, b, c, (ApplyFlag)d));
|
||||
}
|
110
Glamourer.Api/IpcSubscribers/Items.cs
Normal file
110
Glamourer.Api/IpcSubscribers/Items.cs
Normal file
@@ -0,0 +1,110 @@
|
||||
using Dalamud.Plugin;
|
||||
using Glamourer.Api.Api;
|
||||
using Glamourer.Api.Enums;
|
||||
using Glamourer.Api.Helpers;
|
||||
|
||||
namespace Glamourer.Api.IpcSubscribers;
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiItems.SetItem"/>
|
||||
public sealed class SetItem(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<int, byte, ulong, IReadOnlyList<byte>, uint, ulong, int>(pi, Label)
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(SetItem)}.V3";
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiItems.SetItem"/>
|
||||
public GlamourerApiEc Invoke(int objectIndex, ApiEquipSlot slot, ulong itemId, IReadOnlyList<byte> stain, uint key = 0,
|
||||
ApplyFlag flags = ApplyFlag.Once)
|
||||
=> (GlamourerApiEc)Invoke(objectIndex, (byte)slot, itemId, stain, key, (ulong)flags);
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static FuncProvider<int, byte, ulong, IReadOnlyList<byte>, uint, ulong, int> Provider(IDalamudPluginInterface pi,
|
||||
IGlamourerApiItems api)
|
||||
=> new(pi, Label, (a, b, c, d, e, f) => (int)api.SetItem(a, (ApiEquipSlot)b, c, d, e, (ApplyFlag)f));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiItems.SetItemName"/>
|
||||
public sealed class SetItemName(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<string, byte, ulong, IReadOnlyList<byte>, uint, ulong, int>(pi, Label)
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(SetItemName)}.V2";
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiItems.SetItem"/>
|
||||
public GlamourerApiEc Invoke(string objectName, ApiEquipSlot slot, ulong itemId, IReadOnlyList<byte> stain, uint key = 0,
|
||||
ApplyFlag flags = ApplyFlag.Once)
|
||||
=> (GlamourerApiEc)Invoke(objectName, (byte)slot, itemId, stain, key, (ulong)flags);
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static FuncProvider<string, byte, ulong, IReadOnlyList<byte>, uint, ulong, int> Provider(IDalamudPluginInterface pi,
|
||||
IGlamourerApiItems api)
|
||||
=> new(pi, Label, (a, b, c, d, e, f) => (int)api.SetItemName(a, (ApiEquipSlot)b, c, d, e, (ApplyFlag)f));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiItems.SetBonusItem"/>
|
||||
public sealed class SetBonusItem(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<int, byte, ulong, uint, ulong, int>(pi, Label)
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(SetBonusItem)}";
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiItems.SetBonusItem"/>
|
||||
public GlamourerApiEc Invoke(int objectIndex, ApiBonusSlot slot, ulong itemId, uint key = 0, ApplyFlag flags = ApplyFlag.Once)
|
||||
=> (GlamourerApiEc)Invoke(objectIndex, (byte)slot, itemId, key, (ulong)flags);
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static FuncProvider<int, byte, ulong, uint, ulong, int> Provider(IDalamudPluginInterface pi, IGlamourerApiItems api)
|
||||
=> new(pi, Label, (a, b, c, d, e) => (int)api.SetBonusItem(a, (ApiBonusSlot)b, c, d, (ApplyFlag)e));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiItems.SetBonusItemName"/>
|
||||
public sealed class SetBonusItemName(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<string, byte, ulong, uint, ulong, int>(pi, Label)
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(SetBonusItemName)}.V2";
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiItems.SetBonusItemName"/>
|
||||
public GlamourerApiEc Invoke(string objectName, ApiBonusSlot slot, ulong itemId, uint key = 0, ApplyFlag flags = ApplyFlag.Once)
|
||||
=> (GlamourerApiEc)Invoke(objectName, (byte)slot, itemId, key, (ulong)flags);
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static FuncProvider<string, byte, ulong, uint, ulong, int> Provider(IDalamudPluginInterface pi, IGlamourerApiItems api)
|
||||
=> new(pi, Label, (a, b, c, d, e) => (int)api.SetBonusItemName(a, (ApiBonusSlot)b, c, d, (ApplyFlag)e));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiItems.SetMetaState"/>
|
||||
public sealed class SetMetaState(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<int, ulong, bool, uint, ulong, int>(pi, Label)
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(SetMetaState)}";
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiItems.SetMetaState"/>
|
||||
public GlamourerApiEc Invoke(int objectIndex, MetaFlag types, bool newValue, uint key = 0,
|
||||
ApplyFlag flags = ApplyFlag.Once)
|
||||
=> (GlamourerApiEc)Invoke(objectIndex, (ulong)types, newValue, key, (ulong)flags);
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static FuncProvider<int, ulong, bool, uint, ulong, int> Provider(IDalamudPluginInterface pi,
|
||||
IGlamourerApiItems api)
|
||||
=> new(pi, Label, (a, b, c, d, e) => (int)api.SetMetaState(a, (MetaFlag)b, c, d, (ApplyFlag)e));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiItems.SetMetaStateName"/>
|
||||
public sealed class SetMetaStateName(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<string, ulong, bool, uint, ulong, int>(pi, Label)
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(SetMetaStateName)}";
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiItems.SetMetaStateName"/>
|
||||
public GlamourerApiEc Invoke(string objectName, MetaFlag types, bool newValue, uint key = 0,
|
||||
ApplyFlag flags = ApplyFlag.Once)
|
||||
=> (GlamourerApiEc)Invoke(objectName, (ulong)types, newValue, key, (ulong)flags);
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static FuncProvider<string, ulong, bool, uint, ulong, int> Provider(IDalamudPluginInterface pi,
|
||||
IGlamourerApiItems api)
|
||||
=> new(pi, Label, (a, b, c, d, e) => (int)api.SetMetaStateName(a, (MetaFlag)b, c, d, (ApplyFlag)e));
|
||||
}
|
52
Glamourer.Api/IpcSubscribers/Legacy/Designs.cs
Normal file
52
Glamourer.Api/IpcSubscribers/Legacy/Designs.cs
Normal file
@@ -0,0 +1,52 @@
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Dalamud.Plugin;
|
||||
using Glamourer.Api.Helpers;
|
||||
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
namespace Glamourer.Api.IpcSubscribers.Legacy;
|
||||
|
||||
public sealed class GetDesignList(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<(string Name, Guid Identifier)[]>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(GetDesignList)}";
|
||||
|
||||
public new (string Name, Guid Identifier)[] Invoke()
|
||||
=> base.Invoke();
|
||||
}
|
||||
|
||||
public sealed class ApplyByGuid(IDalamudPluginInterface pi)
|
||||
: ActionSubscriber<Guid, string>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(ApplyByGuid)}";
|
||||
|
||||
public new void Invoke(Guid design, string name)
|
||||
=> base.Invoke(design, name);
|
||||
}
|
||||
|
||||
public sealed class ApplyByGuidOnce(IDalamudPluginInterface pi)
|
||||
: ActionSubscriber<Guid, string>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(ApplyByGuidOnce)}";
|
||||
|
||||
public new void Invoke(Guid design, string name)
|
||||
=> base.Invoke(design, name);
|
||||
}
|
||||
|
||||
public sealed class ApplyByGuidToCharacter(IDalamudPluginInterface pi)
|
||||
: ActionSubscriber<Guid, ICharacter?>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(ApplyByGuidToCharacter)}";
|
||||
|
||||
public new void Invoke(Guid design, ICharacter? character)
|
||||
=> base.Invoke(design, character);
|
||||
}
|
||||
|
||||
public sealed class ApplyByGuidOnceToCharacter(IDalamudPluginInterface pi)
|
||||
: ActionSubscriber<Guid, ICharacter?>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(ApplyByGuidOnceToCharacter)}";
|
||||
|
||||
public new void Invoke(Guid design, ICharacter? character)
|
||||
=> base.Invoke(design, character);
|
||||
}
|
66
Glamourer.Api/IpcSubscribers/Legacy/Items.cs
Normal file
66
Glamourer.Api/IpcSubscribers/Legacy/Items.cs
Normal file
@@ -0,0 +1,66 @@
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Dalamud.Plugin;
|
||||
using Glamourer.Api.Api;
|
||||
using Glamourer.Api.Enums;
|
||||
using Glamourer.Api.Helpers;
|
||||
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
namespace Glamourer.Api.IpcSubscribers.Legacy;
|
||||
|
||||
public sealed class SetItem(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<ICharacter?, byte, ulong, byte, uint, int>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(SetItem)}";
|
||||
|
||||
public new GlamourerApiEc Invoke(ICharacter? character, byte slot, ulong itemId, byte stainId, uint key)
|
||||
=> (GlamourerApiEc)base.Invoke(character, slot, itemId, stainId, key);
|
||||
}
|
||||
|
||||
public sealed class SetItemOnce(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<ICharacter?, byte, ulong, byte, uint, int>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(SetItemOnce)}";
|
||||
|
||||
public new GlamourerApiEc Invoke(ICharacter? character, byte slot, ulong itemId, byte stainId, uint key)
|
||||
=> (GlamourerApiEc)base.Invoke(character, slot, itemId, stainId, key);
|
||||
}
|
||||
|
||||
public sealed class SetItemByActorName(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<string, byte, ulong, byte, uint, int>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(SetItemByActorName)}";
|
||||
|
||||
public new GlamourerApiEc Invoke(string actorName, byte slot, ulong itemId, byte stainId, uint key)
|
||||
=> (GlamourerApiEc)base.Invoke(actorName, slot, itemId, stainId, key);
|
||||
}
|
||||
|
||||
public sealed class SetItemOnceByActorName(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<string, byte, ulong, byte, uint, int>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(SetItemOnceByActorName)}";
|
||||
|
||||
public new GlamourerApiEc Invoke(string actorName, byte slot, ulong itemId, byte stainId, uint key)
|
||||
=> (GlamourerApiEc)base.Invoke(actorName, slot, itemId, stainId, key);
|
||||
}
|
||||
|
||||
public sealed class SetItemV2(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<int, byte, ulong, byte, uint, ulong, int>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(SetItem)}.V2";
|
||||
|
||||
public GlamourerApiEc Invoke(int objectIndex, ApiEquipSlot slot, ulong itemId, byte stain, uint key = 0, ApplyFlag flags = ApplyFlag.Once)
|
||||
=> (GlamourerApiEc)Invoke(objectIndex, (byte)slot, itemId, stain, key, (ulong)flags);
|
||||
}
|
||||
|
||||
public sealed class SetItemName(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<string, byte, ulong, byte, uint, ulong, int>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(SetItemName)}";
|
||||
|
||||
public GlamourerApiEc Invoke(string objectName, ApiEquipSlot slot, ulong itemId, byte stain, uint key = 0, ApplyFlag flags = ApplyFlag.Once)
|
||||
=> (GlamourerApiEc)Invoke(objectName, (byte)slot, itemId, stain, key, (ulong)flags);
|
||||
|
||||
public static FuncProvider<string, byte, ulong, byte, uint, ulong, int> Provider(IDalamudPluginInterface pi, IGlamourerApiItems api)
|
||||
=> new(pi, Label, (a, b, c, d, e, f) => (int)api.SetItemName(a, (ApiEquipSlot)b, c, [d], e, (ApplyFlag)f));
|
||||
}
|
15
Glamourer.Api/IpcSubscribers/Legacy/PluginState.cs
Normal file
15
Glamourer.Api/IpcSubscribers/Legacy/PluginState.cs
Normal file
@@ -0,0 +1,15 @@
|
||||
using Dalamud.Plugin;
|
||||
using Glamourer.Api.Helpers;
|
||||
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
namespace Glamourer.Api.IpcSubscribers.Legacy;
|
||||
|
||||
public sealed class ApiVersions(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<(int, int)>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(ApiVersions)}";
|
||||
|
||||
public new (int Major, int Minor) Invoke()
|
||||
=> base.Invoke();
|
||||
}
|
250
Glamourer.Api/IpcSubscribers/Legacy/State.cs
Normal file
250
Glamourer.Api/IpcSubscribers/Legacy/State.cs
Normal file
@@ -0,0 +1,250 @@
|
||||
using Dalamud.Game.ClientState.Objects.Types;
|
||||
using Dalamud.Plugin;
|
||||
using Glamourer.Api.Helpers;
|
||||
|
||||
#pragma warning disable CS1591 // Missing XML comment for publicly visible type or member
|
||||
|
||||
namespace Glamourer.Api.IpcSubscribers.Legacy;
|
||||
|
||||
public sealed class Revert(IDalamudPluginInterface pi)
|
||||
: ActionSubscriber<string>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(Revert)}";
|
||||
|
||||
public new void Invoke(string characterName)
|
||||
=> base.Invoke(characterName);
|
||||
}
|
||||
|
||||
public sealed class RevertCharacter(IDalamudPluginInterface pi)
|
||||
: ActionSubscriber<ICharacter?>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(RevertCharacter)}";
|
||||
|
||||
public new void Invoke(ICharacter? character)
|
||||
=> base.Invoke(character);
|
||||
}
|
||||
|
||||
public sealed class RevertLock(IDalamudPluginInterface pi)
|
||||
: ActionSubscriber<string, uint>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(RevertLock)}";
|
||||
|
||||
public new void Invoke(string characterName, uint key)
|
||||
=> base.Invoke(characterName, key);
|
||||
}
|
||||
|
||||
public sealed class RevertCharacterLock(IDalamudPluginInterface pi)
|
||||
: ActionSubscriber<ICharacter?, uint>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(RevertCharacterLock)}";
|
||||
|
||||
public new void Invoke(ICharacter? character, uint key)
|
||||
=> base.Invoke(character, key);
|
||||
}
|
||||
|
||||
public sealed class RevertToAutomation(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<string, uint, bool>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(RevertToAutomation)}";
|
||||
|
||||
public new bool Invoke(string characterName, uint key)
|
||||
=> base.Invoke(characterName, key);
|
||||
}
|
||||
|
||||
public sealed class RevertToAutomationCharacter(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<ICharacter?, uint, bool>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(RevertToAutomationCharacter)}";
|
||||
|
||||
public new bool Invoke(ICharacter? character, uint key)
|
||||
=> base.Invoke(character, key);
|
||||
}
|
||||
|
||||
public sealed class Unlock(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<ICharacter?, uint, bool>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(Unlock)}";
|
||||
|
||||
public new bool Invoke(ICharacter? character, uint key)
|
||||
=> base.Invoke(character, key);
|
||||
}
|
||||
|
||||
public sealed class UnlockName(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<string, uint, bool>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(UnlockName)}";
|
||||
|
||||
public new bool Invoke(string characterName, uint key)
|
||||
=> base.Invoke(characterName, key);
|
||||
}
|
||||
|
||||
public static class StateChanged
|
||||
{
|
||||
public const string Label = $"Penumbra.{nameof(StateChanged)}";
|
||||
|
||||
public static EventSubscriber<int, nint, Lazy<string>> Subscriber(IDalamudPluginInterface pi,
|
||||
params Action<int, nint, Lazy<string>>[] actions)
|
||||
=> new(pi, Label, actions);
|
||||
}
|
||||
|
||||
public sealed class GetAllCustomization(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<string, string?>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(GetAllCustomization)}";
|
||||
|
||||
public new string? Invoke(string characterName)
|
||||
=> base.Invoke(characterName);
|
||||
}
|
||||
|
||||
public sealed class GetAllCustomizationFromCharacter(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<ICharacter?, string?>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(GetAllCustomizationFromCharacter)}";
|
||||
|
||||
public new string? Invoke(ICharacter? character)
|
||||
=> base.Invoke(character);
|
||||
}
|
||||
|
||||
public sealed class GetAllCustomizationLocked(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<string, uint, string?>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(GetAllCustomizationLocked)}";
|
||||
|
||||
public new string? Invoke(string characterName, uint key)
|
||||
=> base.Invoke(characterName, key);
|
||||
}
|
||||
|
||||
public sealed class GetAllCustomizationFromLockedCharacter(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<ICharacter?, uint, string?>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(GetAllCustomizationFromLockedCharacter)}";
|
||||
|
||||
public new string? Invoke(ICharacter? character, uint key)
|
||||
=> base.Invoke(character, key);
|
||||
}
|
||||
|
||||
public sealed class ApplyAll(IDalamudPluginInterface pi)
|
||||
: ActionSubscriber<string, string>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(ApplyAll)}";
|
||||
|
||||
public new void Invoke(string characterName, string stateBase64)
|
||||
=> base.Invoke(characterName, stateBase64);
|
||||
}
|
||||
|
||||
public sealed class ApplyAllOnce(IDalamudPluginInterface pi)
|
||||
: ActionSubscriber<string, string>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(ApplyAllOnce)}";
|
||||
|
||||
public new void Invoke(string characterName, string stateBase64)
|
||||
=> base.Invoke(characterName, stateBase64);
|
||||
}
|
||||
|
||||
public sealed class ApplyAllToCharacter(IDalamudPluginInterface pi)
|
||||
: ActionSubscriber<ICharacter?, string>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(ApplyAllToCharacter)}";
|
||||
|
||||
public new void Invoke(ICharacter? character, string stateBase64)
|
||||
=> base.Invoke(character, stateBase64);
|
||||
}
|
||||
|
||||
public sealed class ApplyAllOnceToCharacter(IDalamudPluginInterface pi)
|
||||
: ActionSubscriber<ICharacter?, string>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(ApplyAllOnceToCharacter)}";
|
||||
|
||||
public new void Invoke(ICharacter? character, string stateBase64)
|
||||
=> base.Invoke(character, stateBase64);
|
||||
}
|
||||
|
||||
public sealed class ApplyOnlyEquipment(IDalamudPluginInterface pi)
|
||||
: ActionSubscriber<string, string>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(ApplyOnlyEquipment)}";
|
||||
|
||||
public new void Invoke(string characterName, string stateBase64)
|
||||
=> base.Invoke(characterName, stateBase64);
|
||||
}
|
||||
|
||||
public sealed class ApplyOnlyEquipmentToCharacter(IDalamudPluginInterface pi)
|
||||
: ActionSubscriber<ICharacter?, string>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(ApplyOnlyEquipmentToCharacter)}";
|
||||
|
||||
public new void Invoke(ICharacter? character, string stateBase64)
|
||||
=> base.Invoke(character, stateBase64);
|
||||
}
|
||||
|
||||
public sealed class ApplyOnlyCustomization(IDalamudPluginInterface pi)
|
||||
: ActionSubscriber<string, string>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(ApplyOnlyCustomization)}";
|
||||
|
||||
public new void Invoke(string characterName, string stateBase64)
|
||||
=> base.Invoke(characterName, stateBase64);
|
||||
}
|
||||
|
||||
public sealed class ApplyOnlyCustomizationToCharacter(IDalamudPluginInterface pi)
|
||||
: ActionSubscriber<ICharacter?, string>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(ApplyOnlyCustomizationToCharacter)}";
|
||||
|
||||
public new void Invoke(ICharacter? character, string stateBase64)
|
||||
=> base.Invoke(character, stateBase64);
|
||||
}
|
||||
|
||||
public sealed class ApplyAllLock(IDalamudPluginInterface pi)
|
||||
: ActionSubscriber<string, string, uint>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(ApplyAllLock)}";
|
||||
|
||||
public new void Invoke(string characterName, string stateBase64, uint key)
|
||||
=> base.Invoke(characterName, stateBase64, key);
|
||||
}
|
||||
|
||||
public sealed class ApplyAllToCharacterLock(IDalamudPluginInterface pi)
|
||||
: ActionSubscriber<ICharacter?, string, uint>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(ApplyAllToCharacterLock)}";
|
||||
|
||||
public new void Invoke(ICharacter? character, string stateBase64, uint key)
|
||||
=> base.Invoke(character, stateBase64, key);
|
||||
}
|
||||
|
||||
public sealed class ApplyOnlyEquipmentLock(IDalamudPluginInterface pi)
|
||||
: ActionSubscriber<string, string, uint>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(ApplyOnlyEquipmentLock)}";
|
||||
|
||||
public new void Invoke(string characterName, string stateBase64, uint key)
|
||||
=> base.Invoke(characterName, stateBase64, key);
|
||||
}
|
||||
|
||||
public sealed class ApplyOnlyEquipmentToCharacterLock(IDalamudPluginInterface pi)
|
||||
: ActionSubscriber<ICharacter?, string, uint>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(ApplyOnlyEquipmentToCharacterLock)}";
|
||||
|
||||
public new void Invoke(ICharacter? character, string stateBase64, uint key)
|
||||
=> base.Invoke(character, stateBase64, key);
|
||||
}
|
||||
|
||||
public sealed class ApplyOnlyCustomizationLock(IDalamudPluginInterface pi)
|
||||
: ActionSubscriber<string, string, uint>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(ApplyOnlyCustomizationLock)}";
|
||||
|
||||
public new void Invoke(string characterName, string stateBase64, uint key)
|
||||
=> base.Invoke(characterName, stateBase64, key);
|
||||
}
|
||||
|
||||
public sealed class ApplyOnlyCustomizationToCharacterLock(IDalamudPluginInterface pi)
|
||||
: ActionSubscriber<ICharacter?, string, uint>(pi, Label)
|
||||
{
|
||||
public const string Label = $"Glamourer.{nameof(ApplyOnlyCustomizationToCharacterLock)}";
|
||||
|
||||
public new void Invoke(ICharacter? character, string stateBase64, uint key)
|
||||
=> base.Invoke(character, stateBase64, key);
|
||||
}
|
51
Glamourer.Api/IpcSubscribers/PluginState.cs
Normal file
51
Glamourer.Api/IpcSubscribers/PluginState.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
using Dalamud.Plugin;
|
||||
using Glamourer.Api.Api;
|
||||
using Glamourer.Api.Helpers;
|
||||
|
||||
namespace Glamourer.Api.IpcSubscribers;
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiBase.ApiVersion"/>
|
||||
public sealed class ApiVersion(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<(int, int)>(pi, Label)
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(ApiVersion)}.V2";
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiBase.ApiVersion"/>
|
||||
public new (int Major, int Minor) Invoke()
|
||||
=> base.Invoke();
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static FuncProvider<(int, int)> Provider(IDalamudPluginInterface pi, IGlamourerApiBase api)
|
||||
=> new(pi, Label, () => api.ApiVersion);
|
||||
}
|
||||
|
||||
/// <summary> Triggered when the Glamourer API is initialized and ready. </summary>
|
||||
public static class Initialized
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(Initialized)}";
|
||||
|
||||
/// <summary> Create a new event subscriber. </summary>
|
||||
public static EventSubscriber Subscriber(IDalamudPluginInterface pi, params Action[] actions)
|
||||
=> new(pi, Label, actions);
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static EventProvider Provider(IDalamudPluginInterface pi)
|
||||
=> new(pi, Label);
|
||||
}
|
||||
|
||||
/// <summary> Triggered when the Glamourer API is fully disposed and unavailable. </summary>
|
||||
public static class Disposed
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(Disposed)}";
|
||||
|
||||
/// <summary> Create a new event subscriber. </summary>
|
||||
public static EventSubscriber Subscriber(IDalamudPluginInterface pi, params Action[] actions)
|
||||
=> new(pi, Label, actions);
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static EventProvider Provider(IDalamudPluginInterface pi)
|
||||
=> new(pi, Label);
|
||||
}
|
311
Glamourer.Api/IpcSubscribers/State.cs
Normal file
311
Glamourer.Api/IpcSubscribers/State.cs
Normal file
@@ -0,0 +1,311 @@
|
||||
using Dalamud.Plugin;
|
||||
using Glamourer.Api.Api;
|
||||
using Glamourer.Api.Enums;
|
||||
using Glamourer.Api.Helpers;
|
||||
using Newtonsoft.Json.Linq;
|
||||
|
||||
namespace Glamourer.Api.IpcSubscribers;
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.GetState"/>
|
||||
public sealed class GetState(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<int, uint, (int, JObject?)>(pi, Label)
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(GetState)}";
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.GetState"/>
|
||||
public new (GlamourerApiEc, JObject?) Invoke(int objectIndex, uint key = 0)
|
||||
{
|
||||
var (ec, data) = base.Invoke(objectIndex, key);
|
||||
return ((GlamourerApiEc)ec, data);
|
||||
}
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static FuncProvider<int, uint, (int, JObject?)> Provider(IDalamudPluginInterface pi, IGlamourerApiState api)
|
||||
=> new(pi, Label, (a, b) =>
|
||||
{
|
||||
var (ec, data) = api.GetState(a, b);
|
||||
return ((int)ec, data);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.GetStateName"/>
|
||||
public sealed class GetStateName(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<string, uint, (int, JObject?)>(pi, Label)
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(GetStateName)}";
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.GetStateName"/>
|
||||
public new (GlamourerApiEc, JObject?) Invoke(string objectName, uint key = 0)
|
||||
{
|
||||
var (ec, data) = base.Invoke(objectName, key);
|
||||
return ((GlamourerApiEc)ec, data);
|
||||
}
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static FuncProvider<string, uint, (int, JObject?)> Provider(IDalamudPluginInterface pi, IGlamourerApiState api)
|
||||
=> new(pi, Label, (i, k) =>
|
||||
{
|
||||
var (ec, data) = api.GetStateName(i, k);
|
||||
return ((int)ec, data);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.GetStateBase64"/>
|
||||
public sealed class GetStateBase64(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<int, uint, (int, string?)>(pi, Label)
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(GetStateBase64)}";
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.GetStateBase64"/>
|
||||
public new (GlamourerApiEc, string?) Invoke(int objectIndex, uint key = 0)
|
||||
{
|
||||
var (ec, data) = base.Invoke(objectIndex, key);
|
||||
return ((GlamourerApiEc)ec, data);
|
||||
}
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static FuncProvider<int, uint, (int, string?)> Provider(IDalamudPluginInterface pi, IGlamourerApiState api)
|
||||
=> new(pi, Label, (a, b) =>
|
||||
{
|
||||
var (ec, data) = api.GetStateBase64(a, b);
|
||||
return ((int)ec, data);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.GetStateBase64Name"/>
|
||||
public sealed class GetStateBase64Name(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<string, uint, (int, string?)>(pi, Label)
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(GetStateBase64Name)}";
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.GetStateBase64Name"/>
|
||||
public new (GlamourerApiEc, string?) Invoke(string objectName, uint key = 0)
|
||||
{
|
||||
var (ec, data) = base.Invoke(objectName, key);
|
||||
return ((GlamourerApiEc)ec, data);
|
||||
}
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static FuncProvider<string, uint, (int, string?)> Provider(IDalamudPluginInterface pi, IGlamourerApiState api)
|
||||
=> new(pi, Label, (i, k) =>
|
||||
{
|
||||
var (ec, data) = api.GetStateBase64Name(i, k);
|
||||
return ((int)ec, data);
|
||||
});
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.ApplyState"/>
|
||||
public sealed class ApplyState(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<object, int, uint, ulong, int>(pi, Label)
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(ApplyState)}";
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.ApplyState"/>
|
||||
public GlamourerApiEc Invoke(JObject state, int objectIndex, uint key = 0, ApplyFlag flags = ApplyFlagEx.StateDefault)
|
||||
=> (GlamourerApiEc)Invoke(state, objectIndex, key, (ulong)flags);
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.ApplyState"/>
|
||||
public GlamourerApiEc Invoke(string base64State, int objectIndex, uint key = 0, ApplyFlag flags = ApplyFlagEx.StateDefault)
|
||||
=> (GlamourerApiEc)Invoke(base64State, objectIndex, key, (ulong)flags);
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static FuncProvider<object, int, uint, ulong, int> Provider(IDalamudPluginInterface pi, IGlamourerApiState api)
|
||||
=> new(pi, Label, (a, b, c, d) => (int)api.ApplyState(a, b, c, (ApplyFlag)d));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.ApplyStateName"/>
|
||||
public sealed class ApplyStateName(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<object, string, uint, ulong, int>(pi, Label)
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(ApplyStateName)}";
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.ApplyState"/>
|
||||
public GlamourerApiEc Invoke(JObject state, string objectName, uint key = 0, ApplyFlag flags = ApplyFlagEx.StateDefault)
|
||||
=> (GlamourerApiEc)Invoke(state, objectName, key, (ulong)flags);
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.ApplyState"/>
|
||||
public GlamourerApiEc Invoke(string base64State, string objectName, uint key = 0, ApplyFlag flags = ApplyFlagEx.StateDefault)
|
||||
=> (GlamourerApiEc)Invoke(base64State, objectName, key, (ulong)flags);
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static FuncProvider<object, string, uint, ulong, int> Provider(IDalamudPluginInterface pi, IGlamourerApiState api)
|
||||
=> new(pi, Label, (a, b, c, d) => (int)api.ApplyStateName(a, b, c, (ApplyFlag)d));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.RevertState"/>
|
||||
public sealed class RevertState(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<int, uint, ulong, int>(pi, Label)
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(RevertState)}";
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.RevertState"/>
|
||||
public GlamourerApiEc Invoke(int objectIndex, uint key = 0, ApplyFlag flags = ApplyFlagEx.RevertDefault)
|
||||
=> (GlamourerApiEc)Invoke(objectIndex, key, (ulong)flags);
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static FuncProvider<int, uint, ulong, int> Provider(IDalamudPluginInterface pi, IGlamourerApiState api)
|
||||
=> new(pi, Label, (a, b, c) => (int)api.RevertState(a, b, (ApplyFlag)c));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.RevertStateName"/>
|
||||
public sealed class RevertStateName(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<string, uint, ulong, int>(pi, Label)
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(RevertStateName)}";
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.RevertStateName"/>
|
||||
public GlamourerApiEc Invoke(string objectName, uint key = 0, ApplyFlag flags = ApplyFlagEx.RevertDefault)
|
||||
=> (GlamourerApiEc)Invoke(objectName, key, (ulong)flags);
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static FuncProvider<string, uint, ulong, int> Provider(IDalamudPluginInterface pi, IGlamourerApiState api)
|
||||
=> new(pi, Label, (a, b, c) => (int)api.RevertStateName(a, b, (ApplyFlag)c));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.UnlockState"/>
|
||||
public sealed class UnlockState(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<int, uint, int>(pi, Label)
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(UnlockState)}";
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.UnlockState"/>
|
||||
public new GlamourerApiEc Invoke(int objectIndex, uint key = 0)
|
||||
=> (GlamourerApiEc)base.Invoke(objectIndex, key);
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static FuncProvider<int, uint, int> Provider(IDalamudPluginInterface pi, IGlamourerApiState api)
|
||||
=> new(pi, Label, (a, b) => (int)api.UnlockState(a, b));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.UnlockStateName"/>
|
||||
public sealed class UnlockStateName(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<string, uint, int>(pi, Label)
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(UnlockStateName)}";
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.UnlockStateName"/>
|
||||
public new GlamourerApiEc Invoke(string objectName, uint key = 0)
|
||||
=> (GlamourerApiEc)base.Invoke(objectName, key);
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static FuncProvider<string, uint, int> Provider(IDalamudPluginInterface pi, IGlamourerApiState api)
|
||||
=> new(pi, Label, (a, b) => (int)api.UnlockStateName(a, b));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.UnlockAll"/>
|
||||
public sealed class UnlockAll(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<uint, int>(pi, Label)
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(UnlockAll)}";
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.UnlockAll"/>
|
||||
public new int Invoke(uint key)
|
||||
=> base.Invoke(key);
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static FuncProvider<uint, int> Provider(IDalamudPluginInterface pi, IGlamourerApiState api)
|
||||
=> new(pi, Label, api.UnlockAll);
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.RevertToAutomation"/>
|
||||
public sealed class RevertToAutomation(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<int, uint, ulong, int>(pi, Label)
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(RevertToAutomation)}.V2";
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.RevertToAutomation"/>
|
||||
public GlamourerApiEc Invoke(int objectIndex, uint key = 0, ApplyFlag flags = ApplyFlagEx.RevertDefault)
|
||||
=> (GlamourerApiEc)Invoke(objectIndex, key, (ulong)flags);
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static FuncProvider<int, uint, ulong, int> Provider(IDalamudPluginInterface pi, IGlamourerApiState api)
|
||||
=> new(pi, Label, (a, b, c) => (int)api.RevertToAutomation(a, b, (ApplyFlag)c));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.RevertToAutomationName"/>
|
||||
public sealed class RevertToAutomationName(IDalamudPluginInterface pi)
|
||||
: FuncSubscriber<string, uint, ulong, int>(pi, Label)
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Glamourer.{nameof(RevertToAutomationName)}";
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.RevertToAutomationName"/>
|
||||
public GlamourerApiEc Invoke(string objectName, uint key = 0, ApplyFlag flags = ApplyFlagEx.RevertDefault)
|
||||
=> (GlamourerApiEc)Invoke(objectName, key, (ulong)flags);
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static FuncProvider<string, uint, ulong, int> Provider(IDalamudPluginInterface pi, IGlamourerApiState api)
|
||||
=> new(pi, Label, (a, b, c) => (int)api.RevertToAutomationName(a, b, (ApplyFlag)c));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.StateChanged" />
|
||||
public static class StateChanged
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Penumbra.{nameof(StateChanged)}.V2";
|
||||
|
||||
/// <summary> Create a new event subscriber. </summary>
|
||||
public static EventSubscriber<nint> Subscriber(IDalamudPluginInterface pi, params Action<nint>[] actions)
|
||||
=> new(pi, Label, actions);
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static EventProvider<nint> Provider(IDalamudPluginInterface pi, IGlamourerApiState api)
|
||||
=> new(pi, Label, (t => api.StateChanged += t, t => api.StateChanged -= t));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.StateChangedWithType" />
|
||||
public static class StateChangedWithType
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Penumbra.{nameof(StateChangedWithType)}";
|
||||
|
||||
/// <summary> Create a new event subscriber. </summary>
|
||||
public static EventSubscriber<nint, StateChangeType> Subscriber(IDalamudPluginInterface pi, params Action<nint, StateChangeType>[] actions)
|
||||
=> new(pi, Label, actions);
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static EventProvider<nint, StateChangeType> Provider(IDalamudPluginInterface pi, IGlamourerApiState api)
|
||||
=> new(pi, Label, (t => api.StateChangedWithType += t, t => api.StateChangedWithType -= t));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.StateFinalized" />
|
||||
public static class StateFinalized
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Penumbra.{nameof(StateFinalized)}";
|
||||
|
||||
/// <summary> Create a new event subscriber. </summary>
|
||||
public static EventSubscriber<nint, StateFinalizationType> Subscriber(IDalamudPluginInterface pi, params Action<nint, StateFinalizationType>[] actions)
|
||||
=> new(pi, Label, actions);
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static EventProvider<nint, StateFinalizationType> Provider(IDalamudPluginInterface pi, IGlamourerApiState api)
|
||||
=> new(pi, Label, (t => api.StateFinalized += t, t => api.StateFinalized -= t));
|
||||
}
|
||||
|
||||
/// <inheritdoc cref="IGlamourerApiState.GPoseChanged" />
|
||||
public static class GPoseChanged
|
||||
{
|
||||
/// <summary> The label. </summary>
|
||||
public const string Label = $"Penumbra.{nameof(GPoseChanged)}";
|
||||
|
||||
/// <summary> Create a new event subscriber. </summary>
|
||||
public static EventSubscriber<bool> Subscriber(IDalamudPluginInterface pi, params Action<bool>[] actions)
|
||||
=> new(pi, Label, actions);
|
||||
|
||||
/// <summary> Create a provider. </summary>
|
||||
public static EventProvider<bool> Provider(IDalamudPluginInterface pi, IGlamourerApiState api)
|
||||
=> new(pi, Label, (t => api.GPoseChanged += t, t => api.GPoseChanged -= t));
|
||||
}
|
4
Glamourer.Api/README.md
Normal file
4
Glamourer.Api/README.md
Normal file
@@ -0,0 +1,4 @@
|
||||
# Glamourer
|
||||
|
||||
This is an auxiliary repository for Glamourers external API.
|
||||
For more information, see the [main repo](https://github.com/Ottermandias/Glamourer).
|
13
Glamourer.Api/packages.lock.json
Normal file
13
Glamourer.Api/packages.lock.json
Normal file
@@ -0,0 +1,13 @@
|
||||
{
|
||||
"version": 1,
|
||||
"dependencies": {
|
||||
"net9.0-windows7.0": {
|
||||
"DotNet.ReproducibleBuilds": {
|
||||
"type": "Direct",
|
||||
"requested": "[1.2.25, )",
|
||||
"resolved": "1.2.25",
|
||||
"contentHash": "xCXiw7BCxHJ8pF6wPepRUddlh2dlQlbr81gXA72hdk4FLHkKXas7EH/n+fk5UCA/YfMqG1Z6XaPiUjDbUNBUzg=="
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user