From 1d1210d7932b287d66e27157701b92df764528cb Mon Sep 17 00:00:00 2001 From: chai Date: Mon, 5 Nov 2018 07:33:41 +0800 Subject: =?UTF-8?q?+=E7=8A=B6=E6=80=81=E6=9C=BA=E6=B5=8B=E8=AF=95=E4=BB=A3?= =?UTF-8?q?=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/lua/embed/boot.lua.h | 8 +++++++- src/lua/modules/graphics/je_lua_graphics.cpp | 21 +++++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) (limited to 'src/lua') diff --git a/src/lua/embed/boot.lua.h b/src/lua/embed/boot.lua.h index 2369b0f..0884188 100644 --- a/src/lua/embed/boot.lua.h +++ b/src/lua/embed/boot.lua.h @@ -19,6 +19,7 @@ jin.config.title = jin.config.title or ("jin v" .. jin.version) jin.config.resizable = jin.config.resizable or false jin.config.fullscreen = jin.config.fullscreen or false jin.config.fps = jin.config.fps or 60 +jin.config.icon = jin.config.icon or "" ------------------------------------------------------------------------- -- Default game loop @@ -62,6 +63,7 @@ end -- Display error message. local function onError(msg) + jin.graphics.showWindow() local err = "Error:\n" .. msg .. "\n" .. debug.traceback() jin.graphics.reset() jin.graphics.setClearColor(100, 100, 100, 255) @@ -80,7 +82,7 @@ end -- No game screen. local function noGame() - jin.graphics.reset() + jin.graphics.showWindow() jin.graphics.reset() jin.graphics.setClearColor(100, 100, 100, 255) jin.graphics.clear() @@ -114,6 +116,10 @@ end jin.audio.init() jin.graphics.init(jin.config) +------------------------------------------------------------------------- +-- Boot game +------------------------------------------------------------------------- + xpcall(boot, onError) ------------------------------------------------------------------------- diff --git a/src/lua/modules/graphics/je_lua_graphics.cpp b/src/lua/modules/graphics/je_lua_graphics.cpp index 7efb2e7..c45a939 100644 --- a/src/lua/modules/graphics/je_lua_graphics.cpp +++ b/src/lua/modules/graphics/je_lua_graphics.cpp @@ -42,6 +42,7 @@ namespace JinEngine setting.width = luax_getfieldinteger(L, 1, "width"); setting.height = luax_getfieldinteger(L, 1, "height"); setting.title = luax_getfieldstring(L, 1, "title"); + setting.icon = luax_getfieldstring(L, 1, "icon"); setting.vsync = luax_getfieldbool(L, 1, "vsync"); setting.fullscreen = luax_getfieldbool(L, 1, "fullscreen"); setting.resizable = luax_getfieldbool(L, 1, "resizable"); @@ -77,7 +78,21 @@ namespace JinEngine wnd->quit(); return 0; } - + + LUA_IMPLEMENT int l_showWindow(lua_State* L) + { + Window* wnd = Window::get(); + wnd->show(); + return 0; + } + + LUA_IMPLEMENT int l_hideWindow(lua_State* L) + { + Window* wnd = Window::get(); + wnd->hide(); + return 0; + } + LUA_IMPLEMENT int l_getSize(lua_State* L) { Window* wnd = Window::get(); @@ -742,7 +757,9 @@ namespace JinEngine { "getSize", l_getSize }, { "getWidth", l_getWidth }, { "getHeight", l_getHeight }, - { "destroy", l_destroy }, + { "destroy", l_destroy }, + { "hideWindow", l_hideWindow }, + { "showWindow", l_showWindow }, /* creators */ { "newBitmap", l_newBitmap }, { "newTexture", l_newTexture }, -- cgit v1.1-26-g67d0