If autosave prefs open before autosave check, use default
This commit is contained in:
@@ -1297,7 +1297,7 @@ void autosave_preferences(cDialog* parent) {
|
||||
cControl* ctrl = iter->second;
|
||||
cLed* led = dynamic_cast<cLed*>(ctrl);
|
||||
if(led != nullptr){
|
||||
led->setState(get_bool_pref("Autosave_" + id, true) ? led_red : led_off);
|
||||
led->setState(check_autosave_trigger(id) ? led_red : led_off);
|
||||
}
|
||||
}
|
||||
prefsDlog.attachClickHandlers(&prefs_autosave_event_filter, {"okay", "cancel"});
|
||||
|
@@ -491,12 +491,16 @@ std::map<std::string, bool> autosave_trigger_defaults = {
|
||||
{"Eat", false}
|
||||
};
|
||||
|
||||
void try_auto_save(std::string reason) {
|
||||
if(!get_bool_pref("Autosave", true)) return;
|
||||
bool check_autosave_trigger(std::string reason) {
|
||||
bool reason_default_on = false;
|
||||
if(autosave_trigger_defaults.find(reason) != autosave_trigger_defaults.end())
|
||||
reason_default_on = autosave_trigger_defaults[reason];
|
||||
if(!get_bool_pref("Autosave_" + reason, reason_default_on)) return;
|
||||
return get_bool_pref("Autosave_" + reason, reason_default_on);
|
||||
}
|
||||
|
||||
void try_auto_save(std::string reason) {
|
||||
if(!get_bool_pref("Autosave", true)) return;
|
||||
if(!check_autosave_trigger(reason)) return;
|
||||
if(univ.file.empty()){
|
||||
ASB("Autosave: Make a manual save first.");
|
||||
print_buf();
|
||||
|
@@ -32,6 +32,7 @@ void alter_rect(rectangle *r);
|
||||
|
||||
// The player can configure autosaves on/off globally, or individually
|
||||
// for a variety of different trigger reasons
|
||||
bool check_autosave_trigger(std::string reason);
|
||||
void try_auto_save(std::string reason);
|
||||
|
||||
#endif
|
||||
|
Reference in New Issue
Block a user