Autosave settings immediately after closing settings

This commit is contained in:
Ilari Liusvaara 2014-03-30 21:20:21 +03:00
parent 7a1e20e9db
commit 2498bad58d
4 changed files with 17 additions and 1 deletions

View file

@ -41,6 +41,7 @@ void signal_resize_needed();
void _runuifun_async(void (*fn)(void*), void* arg);
void show_projectwindow(wxWindow* modwin);
void signal_core_change();
void do_save_configuration();
std::vector<interface_action_paramval> prompt_action_params(wxWindow* parent, const std::string& label,
const std::list<interface_action_param>& params);

View file

@ -157,6 +157,7 @@ void show_conflictwindow(wxWindow* parent)
return;
}
editor->Destroy();
do_save_configuration();
}
std::map<std::string, std::string> core_selections;

View file

@ -222,7 +222,8 @@ end:
void save_configuration()
{
std::string cfg = get_config_path() + "/lsneswxw.cfg";
std::ofstream cfgfile(cfg.c_str());
std::string cfgtmp = cfg + ".tmp";
std::ofstream cfgfile(cfgtmp.c_str());
//Settings.
for(auto i : lsnes_vsetc.get_all())
cfgfile << "SET " << i.first << " " << i.second << std::endl;
@ -257,6 +258,13 @@ end:
for(auto i : core_selections)
if(i.second != "")
cfgfile << "PREFER " << i.first << " " << i.second << std::endl;
if(!cfgfile) {
show_message_ok(NULL, "Error Saving configuration", "Error saving configuration",
wxICON_EXCLAMATION);
return;
}
cfgfile.close();
zip::rename_overwrite(cfgtmp.c_str(), cfg.c_str());
//Last save.
std::ofstream lsave(get_config_path() + "/" + our_rom_name + ".ls");
lsave << last_save;
@ -535,6 +543,11 @@ int lsnes_app::OnExit()
return 0;
}
void do_save_configuration()
{
save_configuration();
}
namespace
{
struct _graphics_driver drv = {

View file

@ -213,6 +213,7 @@ void display_settings_dialog(wxWindow* parent, settings_tab_factory* singletab)
}
dlg = NULL;
editor->Destroy();
do_save_configuration();
}
void settings_activate_keygrab(std::function<void(std::string key)> callback)