Add prop IToolApi.AvailableTools and use in ClientLuaLibrary
This commit is contained in:
parent
2e428ccc2e
commit
939cd1bcaf
|
@ -1,8 +1,11 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
|
||||||
namespace BizHawk.Client.Common
|
namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
public interface IToolApi : IExternalApi
|
public interface IToolApi : IExternalApi
|
||||||
{
|
{
|
||||||
|
IEnumerable<Type> AvailableTools { get; }
|
||||||
Type GetTool(string name);
|
Type GetTool(string name);
|
||||||
object CreateInstance(string name);
|
object CreateInstance(string name);
|
||||||
void OpenCheats();
|
void OpenCheats();
|
||||||
|
|
|
@ -1,4 +1,5 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
|
||||||
using BizHawk.Client.Common;
|
using BizHawk.Client.Common;
|
||||||
|
@ -8,6 +9,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
public sealed class ToolApi : IToolApi
|
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)
|
public Type GetTool(string name)
|
||||||
{
|
{
|
||||||
var toolType = Util.GetTypeByName(name).FirstOrDefault(x => typeof(IToolForm).IsAssignableFrom(x) && !x.IsInterface);
|
var toolType = Util.GetTypeByName(name).FirstOrDefault(x => typeof(IToolForm).IsAssignableFrom(x) && !x.IsInterface);
|
||||||
|
|
|
@ -295,7 +295,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
[LuaMethodExample("local nlcliget = client.getavailabletools( );")]
|
[LuaMethodExample("local nlcliget = client.getavailabletools( );")]
|
||||||
[LuaMethod("getavailabletools", "Returns a list of the tools currently open")]
|
[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\" );")]
|
[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")]
|
[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")]
|
||||||
|
|
Loading…
Reference in New Issue