mirror of
https://github.com/Ale32bit/Capy64.git
synced 2025-01-18 10:36:44 +00:00
Add OnClose event.
Reboot shortcut resets steps to 0
This commit is contained in:
parent
5a510c6eb6
commit
b84db27f83
3 changed files with 19 additions and 2 deletions
|
@ -21,6 +21,7 @@ public class EventEmitter
|
|||
// Functional events
|
||||
public event EventHandler<TickEvent> OnTick;
|
||||
public event EventHandler OnInit;
|
||||
public event EventHandler OnClose;
|
||||
public event EventHandler OnScreenSizeChange;
|
||||
public event EventHandler<OverlayEvent> OnOverlay;
|
||||
|
||||
|
@ -100,6 +101,14 @@ public class EventEmitter
|
|||
}
|
||||
}
|
||||
|
||||
public void RaiseClose()
|
||||
{
|
||||
if (OnClose is not null)
|
||||
{
|
||||
OnClose(this, EventArgs.Empty);
|
||||
}
|
||||
}
|
||||
|
||||
public void RaiseScreenSizeChange()
|
||||
{
|
||||
if (OnScreenSizeChange is not null)
|
||||
|
|
|
@ -71,7 +71,7 @@ internal class EventEmitter
|
|||
{
|
||||
heldReboot = 0;
|
||||
RuntimeManager.ResetPanic();
|
||||
RuntimeManager.Reboot();
|
||||
RuntimeManager.Reset();
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -5,6 +5,7 @@ using KeraLua;
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Diagnostics.Tracing;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
|
@ -17,8 +18,8 @@ internal class RuntimeManager : IPlugin
|
|||
{
|
||||
private LuaState luaState;
|
||||
private EventEmitter emitter;
|
||||
private int step = 0;
|
||||
|
||||
private static int step = 0;
|
||||
private static bool close = false;
|
||||
private static bool inPanic = false;
|
||||
|
||||
|
@ -65,6 +66,7 @@ internal class RuntimeManager : IPlugin
|
|||
{
|
||||
if (close || !luaState.ProcessQueue())
|
||||
{
|
||||
_game.EventEmitter.RaiseClose();
|
||||
Start();
|
||||
}
|
||||
}
|
||||
|
@ -143,6 +145,12 @@ internal class RuntimeManager : IPlugin
|
|||
}
|
||||
}
|
||||
|
||||
public static void Reset()
|
||||
{
|
||||
close = true;
|
||||
step = 0;
|
||||
}
|
||||
|
||||
public static void Reboot()
|
||||
{
|
||||
close = true;
|
||||
|
|
Loading…
Reference in a new issue