From 2403f38bcc05cd07932b139afd935ded055c8eca Mon Sep 17 00:00:00 2001 From: adelikat Date: Sun, 22 Dec 2019 12:12:03 -0600 Subject: [PATCH] pass in LuaImp to LuaWinform, now the global usage is in the lua library, but baby steps --- .../tools/Lua/Libraries/EmuLuaLibrary.Forms.cs | 2 +- .../tools/Lua/LuaWinform.Designer.cs | 2 -- BizHawk.Client.EmuHawk/tools/Lua/LuaWinform.cs | 14 +++++--------- 3 files changed, 6 insertions(+), 12 deletions(-) diff --git a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Forms.cs b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Forms.cs index f1a53542b8..02bc748d49 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Forms.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/Libraries/EmuLuaLibrary.Forms.cs @@ -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) { diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaWinform.Designer.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaWinform.Designer.cs index 5fdb649fa1..76171eef64 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaWinform.Designer.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaWinform.Designer.cs @@ -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 diff --git a/BizHawk.Client.EmuHawk/tools/Lua/LuaWinform.cs b/BizHawk.Client.EmuHawk/tools/Lua/LuaWinform.cs index e47325c0d3..8dc3f3a32f 100644 --- a/BizHawk.Client.EmuHawk/tools/Lua/LuaWinform.cs +++ b/BizHawk.Client.EmuHawk/tools/Lua/LuaWinform.cs @@ -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 ControlEvents { get; } = new List(); + 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)