pass in LuaImp to LuaWinform, now the global usage is in the lua library, but baby steps

This commit is contained in:
adelikat 2019-12-22 12:12:03 -06:00
parent b9c0d11c16
commit 2403f38bcc
3 changed files with 6 additions and 12 deletions

View File

@ -360,7 +360,7 @@ namespace BizHawk.Client.EmuHawk
"newform", "creates a new default dialog, if both width and height are specified it will create a dialog of the specified size. If title is specified it will be the caption of the dialog, else the dialog caption will be 'Lua Dialog'. The function will return an int representing the handle of the dialog created.")]
public int NewForm(int? width = null, int? height = null, string title = null, LuaFunction onClose = null)
{
var form = new LuaWinform(CurrentFile);
var form = new LuaWinform(CurrentFile, GlobalWin.Tools.LuaConsole.LuaImp);
_luaForms.Add(form);
if (width.HasValue && height.HasValue)
{

View File

@ -39,9 +39,7 @@
this.Name = "LuaWinform";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterParent;
this.Text = "Lua Dialog";
this.Load += new System.EventHandler(this.LuaWinform_Load);
this.ResumeLayout(false);
}
#endregion

View File

@ -1,9 +1,7 @@
using System;
using System.Collections.Generic;
using System.Windows.Forms;
using NLua;
using BizHawk.Client.Common;
namespace BizHawk.Client.EmuHawk
@ -12,24 +10,22 @@ namespace BizHawk.Client.EmuHawk
{
public List<LuaEvent> ControlEvents { get; } = new List<LuaEvent>();
private readonly PlatformEmuLuaLibrary _luaImp;
private readonly string _currentDirectory = Environment.CurrentDirectory;
private readonly LuaFile _ownerFile;
public LuaWinform(LuaFile ownerFile)
public LuaWinform(LuaFile ownerFile, PlatformEmuLuaLibrary luaImp)
{
InitializeComponent();
_ownerFile = ownerFile;
_luaImp = luaImp;
InitializeComponent();
StartPosition = FormStartPosition.CenterParent;
Closing += (o, e) => CloseThis();
}
private void LuaWinform_Load(object sender, EventArgs e)
{
}
private void CloseThis()
{
GlobalWin.Tools.LuaConsole.LuaImp.WindowClosed(Handle);
_luaImp.WindowClosed(Handle);
}
public void DoLuaEvent(IntPtr handle)