Add wrapper for Lua Console log callback and cleanup
This commit is contained in:
parent
939cd1bcaf
commit
663e9cfbec
|
@ -44,12 +44,6 @@ namespace BizHawk.Client.EmuHawk
|
|||
LogWithSeparator("\t", "\n", outputs);
|
||||
}
|
||||
|
||||
// Single param version is used by logOutputCallback of some libraries.
|
||||
public static void LogOutput(object output)
|
||||
{
|
||||
Log(output);
|
||||
}
|
||||
|
||||
[LuaMethodExample("console.writeline( \"New log line.\" );")]
|
||||
[LuaMethod("writeline", "Outputs the given object to the output box on the Lua Console dialog. Note: Can accept a LuaTable")]
|
||||
public static void WriteLine(params object[] outputs)
|
||||
|
|
|
@ -49,7 +49,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
LuaWait = new AutoResetEvent(false);
|
||||
Docs.Clear();
|
||||
var apiContainer = ApiManager.RestartLua(serviceProvider, ConsoleLuaLibrary.LogOutput, mainForm, displayManager, inputManager, config, emulator, game);
|
||||
var apiContainer = ApiManager.RestartLua(serviceProvider, LogToLuaConsole, mainForm, displayManager, inputManager, config, emulator, game);
|
||||
|
||||
// Register lua libraries
|
||||
foreach (var lib in Client.Common.ReflectionCache.Types.Concat(EmuHawk.ReflectionCache.Types)
|
||||
|
@ -64,7 +64,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
if (addLibrary)
|
||||
{
|
||||
var instance = (LuaLibraryBase) Activator.CreateInstance(lib, this, _lua, (Action<string>) ConsoleLuaLibrary.LogOutput);
|
||||
var instance = (LuaLibraryBase) Activator.CreateInstance(lib, this, _lua, (Action<string>) LogToLuaConsole);
|
||||
ServiceInjector.UpdateServices(serviceProvider, instance);
|
||||
|
||||
// TODO: make EmuHawk libraries have a base class with common properties such as this
|
||||
|
@ -101,6 +101,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
private Lua _lua = new Lua();
|
||||
private Lua _currThread;
|
||||
|
||||
private static readonly Action<object[]> _logToLuaConsoleCallback = ConsoleLuaLibrary.Log;
|
||||
|
||||
private FormsLuaLibrary FormsLibrary => (FormsLuaLibrary)Libraries[typeof(FormsLuaLibrary)];
|
||||
|
||||
private EventsLuaLibrary EventsLibrary => (EventsLuaLibrary)Libraries[typeof(EventsLuaLibrary)];
|
||||
|
@ -109,6 +111,8 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public override GuiLuaLibrary GuiLibrary => (GuiLuaLibrary) Libraries[typeof(GuiLuaLibrary)];
|
||||
|
||||
private static void LogToLuaConsole(object outputs) => _logToLuaConsoleCallback(new[] { outputs });
|
||||
|
||||
public override void Restart(IEmulatorServiceProvider newServiceProvider)
|
||||
{
|
||||
foreach (var lib in Libraries)
|
||||
|
@ -244,7 +248,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public static void Print(params object[] outputs)
|
||||
{
|
||||
ConsoleLuaLibrary.Log(outputs);
|
||||
_logToLuaConsoleCallback(outputs);
|
||||
}
|
||||
|
||||
private void Frameadvance()
|
||||
|
|
Loading…
Reference in New Issue