From f41e9e3e0f2f92593a56a099687f143337bded16 Mon Sep 17 00:00:00 2001 From: DS Date: Mon, 17 Jul 2023 20:44:54 +0200 Subject: [PATCH] Add Irrlicht device info to the mainmenu About tab (#13636) --- .github/ISSUE_TEMPLATE/bug_report.md | 4 ++++ builtin/mainmenu/tab_about.lua | 14 +++++++++++--- doc/menu_lua_api.md | 2 ++ src/script/lua_api/l_mainmenu.cpp | 18 ++++++++++++++++++ src/script/lua_api/l_mainmenu.h | 2 ++ 5 files changed, 37 insertions(+), 3 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md index 7cf34bd4a..835d6f564 100644 --- a/.github/ISSUE_TEMPLATE/bug_report.md +++ b/.github/ISSUE_TEMPLATE/bug_report.md @@ -16,6 +16,10 @@ You can use `minetest --version` to find it. ``` + +Active renderer: +Irrlicht device: + ##### OS / Hardware Operating system: diff --git a/builtin/mainmenu/tab_about.lua b/builtin/mainmenu/tab_about.lua index dc74ae728..e0d984a6c 100644 --- a/builtin/mainmenu/tab_about.lua +++ b/builtin/mainmenu/tab_about.lua @@ -172,10 +172,18 @@ return { "scrollbar[15,0.1;0.4,6.9;vertical;scroll_credits;0]" -- Render information + local active_renderer_info = fgettext("Active renderer:") .. " " .. + core.formspec_escape(core.get_active_renderer()) fs = fs .. "style[label_button2;border=false]" .. - "button[0.1,6;5.3,1;label_button2;" .. - fgettext("Active renderer:") .. "\n" .. - core.formspec_escape(core.get_active_renderer()) .. "]" + "button[0.1,6;5.3,0.5;label_button2;" .. active_renderer_info .. "]".. + "tooltip[label_button2;" .. active_renderer_info .. "]" + + -- Irrlicht device information + local irrlicht_device_info = fgettext("Irrlicht device:") .. " " .. + core.formspec_escape(core.get_active_irrlicht_device()) + fs = fs .. "style[label_button3;border=false]" .. + "button[0.1,6.5;5.3,0.5;label_button3;" .. irrlicht_device_info .. "]".. + "tooltip[label_button3;" .. irrlicht_device_info .. "]" if PLATFORM == "Android" then fs = fs .. "button[0.5,5.1;4.5,0.8;share_debug;" .. fgettext("Share debug log") .. "]" diff --git a/doc/menu_lua_api.md b/doc/menu_lua_api.md index 963306c6d..0524d8273 100644 --- a/doc/menu_lua_api.md +++ b/doc/menu_lua_api.md @@ -213,6 +213,8 @@ GUI * technical name of active video driver, e.g. "opengl" * `core.get_active_renderer()`: * name of current renderer, e.g. "OpenGL 4.6" +* `core.get_active_irrlicht_device()`: + * name of current irrlicht device, e.g. "SDL" * `core.get_window_info()`: Same as server-side `get_player_window_information` API. ```lua diff --git a/src/script/lua_api/l_mainmenu.cpp b/src/script/lua_api/l_mainmenu.cpp index f54ec0f4d..9d64a76f6 100644 --- a/src/script/lua_api/l_mainmenu.cpp +++ b/src/script/lua_api/l_mainmenu.cpp @@ -964,6 +964,23 @@ int ModApiMainMenu::l_get_active_renderer(lua_State *L) return 1; } +/******************************************************************************/ +int ModApiMainMenu::l_get_active_irrlicht_device(lua_State *L) +{ + const char *device_name = [] { + switch (RenderingEngine::get_raw_device()->getType()) { + case EIDT_WIN32: return "WIN32"; + case EIDT_X11: return "X11"; + case EIDT_OSX: return "OSX"; + case EIDT_SDL: return "SDL"; + case EIDT_ANDROID: return "ANDROID"; + default: return "Unknown"; + } + }(); + lua_pushstring(L, device_name); + return 1; +} + /******************************************************************************/ int ModApiMainMenu::l_get_min_supp_proto(lua_State *L) { @@ -1108,6 +1125,7 @@ void ModApiMainMenu::Initialize(lua_State *L, int top) API_FCT(get_window_info); API_FCT(get_active_driver); API_FCT(get_active_renderer); + API_FCT(get_active_irrlicht_device); API_FCT(get_min_supp_proto); API_FCT(get_max_supp_proto); API_FCT(open_url); diff --git a/src/script/lua_api/l_mainmenu.h b/src/script/lua_api/l_mainmenu.h index 538beaaa9..6cb8b6d2c 100644 --- a/src/script/lua_api/l_mainmenu.h +++ b/src/script/lua_api/l_mainmenu.h @@ -110,6 +110,8 @@ private: static int l_get_active_renderer(lua_State *L); + static int l_get_active_irrlicht_device(lua_State *L); + //filesystem static int l_get_mainmenu_path(lua_State *L);