From 51ba9cb2a6b0b9395a2912eadeb954c95e4c1d3c Mon Sep 17 00:00:00 2001 From: chai Date: Sun, 20 May 2018 23:37:11 +0800 Subject: =?UTF-8?q?=E4=BF=AE=E6=94=B9=E7=9B=AE=E5=BD=95=E7=BB=93=E6=9E=84?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/script/core/luaopen_core.cpp | 11 +++++++++-- src/script/embed/boot.lua.h | 4 ++++ src/script/graphics/luaopen_graphics.cpp | 9 +++++++++ 3 files changed, 22 insertions(+), 2 deletions(-) (limited to 'src/script') diff --git a/src/script/core/luaopen_core.cpp b/src/script/core/luaopen_core.cpp index 0d76ada..a222013 100644 --- a/src/script/core/luaopen_core.cpp +++ b/src/script/core/luaopen_core.cpp @@ -11,7 +11,7 @@ namespace lua { bool running = Game::get()->running(); luax_pushboolean(L, running); - return 1; + return 1; } static int l_quit(lua_State* L) @@ -19,10 +19,17 @@ namespace lua Game::get()->quit(); return 0; } + + static int l_exit(lua_State* L) + { + Game::get()->exit(); + return 0; + } static const luaL_Reg f[] = { {"running", l_running}, - {"quit", l_quit}, + {"quit", l_quit}, // for end game loop + {"exit", l_exit}, // for exit whole game {0, 0} }; diff --git a/src/script/embed/boot.lua.h b/src/script/embed/boot.lua.h index cb61468..21c1899 100644 --- a/src/script/embed/boot.lua.h +++ b/src/script/embed/boot.lua.h @@ -145,6 +145,10 @@ local function main() end jin.core.run() end + -- quit subsystems + jin.graphics.destroy() + -- exit whole game + jin.core.exit() end main() diff --git a/src/script/graphics/luaopen_graphics.cpp b/src/script/graphics/luaopen_graphics.cpp index 948e28a..40bdaa1 100644 --- a/src/script/graphics/luaopen_graphics.cpp +++ b/src/script/graphics/luaopen_graphics.cpp @@ -38,6 +38,13 @@ namespace lua luax_pushboolean(L, wnd->init(&setting)); return 1; } + + static int l_destroy(lua_State* L) + { + Window* wnd = Window::get(); + wnd->quit(); + return 0; + } /** * Get windows size. @@ -488,6 +495,8 @@ namespace lua {"circle", l_drawCircle}, {"triangle", l_drawTriangle}, {"polygon", l_drawPolygon}, + // + {"destroy", l_destroy}, {0, 0} }; -- cgit v1.1-26-g67d0