Add a stack limit for items to discard
This commit is contained in:
parent
d9ce02123c
commit
22314f556d
@ -17,7 +17,7 @@
|
||||
|
||||
<PropertyGroup>
|
||||
<DalamudLibPath>$(appdata)\XIVLauncher\addon\Hooks\dev\</DalamudLibPath>
|
||||
<AutoRetainerLibPath>$(appdata)\XIVLauncher\installedPlugins\AutoRetainer\4.1.1.6\</AutoRetainerLibPath>
|
||||
<AutoRetainerLibPath>$(appdata)\XIVLauncher\installedPlugins\AutoRetainer\4.1.1.8\</AutoRetainerLibPath>
|
||||
</PropertyGroup>
|
||||
|
||||
<PropertyGroup Condition="'$([System.Runtime.InteropServices.RuntimeInformation]::IsOSPlatform($([System.Runtime.InteropServices.OSPlatform]::Linux)))'">
|
||||
|
@ -13,6 +13,7 @@ internal sealed class Configuration : IPluginConfiguration
|
||||
|
||||
public ArmouryConfiguration Armoury { get; set; } = new();
|
||||
public ContextMenuConfiguration ContextMenu { get; set; } = new();
|
||||
public uint IgnoreItemCountWhenAbove { get; set; } = 50;
|
||||
|
||||
public sealed class CharacterInfo
|
||||
{
|
||||
|
@ -55,10 +55,11 @@ internal sealed class InventoryUtils
|
||||
public unsafe List<ItemWrapper> GetAllItemsToDiscard()
|
||||
{
|
||||
List<ItemWrapper> toDiscard = new List<ItemWrapper>();
|
||||
Dictionary<uint, uint> itemCounts = new();
|
||||
|
||||
InventoryManager* inventoryManager = InventoryManager.Instance();
|
||||
foreach (InventoryType inventoryType in DefaultInventoryTypes)
|
||||
toDiscard.AddRange(GetItemsToDiscard(inventoryManager, inventoryType, false, null));
|
||||
toDiscard.AddRange(GetItemsToDiscard(inventoryManager, inventoryType, itemCounts, false, null));
|
||||
|
||||
if (_configuration.Armoury.DiscardFromArmouryChest)
|
||||
{
|
||||
@ -67,17 +68,21 @@ internal sealed class InventoryUtils
|
||||
if (_configuration.Armoury.CheckLeftSideGear)
|
||||
{
|
||||
foreach (InventoryType inventoryType in LeftSideGearInventoryTypes)
|
||||
toDiscard.AddRange(GetItemsToDiscard(inventoryManager, inventoryType, true, gearsetItems));
|
||||
toDiscard.AddRange(GetItemsToDiscard(inventoryManager, inventoryType, itemCounts, true,
|
||||
gearsetItems));
|
||||
}
|
||||
|
||||
if (_configuration.Armoury.CheckRightSideGear)
|
||||
{
|
||||
foreach (InventoryType inventoryType in RightSideGearInventoryTypes)
|
||||
toDiscard.AddRange(GetItemsToDiscard(inventoryManager, inventoryType, true, gearsetItems));
|
||||
toDiscard.AddRange(GetItemsToDiscard(inventoryManager, inventoryType, itemCounts, true,
|
||||
gearsetItems));
|
||||
}
|
||||
}
|
||||
|
||||
return toDiscard;
|
||||
return toDiscard
|
||||
.Where(x => itemCounts[x.InventoryItem->ItemID] < _configuration.IgnoreItemCountWhenAbove)
|
||||
.ToList();
|
||||
}
|
||||
|
||||
public unsafe InventoryItem* GetNextItemToDiscard(ItemFilter? itemFilter)
|
||||
@ -89,7 +94,8 @@ internal sealed class InventoryUtils
|
||||
}
|
||||
|
||||
private unsafe IReadOnlyList<ItemWrapper> GetItemsToDiscard(InventoryManager* inventoryManager,
|
||||
InventoryType inventoryType, bool doGearChecks, IReadOnlyList<uint>? gearsetItems)
|
||||
InventoryType inventoryType, Dictionary<uint, uint> itemCounts, bool doGearChecks,
|
||||
IReadOnlyList<uint>? gearsetItems)
|
||||
{
|
||||
List<ItemWrapper> toDiscard = new List<ItemWrapper>();
|
||||
InventoryContainer* container = inventoryManager->GetInventoryContainer(inventoryType);
|
||||
@ -99,6 +105,11 @@ internal sealed class InventoryUtils
|
||||
var item = container->GetInventorySlot(i);
|
||||
if (item != null && item->ItemID != 0)
|
||||
{
|
||||
if (itemCounts.TryGetValue(item->ItemID, out uint itemCount))
|
||||
itemCounts[item->ItemID] = itemCount + item->Quantity;
|
||||
else
|
||||
itemCounts[item->ItemID] = item->Quantity;
|
||||
|
||||
if (InternalConfiguration.BlacklistedItems.Contains(item->ItemID))
|
||||
continue;
|
||||
|
||||
|
@ -321,6 +321,16 @@ internal sealed class ConfigWindow : Window
|
||||
ImGui.Unindent(30);
|
||||
ImGui.EndDisabled();
|
||||
|
||||
ImGui.Separator();
|
||||
|
||||
ImGui.SetNextItemWidth(ImGuiHelpers.GlobalScale * 100);
|
||||
int ignoreItemCountWhenAbove = (int)_configuration.IgnoreItemCountWhenAbove;
|
||||
if (ImGui.InputInt("Ignore stacks with >= this number of items", ref ignoreItemCountWhenAbove))
|
||||
{
|
||||
_configuration.IgnoreItemCountWhenAbove = (uint)Math.Max(2, ignoreItemCountWhenAbove);
|
||||
Save();
|
||||
}
|
||||
|
||||
ImGui.EndTabItem();
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user