diff --git a/builtin/common/settings/components.lua b/builtin/common/settings/components.lua index 64cd27c3cbe6b..0a4bf13c7ecf0 100644 --- a/builtin/common/settings/components.lua +++ b/builtin/common/settings/components.lua @@ -249,8 +249,10 @@ local function make_path(setting) } end -if PLATFORM == "Android" then +if PLATFORM == "Android" or INIT == "pause_menu" then -- The Irrlicht file picker doesn't work on Android. + -- Access to the Irrlicht file picker isn't implemented in the pause menu + -- since we want to delete it anyway, so any time spent on it would be wasted. make.path = make.string make.filepath = make.string else diff --git a/src/script/lua_api/CMakeLists.txt b/src/script/lua_api/CMakeLists.txt index 3909eb3feee3a..ef1be9525b569 100644 --- a/src/script/lua_api/CMakeLists.txt +++ b/src/script/lua_api/CMakeLists.txt @@ -37,5 +37,6 @@ set(client_SCRIPT_LUA_API_SRCS ${CMAKE_CURRENT_SOURCE_DIR}/l_menu_common.cpp ${CMAKE_CURRENT_SOURCE_DIR}/l_minimap.cpp ${CMAKE_CURRENT_SOURCE_DIR}/l_particles_local.cpp + ${CMAKE_CURRENT_SOURCE_DIR}/l_pause_menu.cpp ${CMAKE_CURRENT_SOURCE_DIR}/l_storage.cpp PARENT_SCOPE) diff --git a/src/script/lua_api/l_pause_menu.cpp b/src/script/lua_api/l_pause_menu.cpp new file mode 100644 index 0000000000000..6af62d3e3763b --- /dev/null +++ b/src/script/lua_api/l_pause_menu.cpp @@ -0,0 +1,28 @@ +// Luanti +// SPDX-License-Identifier: LGPL-2.1-or-later +// Copyright (C) 2025 grorp + +#include "l_pause_menu.h" +#include "gui/mainmenumanager.h" +#include "lua_api/l_internal.h" + +/******************************************************************************/ +int ModApiPauseMenu::l_show_keys_menu(lua_State *L) +{ + g_gamecallback->keyConfig(); + return 0; +} + +/******************************************************************************/ +int ModApiPauseMenu::l_show_touchscreen_layout(lua_State *L) +{ + g_gamecallback->touchscreenLayout(); + return 0; +} + +/******************************************************************************/ +void ModApiPauseMenu::Initialize(lua_State *L, int top) +{ + API_FCT(show_keys_menu); + API_FCT(show_touchscreen_layout); +} diff --git a/src/script/lua_api/l_pause_menu.h b/src/script/lua_api/l_pause_menu.h new file mode 100644 index 0000000000000..507c1c4b78ad3 --- /dev/null +++ b/src/script/lua_api/l_pause_menu.h @@ -0,0 +1,17 @@ +// Luanti +// SPDX-License-Identifier: LGPL-2.1-or-later +// Copyright (C) 2025 grorp + +#pragma once + +#include "l_base.h" + +class ModApiPauseMenu: public ModApiBase +{ +private: + static int l_show_keys_menu(lua_State *L); + static int l_show_touchscreen_layout(lua_State *L); + +public: + static void Initialize(lua_State *L, int top); +}; diff --git a/src/script/lua_api/l_settings.cpp b/src/script/lua_api/l_settings.cpp index 241eb2542fe31..d5f833fbde576 100644 --- a/src/script/lua_api/l_settings.cpp +++ b/src/script/lua_api/l_settings.cpp @@ -31,6 +31,7 @@ static inline int checkSettingSecurity(lua_State* L, const std::string &name) { #if CHECK_CLIENT_BUILD() // Main menu is allowed everything + // TODO: also permit pause menu if (ModApiBase::getGuiEngine(L) != nullptr) return 0; #endif diff --git a/src/script/scripting_pause_menu.cpp b/src/script/scripting_pause_menu.cpp index 2bbde06284355..ebcc55d2b4c40 100644 --- a/src/script/scripting_pause_menu.cpp +++ b/src/script/scripting_pause_menu.cpp @@ -8,6 +8,7 @@ #include "filesys.h" #include "lua_api/l_client_common.h" #include "lua_api/l_menu_common.h" +#include "lua_api/l_pause_menu.h" #include "lua_api/l_settings.h" #include "lua_api/l_util.h" #include "porting.h" @@ -41,6 +42,7 @@ void PauseMenuScripting::initializeModApi(lua_State *L, int top) LuaSettings::Register(L); // Initialize mod API modules + ModApiPauseMenu::Initialize(L, top); ModApiMenuCommon::Initialize(L, top); ModApiClientCommon::Initialize(L, top); ModApiUtil::Initialize(L, top);