Browse Source

Add "autosavePeriod" to settings.json.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
9789f22d59
4 changed files with 16 additions and 6 deletions
  1. +1
    -1
      include/app/Scene.hpp
  2. +1
    -0
      include/settings.hpp
  3. +7
    -5
      src/app/Scene.cpp
  4. +7
    -0
      src/settings.cpp

+ 1
- 1
include/app/Scene.hpp View File

@@ -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;


+ 1
- 0
include/settings.hpp View File

@@ -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


+ 7
- 5
src/app/Scene.cpp View File

@@ -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();


+ 7
- 0
src/settings.cpp View File

@@ -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<std::tuple<std::string, std::string>, 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);


Loading…
Cancel
Save