From 2876f63dd8caabea6a1b305438f0d091f8779b89 Mon Sep 17 00:00:00 2001 From: Hathor86 Date: Wed, 30 Dec 2015 11:00:56 +0100 Subject: [PATCH] ExternalTools: Allow several tools running simultaneously --- .../Attributes/ExternalToolAttribute.cs | 2 +- BizHawk.Client.EmuHawk/tools/ToolManager.cs | 16 +++++++++++++--- 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/BizHawk.Client.ApiHawk/Attributes/ExternalToolAttribute.cs b/BizHawk.Client.ApiHawk/Attributes/ExternalToolAttribute.cs index 2285079810..260eaf71c7 100644 --- a/BizHawk.Client.ApiHawk/Attributes/ExternalToolAttribute.cs +++ b/BizHawk.Client.ApiHawk/Attributes/ExternalToolAttribute.cs @@ -7,7 +7,7 @@ namespace BizHawk.Client.ApiHawk /// This attribute helps BizHawk to handle ExternalTools /// [AttributeUsage(AttributeTargets.Assembly)] - public class BizHawkExternalToolAttribute : Attribute + public sealed class BizHawkExternalToolAttribute : Attribute { #region Fields diff --git a/BizHawk.Client.EmuHawk/tools/ToolManager.cs b/BizHawk.Client.EmuHawk/tools/ToolManager.cs index 1a15873f24..3bc23bcfb2 100644 --- a/BizHawk.Client.EmuHawk/tools/ToolManager.cs +++ b/BizHawk.Client.EmuHawk/tools/ToolManager.cs @@ -84,12 +84,22 @@ namespace BizHawk.Client.EmuHawk public T Load(string toolPath, bool focus = true) where T : class, IToolForm { - if (!IsAvailable() && typeof(T) != typeof(IExternalToolForm)) + bool isExternal = typeof(T) == typeof(IExternalToolForm); + + if (!IsAvailable() && !isExternal) { return null; } - T existingTool = (T)_tools.FirstOrDefault(x => x is T); + T existingTool; + if (isExternal) + { + existingTool = (T)_tools.FirstOrDefault(x => x is T && x.GetType().Assembly.Location == toolPath); + } + else + { + existingTool = (T)_tools.FirstOrDefault(x => x is T); + } if (existingTool != null) { @@ -446,7 +456,7 @@ namespace BizHawk.Client.EmuHawk restartTool = true; if (tool is LuaConsole && ((LuaConsole)tool).IsRebootingCore) restartTool = false; - if(restartTool) + if (restartTool) { tool.Restart(); }