diff --git a/include/app/Scene.hpp b/include/app/Scene.hpp index 83f7088a..92d32acd 100644 --- a/include/app/Scene.hpp +++ b/include/app/Scene.hpp @@ -17,7 +17,7 @@ struct Scene : widget::OpaqueWidget { MenuBar *menuBar; widget::Widget *moduleBrowser; - double lastAutoSaveTime = 0.0; + double lastAutosaveTime = 0.0; // Version checking bool checkVersion = true; diff --git a/include/settings.hpp b/include/settings.hpp index a4732dd5..843b40fb 100644 --- a/include/settings.hpp +++ b/include/settings.hpp @@ -36,6 +36,7 @@ extern bool cpuMeter; extern bool lockModules; extern float frameRateLimit; extern bool frameRateSync; +extern float autosavePeriod; extern bool skipLoadOnLaunch; extern std::string patchPath; // (plugin, model) -> score diff --git a/src/app/Scene.cpp b/src/app/Scene.cpp index d874d4d7..26d18df6 100644 --- a/src/app/Scene.cpp +++ b/src/app/Scene.cpp @@ -39,11 +39,13 @@ void Scene::step() { rackScroll->box.size = box.size.minus(rackScroll->box.pos); // Autosave every 15 seconds - double time = glfwGetTime(); - if (time - lastAutoSaveTime >= 15.0) { - lastAutoSaveTime = time; - APP->patch->save(asset::user("autosave.vcv")); - settings::save(asset::user("settings.json")); + if (settings::autosavePeriod > 0.0) { + double time = glfwGetTime(); + if (time - lastAutosaveTime >= settings::autosavePeriod) { + lastAutosaveTime = time; + APP->patch->save(asset::user("autosave.vcv")); + settings::save(asset::user("settings.json")); + } } Widget::step(); diff --git a/src/settings.cpp b/src/settings.cpp index c318affb..6476c1fe 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -31,6 +31,7 @@ bool cpuMeter = false; bool lockModules = false; float frameRateLimit = 70.0; bool frameRateSync = true; +float autosavePeriod = 15.0; bool skipLoadOnLaunch = false; std::string patchPath; std::map, float> favoriteScores; @@ -79,6 +80,8 @@ json_t *toJson() { json_object_set_new(rootJ, "frameRateSync", json_boolean(frameRateSync)); + json_object_set_new(rootJ, "autosavePeriod", json_real(autosavePeriod)); + if (skipLoadOnLaunch) { json_object_set_new(rootJ, "skipLoadOnLaunch", json_true()); } @@ -179,6 +182,10 @@ void fromJson(json_t *rootJ) { if (frameRateSyncJ) frameRateSync = json_boolean_value(frameRateSyncJ); + json_t *autosavePeriodJ = json_object_get(rootJ, "autosavePeriod"); + if (autosavePeriodJ) + autosavePeriod = json_number_value(autosavePeriodJ); + json_t *skipLoadOnLaunchJ = json_object_get(rootJ, "skipLoadOnLaunch"); if (skipLoadOnLaunchJ) skipLoadOnLaunch = json_boolean_value(skipLoadOnLaunchJ);