Improves inventory window management.
Addresses an issue where the inventory window doesn't always open correctly when the game inventory is opened. Adds logic to ensure the inventory window closes when the inventory addon is hidden. Updates the inventory opening logic to check for visibility using RaptureAtkUnitManager instead of AtkValues.
This commit is contained in:
@@ -28,7 +28,6 @@ public static unsafe class DragDropState
|
||||
|
||||
public class InventoryMonitor : IDisposable
|
||||
{
|
||||
|
||||
public InventoryMonitor()
|
||||
{
|
||||
var bags = new[] { "Inventory", "InventoryLarge", "InventoryExpansion" };
|
||||
@@ -42,6 +41,8 @@ public class InventoryMonitor : IDisposable
|
||||
Services.AddonLifecycle.RegisterListener(AddonEvent.PreFinalize, retainer, OnPreFinalize);
|
||||
Services.AddonLifecycle.RegisterListener(AddonEvent.PreFinalize, bags, OnInventoryPreFinalize);
|
||||
|
||||
Services.AddonLifecycle.RegisterListener(AddonEvent.PreHide, bags, OnInventoryPreHide);
|
||||
|
||||
// PreRefresh Handlers
|
||||
Services.AddonLifecycle.RegisterListener(AddonEvent.PreRefresh, bags, InventoryPreRefreshHandler);
|
||||
|
||||
@@ -71,6 +72,14 @@ public class InventoryMonitor : IDisposable
|
||||
System.AddonInventoryWindow.Close();
|
||||
}
|
||||
|
||||
private void OnInventoryPreHide(AddonEvent type, AddonArgs args)
|
||||
{
|
||||
if (System.Config.General.OpenWithGameInventory)
|
||||
{
|
||||
System.AddonInventoryWindow.Close();
|
||||
}
|
||||
}
|
||||
|
||||
private unsafe void OpenInventories(string name)
|
||||
{
|
||||
GeneralSettings config = System.Config.General;
|
||||
@@ -192,14 +201,10 @@ public class InventoryMonitor : IDisposable
|
||||
|
||||
if (config.OpenWithGameInventory)
|
||||
{
|
||||
AtkValue* value1 = (AtkValue*)atkValues[1].Address;
|
||||
int openTitleId = value1->Int;
|
||||
var addon = RaptureAtkUnitManager.Instance()->GetAddonByName(args.AddonName);
|
||||
bool isCurrentlyVisible = addon != null && addon->IsVisible;
|
||||
|
||||
if (openTitleId == 0)
|
||||
{
|
||||
System.AddonInventoryWindow.Toggle();
|
||||
}
|
||||
else
|
||||
if (!isCurrentlyVisible)
|
||||
{
|
||||
System.AddonInventoryWindow.Open();
|
||||
}
|
||||
@@ -245,6 +250,6 @@ public class InventoryMonitor : IDisposable
|
||||
public void Dispose()
|
||||
{
|
||||
Services.GameInventory.InventoryChangedRaw -= OnInventoryChangedRaw;
|
||||
Services.AddonLifecycle.UnregisterListener(OnPostSetup, OnPreFinalize, OnInventoryUpdate, OnSaddleBagUpdate, OnRetainerInventoryUpdate, OnInventoryPreFinalize, InventoryPreRefreshHandler);
|
||||
Services.AddonLifecycle.UnregisterListener(OnPostSetup, OnPreFinalize, OnInventoryUpdate, OnSaddleBagUpdate, OnRetainerInventoryUpdate, OnInventoryPreFinalize, OnInventoryPreHide, InventoryPreRefreshHandler);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user