mirror of
https://github.com/luanti-org/luanti.git
synced 2025-10-27 05:45:18 +01:00
Save the settings in more cases to avoid losing setting changes (especially on Android) (#14266)
This commit is contained in:
@@ -247,11 +247,8 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args)
|
||||
}
|
||||
|
||||
// Break out of menu-game loop to shut down cleanly
|
||||
if (!m_rendering_engine->run() || *kill) {
|
||||
if (!g_settings_path.empty())
|
||||
g_settings->updateConfigFile(g_settings_path.c_str());
|
||||
if (!m_rendering_engine->run() || *kill)
|
||||
break;
|
||||
}
|
||||
|
||||
m_rendering_engine->get_video_driver()->setTextureCreationFlag(
|
||||
video::ETCF_CREATE_MIP_MAPS, g_settings->getBool("mip_map"));
|
||||
@@ -292,6 +289,16 @@ bool ClientLauncher::run(GameStartData &start_data, const Settings &cmd_args)
|
||||
receiver->m_touchscreengui = NULL;
|
||||
#endif
|
||||
|
||||
/* Save the settings when leaving the game.
|
||||
* This makes sure that setting changes made in-game are persisted even
|
||||
* in case of a later unclean exit from the mainmenu.
|
||||
* This is especially useful on Android because closing the app from the
|
||||
* "Recents screen" results in an unclean exit.
|
||||
* Caveat: This means that the settings are saved twice when exiting Minetest.
|
||||
*/
|
||||
if (!g_settings_path.empty())
|
||||
g_settings->updateConfigFile(g_settings_path.c_str());
|
||||
|
||||
// If no main menu, show error and exit
|
||||
if (skip_main_menu) {
|
||||
if (!error_message.empty()) {
|
||||
@@ -555,6 +562,16 @@ void ClientLauncher::main_menu(MainMenuData *menudata)
|
||||
|
||||
/* leave scene manager in a clean state */
|
||||
m_rendering_engine->get_scene_manager()->clear();
|
||||
|
||||
/* Save the settings when leaving the mainmenu.
|
||||
* This makes sure that setting changes made in the mainmenu are persisted
|
||||
* even in case of a later unclean exit from the game.
|
||||
* This is especially useful on Android because closing the app from the
|
||||
* "Recents screen" results in an unclean exit.
|
||||
* Caveat: This means that the settings are saved twice when exiting Minetest.
|
||||
*/
|
||||
if (!g_settings_path.empty())
|
||||
g_settings->updateConfigFile(g_settings_path.c_str());
|
||||
}
|
||||
|
||||
void ClientLauncher::speed_tests()
|
||||
|
||||
@@ -28,6 +28,7 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
#include "config.h"
|
||||
#include "filesys.h"
|
||||
#include "log.h"
|
||||
#include "settings.h"
|
||||
|
||||
#include <sstream>
|
||||
#include <exception>
|
||||
@@ -39,6 +40,12 @@ with this program; if not, write to the Free Software Foundation, Inc.,
|
||||
|
||||
extern int main(int argc, char *argv[]);
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Java_net_minetest_minetest_GameActivity_saveSettings(JNIEnv* env, jobject /* this */) {
|
||||
if (!g_settings_path.empty())
|
||||
g_settings->updateConfigFile(g_settings_path.c_str());
|
||||
}
|
||||
|
||||
void android_main(android_app *app)
|
||||
{
|
||||
int retval = 0;
|
||||
|
||||
Reference in New Issue
Block a user