Get DragDropping working

This commit is contained in:
Zeffuro
2025-12-24 11:11:30 +01:00
parent 066dd8d2fa
commit aef50e39d3
3 changed files with 101 additions and 2 deletions
@@ -0,0 +1,65 @@
using FFXIVClientStructs.FFXIV.Client.Game;
namespace AetherBags.Extensions;
public static class InventoryTypeExtensions
{
extension(InventoryType inventoryType)
{
public uint AgentItemContainerId =>
inventoryType switch
{
InventoryType.EquippedItems => 4,
InventoryType.KeyItems => 7,
InventoryType.Inventory1 => 48,
InventoryType.Inventory2 => 49,
InventoryType.Inventory3 => 50,
InventoryType.Inventory4 => 51,
InventoryType.ArmoryMainHand => 57,
InventoryType.ArmoryHead => 58,
InventoryType.ArmoryBody => 59,
InventoryType.ArmoryHands => 60,
InventoryType.ArmoryLegs => 61,
InventoryType.ArmoryFeets => 62,
InventoryType.ArmoryOffHand => 63,
InventoryType.ArmoryEar => 64,
InventoryType.ArmoryNeck => 65,
InventoryType.ArmoryWrist => 66,
InventoryType.ArmoryRings => 67,
InventoryType.ArmorySoulCrystal => 68,
InventoryType.SaddleBag1 => 69,
InventoryType.SaddleBag2 => 70,
InventoryType.PremiumSaddleBag1 => 71,
InventoryType.PremiumSaddleBag2 => 72,
_ => 0
};
public static InventoryType GetInventoryTypeFromContainerId(int id) =>
id switch
{
4 => InventoryType.EquippedItems,
7 => InventoryType.KeyItems,
48 => InventoryType.Inventory1,
49 => InventoryType.Inventory2,
50 => InventoryType.Inventory3,
51 => InventoryType.Inventory4,
57 => InventoryType.ArmoryMainHand,
58 => InventoryType.ArmoryHead,
59 => InventoryType.ArmoryBody,
60 => InventoryType.ArmoryHands,
61 => InventoryType.ArmoryLegs,
62 => InventoryType.ArmoryFeets,
63 => InventoryType.ArmoryOffHand,
64 => InventoryType.ArmoryEar,
65 => InventoryType.ArmoryNeck,
66 => InventoryType.ArmoryWrist,
67 => InventoryType.ArmoryRings,
68 => InventoryType.ArmorySoulCrystal,
69 => InventoryType.SaddleBag1,
70 => InventoryType.SaddleBag2,
71 => InventoryType.PremiumSaddleBag1,
72 => InventoryType.PremiumSaddleBag2,
_ => (InventoryType)0
};
}
}
+5
View File
@@ -630,6 +630,11 @@ public static unsafe class InventoryState
};
}
public static InventoryContainer* GetInventoryContainer(InventoryType inventoryType)
{
return InventoryManager.Instance()->GetInventoryContainer(inventoryType);
}
private struct AggregatedItem
{
public InventoryItem First;
+31 -2
View File
@@ -7,9 +7,11 @@ using KamiToolKit.Classes;
using KamiToolKit.Nodes;
using System;
using System.Numerics;
using FFXIVClientStructs.FFXIV.Client.UI;
// TODO: Switch back to CS version when Dalamud Updated
using DragDropFixedNode = AetherBags.Nodes.DragDropNode;
using ValueType = FFXIVClientStructs.FFXIV.Component.GUI.ValueType;
namespace AetherBags.Nodes;
@@ -285,11 +287,38 @@ public class InventoryCategoryNode : SimpleComponentNode
private unsafe void OnPayloadAccepted(DragDropNode node, DragDropPayload payload, ItemInfo itemInfo)
{
if (payload.Type != DragDropType.Item) return;
Services.Logger.Debug($"Inventory DragDropNode Payload Accepted: {payload.Type} Int1: {payload.Int1} Int2: {payload.Int2}");
InventoryType inventoryType = (InventoryType)payload.Int1;
InventoryType inventoryType = InventoryType.GetInventoryTypeFromContainerId(payload.Int1);
ushort sourceSlot = (ushort)payload.Int2;
System.AddonInventoryWindow.ManualInventoryRefresh();
// Should work for swapping item but need a fake empty slot to put new items in probably.
InventoryManager.Instance()->MoveItemSlot(inventoryType, sourceSlot, itemInfo.Item.Container, itemInfo.Item.GetSlot());
// Services.Logger.Debug($"Moving Item from {inventoryType} Slot {sourceSlot} to {itemInfo.Item.Container} Slot {itemInfo.Item.GetSlot()}");
InventoryManager.Instance()->MoveItemSlot(inventoryType, sourceSlot, itemInfo.Item.Container, itemInfo.Item.GetSlot(), false);
//MoveItem(inventoryType, sourceSlot, itemInfo.Item.Container, itemInfo.Item.GetSlot());
}
// Possibly still use this
private unsafe void MoveItem(InventoryType sourceInventory, uint sourceSlot, InventoryType destinationInventory, uint destinationSlot)
{
var sourceContainerId = sourceInventory.AgentItemContainerId;
var destinationContainerId = destinationInventory.AgentItemContainerId;
if (sourceContainerId != 0 && destinationContainerId != 0) {
var atkValues = stackalloc AtkValue[4];
for (var i = 0; i < 4; i++) atkValues[i].Type = ValueType.UInt;
atkValues[0].UInt = sourceContainerId;
atkValues[1].UInt = sourceSlot;
atkValues[2].UInt = destinationContainerId;
atkValues[3].UInt = destinationSlot;
var retVal = stackalloc AtkValue[1];
RaptureAtkModule* atkModule = RaptureAtkModule.Instance();
// (RaptureAtkModule* a1, void* outValue, AtkValue* atkValues);
// (AtkValue* returnValue, AtkValue* values, uint valueCount)
atkModule->HandleItemMove(retVal, atkValues, 4);
}
}
}