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 class InventoryMonitor : IDisposable
|
||||||
{
|
{
|
||||||
|
|
||||||
public InventoryMonitor()
|
public InventoryMonitor()
|
||||||
{
|
{
|
||||||
var bags = new[] { "Inventory", "InventoryLarge", "InventoryExpansion" };
|
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, retainer, OnPreFinalize);
|
||||||
Services.AddonLifecycle.RegisterListener(AddonEvent.PreFinalize, bags, OnInventoryPreFinalize);
|
Services.AddonLifecycle.RegisterListener(AddonEvent.PreFinalize, bags, OnInventoryPreFinalize);
|
||||||
|
|
||||||
|
Services.AddonLifecycle.RegisterListener(AddonEvent.PreHide, bags, OnInventoryPreHide);
|
||||||
|
|
||||||
// PreRefresh Handlers
|
// PreRefresh Handlers
|
||||||
Services.AddonLifecycle.RegisterListener(AddonEvent.PreRefresh, bags, InventoryPreRefreshHandler);
|
Services.AddonLifecycle.RegisterListener(AddonEvent.PreRefresh, bags, InventoryPreRefreshHandler);
|
||||||
|
|
||||||
@@ -71,6 +72,14 @@ public class InventoryMonitor : IDisposable
|
|||||||
System.AddonInventoryWindow.Close();
|
System.AddonInventoryWindow.Close();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void OnInventoryPreHide(AddonEvent type, AddonArgs args)
|
||||||
|
{
|
||||||
|
if (System.Config.General.OpenWithGameInventory)
|
||||||
|
{
|
||||||
|
System.AddonInventoryWindow.Close();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private unsafe void OpenInventories(string name)
|
private unsafe void OpenInventories(string name)
|
||||||
{
|
{
|
||||||
GeneralSettings config = System.Config.General;
|
GeneralSettings config = System.Config.General;
|
||||||
@@ -192,14 +201,10 @@ public class InventoryMonitor : IDisposable
|
|||||||
|
|
||||||
if (config.OpenWithGameInventory)
|
if (config.OpenWithGameInventory)
|
||||||
{
|
{
|
||||||
AtkValue* value1 = (AtkValue*)atkValues[1].Address;
|
var addon = RaptureAtkUnitManager.Instance()->GetAddonByName(args.AddonName);
|
||||||
int openTitleId = value1->Int;
|
bool isCurrentlyVisible = addon != null && addon->IsVisible;
|
||||||
|
|
||||||
if (openTitleId == 0)
|
if (!isCurrentlyVisible)
|
||||||
{
|
|
||||||
System.AddonInventoryWindow.Toggle();
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
{
|
||||||
System.AddonInventoryWindow.Open();
|
System.AddonInventoryWindow.Open();
|
||||||
}
|
}
|
||||||
@@ -245,6 +250,6 @@ public class InventoryMonitor : IDisposable
|
|||||||
public void Dispose()
|
public void Dispose()
|
||||||
{
|
{
|
||||||
Services.GameInventory.InventoryChangedRaw -= OnInventoryChangedRaw;
|
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