1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-07-22 17:18:39 +00:00

Save the settings in more cases to avoid losing setting changes (especially on Android) (#14266)

This commit is contained in:
grorp 2024-01-23 21:33:27 +01:00 committed by GitHub
parent f6ecd931dc
commit a29d3cf074
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 55 additions and 4 deletions

View file

@ -250,11 +250,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"));
@ -299,6 +296,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()) {
@ -562,6 +569,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()

View file

@ -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());
}
namespace porting {
// used here:
void cleanupAndroid();