mirror of
https://github.com/Ottermandias/Glamourer.git
synced 2025-12-12 18:27:24 +01:00
Update Item API.
This commit is contained in:
parent
3f99d11179
commit
c1d9af2dd0
4 changed files with 16 additions and 9 deletions
|
|
@ -1 +1 @@
|
||||||
Subproject commit a20d4ab1811a7f66918afab9b41ec723f75054f5
|
Subproject commit 4aaece34289d64363bc32aaa8fe52c8e7d3dce32
|
||||||
|
|
@ -2,6 +2,8 @@ using Dalamud.Plugin;
|
||||||
using Glamourer.Api.Api;
|
using Glamourer.Api.Api;
|
||||||
using Glamourer.Api.Helpers;
|
using Glamourer.Api.Helpers;
|
||||||
using OtterGui.Services;
|
using OtterGui.Services;
|
||||||
|
using System.Reflection.Emit;
|
||||||
|
using Glamourer.Api.Enums;
|
||||||
|
|
||||||
namespace Glamourer.Api;
|
namespace Glamourer.Api;
|
||||||
|
|
||||||
|
|
@ -12,7 +14,7 @@ public sealed class IpcProviders : IDisposable, IApiService
|
||||||
private readonly EventProvider _disposedProvider;
|
private readonly EventProvider _disposedProvider;
|
||||||
private readonly EventProvider _initializedProvider;
|
private readonly EventProvider _initializedProvider;
|
||||||
|
|
||||||
public IpcProviders(DalamudPluginInterface pi, IGlamourerApi api)
|
public IpcProviders(IDalamudPluginInterface pi, IGlamourerApi api)
|
||||||
{
|
{
|
||||||
_disposedProvider = IpcSubscribers.Disposed.Provider(pi);
|
_disposedProvider = IpcSubscribers.Disposed.Provider(pi);
|
||||||
_initializedProvider = IpcSubscribers.Initialized.Provider(pi);
|
_initializedProvider = IpcSubscribers.Initialized.Provider(pi);
|
||||||
|
|
@ -28,6 +30,11 @@ public sealed class IpcProviders : IDisposable, IApiService
|
||||||
|
|
||||||
IpcSubscribers.SetItem.Provider(pi, api.Items),
|
IpcSubscribers.SetItem.Provider(pi, api.Items),
|
||||||
IpcSubscribers.SetItemName.Provider(pi, api.Items),
|
IpcSubscribers.SetItemName.Provider(pi, api.Items),
|
||||||
|
// backward compatibility
|
||||||
|
new FuncProvider<int, byte, ulong, byte, uint, ulong, int>(pi, IpcSubscribers.Legacy.SetItemV2.Label,
|
||||||
|
(a, b, c, d, e, f) => (int)api.Items.SetItem(a, (ApiEquipSlot)b, c, [d], e, (ApplyFlag)f)),
|
||||||
|
new FuncProvider<string, byte, ulong, byte, uint, ulong, int>(pi, IpcSubscribers.Legacy.SetItemName.Label,
|
||||||
|
(a, b, c, d, e, f) => (int)api.Items.SetItemName(a, (ApiEquipSlot)b, c, [d], e, (ApplyFlag)f)),
|
||||||
|
|
||||||
IpcSubscribers.GetState.Provider(pi, api.State),
|
IpcSubscribers.GetState.Provider(pi, api.State),
|
||||||
IpcSubscribers.GetStateName.Provider(pi, api.State),
|
IpcSubscribers.GetStateName.Provider(pi, api.State),
|
||||||
|
|
|
||||||
|
|
@ -11,9 +11,9 @@ namespace Glamourer.Api;
|
||||||
|
|
||||||
public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager stateManager) : IGlamourerApiItems, IApiService
|
public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager stateManager) : IGlamourerApiItems, IApiService
|
||||||
{
|
{
|
||||||
public GlamourerApiEc SetItem(int objectIndex, ApiEquipSlot slot, ulong itemId, byte stain, uint key, ApplyFlag flags)
|
public GlamourerApiEc SetItem(int objectIndex, ApiEquipSlot slot, ulong itemId, IReadOnlyList<byte> stains, uint key, ApplyFlag flags)
|
||||||
{
|
{
|
||||||
var args = ApiHelpers.Args("Index", objectIndex, "Slot", slot, "ID", itemId, "Stain", stain, "Key", key, "Flags", flags);
|
var args = ApiHelpers.Args("Index", objectIndex, "Slot", slot, "ID", itemId, "Stains", stains, "Key", key, "Flags", flags);
|
||||||
if (!ResolveItem(slot, itemId, out var item))
|
if (!ResolveItem(slot, itemId, out var item))
|
||||||
return ApiHelpers.Return(GlamourerApiEc.ItemInvalid, args);
|
return ApiHelpers.Return(GlamourerApiEc.ItemInvalid, args);
|
||||||
|
|
||||||
|
|
@ -27,14 +27,14 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager
|
||||||
return ApiHelpers.Return(GlamourerApiEc.InvalidKey, args);
|
return ApiHelpers.Return(GlamourerApiEc.InvalidKey, args);
|
||||||
|
|
||||||
var settings = new ApplySettings(Source: flags.HasFlag(ApplyFlag.Once) ? StateSource.IpcManual : StateSource.IpcFixed, Key: key);
|
var settings = new ApplySettings(Source: flags.HasFlag(ApplyFlag.Once) ? StateSource.IpcManual : StateSource.IpcFixed, Key: key);
|
||||||
stateManager.ChangeEquip(state, (EquipSlot)slot, item, stain, settings);
|
stateManager.ChangeEquip(state, (EquipSlot)slot, item, new StainIds(stains), settings);
|
||||||
ApiHelpers.Lock(state, key, flags);
|
ApiHelpers.Lock(state, key, flags);
|
||||||
return GlamourerApiEc.Success;
|
return GlamourerApiEc.Success;
|
||||||
}
|
}
|
||||||
|
|
||||||
public GlamourerApiEc SetItemName(string playerName, ApiEquipSlot slot, ulong itemId, byte stain, uint key, ApplyFlag flags)
|
public GlamourerApiEc SetItemName(string playerName, ApiEquipSlot slot, ulong itemId, IReadOnlyList<byte> stains, uint key, ApplyFlag flags)
|
||||||
{
|
{
|
||||||
var args = ApiHelpers.Args("Name", playerName, "Slot", slot, "ID", itemId, "Stain", stain, "Key", key, "Flags", flags);
|
var args = ApiHelpers.Args("Name", playerName, "Slot", slot, "ID", itemId, "Stains", stains, "Key", key, "Flags", flags);
|
||||||
if (!ResolveItem(slot, itemId, out var item))
|
if (!ResolveItem(slot, itemId, out var item))
|
||||||
return ApiHelpers.Return(GlamourerApiEc.ItemInvalid, args);
|
return ApiHelpers.Return(GlamourerApiEc.ItemInvalid, args);
|
||||||
|
|
||||||
|
|
@ -53,7 +53,7 @@ public class ItemsApi(ApiHelpers helpers, ItemManager itemManager, StateManager
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
anyUnlocked = true;
|
anyUnlocked = true;
|
||||||
stateManager.ChangeEquip(state, (EquipSlot)slot, item, stain, settings);
|
stateManager.ChangeEquip(state, (EquipSlot)slot, item, new StainIds(stains), settings);
|
||||||
ApiHelpers.Lock(state, key, flags);
|
ApiHelpers.Lock(state, key, flags);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -1 +1 @@
|
||||||
Subproject commit f1e4e520daaa8f23e5c8b71d55e5992b8f6768e2
|
Subproject commit f4c6144ca2012b279e6d8aa52b2bef6cc2ba32d9
|
||||||
Loading…
Add table
Add a link
Reference in a new issue