Improves inventory refresh logic and fixes UI glitches
This commit is contained in:
@@ -101,12 +101,7 @@ public unsafe class AddonInventoryWindow : InventoryAddonBase
|
||||
private void OnLootedItemsChanged(IReadOnlyList<LootedItemInfo> lootedItems)
|
||||
{
|
||||
if (!IsOpen || !IsSetupComplete) return;
|
||||
|
||||
Services.Framework.RunOnTick(() =>
|
||||
{
|
||||
if (!IsOpen) return;
|
||||
UpdateLootedCategory(lootedItems);
|
||||
}, delayTicks: 1);
|
||||
UpdateLootedCategory(lootedItems);
|
||||
}
|
||||
|
||||
private void UpdateLootedCategory(IReadOnlyList<LootedItemInfo> lootedItems)
|
||||
@@ -119,6 +114,7 @@ public unsafe class AddonInventoryWindow : InventoryAddonBase
|
||||
{
|
||||
CategoriesNode.SetHoistedNode(_lootedCategoryNode);
|
||||
}
|
||||
AutoSizeWindow();
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -131,6 +127,7 @@ public unsafe class AddonInventoryWindow : InventoryAddonBase
|
||||
|
||||
CategoriesNode.RemoveNode(_lootedCategoryNode);
|
||||
}
|
||||
AutoSizeWindow();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -158,6 +155,7 @@ public unsafe class AddonInventoryWindow : InventoryAddonBase
|
||||
}, delayTicks: 3);
|
||||
}
|
||||
|
||||
|
||||
protected override void OnFinalize(AtkUnitBase* addon)
|
||||
{
|
||||
System.LootedItemsTracker.OnLootedItemsChanged -= OnLootedItemsChanged;
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Numerics;
|
||||
using AetherBags.AddonLifecycles;
|
||||
using AetherBags.Configuration;
|
||||
using AetherBags.Helpers;
|
||||
using AetherBags.Inventory;
|
||||
@@ -169,11 +170,10 @@ public abstract unsafe class InventoryAddonBase : NativeAddon, IInventoryWindow
|
||||
CategoriesNode.SyncWithListDataByKey<CategorizedInventory, InventoryCategoryNode, uint>(
|
||||
dataList: categories,
|
||||
getKeyFromData: categorizedInventory => categorizedInventory.Key,
|
||||
getKeyFromNode: node => node.Key,
|
||||
getKeyFromNode: node => node.CategorizedInventory.Key,
|
||||
updateNode: (node, data) =>
|
||||
{
|
||||
node.CategorizedInventory = data;
|
||||
node.ItemsPerLine = Math.Min(data.Items.Count, maxItemsPerLine);
|
||||
node.SetCategoryData(data, Math.Min(data.Items.Count, maxItemsPerLine));
|
||||
node.RefreshNodeVisuals();
|
||||
},
|
||||
createNodeMethod: _ => CreateCategoryNode());
|
||||
@@ -409,6 +409,9 @@ public abstract unsafe class InventoryAddonBase : NativeAddon, IInventoryWindow
|
||||
{
|
||||
base.OnRequestedUpdate(addon, numberArrayData, stringArrayData);
|
||||
|
||||
if (DragDropState.IsDragging)
|
||||
return;
|
||||
|
||||
InventoryState.RefreshFromGame();
|
||||
RefreshCategoriesCore(autosize: true);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user