Add prop IToolApi.AvailableTools and use in ClientLuaLibrary

This commit is contained in:
YoshiRulz 2020-11-26 22:12:12 +10:00
parent 2e428ccc2e
commit 939cd1bcaf
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
3 changed files with 7 additions and 1 deletions

View File

@ -1,8 +1,11 @@
using System;
using System.Collections.Generic;
namespace BizHawk.Client.Common
{
public interface IToolApi : IExternalApi
{
IEnumerable<Type> AvailableTools { get; }
Type GetTool(string name);
object CreateInstance(string name);
void OpenCheats();

View File

@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using System.Linq;
using BizHawk.Client.Common;
@ -8,6 +9,8 @@ namespace BizHawk.Client.EmuHawk
{
public sealed class ToolApi : IToolApi
{
public IEnumerable<Type> AvailableTools => GlobalWin.Tools.AvailableTools.ToList(); // defensive copy in case ToolManager's implementation changes
public Type GetTool(string name)
{
var toolType = Util.GetTypeByName(name).FirstOrDefault(x => typeof(IToolForm).IsAssignableFrom(x) && !x.IsInterface);

View File

@ -295,7 +295,7 @@ namespace BizHawk.Client.EmuHawk
[LuaMethodExample("local nlcliget = client.getavailabletools( );")]
[LuaMethod("getavailabletools", "Returns a list of the tools currently open")]
public LuaTable GetAvailableTools() => GlobalWin.Tools.AvailableTools.Select(tool => tool.Name.ToLower()).EnumerateToLuaTable(Lua);
public LuaTable GetAvailableTools() => APIs.Tool.AvailableTools.Select(tool => tool.Name.ToLower()).EnumerateToLuaTable(Lua);
[LuaMethodExample("local nlcliget = client.gettool( \"Tool name\" );")]
[LuaMethod("gettool", "Returns an object that represents a tool of the given name (not case sensitive). If the tool is not open, it will be loaded if available. Use gettools to get a list of names")]