From 82f26ee4ecb38ddd298a7fc95ab8381ebe8ed734 Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 18 Apr 2021 09:54:30 -0500 Subject: [PATCH] fix autoloading of ram watch that was broken in the 2.5 releas --- src/BizHawk.Client.EmuHawk/MainForm.Events.cs | 3 +-- src/BizHawk.Client.EmuHawk/tools/ToolManager.cs | 16 +++++++++++++++- 2 files changed, 16 insertions(+), 3 deletions(-) diff --git a/src/BizHawk.Client.EmuHawk/MainForm.Events.cs b/src/BizHawk.Client.EmuHawk/MainForm.Events.cs index 04c3ef0efa..a1787ef5ab 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -2541,8 +2541,6 @@ namespace BizHawk.Client.EmuHawk Tools.Load(); } - Tools.AutoLoad(); - if (Config.RecentWatches.AutoLoad) { Tools.LoadRamWatch(!Config.DisplayRamWatch); @@ -2553,6 +2551,7 @@ namespace BizHawk.Client.EmuHawk Tools.Load(); } + Tools.AutoLoad(); HandlePlatformMenus(); } diff --git a/src/BizHawk.Client.EmuHawk/tools/ToolManager.cs b/src/BizHawk.Client.EmuHawk/tools/ToolManager.cs index c902949599..9d661c05d4 100644 --- a/src/BizHawk.Client.EmuHawk/tools/ToolManager.cs +++ b/src/BizHawk.Client.EmuHawk/tools/ToolManager.cs @@ -227,7 +227,10 @@ namespace BizHawk.Client.EmuHawk } else { - Load(t, false); + if (!IsLoaded(t)) + { + Load(t, false); + } } } } @@ -460,6 +463,17 @@ namespace BizHawk.Client.EmuHawk return false; } + public bool IsLoaded(Type toolType) + { + var existingTool = _tools.FirstOrDefault(t => t.GetType() == toolType); + if (existingTool != null) + { + return !existingTool.IsDisposed || (existingTool is RamWatch && _config.DisplayRamWatch); + } + + return false; + } + public bool IsOnScreen(Point topLeft) { return Screen.AllScreens.Any(