1
0

Save settings when closing volume/keys dialogs

This commit is contained in:
luk3yx 2022-09-19 19:52:20 +12:00 committed by Maksym H
parent bd51d690ab
commit 6befa9c8e9
4 changed files with 17 additions and 5 deletions

View File

@ -331,6 +331,9 @@ bool GUIKeyChangeMenu::acceptInput()
g_gamecallback->signalKeyConfigChange();
if (!g_settings_path.empty())
g_settings->updateConfigFile(g_settings_path.c_str());
return true;
}

View File

@ -170,16 +170,23 @@ void GUIVolumeChange::drawMenu()
gui::IGUIElement::draw();
}
void GUIVolumeChange::saveSettingsAndQuit()
{
if (!g_settings_path.empty())
g_settings->updateConfigFile(g_settings_path.c_str());
quitMenu();
}
bool GUIVolumeChange::OnEvent(const SEvent& event)
{
if (event.EventType == EET_KEY_INPUT_EVENT) {
if (event.KeyInput.Key == KEY_ESCAPE && event.KeyInput.PressedDown) {
quitMenu();
saveSettingsAndQuit();
return true;
}
if (event.KeyInput.Key == KEY_RETURN && event.KeyInput.PressedDown) {
quitMenu();
saveSettingsAndQuit();
return true;
}
} else if (event.EventType == EET_GUI_EVENT) {
@ -195,7 +202,7 @@ bool GUIVolumeChange::OnEvent(const SEvent& event)
if (event.GUIEvent.EventType == gui::EGET_BUTTON_CLICKED) {
if (event.GUIEvent.Caller->getID() == ID_soundExitButton) {
quitMenu();
saveSettingsAndQuit();
return true;
}
Environment->setFocus(this);

View File

@ -50,6 +50,8 @@ protected:
std::string getNameByID(s32 id) { return ""; }
private:
void saveSettingsAndQuit();
ISimpleTextureSource *m_tsrc;
video::SColor m_fullscreen_bgcolor;
};

View File

@ -146,8 +146,8 @@ int ModApiMainMenu::l_start(lua_State *L)
data->servername = getTextData(L,"servername");
#ifdef __IOS__
std::string conf_path = porting::path_user + DIR_DELIM + "multicraft.conf";
g_settings->updateConfigFile(conf_path.c_str());
if (!g_settings_path.empty())
g_settings->updateConfigFile(g_settings_path.c_str());
#endif
//close menu next time