Permalink
Browse files

Add close event

  • Loading branch information...
LBPHacker authored and jacob1 committed Nov 16, 2018
1 parent 3de68c4 commit e48bd482f6c1e14ce3a1b6095eeb035ba83669ed
@@ -304,6 +304,7 @@ void EventProcess(SDL_Event event)
switch (event.type)
{
case SDL_QUIT:
engine->onClose();
if (engine->GetFastQuit() || engine->CloseWindow())
engine->Exit();
break;
@@ -865,6 +865,8 @@ void GameController::Tick()
void GameController::Exit()
{
CloseEvent ev;
commandInterface->HandleEvent(LuaEvents::close, &ev);
gameView->CloseActiveWindow();
HasDone = true;
}
@@ -1855,6 +1855,12 @@ void GameView::DoKeyRelease(int key, int scan, bool repeat, bool shift, bool ctr
Window::DoKeyRelease(key, scan, repeat, shift, ctrl, alt);
}
void GameView::DoExit()
{
Window::DoExit();
c->Exit();
}
void GameView::DoDraw()
{
Window::DoDraw();
@@ -198,6 +198,7 @@ class GameView: public ui::Window
virtual void OnBlur();
//Top-level handlers, for Lua interface
virtual void DoExit();
virtual void DoDraw();
virtual void DoMouseMove(int x, int y, int dx, int dy);
virtual void DoMouseDown(int x, int y, unsigned button);
@@ -98,6 +98,12 @@ class TickEvent: public Event
int PushToStack(lua_State *l) override { return 0; }
};
class CloseEvent: public Event
{
public:
int PushToStack(lua_State *l) override { return 0; }
};
class LuaEvents
{
public:
@@ -109,7 +115,8 @@ class LuaEvents
mouseup,
mousemove,
mousewheel,
tick
tick,
close
};
static int RegisterEventHook(lua_State* l, ByteString eventName);
@@ -3311,6 +3311,7 @@ void LuaScriptInterface::initEventAPI()
lua_pushinteger(l, LuaEvents::mousemove); lua_setfield(l, -2, "mousemove");
lua_pushinteger(l, LuaEvents::mousewheel); lua_setfield(l, -2, "mousewheel");
lua_pushinteger(l, LuaEvents::tick); lua_setfield(l, -2, "tick");
lua_pushinteger(l, LuaEvents::close); lua_setfield(l, -2, "close");
}
int LuaScriptInterface::event_register(lua_State * l)

0 comments on commit e48bd48

Please sign in to comment.