Make ConsoleLuaLib funcs not static, save callback on init of lib
This commit is contained in:
parent
9e0a3c0e34
commit
256f4d5b06
|
@ -16,7 +16,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
[LuaMethodExample("console.clear( );")]
|
||||
[LuaMethod("clear", "clears the output box of the Lua Console window")]
|
||||
public static void Clear()
|
||||
public void Clear()
|
||||
{
|
||||
if (GlobalWin.Tools.Has<LuaConsole>())
|
||||
{
|
||||
|
@ -39,27 +39,27 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
[LuaMethodExample("console.log( \"New log.\" );")]
|
||||
[LuaMethod("log", "Outputs the given object to the output box on the Lua Console dialog. Note: Can accept a LuaTable")]
|
||||
public static void Log(params object[] outputs)
|
||||
public void Log(params object[] outputs)
|
||||
{
|
||||
LogWithSeparator("\t", "\n", outputs);
|
||||
}
|
||||
|
||||
[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)
|
||||
public void WriteLine(params object[] outputs)
|
||||
{
|
||||
LogWithSeparator("\n", "\n", outputs);
|
||||
}
|
||||
|
||||
[LuaMethodExample("console.write( \"New log message.\" );")]
|
||||
[LuaMethod("write", "Outputs the given object to the output box on the Lua Console dialog. Note: Can accept a LuaTable")]
|
||||
public static void Write(params object[] outputs)
|
||||
public void Write(params object[] outputs)
|
||||
{
|
||||
LogWithSeparator("", "", outputs);
|
||||
}
|
||||
|
||||
// Outputs the given object to the output box on the Lua Console dialog. Note: Can accept a LuaTable
|
||||
private static void LogWithSeparator(string separator, string terminator, params object[] outputs)
|
||||
private void LogWithSeparator(string separator, string terminator, params object[] outputs)
|
||||
{
|
||||
static string SerializeTable(LuaTable lti)
|
||||
{
|
||||
|
|
|
@ -73,6 +73,10 @@ namespace BizHawk.Client.EmuHawk
|
|||
{
|
||||
clientLib.MainForm = mainForm;
|
||||
}
|
||||
else if (instance is ConsoleLuaLibrary consoleLib)
|
||||
{
|
||||
_logToLuaConsoleCallback = consoleLib.Log;
|
||||
}
|
||||
else if (instance is GuiLuaLibrary guiLib)
|
||||
{
|
||||
guiLib.CreateLuaCanvasCallback = (width, height, x, y) =>
|
||||
|
@ -101,7 +105,7 @@ namespace BizHawk.Client.EmuHawk
|
|||
private Lua _lua = new Lua();
|
||||
private Lua _currThread;
|
||||
|
||||
private static readonly Action<object[]> _logToLuaConsoleCallback = ConsoleLuaLibrary.Log;
|
||||
private static Action<object[]> _logToLuaConsoleCallback = a => Console.WriteLine("a Lua lib is logging during init and the console lib hasn't been initialised yet");
|
||||
|
||||
private FormsLuaLibrary FormsLibrary => (FormsLuaLibrary)Libraries[typeof(FormsLuaLibrary)];
|
||||
|
||||
|
|
Loading…
Reference in New Issue