Skip to content

Commit

Permalink
Return the tool from IToolApi.GetTool instead of its type
Browse files Browse the repository at this point in the history
also affects Lua client.gettool; this has been broken for quite a while
  • Loading branch information
YoshiRulz committed Dec 22, 2020
1 parent 5a09805 commit a5fd5f5
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 5 deletions.
13 changes: 11 additions & 2 deletions src/BizHawk.Client.Common/Api/Interfaces/IToolApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,14 +6,23 @@ namespace BizHawk.Client.Common
public interface IToolApi : IExternalApi
{
IEnumerable<Type> AvailableTools { get; }
Type GetTool(string name);

object CreateInstance(string name);

IToolForm GetTool(string name);

void OpenCheats();

void OpenHexEditor();
void OpenRamWatch();

void OpenRamSearch();

void OpenRamWatch();

void OpenTasStudio();

void OpenToolBox();

void OpenTraceLogger();
}
}
6 changes: 3 additions & 3 deletions src/BizHawk.Client.EmuHawk/Api/Libraries/ToolApi.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,11 @@ public sealed class ToolApi : IToolApi

public ToolApi(ToolManager toolManager) => _toolManager = toolManager;

public Type GetTool(string name)
public IToolForm GetTool(string name)
{
var toolType = Util.GetTypeByName(name).FirstOrDefault(x => typeof(IToolForm).IsAssignableFrom(x) && !x.IsInterface);
if (toolType != null) _toolManager.Load(toolType);
return _toolManager.AvailableTools.FirstOrDefault(tool => tool.Name.Equals(name, StringComparison.InvariantCultureIgnoreCase));
if (toolType == null) return null;
return _toolManager.Load(toolType);
}

public object CreateInstance(string name)
Expand Down

0 comments on commit a5fd5f5

Please sign in to comment.