Move GuiLuaLibrary to Client.Common
This commit is contained in:
parent
20111fb4a2
commit
6c05361cda
|
@ -1,12 +1,14 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Drawing;
|
using System.Drawing;
|
||||||
using NLua;
|
|
||||||
using BizHawk.Client.Common;
|
|
||||||
|
|
||||||
namespace BizHawk.Client.EmuHawk
|
using NLua;
|
||||||
|
|
||||||
|
namespace BizHawk.Client.Common
|
||||||
{
|
{
|
||||||
public sealed class GuiLuaLibrary : DelegatingLuaLibrary, IDisposable
|
public sealed class GuiLuaLibrary : DelegatingLuaLibrary, IDisposable
|
||||||
{
|
{
|
||||||
|
public Func<int, int, int?, int?, LuaTable> CreateLuaCanvasCallback { get; set; }
|
||||||
|
|
||||||
public GuiLuaLibrary(Lua lua)
|
public GuiLuaLibrary(Lua lua)
|
||||||
: base(lua) { }
|
: base(lua) { }
|
||||||
|
|
||||||
|
@ -176,12 +178,7 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
[LuaMethodExample("local nlguicre = gui.createcanvas( 77, 99, 2, 48 );")]
|
[LuaMethodExample("local nlguicre = gui.createcanvas( 77, 99, 2, 48 );")]
|
||||||
[LuaMethod("createcanvas", "Creates a canvas of the given size and, if specified, the given coordinates.")]
|
[LuaMethod("createcanvas", "Creates a canvas of the given size and, if specified, the given coordinates.")]
|
||||||
public LuaTable Text(int width, int height, int? x = null, int? y = null)
|
public LuaTable Text(int width, int height, int? x = null, int? y = null) => CreateLuaCanvasCallback(width, height, x, y);
|
||||||
{
|
|
||||||
var canvas = new LuaCanvas(width, height, x, y);
|
|
||||||
canvas.Show();
|
|
||||||
return Lua.TableFromObject(canvas);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void Dispose() => APIs.Gui.Dispose();
|
public void Dispose() => APIs.Gui.Dispose();
|
||||||
}
|
}
|
|
@ -67,6 +67,15 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
clientLib.MainForm = mainForm;
|
clientLib.MainForm = mainForm;
|
||||||
}
|
}
|
||||||
|
else if (instance is GuiLuaLibrary guiLib)
|
||||||
|
{
|
||||||
|
guiLib.CreateLuaCanvasCallback = (width, height, x, y) =>
|
||||||
|
{
|
||||||
|
var canvas = new LuaCanvas(width, height, x, y);
|
||||||
|
canvas.Show();
|
||||||
|
return _lua.TableFromObject(canvas);
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
if (instance is DelegatingLuaLibrary dlgInstance) dlgInstance.APIs = apiContainer;
|
if (instance is DelegatingLuaLibrary dlgInstance) dlgInstance.APIs = apiContainer;
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue