Skip to content

Commit

Permalink
Implement keychange/touchscreenlayout, don't implement filepicker
Browse files Browse the repository at this point in the history
  • Loading branch information
grorp committed Jan 1, 2025
1 parent 2184348 commit f06affc
Show file tree
Hide file tree
Showing 6 changed files with 52 additions and 1 deletion.
4 changes: 3 additions & 1 deletion builtin/common/settings/components.lua
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
1 change: 1 addition & 0 deletions src/script/lua_api/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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)
28 changes: 28 additions & 0 deletions src/script/lua_api/l_pause_menu.cpp
Original file line number Diff line number Diff line change
@@ -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);
}
17 changes: 17 additions & 0 deletions src/script/lua_api/l_pause_menu.h
Original file line number Diff line number Diff line change
@@ -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);
};
1 change: 1 addition & 0 deletions src/script/lua_api/l_settings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions src/script/scripting_pause_menu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit f06affc

Please sign in to comment.