Pass global ToolManager to Console and TAStudio Lua libs on init
This commit is contained in:
parent
256f4d5b06
commit
794c4b5b84
|
@ -9,6 +9,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
public sealed class ConsoleLuaLibrary : LuaLibraryBase
|
||||
{
|
||||
public ToolManager Tools { get; set; }
|
||||
|
||||
public ConsoleLuaLibrary(LuaLibraries luaLibsImpl, Lua lua, Action<string> logOutputCallback)
|
||||
: base(luaLibsImpl, lua, logOutputCallback) {}
|
||||
|
||||
|
@ -18,9 +20,9 @@ namespace BizHawk.Client.EmuHawk
|
|||
[LuaMethod("clear", "clears the output box of the Lua Console window")]
|
||||
public void Clear()
|
||||
{
|
||||
if (GlobalWin.Tools.Has<LuaConsole>())
|
||||
if (Tools.Has<LuaConsole>())
|
||||
{
|
||||
GlobalWin.Tools.LuaConsole.ClearOutputWindow();
|
||||
Tools.LuaConsole.ClearOutputWindow();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -83,7 +85,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
);
|
||||
}
|
||||
|
||||
if (!GlobalWin.Tools.Has<LuaConsole>())
|
||||
if (!Tools.Has<LuaConsole>())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
@ -114,7 +116,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
sb.Append(terminator);
|
||||
}
|
||||
|
||||
GlobalWin.Tools.LuaConsole.WriteToOutputWindow(sb.ToString());
|
||||
Tools.LuaConsole.WriteToOutputWindow(sb.ToString());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -16,12 +16,14 @@ namespace BizHawk.Client.EmuHawk
|
|||
[LuaLibrary(released: true)]
|
||||
public sealed class TAStudioLuaLibrary : LuaLibraryBase
|
||||
{
|
||||
public ToolManager Tools { get; set; }
|
||||
|
||||
public TAStudioLuaLibrary(LuaLibraries luaLibsImpl, Lua lua, Action<string> logOutputCallback)
|
||||
: base(luaLibsImpl, lua, logOutputCallback) {}
|
||||
|
||||
public override string Name => "tastudio";
|
||||
|
||||
private TAStudio Tastudio => GlobalWin.Tools.Get<TAStudio>() as TAStudio;
|
||||
private TAStudio Tastudio => Tools.Get<TAStudio>() as TAStudio;
|
||||
|
||||
private struct PendingChanges
|
||||
{
|
||||
|
@ -61,7 +63,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
[LuaMethod("engaged", "returns whether or not tastudio is currently engaged (active)")]
|
||||
public bool Engaged()
|
||||
{
|
||||
return GlobalWin.Tools.Has<TAStudio>(); // TODO: eventually tastudio should have an engaged flag
|
||||
return Tools.Has<TAStudio>(); // TODO: eventually tastudio should have an engaged flag
|
||||
}
|
||||
|
||||
[LuaMethodExample("if ( tastudio.getrecording( ) ) then\r\n\tconsole.log( \"returns whether or not TAStudio is in recording mode\" );\r\nend;")]
|
||||
|
|
|
@ -75,6 +75,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
}
|
||||
else if (instance is ConsoleLuaLibrary consoleLib)
|
||||
{
|
||||
consoleLib.Tools = GlobalWin.Tools;
|
||||
_logToLuaConsoleCallback = consoleLib.Log;
|
||||
}
|
||||
else if (instance is GuiLuaLibrary guiLib)
|
||||
|
@ -86,6 +87,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
return _lua.TableFromObject(canvas);
|
||||
};
|
||||
}
|
||||
else if (instance is TAStudioLuaLibrary tastudioLib)
|
||||
{
|
||||
tastudioLib.Tools = GlobalWin.Tools;
|
||||
}
|
||||
|
||||
if (instance is DelegatingLuaLibrary dlgInstance) dlgInstance.APIs = apiContainer;
|
||||
|
||||
|
|
Loading…
Reference in New Issue