diff --git a/doc/menu_lua_api.txt b/doc/menu_lua_api.txt index e8d7b6e400f02..a2854fbd49870 100644 --- a/doc/menu_lua_api.txt +++ b/doc/menu_lua_api.txt @@ -203,6 +203,7 @@ GUI will be added to fieldname value is set to formname itself * if `is_file_select` is `true`, a file and not a folder will be selected * returns nil or selected file/folder +* `core.get_screen_info()`: DEPRECATED, use below 2 functions instead. * `core.get_active_renderer()`: Ex: "OpenGL 4.6". * `core.get_window_info()`: Same as server-side `get_player_window_information` API. diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index 4c25d4ba1b6ae..ba575fa1ae5db 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -952,6 +952,31 @@ int ModApiMainMenu::l_get_window_info(lua_State *L) return 1; } +/******************************************************************************/ +int ModApiMainMenu::l_get_screen_info(lua_State *L) +{ + lua_newtable(L); + int top = lua_gettop(L); + lua_pushstring(L,"density"); + lua_pushnumber(L,RenderingEngine::getDisplayDensity()); + lua_settable(L, top); + + const v2u32 &window_size = RenderingEngine::getWindowSize(); + lua_pushstring(L,"window_width"); + lua_pushnumber(L, window_size.X); + lua_settable(L, top); + + lua_pushstring(L,"window_height"); + lua_pushnumber(L, window_size.Y); + lua_settable(L, top); + + lua_pushstring(L, "render_info"); + lua_pushstring(L, wide_to_utf8(RenderingEngine::get_video_driver()->getName()).c_str()); + lua_settable(L, top); + return 1; +} +/******************************************************************************/ + int ModApiMainMenu::l_get_active_renderer(lua_State *L) { lua_pushstring(L, wide_to_utf8(RenderingEngine::get_video_driver()->getName()).c_str()); @@ -1099,6 +1124,7 @@ void ModApiMainMenu::Initialize(lua_State *L, int top) API_FCT(download_file); API_FCT(gettext); API_FCT(get_video_drivers); + API_FCT(get_screen_info()); API_FCT(get_window_info); API_FCT(get_active_renderer); API_FCT(get_min_supp_proto); diff --git a/src/script/lua_api/l_mainmenu.h b/src/script/lua_api/l_mainmenu.h index bb5c93cd599f8..b01aaff6f3a38 100644 --- a/src/script/lua_api/l_mainmenu.h +++ b/src/script/lua_api/l_mainmenu.h @@ -104,6 +104,8 @@ class ModApiMainMenu: public ModApiBase static int l_set_formspec_prepend(lua_State *L); + static int l_get_screen_info(lua_State *L); + static int l_get_window_info(lua_State *L); static int l_get_active_renderer(lua_State *L);