Add close event
This commit is contained in:
parent
3de68c4346
commit
e48bd482f6
@ -304,6 +304,7 @@ void EventProcess(SDL_Event event)
|
|||||||
switch (event.type)
|
switch (event.type)
|
||||||
{
|
{
|
||||||
case SDL_QUIT:
|
case SDL_QUIT:
|
||||||
|
engine->onClose();
|
||||||
if (engine->GetFastQuit() || engine->CloseWindow())
|
if (engine->GetFastQuit() || engine->CloseWindow())
|
||||||
engine->Exit();
|
engine->Exit();
|
||||||
break;
|
break;
|
||||||
|
@ -865,6 +865,8 @@ void GameController::Tick()
|
|||||||
|
|
||||||
void GameController::Exit()
|
void GameController::Exit()
|
||||||
{
|
{
|
||||||
|
CloseEvent ev;
|
||||||
|
commandInterface->HandleEvent(LuaEvents::close, &ev);
|
||||||
gameView->CloseActiveWindow();
|
gameView->CloseActiveWindow();
|
||||||
HasDone = true;
|
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);
|
Window::DoKeyRelease(key, scan, repeat, shift, ctrl, alt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void GameView::DoExit()
|
||||||
|
{
|
||||||
|
Window::DoExit();
|
||||||
|
c->Exit();
|
||||||
|
}
|
||||||
|
|
||||||
void GameView::DoDraw()
|
void GameView::DoDraw()
|
||||||
{
|
{
|
||||||
Window::DoDraw();
|
Window::DoDraw();
|
||||||
|
@ -198,6 +198,7 @@ public:
|
|||||||
virtual void OnBlur();
|
virtual void OnBlur();
|
||||||
|
|
||||||
//Top-level handlers, for Lua interface
|
//Top-level handlers, for Lua interface
|
||||||
|
virtual void DoExit();
|
||||||
virtual void DoDraw();
|
virtual void DoDraw();
|
||||||
virtual void DoMouseMove(int x, int y, int dx, int dy);
|
virtual void DoMouseMove(int x, int y, int dx, int dy);
|
||||||
virtual void DoMouseDown(int x, int y, unsigned button);
|
virtual void DoMouseDown(int x, int y, unsigned button);
|
||||||
|
@ -98,6 +98,12 @@ public:
|
|||||||
int PushToStack(lua_State *l) override { return 0; }
|
int PushToStack(lua_State *l) override { return 0; }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
class CloseEvent: public Event
|
||||||
|
{
|
||||||
|
public:
|
||||||
|
int PushToStack(lua_State *l) override { return 0; }
|
||||||
|
};
|
||||||
|
|
||||||
class LuaEvents
|
class LuaEvents
|
||||||
{
|
{
|
||||||
public:
|
public:
|
||||||
@ -109,7 +115,8 @@ public:
|
|||||||
mouseup,
|
mouseup,
|
||||||
mousemove,
|
mousemove,
|
||||||
mousewheel,
|
mousewheel,
|
||||||
tick
|
tick,
|
||||||
|
close
|
||||||
};
|
};
|
||||||
|
|
||||||
static int RegisterEventHook(lua_State* l, ByteString eventName);
|
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::mousemove); lua_setfield(l, -2, "mousemove");
|
||||||
lua_pushinteger(l, LuaEvents::mousewheel); lua_setfield(l, -2, "mousewheel");
|
lua_pushinteger(l, LuaEvents::mousewheel); lua_setfield(l, -2, "mousewheel");
|
||||||
lua_pushinteger(l, LuaEvents::tick); lua_setfield(l, -2, "tick");
|
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)
|
int LuaScriptInterface::event_register(lua_State * l)
|
||||||
|
Loading…
Reference in New Issue
Block a user