Cleanup FormsLuaLibrary.WindowClosed and usages
This commit is contained in:
parent
d51f9c3e88
commit
89a66563f1
|
@ -47,7 +47,6 @@ namespace BizHawk.Client.Common
|
||||||
public abstract (bool WaitForFrame, bool Terminated) ResumeScript(LuaFile lf);
|
public abstract (bool WaitForFrame, bool Terminated) ResumeScript(LuaFile lf);
|
||||||
public abstract void SpawnAndSetFileThread(string pathToLoad, LuaFile lf);
|
public abstract void SpawnAndSetFileThread(string pathToLoad, LuaFile lf);
|
||||||
public abstract void StartLuaDrawing();
|
public abstract void StartLuaDrawing();
|
||||||
public abstract void WindowClosed(IntPtr handle);
|
|
||||||
|
|
||||||
public abstract void RunScheduledDisposes();
|
public abstract void RunScheduledDisposes();
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,14 +23,8 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public void WindowClosed(IntPtr handle)
|
public void WindowClosed(IntPtr handle)
|
||||||
{
|
{
|
||||||
foreach (var form in _luaForms)
|
var form = _luaForms.FirstOrDefault(form => form.Handle == handle);
|
||||||
{
|
if (form != null) _luaForms.Remove(form);
|
||||||
if (form.Handle == handle)
|
|
||||||
{
|
|
||||||
_luaForms.Remove(form);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private LuaWinform GetForm(int formHandle)
|
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.")]
|
"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)
|
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);
|
_luaForms.Add(form);
|
||||||
if (width.HasValue && height.HasValue)
|
if (width.HasValue && height.HasValue)
|
||||||
{
|
{
|
||||||
|
|
|
@ -10,18 +10,16 @@ namespace BizHawk.Client.EmuHawk
|
||||||
{
|
{
|
||||||
public List<LuaEvent> ControlEvents { get; } = new List<LuaEvent>();
|
public List<LuaEvent> ControlEvents { get; } = new List<LuaEvent>();
|
||||||
|
|
||||||
private readonly LuaLibraries _luaImp;
|
|
||||||
private readonly string _currentDirectory = Environment.CurrentDirectory;
|
private readonly string _currentDirectory = Environment.CurrentDirectory;
|
||||||
private readonly LuaFile _ownerFile;
|
private readonly LuaFile _ownerFile;
|
||||||
|
|
||||||
public LuaWinform(LuaFile ownerFile, LuaLibraries luaImp)
|
public LuaWinform(LuaFile ownerFile, Action<IntPtr> formsWindowClosedCallback)
|
||||||
{
|
{
|
||||||
_ownerFile = ownerFile;
|
_ownerFile = ownerFile;
|
||||||
_luaImp = luaImp;
|
|
||||||
InitializeComponent();
|
InitializeComponent();
|
||||||
Icon = Properties.Resources.TextDocIcon;
|
Icon = Properties.Resources.TextDocIcon;
|
||||||
StartPosition = FormStartPosition.CenterParent;
|
StartPosition = FormStartPosition.CenterParent;
|
||||||
Closing += (o, e) => { _luaImp.WindowClosed(Handle); };
|
Closing += (o, e) => formsWindowClosedCallback(Handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void DoLuaEvent(IntPtr handle)
|
public void DoLuaEvent(IntPtr handle)
|
||||||
|
|
|
@ -52,9 +52,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
public override void StartLuaDrawing()
|
public override void StartLuaDrawing()
|
||||||
{
|
{
|
||||||
}
|
}
|
||||||
public override void WindowClosed(IntPtr handle)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void RunScheduledDisposes()
|
public override void RunScheduledDisposes()
|
||||||
{
|
{
|
||||||
|
|
|
@ -150,11 +150,6 @@ namespace BizHawk.Client.EmuHawk
|
||||||
|
|
||||||
public override LuaFunctionList RegisteredFunctions => EventsLibrary.RegisteredFunctions;
|
public override LuaFunctionList RegisteredFunctions => EventsLibrary.RegisteredFunctions;
|
||||||
|
|
||||||
public override void WindowClosed(IntPtr handle)
|
|
||||||
{
|
|
||||||
FormsLibrary.WindowClosed(handle);
|
|
||||||
}
|
|
||||||
|
|
||||||
public override void CallSaveStateEvent(string name)
|
public override void CallSaveStateEvent(string name)
|
||||||
{
|
{
|
||||||
EventsLibrary.CallSaveStateEvent(name);
|
EventsLibrary.CallSaveStateEvent(name);
|
||||||
|
|
Loading…
Reference in New Issue