diff --git a/builtin/client/pause_menu.lua b/builtin/client/pause_menu.lua index f3c6a7206..bd867374e 100644 --- a/builtin/client/pause_menu.lua +++ b/builtin/client/pause_menu.lua @@ -107,7 +107,12 @@ function dialog_create(name, spec, buttonhandler, eventhandler) minetest.show_formspec(name, spec({})) end -function core.show_settings() - load(true, false) - show_settings_client_formspec("MT_PAUSE_MENU_SETTINGS") +load(true, false) + +function core.show_settings(page_id) + if not page_id then + show_settings_client_formspec("MT_PAUSE_MENU_SETTINGS", {}) + else + show_settings_client_formspec("MT_PAUSE_MENU_SETTINGS", {page_id = page_id}) + end end diff --git a/builtin/mainmenu/settings/dlg_settings.lua b/builtin/mainmenu/settings/dlg_settings.lua index 053cde2e9..d8a96a1fb 100644 --- a/builtin/mainmenu/settings/dlg_settings.lua +++ b/builtin/mainmenu/settings/dlg_settings.lua @@ -756,6 +756,6 @@ function create_settings_dlg() return dlg end -function show_settings_client_formspec(name) - minetest.show_formspec(name or "dlg_settings", get_formspec({})) +function show_settings_client_formspec(name, data) + minetest.show_formspec(name or "dlg_settings", get_formspec(data)) end diff --git a/src/client/game.cpp b/src/client/game.cpp index c71b19c6b..62949b489 100644 --- a/src/client/game.cpp +++ b/src/client/game.cpp @@ -198,8 +198,14 @@ struct LocalFormspecHandler : public TextDest if (g_settings->existsLocal(i.first) && g_settings->get(i.first) != i.second) { g_settings->set(i.first, i.second); - //std::cout << "Setting " << i.first << " set!" << std::endl; } + if (i.first.rfind("page_", 0) == 0) + { + m_client->getScript()->show_settings(i.first.substr(5)); + std::cout << "Found ..." << m_client << std::endl; + } + //std::cout << "Setting " << i.first << " set!" << std::endl; + } return; } diff --git a/src/script/cpp_api/s_client.cpp b/src/script/cpp_api/s_client.cpp index 5af8758d4..32db7a528 100644 --- a/src/script/cpp_api/s_client.cpp +++ b/src/script/cpp_api/s_client.cpp @@ -310,7 +310,7 @@ void ScriptApiClient::show_pause_menu(bool is_singleplayer, bool is_touchscreen, lua_pop(L, 1); } -void ScriptApiClient::show_settings() +void ScriptApiClient::show_settings(const std::string& page) { SCRIPTAPI_PRECHECKHEADER @@ -319,7 +319,14 @@ void ScriptApiClient::show_settings() lua_getglobal(L, "core"); lua_getfield(L, -1, "show_settings"); - PCALL_RES(lua_pcall(L, 0, 0, error_handler)); + if (page != "") + { + lua_pushstring(L, page.c_str()); + } + else + lua_pushnil(L); + + PCALL_RES(lua_pcall(L, 1, 0, error_handler)); lua_pop(L, 1); } diff --git a/src/script/cpp_api/s_client.h b/src/script/cpp_api/s_client.h index 61efa40bd..c0f8a4196 100644 --- a/src/script/cpp_api/s_client.h +++ b/src/script/cpp_api/s_client.h @@ -61,7 +61,7 @@ class ScriptApiClient : virtual public ScriptApiBase bool on_inventory_open(Inventory *inventory); void show_pause_menu(bool is_singleplayer, bool is_touchscreen, const std::string& server_address); - void show_settings(); + void show_settings(const std::string& page = ""); void setEnv(ClientEnvironment *env); };