| @@ -93,8 +93,8 @@ ModuleUsage* getModuleUsage(const std::string& pluginSlug, const std::string& mo | |||||
| void init(); | void init(); | ||||
| json_t* toJson(); | json_t* toJson(); | ||||
| void fromJson(json_t* rootJ); | void fromJson(json_t* rootJ); | ||||
| void save(const std::string& path); | |||||
| void load(const std::string& path); | |||||
| void save(std::string path = ""); | |||||
| void load(std::string path = ""); | |||||
| } // namespace settings | } // namespace settings | ||||
| @@ -83,7 +83,7 @@ void Scene::step() { | |||||
| if (time - lastAutosaveTime >= settings::autosaveInterval) { | if (time - lastAutosaveTime >= settings::autosaveInterval) { | ||||
| lastAutosaveTime = time; | lastAutosaveTime = time; | ||||
| APP->patch->saveAutosave(); | APP->patch->saveAutosave(); | ||||
| settings::save(settings::settingsPath); | |||||
| settings::save(); | |||||
| } | } | ||||
| } | } | ||||
| @@ -351,7 +351,10 @@ void fromJson(json_t* rootJ) { | |||||
| } | } | ||||
| } | } | ||||
| void save(const std::string& path) { | |||||
| void save(std::string path) { | |||||
| if (path.empty()) | |||||
| path = settingsPath; | |||||
| INFO("Saving settings %s", path.c_str()); | INFO("Saving settings %s", path.c_str()); | ||||
| json_t* rootJ = toJson(); | json_t* rootJ = toJson(); | ||||
| if (!rootJ) | if (!rootJ) | ||||
| @@ -367,7 +370,10 @@ void save(const std::string& path) { | |||||
| json_decref(rootJ); | json_decref(rootJ); | ||||
| } | } | ||||
| void load(const std::string& path) { | |||||
| void load(std::string path) { | |||||
| if (path.empty()) | |||||
| path = settingsPath; | |||||
| INFO("Loading settings %s", path.c_str()); | INFO("Loading settings %s", path.c_str()); | ||||
| FILE* file = std::fopen(path.c_str(), "r"); | FILE* file = std::fopen(path.c_str(), "r"); | ||||
| if (!file) | if (!file) | ||||
| @@ -146,7 +146,7 @@ int main(int argc, char* argv[]) { | |||||
| // Load settings | // Load settings | ||||
| settings::init(); | settings::init(); | ||||
| try { | try { | ||||
| settings::load(settings::settingsPath); | |||||
| settings::load(); | |||||
| } | } | ||||
| catch (Exception& e) { | catch (Exception& e) { | ||||
| std::string msg = e.what(); | std::string msg = e.what(); | ||||
| @@ -241,7 +241,7 @@ int main(int argc, char* argv[]) { | |||||
| delete APP; | delete APP; | ||||
| contextSet(NULL); | contextSet(NULL); | ||||
| if (!settings::headless) { | if (!settings::headless) { | ||||
| settings::save(settings::settingsPath); | |||||
| settings::save(); | |||||
| } | } | ||||
| // Destroy environment | // Destroy environment | ||||