Cleanup FormsLuaLibrary.WindowClosed and usages

This commit is contained in:
YoshiRulz 2020-12-04 23:13:36 +10:00
parent d51f9c3e88
commit 89a66563f1
No known key found for this signature in database
GPG Key ID: C4DE31C245353FB7
5 changed files with 5 additions and 22 deletions

View File

@ -47,7 +47,6 @@ namespace BizHawk.Client.Common
public abstract (bool WaitForFrame, bool Terminated) ResumeScript(LuaFile lf);
public abstract void SpawnAndSetFileThread(string pathToLoad, LuaFile lf);
public abstract void StartLuaDrawing();
public abstract void WindowClosed(IntPtr handle);
public abstract void RunScheduledDisposes();
}

View File

@ -23,14 +23,8 @@ namespace BizHawk.Client.EmuHawk
public void WindowClosed(IntPtr handle)
{
foreach (var form in _luaForms)
{
if (form.Handle == handle)
{
_luaForms.Remove(form);
return;
}
}
var form = _luaForms.FirstOrDefault(form => form.Handle == handle);
if (form != null) _luaForms.Remove(form);
}
private LuaWinform GetForm(int formHandle)
@ -352,7 +346,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, _luaLibsImpl);
var form = new LuaWinform(CurrentFile, WindowClosed);
_luaForms.Add(form);
if (width.HasValue && height.HasValue)
{

View File

@ -10,18 +10,16 @@ namespace BizHawk.Client.EmuHawk
{
public List<LuaEvent> ControlEvents { get; } = new List<LuaEvent>();
private readonly LuaLibraries _luaImp;
private readonly string _currentDirectory = Environment.CurrentDirectory;
private readonly LuaFile _ownerFile;
public LuaWinform(LuaFile ownerFile, LuaLibraries luaImp)
public LuaWinform(LuaFile ownerFile, Action<IntPtr> formsWindowClosedCallback)
{
_ownerFile = ownerFile;
_luaImp = luaImp;
InitializeComponent();
Icon = Properties.Resources.TextDocIcon;
StartPosition = FormStartPosition.CenterParent;
Closing += (o, e) => { _luaImp.WindowClosed(Handle); };
Closing += (o, e) => formsWindowClosedCallback(Handle);
}
public void DoLuaEvent(IntPtr handle)

View File

@ -52,9 +52,6 @@ namespace BizHawk.Client.EmuHawk
public override void StartLuaDrawing()
{
}
public override void WindowClosed(IntPtr handle)
{
}
public override void RunScheduledDisposes()
{

View File

@ -150,11 +150,6 @@ namespace BizHawk.Client.EmuHawk
public override LuaFunctionList RegisteredFunctions => EventsLibrary.RegisteredFunctions;
public override void WindowClosed(IntPtr handle)
{
FormsLibrary.WindowClosed(handle);
}
public override void CallSaveStateEvent(string name)
{
EventsLibrary.CallSaveStateEvent(name);