Add Retainers, need to refactor more
This commit is contained in:
@@ -2,5 +2,7 @@
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AAgentSatisfactionSupply_002Ecs_002Fl_003AC_0021_003FUsers_003FJeffro_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fb2cd0663609440e590f52980cafc1ba3822648_003F28_003Ffa48b62e_003FAgentSatisfactionSupply_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AAtkValue_002Ecs_002Fl_003AC_0021_003FUsers_003FJeffro_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003F1b966bf9f0d5b3eb39a7ee3ff6ab5c83f5bea8a841eafd7c8a1e55532d2d952_003FAtkValue_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003ACurrencyManager_002Ecs_002Fl_003AC_0021_003FUsers_003FJeffro_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003Fe66db7cd515142b9bbfb1b4e18f82ace825448_003Ffc_003F78df30c7_003FCurrencyManager_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AInventoryItem_002Ecs_002Fl_003AC_0021_003FUsers_003FJeffro_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FDecompilerCache_003Fdecompiler_003F9e458ae8a124476099a99b081d71ce27826848_003F6f_003Ffa56b446_003FInventoryItem_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AInventoryManager_002Ecs_002Fl_003AC_0021_003FUsers_003FJeffro_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003F7d322ffbe41aca452171c1858ac4d72a967922191dfb8ada66667df5fd58b_003FInventoryManager_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AItemOrderModule_002Ecs_002Fl_003AC_0021_003FUsers_003FJeffro_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003F77e1e4eb417120eb1e45bbb81bf6a70e47ea3c097bdf493584be7f333fa_003FItemOrderModule_002Ecs/@EntryIndexedValue">ForceIncluded</s:String>
|
||||
<s:String x:Key="/Default/CodeInspection/ExcludedFiles/FilesAndFoldersToSkip2/=7020124F_002D9FFC_002D4AC3_002D8F3D_002DAAB8E0240759_002Ff_003AItem_002Eg_002Ecs_002Fl_003AC_0021_003FUsers_003FJeffro_003FAppData_003FRoaming_003FJetBrains_003FRider2025_002E3_003Fresharper_002Dhost_003FSourcesCache_003F8ec7cc8a18dbb6a6f3c21f8adcb4e2661dc7979_003FItem_002Eg_002Ecs/@EntryIndexedValue">ForceIncluded</s:String></wpf:ResourceDictionary>
|
||||
@@ -17,6 +17,11 @@ public static unsafe class InventoryTypeExtensions
|
||||
InventoryType.Inventory2 => 49,
|
||||
InventoryType.Inventory3 => 50,
|
||||
InventoryType.Inventory4 => 51,
|
||||
InventoryType.RetainerPage1 => 52,
|
||||
InventoryType.RetainerPage2 => 53,
|
||||
InventoryType.RetainerPage3 => 54,
|
||||
InventoryType.RetainerPage4 => 55,
|
||||
InventoryType.RetainerPage5 => 56,
|
||||
InventoryType.ArmoryMainHand => 57,
|
||||
InventoryType.ArmoryHead => 58,
|
||||
InventoryType.ArmoryBody => 59,
|
||||
@@ -45,6 +50,11 @@ public static unsafe class InventoryTypeExtensions
|
||||
49 => InventoryType.Inventory2,
|
||||
50 => InventoryType.Inventory3,
|
||||
51 => InventoryType.Inventory4,
|
||||
52 => InventoryType.RetainerPage1,
|
||||
53 => InventoryType.RetainerPage2,
|
||||
54 => InventoryType.RetainerPage3,
|
||||
55 => InventoryType.RetainerPage4,
|
||||
56 => InventoryType.RetainerPage5,
|
||||
57 => InventoryType.ArmoryMainHand,
|
||||
58 => InventoryType.ArmoryHead,
|
||||
59 => InventoryType.ArmoryBody,
|
||||
@@ -85,6 +95,13 @@ public static unsafe class InventoryTypeExtensions
|
||||
InventoryType.SaddleBag2 => ItemOrderModule.Instance()->SaddleBagSorter,
|
||||
InventoryType.PremiumSaddleBag1 => ItemOrderModule.Instance()->PremiumSaddleBagSorter,
|
||||
InventoryType.PremiumSaddleBag2 => ItemOrderModule.Instance()->PremiumSaddleBagSorter,
|
||||
InventoryType.RetainerPage1 => ItemOrderModule.Instance()->GetActiveRetainerSorter(),
|
||||
InventoryType.RetainerPage2 => ItemOrderModule.Instance()->GetActiveRetainerSorter(),
|
||||
InventoryType.RetainerPage3 => ItemOrderModule.Instance()->GetActiveRetainerSorter(),
|
||||
InventoryType.RetainerPage4 => ItemOrderModule.Instance()->GetActiveRetainerSorter(),
|
||||
InventoryType.RetainerPage5 => ItemOrderModule.Instance()->GetActiveRetainerSorter(),
|
||||
InventoryType.RetainerPage6 => ItemOrderModule.Instance()->GetActiveRetainerSorter(),
|
||||
InventoryType.RetainerPage7 => ItemOrderModule.Instance()->GetActiveRetainerSorter(),
|
||||
_ => null,
|
||||
};
|
||||
|
||||
@@ -94,6 +111,12 @@ public static unsafe class InventoryTypeExtensions
|
||||
InventoryType.Inventory4 => inventoryType.GetInventorySorter->ItemsPerPage * 3,
|
||||
InventoryType.SaddleBag2 => inventoryType.GetInventorySorter->ItemsPerPage,
|
||||
InventoryType.PremiumSaddleBag2 => inventoryType.GetInventorySorter->ItemsPerPage,
|
||||
InventoryType.RetainerPage2 => inventoryType.GetInventorySorter->ItemsPerPage,
|
||||
InventoryType.RetainerPage3 => inventoryType.GetInventorySorter->ItemsPerPage * 2,
|
||||
InventoryType.RetainerPage4 => inventoryType.GetInventorySorter->ItemsPerPage * 3,
|
||||
InventoryType.RetainerPage5 => inventoryType.GetInventorySorter->ItemsPerPage * 4,
|
||||
InventoryType.RetainerPage6 => inventoryType.GetInventorySorter->ItemsPerPage * 5,
|
||||
InventoryType.RetainerPage7 => inventoryType.GetInventorySorter->ItemsPerPage * 6,
|
||||
_ => 0,
|
||||
};
|
||||
|
||||
@@ -123,11 +146,21 @@ public static unsafe class InventoryTypeExtensions
|
||||
InventoryType.ArmoryRings or
|
||||
InventoryType.ArmorySoulCrystal;
|
||||
|
||||
public bool IsRetainer => inventoryType is
|
||||
InventoryType.RetainerPage1 or
|
||||
InventoryType.RetainerPage2 or
|
||||
InventoryType.RetainerPage3 or
|
||||
InventoryType.RetainerPage4 or
|
||||
InventoryType.RetainerPage5 or
|
||||
InventoryType.RetainerPage6 or
|
||||
InventoryType.RetainerPage7;
|
||||
|
||||
public int ContainerGroup => inventoryType switch
|
||||
{
|
||||
_ when inventoryType.IsMainInventory => 1,
|
||||
_ when inventoryType.IsSaddleBag => 2,
|
||||
_ when inventoryType.IsArmory => 3,
|
||||
_ when inventoryType.IsRetainer => 4,
|
||||
_ => 0,
|
||||
};
|
||||
|
||||
@@ -157,9 +190,10 @@ public static unsafe class InventoryTypeExtensions
|
||||
InventoryType baseType = inventoryType switch
|
||||
{
|
||||
_ when inventoryType.IsMainInventory => InventoryType.Inventory1,
|
||||
_ when inventoryType.IsSaddleBag => inventoryType is InventoryType. SaddleBag1 or InventoryType.SaddleBag2
|
||||
? InventoryType. SaddleBag1
|
||||
_ when inventoryType.IsSaddleBag => inventoryType is InventoryType.SaddleBag1 or InventoryType.SaddleBag2
|
||||
? InventoryType.SaddleBag1
|
||||
: InventoryType.PremiumSaddleBag1,
|
||||
_ when inventoryType.IsRetainer => InventoryType.RetainerPage1,
|
||||
_ => inventoryType,
|
||||
};
|
||||
|
||||
@@ -168,5 +202,43 @@ public static unsafe class InventoryTypeExtensions
|
||||
|
||||
return (realContainer, realSlot);
|
||||
}
|
||||
|
||||
public int GetVisualSlotFromReal(int realSlot)
|
||||
{
|
||||
var sorter = inventoryType.GetInventorySorter;
|
||||
if (sorter == null)
|
||||
return realSlot;
|
||||
|
||||
int startIndex = inventoryType.GetInventoryStartIndex;
|
||||
long itemCount = sorter->Items.LongCount;
|
||||
|
||||
// Search through the sorter to find which visual index maps to this real slot
|
||||
for (int visualIdx = 0; visualIdx < itemCount; visualIdx++)
|
||||
{
|
||||
var entry = sorter->Items[visualIdx]. Value;
|
||||
if (entry == null) continue;
|
||||
|
||||
// Calculate what container this entry belongs to
|
||||
InventoryType baseType = inventoryType switch
|
||||
{
|
||||
_ when inventoryType.IsMainInventory => InventoryType. Inventory1,
|
||||
_ when inventoryType.IsSaddleBag => inventoryType is InventoryType.SaddleBag1 or InventoryType.SaddleBag2
|
||||
? InventoryType. SaddleBag1
|
||||
: InventoryType.PremiumSaddleBag1,
|
||||
_ when inventoryType.IsRetainer => InventoryType.RetainerPage1,
|
||||
_ => inventoryType,
|
||||
};
|
||||
|
||||
InventoryType entryContainer = baseType + entry->Page;
|
||||
|
||||
if (entryContainer == inventoryType && entry->Slot == realSlot)
|
||||
{
|
||||
// Found it! Return visual index relative to the container's start
|
||||
return visualIdx - startIndex;
|
||||
}
|
||||
}
|
||||
|
||||
return realSlot; // Fallback
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,10 @@ public static unsafe class InventoryMoveHelper
|
||||
{
|
||||
public static void MoveItem(InventoryType sourceContainer, ushort sourceSlot, InventoryType destContainer, ushort destSlot)
|
||||
{
|
||||
Services.Logger.Debug($"[MoveItem] {sourceContainer}@{sourceSlot} -> {destContainer}@{destSlot}");
|
||||
InventoryManager.Instance()->MoveItemSlot(sourceContainer, sourceSlot, destContainer, destSlot, true);
|
||||
System.AddonInventoryWindow.ManualInventoryRefresh();
|
||||
return;
|
||||
bool isCrossContainerMove = ! sourceContainer.IsSameContainerGroup(destContainer);
|
||||
|
||||
if (isCrossContainerMove)
|
||||
|
||||
@@ -46,7 +46,7 @@ public sealed unsafe class InventoryHooks : IDisposable
|
||||
InventoryItem* sourceItem = InventoryManager.Instance()->GetInventorySlot(srcType, srcSlot);
|
||||
InventoryItem* destItem = InventoryManager.Instance()->GetInventorySlot(dstType, dstSlot);
|
||||
|
||||
Services.Logger.Debug($"[MoveItemSlot] Moving {srcType}@{srcSlot} ID:{sourceItem->ItemId} -> {dstType}@{dstSlot} ID:{destItem->ItemId} Unk: {unk}");
|
||||
Services.Logger.Debug($"[MoveItemSlot Hook] Moving {srcType}@{srcSlot} ID:{sourceItem->ItemId} -> {dstType}@{dstSlot} ID:{destItem->ItemId} Unk: {unk}");
|
||||
|
||||
return _moveItemSlotHook!.Original(manager, srcType, srcSlot, dstType, dstSlot, unk);
|
||||
}
|
||||
|
||||
@@ -248,6 +248,7 @@ public class InventoryCategoryNode : SimpleComponentNode
|
||||
if (payload.Type != DragDropType.Item && payload.Type != DragDropType.Inventory_Item)
|
||||
return;
|
||||
|
||||
Services.Logger.Debug($"[OnPayload] Received payload of type {payload.Type}, Int1={payload.Int1}, Int2={payload.Int2}, RefIndex={payload.ReferenceIndex}, Text={payload.Text}");
|
||||
var (sourceContainer, sourceSlot) = ResolveSourceFromPayload(payload);
|
||||
|
||||
if (sourceContainer == 0)
|
||||
@@ -272,21 +273,35 @@ public class InventoryCategoryNode : SimpleComponentNode
|
||||
}
|
||||
|
||||
int containerId = payload.Int1;
|
||||
int slotIndex = payload.Int2;
|
||||
int uiSlot = payload.Int2;
|
||||
|
||||
InventoryType sourceContainer = InventoryType.GetInventoryTypeFromContainerId(containerId);
|
||||
|
||||
if (sourceContainer == 0)
|
||||
return (0, 0);
|
||||
|
||||
// For main inventory, resolve the real slot via ItemOrderModule
|
||||
if (sourceContainer.IsMainInventory)
|
||||
// Retainers have special handling: UI has 5 tabs × 35 slots, data has 7 pages × 25 slots
|
||||
if (sourceContainer. IsRetainer)
|
||||
{
|
||||
var (realContainer, realSlot) = sourceContainer.GetRealItemLocation(slotIndex);
|
||||
// Container IDs 52-56 = UI tabs 0-4
|
||||
int uiTabIndex = containerId - 52;
|
||||
|
||||
// Convert to global data index
|
||||
int globalDataIndex = (uiTabIndex * 35) + uiSlot;
|
||||
|
||||
// Calculate data page and slot
|
||||
int dataPage = globalDataIndex / 25;
|
||||
int dataSlot = globalDataIndex % 25;
|
||||
|
||||
InventoryType dataContainer = InventoryType.RetainerPage1 + (uint)dataPage;
|
||||
|
||||
// Now resolve through sorter for the actual storage location
|
||||
var (realContainer, realSlot) = dataContainer.GetRealItemLocation(dataSlot);
|
||||
return (realContainer, realSlot);
|
||||
}
|
||||
|
||||
// For other containers (saddlebags, armory, etc.), use the slot directly
|
||||
return (sourceContainer, (ushort)slotIndex);
|
||||
// For non-retainers, use the standard resolution
|
||||
var (realContainerOther, realSlotOther) = sourceContainer.GetRealItemLocation(uiSlot);
|
||||
return (realContainerOther, realSlotOther);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user