one more tweak to make lua library constructors unified
This commit is contained in:
parent
17568997bf
commit
e88b7cc93e
|
@ -13,8 +13,10 @@ namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
public class EmulatorLuaLibrary : LuaLibraryBase
|
public class EmulatorLuaLibrary : LuaLibraryBase
|
||||||
{
|
{
|
||||||
private readonly Action _frameAdvanceCallback;
|
public Action FrameAdvanceCallback { get; set; }
|
||||||
private readonly Action _yieldCallback;
|
public Action YieldCallback { get; set; }
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
public EmulatorLuaLibrary(Lua lua)
|
public EmulatorLuaLibrary(Lua lua)
|
||||||
: base(lua) { }
|
: base(lua) { }
|
||||||
|
@ -22,13 +24,6 @@ namespace BizHawk.Client.Common
|
||||||
public EmulatorLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
public EmulatorLuaLibrary(Lua lua, Action<string> logOutputCallback)
|
||||||
: base(lua, logOutputCallback) { }
|
: base(lua, logOutputCallback) { }
|
||||||
|
|
||||||
public EmulatorLuaLibrary(Lua lua, Action<string> logOutputCallback, Action frameAdvanceCallback, Action yieldCallback)
|
|
||||||
: this(lua, logOutputCallback)
|
|
||||||
{
|
|
||||||
_frameAdvanceCallback = frameAdvanceCallback;
|
|
||||||
_yieldCallback = yieldCallback;
|
|
||||||
}
|
|
||||||
|
|
||||||
public override string Name { get { return "emu"; } }
|
public override string Name { get { return "emu"; } }
|
||||||
|
|
||||||
[LuaMethodAttributes(
|
[LuaMethodAttributes(
|
||||||
|
@ -46,7 +41,7 @@ namespace BizHawk.Client.Common
|
||||||
)]
|
)]
|
||||||
public void FrameAdvance()
|
public void FrameAdvance()
|
||||||
{
|
{
|
||||||
_frameAdvanceCallback();
|
FrameAdvanceCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
[LuaMethodAttributes(
|
[LuaMethodAttributes(
|
||||||
|
@ -180,7 +175,7 @@ namespace BizHawk.Client.Common
|
||||||
)]
|
)]
|
||||||
public void Yield()
|
public void Yield()
|
||||||
{
|
{
|
||||||
_yieldCallback();
|
YieldCallback();
|
||||||
}
|
}
|
||||||
|
|
||||||
[LuaMethodAttributes(
|
[LuaMethodAttributes(
|
||||||
|
|
|
@ -29,8 +29,12 @@ namespace BizHawk.Client.EmuHawk
|
||||||
_caller = passed.Get();
|
_caller = passed.Get();
|
||||||
|
|
||||||
// Register lua libraries
|
// Register lua libraries
|
||||||
|
|
||||||
_lua.RegisterFunction("print", this, GetType().GetMethod("Print"));
|
_lua.RegisterFunction("print", this, GetType().GetMethod("Print"));
|
||||||
|
|
||||||
|
// TODO: Search the assemblies for objects that inherit LuaBaseLibrary, and instantiate and register them and put them into an array,
|
||||||
|
// rather than call them all by name here
|
||||||
|
|
||||||
_formsLibrary = new FormsLuaLibrary(_lua, ConsoleLuaLibrary.LogOutput);
|
_formsLibrary = new FormsLuaLibrary(_lua, ConsoleLuaLibrary.LogOutput);
|
||||||
_formsLibrary.LuaRegister(Docs);
|
_formsLibrary.LuaRegister(Docs);
|
||||||
|
|
||||||
|
@ -44,11 +48,13 @@ namespace BizHawk.Client.EmuHawk
|
||||||
new EmuHawkLuaLibrary(_lua, ConsoleLuaLibrary.LogOutput).LuaRegister(Docs);
|
new EmuHawkLuaLibrary(_lua, ConsoleLuaLibrary.LogOutput).LuaRegister(Docs);
|
||||||
new ConsoleLuaLibrary(_lua, ConsoleLuaLibrary.LogOutput).LuaRegister(Docs);
|
new ConsoleLuaLibrary(_lua, ConsoleLuaLibrary.LogOutput).LuaRegister(Docs);
|
||||||
|
|
||||||
new EmulatorLuaLibrary(
|
var emuLib = new EmulatorLuaLibrary(_lua, ConsoleLuaLibrary.LogOutput)
|
||||||
_lua,
|
{
|
||||||
ConsoleLuaLibrary.LogOutput,
|
FrameAdvanceCallback = Frameadvance,
|
||||||
Frameadvance,
|
YieldCallback = EmuYield
|
||||||
EmuYield).LuaRegister(Docs);
|
};
|
||||||
|
|
||||||
|
emuLib.LuaRegister(Docs);
|
||||||
|
|
||||||
new InputLuaLibrary(_lua, ConsoleLuaLibrary.LogOutput).LuaRegister(Docs);
|
new InputLuaLibrary(_lua, ConsoleLuaLibrary.LogOutput).LuaRegister(Docs);
|
||||||
new JoypadLuaLibrary(_lua, ConsoleLuaLibrary.LogOutput).LuaRegister(Docs);
|
new JoypadLuaLibrary(_lua, ConsoleLuaLibrary.LogOutput).LuaRegister(Docs);
|
||||||
|
|
Loading…
Reference in New Issue