diff --git a/src/scenedit/scen.fileio.cpp b/src/scenedit/scen.fileio.cpp index 132f0e3ae..4b8af48f2 100644 --- a/src/scenedit/scen.fileio.cpp +++ b/src/scenedit/scen.fileio.cpp @@ -1101,13 +1101,12 @@ struct overrides_sheet { } }; -const int MAX_ED_AUTOSAVE_DEFAULT = 10; // TODO make a pref static fs::path next_autosave_path() { extern fs::path edAutoDir; auto ed_autosaves = sorted_file_mtimes(edAutoDir, {".boes"}); - if(ed_autosaves.size() >= MAX_ED_AUTOSAVE_DEFAULT){ + if(ed_autosaves.size() >= get_int_pref("EdAutoSlots", 10)){ // TODO allow changing the pref return ed_autosaves.back().first; // Reuse oldest auto slot }else if(ed_autosaves.empty()){ return edAutoDir / "auto0.boes"; diff --git a/src/scenedit/scen.main.cpp b/src/scenedit/scen.main.cpp index 5ece4f8c0..d2e8a5750 100644 --- a/src/scenedit/scen.main.cpp +++ b/src/scenedit/scen.main.cpp @@ -195,8 +195,15 @@ static void launch_scenario(eLaunchType type) { //Changed to ISO C specified argument and return type. int main(int argc, char* argv[]) { extern cUndoList undo_list; - undo_list.onChange = []() -> void { - save_scenario(false, true); + int change_counter = 0; + undo_list.onChange = [&change_counter]() -> void { + ++change_counter; + // TODO allow setting this pref (min 1) + if(change_counter == get_int_pref("EdAutoInterval", 3)){ + save_scenario(false, true); + change_counter = 0; + } + }; try { init_scened(argc, argv);