diff --git a/src/BizHawk.Client.EmuHawk/MainForm.Events.cs b/src/BizHawk.Client.EmuHawk/MainForm.Events.cs index 36c084086c..06913c66ee 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.Events.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.Events.cs @@ -1194,7 +1194,7 @@ namespace BizHawk.Client.EmuHawk { ExternalToolMenuItem.DropDownItems.Clear(); - foreach (var item in ExternalToolManager.ToolStripMenu) + foreach (var item in ExtToolManager.ToolStripMenu) { if (item.Tag is ValueTuple tuple) { diff --git a/src/BizHawk.Client.EmuHawk/MainForm.cs b/src/BizHawk.Client.EmuHawk/MainForm.cs index e3d2fcf508..45614e4485 100644 --- a/src/BizHawk.Client.EmuHawk/MainForm.cs +++ b/src/BizHawk.Client.EmuHawk/MainForm.cs @@ -135,7 +135,7 @@ namespace BizHawk.Client.EmuHawk var requestedExtToolDll = _argParser.openExtToolDll; if (requestedExtToolDll != null) { - var enabled = ExternalToolManager.ToolStripMenu.Where(item => item.Enabled) + var enabled = ExtToolManager.ToolStripMenu.Where(item => item.Enabled) .Select(item => ((string, string)) item.Tag) .ToList(); try @@ -344,6 +344,7 @@ namespace BizHawk.Client.EmuHawk Controls.SetChildIndex(_presentationPanel, 0); Tools = new ToolManager(this, Config, DisplayManager, InputManager, Emulator, MovieSession, Game); + ExtToolManager = new ExternalToolManager(); // TODO GL - move these event handlers somewhere less obnoxious line in the On* overrides Load += (o, e) => @@ -865,6 +866,8 @@ namespace BizHawk.Client.EmuHawk private readonly IGL GL; + private readonly ExternalToolManager ExtToolManager; + public readonly ToolManager Tools; private DisplayManager DisplayManager; @@ -3789,7 +3792,7 @@ namespace BizHawk.Client.EmuHawk } } - ExternalToolManager.BuildToolStrip(); + ExtToolManager.BuildToolStrip(); EmuClient.OnRomLoaded(Emulator); return true; diff --git a/src/BizHawk.Client.EmuHawk/tools/ExternalToolManager.cs b/src/BizHawk.Client.EmuHawk/tools/ExternalToolManager.cs index f298f91e7e..f2ca8feb7d 100644 --- a/src/BizHawk.Client.EmuHawk/tools/ExternalToolManager.cs +++ b/src/BizHawk.Client.EmuHawk/tools/ExternalToolManager.cs @@ -11,18 +11,13 @@ using BizHawk.Common; namespace BizHawk.Client.EmuHawk { - /// - /// This static class handle all ExternalTools - /// - public static class ExternalToolManager + public sealed class ExternalToolManager { - private static readonly FileSystemWatcher DirectoryMonitor; - private static readonly List MenuItems = new List(); + private readonly FileSystemWatcher DirectoryMonitor; - /// - /// Initialization - /// - static ExternalToolManager() + private readonly List MenuItems = new List(); + + public ExternalToolManager() { if(!Directory.Exists(GlobalWin.Config.PathEntries["Global", "External Tools"].Path)) { @@ -41,10 +36,7 @@ namespace BizHawk.Client.EmuHawk BuildToolStrip(); } - /// - /// Build the ToolStrip menu - /// - internal static void BuildToolStrip() + internal void BuildToolStrip() { MenuItems.Clear(); if (Directory.Exists(DirectoryMonitor.Path)) @@ -63,7 +55,7 @@ namespace BizHawk.Client.EmuHawk /// a with its containing a (string, string); /// the first is the assembly path () and the second is the of the entry point form's type /// - private static ToolStripMenuItem GenerateToolTipFromFileName(string fileName) + private ToolStripMenuItem GenerateToolTipFromFileName(string fileName) { if (fileName == null) throw new Exception(); var item = new ToolStripMenuItem(Path.GetFileName(fileName)) { Enabled = false }; @@ -144,7 +136,7 @@ namespace BizHawk.Client.EmuHawk /// /// Object that raised the event /// Event arguments - private static void DirectoryMonitor_Created(object sender, FileSystemEventArgs e) + private void DirectoryMonitor_Created(object sender, FileSystemEventArgs e) { MenuItems.Add(GenerateToolTipFromFileName(e.FullPath)); } @@ -153,6 +145,6 @@ namespace BizHawk.Client.EmuHawk /// Gets a prebuild /// This list auto-updated by the itself /// - public static IEnumerable ToolStripMenu => MenuItems; + public IEnumerable ToolStripMenu => MenuItems; } }