ExternalTools: Allow several tools running simultaneously

This commit is contained in:
Hathor86 2015-12-30 11:00:56 +01:00
parent 485d1e53d0
commit 2876f63dd8
2 changed files with 14 additions and 4 deletions

View File

@ -7,7 +7,7 @@ namespace BizHawk.Client.ApiHawk
/// This attribute helps BizHawk to handle ExternalTools
/// </summary>
[AttributeUsage(AttributeTargets.Assembly)]
public class BizHawkExternalToolAttribute : Attribute
public sealed class BizHawkExternalToolAttribute : Attribute
{
#region Fields

View File

@ -84,12 +84,22 @@ namespace BizHawk.Client.EmuHawk
public T Load<T>(string toolPath, bool focus = true)
where T : class, IToolForm
{
if (!IsAvailable<T>() && typeof(T) != typeof(IExternalToolForm))
bool isExternal = typeof(T) == typeof(IExternalToolForm);
if (!IsAvailable<T>() && !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();
}