diff options
Diffstat (limited to 'src/script/lua_api')
-rw-r--r-- | src/script/lua_api/l_mainmenu.cpp | 28 | ||||
-rw-r--r-- | src/script/lua_api/l_mainmenu.h | 2 |
2 files changed, 30 insertions, 0 deletions
diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index fbb70c389..5de1c77f0 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -1003,6 +1003,33 @@ int ModApiMainMenu::l_gettext(lua_State *L) } /******************************************************************************/ +int ModApiMainMenu::l_get_screen_info(lua_State *L) +{ + lua_newtable(L); + int top = lua_gettop(L); + lua_pushstring(L,"density"); + lua_pushnumber(L,porting::getDisplayDensity()); + lua_settable(L, top); + + lua_pushstring(L,"display_width"); + lua_pushnumber(L,porting::getDisplaySize().X); + lua_settable(L, top); + + lua_pushstring(L,"display_height"); + lua_pushnumber(L,porting::getDisplaySize().Y); + lua_settable(L, top); + + lua_pushstring(L,"window_width"); + lua_pushnumber(L,porting::getWindowSize().X); + lua_settable(L, top); + + lua_pushstring(L,"window_height"); + lua_pushnumber(L,porting::getWindowSize().Y); + lua_settable(L, top); + return 1; +} + +/******************************************************************************/ int ModApiMainMenu::l_do_async_callback(lua_State *L) { GUIEngine* engine = getGuiEngine(L); @@ -1060,6 +1087,7 @@ void ModApiMainMenu::Initialize(lua_State *L, int top) API_FCT(sound_play); API_FCT(sound_stop); API_FCT(gettext); + API_FCT(get_screen_info); API_FCT(do_async_callback); } diff --git a/src/script/lua_api/l_mainmenu.h b/src/script/lua_api/l_mainmenu.h index 69011c7b5..b711f2f86 100644 --- a/src/script/lua_api/l_mainmenu.h +++ b/src/script/lua_api/l_mainmenu.h @@ -103,6 +103,8 @@ private: static int l_update_formspec(lua_State *L); + static int l_get_screen_info(lua_State *L); + //filesystem static int l_get_scriptdir(lua_State *L); |