v1.0.7.0: Hotbar charge count on slots; fix WndProc restore on unload (left-click after disable)
Co-authored-by: Cursor <cursoragent@cursor.com>
This commit is contained in:
+28
-11
@@ -142,8 +142,22 @@ namespace HSUI.Helpers
|
||||
return;
|
||||
}
|
||||
|
||||
ConfigurationManager.Instance.ResetEvent -= OnConfigReset;
|
||||
Plugin.Framework.Update -= OnFrameworkUpdate;
|
||||
// Restore WndProc first so left-click works again immediately after unload.
|
||||
// After a game/Dalamud patch, other singletons may be disposed before us;
|
||||
// if we unsub or touch config first and that throws, we would never restore and LButton stays broken.
|
||||
RestoreWndProc();
|
||||
|
||||
try
|
||||
{
|
||||
ConfigurationManager.Instance.ResetEvent -= OnConfigReset;
|
||||
}
|
||||
catch { /* Instance may already be disposed */ }
|
||||
|
||||
try
|
||||
{
|
||||
Plugin.Framework.Update -= OnFrameworkUpdate;
|
||||
}
|
||||
catch { /* Framework may already be disposed */ }
|
||||
|
||||
Plugin.Logger.Info("\t\tDisposing _requestActionHook: " + (_requestActionHook?.Address.ToString("X") ?? "null"));
|
||||
_requestActionHook?.Disable();
|
||||
@@ -151,9 +165,6 @@ namespace HSUI.Helpers
|
||||
_executeSlotByIdHook?.Disable();
|
||||
_executeSlotByIdHook?.Dispose();
|
||||
|
||||
// give imgui the control of inputs again
|
||||
RestoreWndProc();
|
||||
|
||||
Instance = null!;
|
||||
}
|
||||
#endregion
|
||||
@@ -556,15 +567,21 @@ namespace HSUI.Helpers
|
||||
|
||||
private void RestoreWndProc()
|
||||
{
|
||||
if (_wndHandle != IntPtr.Zero && _imguiWndProcPtr != IntPtr.Zero)
|
||||
if (_wndHandle == IntPtr.Zero || _imguiWndProcPtr == IntPtr.Zero)
|
||||
return;
|
||||
|
||||
try
|
||||
{
|
||||
Plugin.Logger.Info("\t\tRestoring WndProc");
|
||||
Plugin.Logger.Info("\t\t\tOld _wndHandle = " + _wndHandle.ToString("X"));
|
||||
Plugin.Logger.Info("\t\t\tOld _imguiWndProcPtr = " + _imguiWndProcPtr.ToString("X"));
|
||||
|
||||
SetWindowLongPtr(_wndHandle, GWL_WNDPROC, _imguiWndProcPtr);
|
||||
Plugin.Logger.Info("\t\t\tDone!");
|
||||
|
||||
Plugin.Logger.Info("\t\t\tWndProc restored.");
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
Plugin.Logger.Warning($"\t\tRestoreWndProc failed: {ex.Message}");
|
||||
}
|
||||
finally
|
||||
{
|
||||
_wndHandle = IntPtr.Zero;
|
||||
_imguiWndProcPtr = IntPtr.Zero;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user