mirror of
https://github.com/goatcorp/Dalamud.git
synced 2025-12-12 18:27:23 +01:00
[GameInventory] Service Prototype
This commit is contained in:
parent
d52118b3ad
commit
92f4df625f
6 changed files with 831 additions and 0 deletions
268
Dalamud/Game/Inventory/GameInventory.cs
Normal file
268
Dalamud/Game/Inventory/GameInventory.cs
Normal file
|
|
@ -0,0 +1,268 @@
|
|||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Linq;
|
||||
|
||||
using Dalamud.IoC;
|
||||
using Dalamud.IoC.Internal;
|
||||
using Dalamud.Logging.Internal;
|
||||
using Dalamud.Plugin.Services;
|
||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||
|
||||
namespace Dalamud.Game.Inventory;
|
||||
|
||||
/// <summary>
|
||||
/// This class provides events for the players in-game inventory.
|
||||
/// </summary>
|
||||
[InterfaceVersion("1.0")]
|
||||
[ServiceManager.EarlyLoadedService]
|
||||
internal class GameInventory : IDisposable, IServiceType, IGameInventory
|
||||
{
|
||||
private static readonly ModuleLog Log = new("GameInventory");
|
||||
|
||||
[ServiceManager.ServiceDependency]
|
||||
private readonly Framework framework = Service<Framework>.Get();
|
||||
|
||||
private readonly Dictionary<GameInventoryType, Dictionary<int, InventoryItem>> inventoryCache;
|
||||
|
||||
[ServiceManager.ServiceConstructor]
|
||||
private GameInventory()
|
||||
{
|
||||
this.inventoryCache = new Dictionary<GameInventoryType, Dictionary<int, InventoryItem>>();
|
||||
|
||||
foreach (var inventoryType in Enum.GetValues<GameInventoryType>())
|
||||
{
|
||||
this.inventoryCache.Add(inventoryType, new Dictionary<int, InventoryItem>());
|
||||
}
|
||||
|
||||
this.framework.Update += this.OnFrameworkUpdate;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event IGameInventory.OnItemMovedDelegate? ItemMoved;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event IGameInventory.OnItemRemovedDelegate? ItemRemoved;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event IGameInventory.OnItemAddedDelegate? ItemAdded;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event IGameInventory.OnItemChangedDelegate? ItemChanged;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
this.framework.Update -= this.OnFrameworkUpdate;
|
||||
}
|
||||
|
||||
private void OnFrameworkUpdate(IFramework framework1)
|
||||
{
|
||||
// If no one is listening for event's then we don't need to track anything.
|
||||
if (!this.AnyListeners()) return;
|
||||
|
||||
var performanceMonitor = Stopwatch.StartNew();
|
||||
|
||||
var changelog = new List<GameInventoryItemChangelog>();
|
||||
|
||||
foreach (var (inventoryType, cachedInventoryItems) in this.inventoryCache)
|
||||
{
|
||||
foreach (var item in this.GetItemsForInventory(inventoryType))
|
||||
{
|
||||
if (cachedInventoryItems.TryGetValue(item.Slot, out var inventoryItem))
|
||||
{
|
||||
// Gained Item
|
||||
// If the item we have cached has an item id of 0, then we expect it to be an empty slot.
|
||||
// However, if the item we see in the game data has an item id that is not 0, then it now has an item.
|
||||
if (inventoryItem.ItemID is 0 && item.ItemID is not 0)
|
||||
{
|
||||
var gameInventoryItem = new GameInventoryItem(item);
|
||||
this.ItemAdded?.Invoke(inventoryType, (uint)item.Slot, gameInventoryItem);
|
||||
changelog.Add(new GameInventoryItemChangelog(GameInventoryChangelogState.Added, gameInventoryItem));
|
||||
|
||||
Log.Verbose($"New Item Added to {inventoryType}: {item.ItemID}");
|
||||
this.inventoryCache[inventoryType][item.Slot] = item;
|
||||
}
|
||||
|
||||
// Removed Item
|
||||
// If the item we have cached has an item id of not 0, then we expect it to have an item.
|
||||
// However, if the item we see in the game data has an item id that is 0, then it was removed from this inventory.
|
||||
if (inventoryItem.ItemID is not 0 && item.ItemID is 0)
|
||||
{
|
||||
var gameInventoryItem = new GameInventoryItem(inventoryItem);
|
||||
this.ItemRemoved?.Invoke(inventoryType, (uint)item.Slot, gameInventoryItem);
|
||||
changelog.Add(new GameInventoryItemChangelog(GameInventoryChangelogState.Removed, gameInventoryItem));
|
||||
|
||||
Log.Verbose($"Item Removed from {inventoryType}: {inventoryItem.ItemID}");
|
||||
this.inventoryCache[inventoryType][item.Slot] = item;
|
||||
}
|
||||
|
||||
// Changed Item
|
||||
// If the item we have cached, does not match the item that we see in the game data
|
||||
// AND if neither item is empty, then the item has been changed.
|
||||
if (this.IsItemChanged(inventoryItem, item) && inventoryItem.ItemID is not 0 && item.ItemID is not 0)
|
||||
{
|
||||
var gameInventoryItem = new GameInventoryItem(inventoryItem);
|
||||
this.ItemChanged?.Invoke(inventoryType, (uint)item.Slot, gameInventoryItem);
|
||||
|
||||
Log.Verbose($"Item Changed {inventoryType}: {inventoryItem.ItemID}");
|
||||
this.inventoryCache[inventoryType][item.Slot] = item;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
cachedInventoryItems.Add(item.Slot, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Resolve changelog for item moved
|
||||
// Group all changelogs that have the same itemId, and check if there was an add and a remove event for that item.
|
||||
foreach (var itemGroup in changelog.GroupBy(log => log.Item.ItemId))
|
||||
{
|
||||
var hasAdd = false;
|
||||
var hasRemove = false;
|
||||
|
||||
foreach (var log in itemGroup)
|
||||
{
|
||||
switch (log.State)
|
||||
{
|
||||
case GameInventoryChangelogState.Added:
|
||||
hasAdd = true;
|
||||
break;
|
||||
|
||||
case GameInventoryChangelogState.Removed:
|
||||
hasRemove = true;
|
||||
break;
|
||||
|
||||
default:
|
||||
throw new ArgumentOutOfRangeException();
|
||||
}
|
||||
}
|
||||
|
||||
var itemMoved = hasAdd && hasRemove;
|
||||
if (itemMoved)
|
||||
{
|
||||
var added = itemGroup.FirstOrDefault(log => log.State == GameInventoryChangelogState.Added);
|
||||
var removed = itemGroup.FirstOrDefault(log => log.State == GameInventoryChangelogState.Removed);
|
||||
if (added is null || removed is null) continue;
|
||||
|
||||
this.ItemMoved?.Invoke(removed.Item.ContainerType, removed.Item.InventorySlot, added.Item.ContainerType, added.Item.InventorySlot, added.Item);
|
||||
|
||||
Log.Verbose($"Item Moved {removed.Item.ContainerType}:{removed.Item.InventorySlot} -> {added.Item.ContainerType}:{added.Item.InventorySlot}: {added.Item.ItemId}");
|
||||
}
|
||||
}
|
||||
|
||||
var elapsed = performanceMonitor.Elapsed;
|
||||
|
||||
Log.Verbose($"Processing Time: {elapsed.Ticks}ticks :: {elapsed.TotalMilliseconds}ms");
|
||||
}
|
||||
|
||||
private bool AnyListeners()
|
||||
{
|
||||
if (this.ItemMoved is not null) return true;
|
||||
if (this.ItemRemoved is not null) return true;
|
||||
if (this.ItemAdded is not null) return true;
|
||||
if (this.ItemChanged is not null) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private unsafe ReadOnlySpan<InventoryItem> GetItemsForInventory(GameInventoryType type)
|
||||
{
|
||||
var inventoryManager = InventoryManager.Instance();
|
||||
if (inventoryManager is null) return ReadOnlySpan<InventoryItem>.Empty;
|
||||
|
||||
var inventory = inventoryManager->GetInventoryContainer((InventoryType)type);
|
||||
if (inventory is null) return ReadOnlySpan<InventoryItem>.Empty;
|
||||
|
||||
return new ReadOnlySpan<InventoryItem>(inventory->Items, (int)inventory->Size);
|
||||
}
|
||||
|
||||
private bool IsItemChanged(InventoryItem a, InventoryItem b)
|
||||
{
|
||||
if (a.Container != b.Container) return true; // Shouldn't be possible, but shouldn't hurt.
|
||||
if (a.Slot != b.Slot) return true; // Shouldn't be possible, but shouldn't hurt.
|
||||
if (a.ItemID != b.ItemID) return true;
|
||||
if (a.Quantity != b.Quantity) return true;
|
||||
if (a.Spiritbond != b.Spiritbond) return true;
|
||||
if (a.Condition != b.Condition) return true;
|
||||
if (a.Flags != b.Flags) return true;
|
||||
if (a.CrafterContentID != b.CrafterContentID) return true;
|
||||
if (this.IsMateriaChanged(a, b)) return true;
|
||||
if (this.IsMateriaGradeChanged(a, b)) return true;
|
||||
if (a.Stain != b.Stain) return true;
|
||||
if (a.GlamourID != b.GlamourID) return true;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
private unsafe bool IsMateriaChanged(InventoryItem a, InventoryItem b)
|
||||
=> new ReadOnlySpan<ushort>(a.Materia, 5) == new ReadOnlySpan<ushort>(b.Materia, 5);
|
||||
|
||||
private unsafe bool IsMateriaGradeChanged(InventoryItem a, InventoryItem b)
|
||||
=> new ReadOnlySpan<byte>(a.MateriaGrade, 5) == new ReadOnlySpan<byte>(b.MateriaGrade, 5);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Plugin-scoped version of a GameInventory service.
|
||||
/// </summary>
|
||||
[PluginInterface]
|
||||
[InterfaceVersion("1.0")]
|
||||
[ServiceManager.ScopedService]
|
||||
#pragma warning disable SA1015
|
||||
[ResolveVia<IGameInventory>]
|
||||
#pragma warning restore SA1015
|
||||
internal class GameInventoryPluginScoped : IDisposable, IServiceType, IGameInventory
|
||||
{
|
||||
[ServiceManager.ServiceDependency]
|
||||
private readonly GameInventory gameInventoryService = Service<GameInventory>.Get();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GameInventoryPluginScoped"/> class.
|
||||
/// </summary>
|
||||
public GameInventoryPluginScoped()
|
||||
{
|
||||
this.gameInventoryService.ItemMoved += this.OnItemMovedForward;
|
||||
this.gameInventoryService.ItemRemoved += this.OnItemRemovedForward;
|
||||
this.gameInventoryService.ItemAdded += this.OnItemAddedForward;
|
||||
this.gameInventoryService.ItemChanged += this.OnItemChangedForward;
|
||||
}
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event IGameInventory.OnItemMovedDelegate? ItemMoved;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event IGameInventory.OnItemRemovedDelegate? ItemRemoved;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event IGameInventory.OnItemAddedDelegate? ItemAdded;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public event IGameInventory.OnItemChangedDelegate? ItemChanged;
|
||||
|
||||
/// <inheritdoc/>
|
||||
public void Dispose()
|
||||
{
|
||||
this.gameInventoryService.ItemMoved -= this.OnItemMovedForward;
|
||||
this.gameInventoryService.ItemRemoved -= this.OnItemRemovedForward;
|
||||
this.gameInventoryService.ItemAdded -= this.OnItemAddedForward;
|
||||
this.gameInventoryService.ItemChanged -= this.OnItemChangedForward;
|
||||
|
||||
this.ItemMoved = null;
|
||||
this.ItemRemoved = null;
|
||||
this.ItemAdded = null;
|
||||
this.ItemChanged = null;
|
||||
}
|
||||
|
||||
private void OnItemMovedForward(GameInventoryType source, uint sourceSlot, GameInventoryType destination, uint destinationSlot, GameInventoryItem item)
|
||||
=> this.ItemMoved?.Invoke(source, sourceSlot, destination, destinationSlot, item);
|
||||
|
||||
private void OnItemRemovedForward(GameInventoryType source, uint sourceSlot, GameInventoryItem item)
|
||||
=> this.ItemRemoved?.Invoke(source, sourceSlot, item);
|
||||
|
||||
private void OnItemAddedForward(GameInventoryType destination, uint destinationSlot, GameInventoryItem item)
|
||||
=> this.ItemAdded?.Invoke(destination, destinationSlot, item);
|
||||
|
||||
private void OnItemChangedForward(GameInventoryType inventory, uint slot, GameInventoryItem item)
|
||||
=> this.ItemChanged?.Invoke(inventory, slot, item);
|
||||
}
|
||||
28
Dalamud/Game/Inventory/GameInventoryChangelog.cs
Normal file
28
Dalamud/Game/Inventory/GameInventoryChangelog.cs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
namespace Dalamud.Game.Inventory;
|
||||
|
||||
/// <summary>
|
||||
/// Class representing an inventory item change event.
|
||||
/// </summary>
|
||||
internal class GameInventoryItemChangelog
|
||||
{
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GameInventoryItemChangelog"/> class.
|
||||
/// </summary>
|
||||
/// <param name="state">Item state.</param>
|
||||
/// <param name="item">Item.</param>
|
||||
internal GameInventoryItemChangelog(GameInventoryChangelogState state, GameInventoryItem item)
|
||||
{
|
||||
this.State = state;
|
||||
this.Item = item;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the state of this changelog event.
|
||||
/// </summary>
|
||||
internal GameInventoryChangelogState State { get; }
|
||||
|
||||
/// <summary>
|
||||
/// Gets the item for this changelog event.
|
||||
/// </summary>
|
||||
internal GameInventoryItem Item { get; }
|
||||
}
|
||||
17
Dalamud/Game/Inventory/GameInventoryChangelogState.cs
Normal file
17
Dalamud/Game/Inventory/GameInventoryChangelogState.cs
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
namespace Dalamud.Game.Inventory;
|
||||
|
||||
/// <summary>
|
||||
/// Class representing a item's changelog state.
|
||||
/// </summary>
|
||||
internal enum GameInventoryChangelogState
|
||||
{
|
||||
/// <summary>
|
||||
/// Item was added to an inventory.
|
||||
/// </summary>
|
||||
Added,
|
||||
|
||||
/// <summary>
|
||||
/// Item was removed from an inventory.
|
||||
/// </summary>
|
||||
Removed,
|
||||
}
|
||||
98
Dalamud/Game/Inventory/GameInventoryItem.cs
Normal file
98
Dalamud/Game/Inventory/GameInventoryItem.cs
Normal file
|
|
@ -0,0 +1,98 @@
|
|||
using System.Runtime.CompilerServices;
|
||||
|
||||
using FFXIVClientStructs.FFXIV.Client.Game;
|
||||
|
||||
namespace Dalamud.Game.Inventory;
|
||||
|
||||
/// <summary>
|
||||
/// Dalamud wrapper around a ClientStructs InventoryItem.
|
||||
/// </summary>
|
||||
public unsafe class GameInventoryItem
|
||||
{
|
||||
private InventoryItem internalItem;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GameInventoryItem"/> class.
|
||||
/// </summary>
|
||||
/// <param name="item">Inventory item to wrap.</param>
|
||||
internal GameInventoryItem(InventoryItem item)
|
||||
{
|
||||
this.internalItem = item;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Gets the container inventory type.
|
||||
/// </summary>
|
||||
public GameInventoryType ContainerType => (GameInventoryType)this.internalItem.Container;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the inventory slot index this item is in.
|
||||
/// </summary>
|
||||
public uint InventorySlot => (uint)this.internalItem.Slot;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the item id.
|
||||
/// </summary>
|
||||
public uint ItemId => this.internalItem.ItemID;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the quantity of items in this item stack.
|
||||
/// </summary>
|
||||
public uint Quantity => this.internalItem.Quantity;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the spiritbond of this item.
|
||||
/// </summary>
|
||||
public uint Spiritbond => this.internalItem.Spiritbond;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the repair condition of this item.
|
||||
/// </summary>
|
||||
public uint Condition => this.internalItem.Condition;
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the item is High Quality.
|
||||
/// </summary>
|
||||
public bool IsHq => this.internalItem.Flags.HasFlag(InventoryItem.ItemFlags.HQ);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the item has a company crest applied.
|
||||
/// </summary>
|
||||
public bool IsCompanyCrestApplied => this.internalItem.Flags.HasFlag(InventoryItem.ItemFlags.CompanyCrestApplied);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the item is a relic.
|
||||
/// </summary>
|
||||
public bool IsRelic => this.internalItem.Flags.HasFlag(InventoryItem.ItemFlags.Relic);
|
||||
|
||||
/// <summary>
|
||||
/// Gets a value indicating whether the is a collectable.
|
||||
/// </summary>
|
||||
public bool IsCollectable => this.internalItem.Flags.HasFlag(InventoryItem.ItemFlags.Collectable);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the array of materia types.
|
||||
/// </summary>
|
||||
public ReadOnlySpan<ushort> Materia => new(Unsafe.AsPointer(ref this.internalItem.Materia[0]), 5);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the array of materia grades.
|
||||
/// </summary>
|
||||
public ReadOnlySpan<ushort> MateriaGrade => new(Unsafe.AsPointer(ref this.internalItem.MateriaGrade[0]), 5);
|
||||
|
||||
/// <summary>
|
||||
/// Gets the color used for this item.
|
||||
/// </summary>
|
||||
public byte Stain => this.internalItem.Stain;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the glamour id for this item.
|
||||
/// </summary>
|
||||
public uint GlmaourId => this.internalItem.GlamourID;
|
||||
|
||||
/// <summary>
|
||||
/// Gets the items crafter's content id.
|
||||
/// NOTE: I'm not sure if this is a good idea to include or not in the dalamud api. Marked internal for now.
|
||||
/// </summary>
|
||||
internal ulong CrafterContentId => this.internalItem.CrafterContentID;
|
||||
}
|
||||
351
Dalamud/Game/Inventory/GameInventoryType.cs
Normal file
351
Dalamud/Game/Inventory/GameInventoryType.cs
Normal file
|
|
@ -0,0 +1,351 @@
|
|||
namespace Dalamud.Game.Inventory;
|
||||
|
||||
/// <summary>
|
||||
/// Enum representing various player inventories.
|
||||
/// </summary>
|
||||
public enum GameInventoryType : uint
|
||||
{
|
||||
/// <summary>
|
||||
/// First panel of main player inventory.
|
||||
/// </summary>
|
||||
Inventory1 = 0,
|
||||
|
||||
/// <summary>
|
||||
/// Second panel of main player inventory.
|
||||
/// </summary>
|
||||
Inventory2 = 1,
|
||||
|
||||
/// <summary>
|
||||
/// Third panel of main player inventory.
|
||||
/// </summary>
|
||||
Inventory3 = 2,
|
||||
|
||||
/// <summary>
|
||||
/// Fourth panel of main player inventory.
|
||||
/// </summary>
|
||||
Inventory4 = 3,
|
||||
|
||||
/// <summary>
|
||||
/// Items that are currently equipped by the player.
|
||||
/// </summary>
|
||||
EquippedItems = 1000,
|
||||
|
||||
/// <summary>
|
||||
/// Player currency container.
|
||||
/// ie, gil, serpent seals, sacks of nuts.
|
||||
/// </summary>
|
||||
Currency = 2000,
|
||||
|
||||
/// <summary>
|
||||
/// Crystal container.
|
||||
/// </summary>
|
||||
Crystals = 2001,
|
||||
|
||||
/// <summary>
|
||||
/// Mail container.
|
||||
/// </summary>
|
||||
Mail = 2003,
|
||||
|
||||
/// <summary>
|
||||
/// Key item container.
|
||||
/// </summary>
|
||||
KeyItems = 2004,
|
||||
|
||||
/// <summary>
|
||||
/// Quest item hand-in inventory.
|
||||
/// </summary>
|
||||
HandIn = 2005,
|
||||
|
||||
/// <summary>
|
||||
/// DamagedGear container.
|
||||
/// </summary>
|
||||
DamagedGear = 2007,
|
||||
|
||||
/// <summary>
|
||||
/// Examine window container.
|
||||
/// </summary>
|
||||
Examine = 2009,
|
||||
|
||||
/// <summary>
|
||||
/// Doman Enclave Reconstruction Reclamation Box.
|
||||
/// </summary>
|
||||
ReconstructionBuyback = 2013,
|
||||
|
||||
/// <summary>
|
||||
/// Armory off-hand weapon container.
|
||||
/// </summary>
|
||||
ArmoryOffHand = 3200,
|
||||
|
||||
/// <summary>
|
||||
/// Armory head container.
|
||||
/// </summary>
|
||||
ArmoryHead = 3201,
|
||||
|
||||
/// <summary>
|
||||
/// Armory body container.
|
||||
/// </summary>
|
||||
ArmoryBody = 3202,
|
||||
|
||||
/// <summary>
|
||||
/// Armory hand/gloves container.
|
||||
/// </summary>
|
||||
ArmoryHands = 3203,
|
||||
|
||||
/// <summary>
|
||||
/// Armory waist container.
|
||||
/// <remarks>
|
||||
/// This container should be unused as belt items were removed from the game in Shadowbringers.
|
||||
/// </remarks>
|
||||
/// </summary>
|
||||
ArmoryWaist = 3204,
|
||||
|
||||
/// <summary>
|
||||
/// Armory legs/pants/skirt container.
|
||||
/// </summary>
|
||||
ArmoryLegs = 3205,
|
||||
|
||||
/// <summary>
|
||||
/// Armory feet/boots/shoes container.
|
||||
/// </summary>
|
||||
ArmoryFeets = 3206,
|
||||
|
||||
/// <summary>
|
||||
/// Armory earring container.
|
||||
/// </summary>
|
||||
ArmoryEar = 3207,
|
||||
|
||||
/// <summary>
|
||||
/// Armory necklace container.
|
||||
/// </summary>
|
||||
ArmoryNeck = 3208,
|
||||
|
||||
/// <summary>
|
||||
/// Armory bracelet container.
|
||||
/// </summary>
|
||||
ArmoryWrist = 3209,
|
||||
|
||||
/// <summary>
|
||||
/// Armory ring container.
|
||||
/// </summary>
|
||||
ArmoryRings = 3300,
|
||||
|
||||
/// <summary>
|
||||
/// Armory soul crystal container.
|
||||
/// </summary>
|
||||
ArmorySoulCrystal = 3400,
|
||||
|
||||
/// <summary>
|
||||
/// Armory main-hand weapon container.
|
||||
/// </summary>
|
||||
ArmoryMainHand = 3500,
|
||||
|
||||
/// <summary>
|
||||
/// First panel of saddelbag inventory.
|
||||
/// </summary>
|
||||
SaddleBag1 = 4000,
|
||||
|
||||
/// <summary>
|
||||
/// Second panel of Saddlebag inventory.
|
||||
/// </summary>
|
||||
SaddleBag2 = 4001,
|
||||
|
||||
/// <summary>
|
||||
/// First panel of premium saddlebag inventory.
|
||||
/// </summary>
|
||||
PremiumSaddleBag1 = 4100,
|
||||
|
||||
/// <summary>
|
||||
/// Second panel of premium saddlebag inventory.
|
||||
/// </summary>
|
||||
PremiumSaddleBag2 = 4101,
|
||||
|
||||
/// <summary>
|
||||
/// First panel of retainer inventory.
|
||||
/// </summary>
|
||||
RetainerPage1 = 10000,
|
||||
|
||||
/// <summary>
|
||||
/// Second panel of retainer inventory.
|
||||
/// </summary>
|
||||
RetainerPage2 = 10001,
|
||||
|
||||
/// <summary>
|
||||
/// Third panel of retainer inventory.
|
||||
/// </summary>
|
||||
RetainerPage3 = 10002,
|
||||
|
||||
/// <summary>
|
||||
/// Fourth panel of retainer inventory.
|
||||
/// </summary>
|
||||
RetainerPage4 = 10003,
|
||||
|
||||
/// <summary>
|
||||
/// Fifth panel of retainer inventory.
|
||||
/// </summary>
|
||||
RetainerPage5 = 10004,
|
||||
|
||||
/// <summary>
|
||||
/// Sixth panel of retainer inventory.
|
||||
/// </summary>
|
||||
RetainerPage6 = 10005,
|
||||
|
||||
/// <summary>
|
||||
/// Seventh panel of retainer inventory.
|
||||
/// </summary>
|
||||
RetainerPage7 = 10006,
|
||||
|
||||
/// <summary>
|
||||
/// Retainer equipment container.
|
||||
/// </summary>
|
||||
RetainerEquippedItems = 11000,
|
||||
|
||||
/// <summary>
|
||||
/// Retainer currency container.
|
||||
/// </summary>
|
||||
RetainerGil = 12000,
|
||||
|
||||
/// <summary>
|
||||
/// Retainer crystal container.
|
||||
/// </summary>
|
||||
RetainerCrystals = 12001,
|
||||
|
||||
/// <summary>
|
||||
/// Retainer market item container.
|
||||
/// </summary>
|
||||
RetainerMarket = 12002,
|
||||
|
||||
/// <summary>
|
||||
/// First panel of Free Company inventory.
|
||||
/// </summary>
|
||||
FreeCompanyPage1 = 20000,
|
||||
|
||||
/// <summary>
|
||||
/// Second panel of Free Company inventory.
|
||||
/// </summary>
|
||||
FreeCompanyPage2 = 20001,
|
||||
|
||||
/// <summary>
|
||||
/// Third panel of Free Company inventory.
|
||||
/// </summary>
|
||||
FreeCompanyPage3 = 20002,
|
||||
|
||||
/// <summary>
|
||||
/// Fourth panel of Free Company inventory.
|
||||
/// </summary>
|
||||
FreeCompanyPage4 = 20003,
|
||||
|
||||
/// <summary>
|
||||
/// Fifth panel of Free Company inventory.
|
||||
/// </summary>
|
||||
FreeCompanyPage5 = 20004,
|
||||
|
||||
/// <summary>
|
||||
/// Free Company currency container.
|
||||
/// </summary>
|
||||
FreeCompanyGil = 22000,
|
||||
|
||||
/// <summary>
|
||||
/// Free Company crystal container.
|
||||
/// </summary>
|
||||
FreeCompanyCrystals = 22001,
|
||||
|
||||
/// <summary>
|
||||
/// Housing exterior appearance container.
|
||||
/// </summary>
|
||||
HousingExteriorAppearance = 25000,
|
||||
|
||||
/// <summary>
|
||||
/// Housing exterior placed items container.
|
||||
/// </summary>
|
||||
HousingExteriorPlacedItems = 25001,
|
||||
|
||||
/// <summary>
|
||||
/// Housing interior appearance container.
|
||||
/// </summary>
|
||||
HousingInteriorAppearance = 25002,
|
||||
|
||||
/// <summary>
|
||||
/// First panel of housing interior inventory.
|
||||
/// </summary>
|
||||
HousingInteriorPlacedItems1 = 25003,
|
||||
|
||||
/// <summary>
|
||||
/// Second panel of housing interior inventory.
|
||||
/// </summary>
|
||||
HousingInteriorPlacedItems2 = 25004,
|
||||
|
||||
/// <summary>
|
||||
/// Third panel of housing interior inventory.
|
||||
/// </summary>
|
||||
HousingInteriorPlacedItems3 = 25005,
|
||||
|
||||
/// <summary>
|
||||
/// Fourth panel of housing interior inventory.
|
||||
/// </summary>
|
||||
HousingInteriorPlacedItems4 = 25006,
|
||||
|
||||
/// <summary>
|
||||
/// Fifth panel of housing interior inventory.
|
||||
/// </summary>
|
||||
HousingInteriorPlacedItems5 = 25007,
|
||||
|
||||
/// <summary>
|
||||
/// Sixth panel of housing interior inventory.
|
||||
/// </summary>
|
||||
HousingInteriorPlacedItems6 = 25008,
|
||||
|
||||
/// <summary>
|
||||
/// Seventh panel of housing interior inventory.
|
||||
/// </summary>
|
||||
HousingInteriorPlacedItems7 = 25009,
|
||||
|
||||
/// <summary>
|
||||
/// Eighth panel of housing interior inventory.
|
||||
/// </summary>
|
||||
HousingInteriorPlacedItems8 = 25010,
|
||||
|
||||
/// <summary>
|
||||
/// Housing exterior storeroom inventory.
|
||||
/// </summary>
|
||||
HousingExteriorStoreroom = 27000,
|
||||
|
||||
/// <summary>
|
||||
/// First panel of housing interior storeroom inventory.
|
||||
/// </summary>
|
||||
HousingInteriorStoreroom1 = 27001,
|
||||
|
||||
/// <summary>
|
||||
/// Second panel of housing interior storeroom inventory.
|
||||
/// </summary>
|
||||
HousingInteriorStoreroom2 = 27002,
|
||||
|
||||
/// <summary>
|
||||
/// Third panel of housing interior storeroom inventory.
|
||||
/// </summary>
|
||||
HousingInteriorStoreroom3 = 27003,
|
||||
|
||||
/// <summary>
|
||||
/// Fourth panel of housing interior storeroom inventory.
|
||||
/// </summary>
|
||||
HousingInteriorStoreroom4 = 27004,
|
||||
|
||||
/// <summary>
|
||||
/// Fifth panel of housing interior storeroom inventory.
|
||||
/// </summary>
|
||||
HousingInteriorStoreroom5 = 27005,
|
||||
|
||||
/// <summary>
|
||||
/// Sixth panel of housing interior storeroom inventory.
|
||||
/// </summary>
|
||||
HousingInteriorStoreroom6 = 27006,
|
||||
|
||||
/// <summary>
|
||||
/// Seventh panel of housing interior storeroom inventory.
|
||||
/// </summary>
|
||||
HousingInteriorStoreroom7 = 27007,
|
||||
|
||||
/// <summary>
|
||||
/// Eighth panel of housing interior storeroom inventory.
|
||||
/// </summary>
|
||||
HousingInteriorStoreroom8 = 27008,
|
||||
}
|
||||
69
Dalamud/Plugin/Services/IGameInventory.cs
Normal file
69
Dalamud/Plugin/Services/IGameInventory.cs
Normal file
|
|
@ -0,0 +1,69 @@
|
|||
using Dalamud.Game.Inventory;
|
||||
|
||||
namespace Dalamud.Plugin.Services;
|
||||
|
||||
/// <summary>
|
||||
/// This class provides events for the in-game inventory.
|
||||
/// </summary>
|
||||
public interface IGameInventory
|
||||
{
|
||||
/// <summary>
|
||||
/// Delegate function for when an item is moved from one inventory to the next.
|
||||
/// </summary>
|
||||
/// <param name="source">Which inventory the item was moved from.</param>
|
||||
/// <param name="sourceSlot">The slot this item was moved from.</param>
|
||||
/// <param name="destination">Which inventory the item was moved to.</param>
|
||||
/// <param name="destinationSlot">The slot this item was moved to.</param>
|
||||
/// <param name="item">The item moved.</param>
|
||||
public delegate void OnItemMovedDelegate(GameInventoryType source, uint sourceSlot, GameInventoryType destination, uint destinationSlot, GameInventoryItem item);
|
||||
|
||||
/// <summary>
|
||||
/// Delegate function for when an item is removed from an inventory.
|
||||
/// </summary>
|
||||
/// <param name="source">Which inventory the item was removed from.</param>
|
||||
/// <param name="sourceSlot">The slot this item was removed from.</param>
|
||||
/// <param name="item">The item removed.</param>
|
||||
public delegate void OnItemRemovedDelegate(GameInventoryType source, uint sourceSlot, GameInventoryItem item);
|
||||
|
||||
/// <summary>
|
||||
/// Delegate function for when an item is added to an inventory.
|
||||
/// </summary>
|
||||
/// <param name="destination">Which inventory the item was added to.</param>
|
||||
/// <param name="destinationSlot">The slot this item was added to.</param>
|
||||
/// <param name="item">The item added.</param>
|
||||
public delegate void OnItemAddedDelegate(GameInventoryType destination, uint destinationSlot, GameInventoryItem item);
|
||||
|
||||
/// <summary>
|
||||
/// Delegate function for when an items properties are changed.
|
||||
/// </summary>
|
||||
/// <param name="inventory">Which inventory the item that was changed is in.</param>
|
||||
/// <param name="slot">The slot the item that was changed is in.</param>
|
||||
/// <param name="item">The item changed.</param>
|
||||
public delegate void OnItemChangedDelegate(GameInventoryType inventory, uint slot, GameInventoryItem item);
|
||||
|
||||
/// <summary>
|
||||
/// Event that is fired when an item is moved from one inventory to another.
|
||||
/// </summary>
|
||||
public event OnItemMovedDelegate ItemMoved;
|
||||
|
||||
/// <summary>
|
||||
/// Event that is fired when an item is removed from one inventory.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This event will also be fired when an item is moved from one inventory to another.
|
||||
/// </remarks>
|
||||
public event OnItemRemovedDelegate ItemRemoved;
|
||||
|
||||
/// <summary>
|
||||
/// Event that is fired when an item is added to one inventory.
|
||||
/// </summary>
|
||||
/// <remarks>
|
||||
/// This event will also be fired when an item is moved from one inventory to another.
|
||||
/// </remarks>
|
||||
public event OnItemAddedDelegate ItemAdded;
|
||||
|
||||
/// <summary>
|
||||
/// Event that is fired when an items properties are changed.
|
||||
/// </summary>
|
||||
public event OnItemChangedDelegate ItemChanged;
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue