Add event.onconsoleclose (squashed PR #2884)
This commit is contained in:
parent
0f294a220e
commit
dc66b4357f
|
@ -232,6 +232,12 @@ namespace BizHawk.Client.Common
|
|||
=> _luaLibsImpl.CreateAndRegisterNamedFunction(luaf, "OnExit", LogOutputCallback, CurrentFile, name)
|
||||
.Guid.ToString();
|
||||
|
||||
[LuaMethodExample("local closeGuid = event.onconsoleclose(\r\n\tfunction()\r\n\t\tconsole.log( \"Fires when the emulator console closes\" );\r\n\tend\r\n\t, \"Frame name\" );")]
|
||||
[LuaMethod("onconsoleclose", "Fires when the emulator console closes")]
|
||||
public string OnConsoleClose(LuaFunction luaf, string name = null)
|
||||
=> _luaLibsImpl.CreateAndRegisterNamedFunction(luaf, "OnConsoleClose", LogOutputCallback, CurrentFile, name)
|
||||
.Guid.ToString();
|
||||
|
||||
[LuaMethodExample("if ( event.unregisterbyid( \"4d1810b7 - 0d28 - 4acb - 9d8b - d87721641551\" ) ) then\r\n\tconsole.log( \"Removes the registered function that matches the guid.If a function is found and remove the function will return true.If unable to find a match, the function will return false.\" );\r\nend;")]
|
||||
[LuaMethod("unregisterbyid", "Removes the registered function that matches the guid. If a function is found and remove the function will return true. If unable to find a match, the function will return false.")]
|
||||
public bool UnregisterById(string guid) => _luaLibsImpl.RemoveNamedFunctionMatching(nlf => nlf.Guid.ToString() == guid);
|
||||
|
|
|
@ -247,6 +247,12 @@ namespace BizHawk.Client.EmuHawk
|
|||
|
||||
public void Close()
|
||||
{
|
||||
foreach (var closeCallback in RegisteredFunctions
|
||||
.Where(l => l.Event == "OnConsoleClose"))
|
||||
{
|
||||
closeCallback.Call();
|
||||
}
|
||||
|
||||
RegisteredFunctions.Clear(_mainForm.Emulator);
|
||||
ScriptList.Clear();
|
||||
FormsLibrary.DestroyAll();
|
||||
|
|
Loading…
Reference in New Issue