This commit is contained in:
2025-08-22 02:19:48 +01:00
commit a4c82452be
373 changed files with 52044 additions and 0 deletions

View 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; }
}

View 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; }
}

View 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);
}

View 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);
}

View 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;
}