mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-15 09:25:37 +02:00
Implement an editor to customize the touchscreen controls (#14933)
- The editor is accessible via the pause menu and the settings menu. - Buttons can be moved via drag & drop. - Buttons can be added/removed. The grid menu added by #14918 is used to show all buttons not included in the layout. - Custom layouts are responsive and adapt to changed screen size / DPI / hud_scaling. - The layout is saved as JSON in the "touch_layout" setting.
This commit is contained in:
@@ -11,6 +11,7 @@
|
||||
#include "gui/guiMainMenu.h"
|
||||
#include "gui/guiKeyChangeMenu.h"
|
||||
#include "gui/guiPathSelectMenu.h"
|
||||
#include "gui/touchscreeneditor.h"
|
||||
#include "version.h"
|
||||
#include "porting.h"
|
||||
#include "filesys.h"
|
||||
@@ -535,6 +536,22 @@ int ModApiMainMenu::l_show_keys_menu(lua_State *L)
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int ModApiMainMenu::l_show_touchscreen_layout(lua_State *L)
|
||||
{
|
||||
GUIEngine *engine = getGuiEngine(L);
|
||||
sanity_check(engine != NULL);
|
||||
|
||||
GUITouchscreenLayout *gui = new GUITouchscreenLayout(
|
||||
engine->m_rendering_engine->get_gui_env(),
|
||||
engine->m_parent,
|
||||
-1,
|
||||
engine->m_menumanager,
|
||||
engine->m_texture_source.get());
|
||||
gui->drop();
|
||||
return 0;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
int ModApiMainMenu::l_create_world(lua_State *L)
|
||||
{
|
||||
@@ -1080,6 +1097,7 @@ void ModApiMainMenu::Initialize(lua_State *L, int top)
|
||||
API_FCT(start);
|
||||
API_FCT(close);
|
||||
API_FCT(show_keys_menu);
|
||||
API_FCT(show_touchscreen_layout);
|
||||
API_FCT(create_world);
|
||||
API_FCT(delete_world);
|
||||
API_FCT(set_background);
|
||||
|
@@ -69,6 +69,8 @@ private:
|
||||
|
||||
static int l_show_keys_menu(lua_State *L);
|
||||
|
||||
static int l_show_touchscreen_layout(lua_State *L);
|
||||
|
||||
static int l_show_path_select_dialog(lua_State *L);
|
||||
|
||||
static int l_set_topleft_text(lua_State *L);
|
||||
|
Reference in New Issue
Block a user