mirror of
https://github.com/Ale32bit/Capy64.git
synced 2025-01-18 18:46:43 +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
|
// Functional events
|
||||||
public event EventHandler<TickEvent> OnTick;
|
public event EventHandler<TickEvent> OnTick;
|
||||||
public event EventHandler OnInit;
|
public event EventHandler OnInit;
|
||||||
|
public event EventHandler OnClose;
|
||||||
public event EventHandler OnScreenSizeChange;
|
public event EventHandler OnScreenSizeChange;
|
||||||
public event EventHandler<OverlayEvent> OnOverlay;
|
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()
|
public void RaiseScreenSizeChange()
|
||||||
{
|
{
|
||||||
if (OnScreenSizeChange is not null)
|
if (OnScreenSizeChange is not null)
|
||||||
|
|
|
@ -71,7 +71,7 @@ internal class EventEmitter
|
||||||
{
|
{
|
||||||
heldReboot = 0;
|
heldReboot = 0;
|
||||||
RuntimeManager.ResetPanic();
|
RuntimeManager.ResetPanic();
|
||||||
RuntimeManager.Reboot();
|
RuntimeManager.Reset();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -5,6 +5,7 @@ using KeraLua;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
using System.Diagnostics.Tracing;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text;
|
using System.Text;
|
||||||
|
@ -17,8 +18,8 @@ internal class RuntimeManager : IPlugin
|
||||||
{
|
{
|
||||||
private LuaState luaState;
|
private LuaState luaState;
|
||||||
private EventEmitter emitter;
|
private EventEmitter emitter;
|
||||||
private int step = 0;
|
|
||||||
|
|
||||||
|
private static int step = 0;
|
||||||
private static bool close = false;
|
private static bool close = false;
|
||||||
private static bool inPanic = false;
|
private static bool inPanic = false;
|
||||||
|
|
||||||
|
@ -65,6 +66,7 @@ internal class RuntimeManager : IPlugin
|
||||||
{
|
{
|
||||||
if (close || !luaState.ProcessQueue())
|
if (close || !luaState.ProcessQueue())
|
||||||
{
|
{
|
||||||
|
_game.EventEmitter.RaiseClose();
|
||||||
Start();
|
Start();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -143,6 +145,12 @@ internal class RuntimeManager : IPlugin
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void Reset()
|
||||||
|
{
|
||||||
|
close = true;
|
||||||
|
step = 0;
|
||||||
|
}
|
||||||
|
|
||||||
public static void Reboot()
|
public static void Reboot()
|
||||||
{
|
{
|
||||||
close = true;
|
close = true;
|
||||||
|
|
Loading…
Reference in a new issue