diff --git a/include/patch.hpp b/include/patch.hpp index 83986a8d..7f1edc21 100644 --- a/include/patch.hpp +++ b/include/patch.hpp @@ -10,8 +10,6 @@ namespace rack { struct PatchManager { /** The currently loaded patch file path */ std::string path; - /** Enables certain compatibility behavior based on the value */ - int legacy = 0; std::string warningLog; PatchManager(); @@ -47,7 +45,6 @@ struct PatchManager { json_t* toJson(); void fromJson(json_t* rootJ); - bool isLegacy(int level); void log(std::string msg); }; diff --git a/src/app/RackWidget.cpp b/src/app/RackWidget.cpp index 55ca911d..ca024987 100644 --- a/src/app/RackWidget.cpp +++ b/src/app/RackWidget.cpp @@ -224,6 +224,18 @@ void RackWidget::mergeJson(json_t* rootJ) { } void RackWidget::fromJson(json_t* rootJ) { + // version + std::string version; + json_t* versionJ = json_object_get(rootJ, "version"); + if (versionJ) + version = json_string_value(versionJ); + + bool legacyV05 = false; + if (string::startsWith(version, "0.3.") || string::startsWith(version, "0.4.") || string::startsWith(version, "0.5.") || version == "dev") { + legacyV05 = true; + } + + // modules json_t* modulesJ = json_object_get(rootJ, "modules"); if (!modulesJ) @@ -255,7 +267,7 @@ void RackWidget::fromJson(json_t* rootJ) { double x = 0.0, y = 0.0; json_unpack(posJ, "[F, F]", &x, &y); math::Vec pos = math::Vec(x, y); - if (APP->patch->isLegacy(1)) { + if (legacyV05) { // In <=v0.5, positions were in pixel units moduleWidget->box.pos = pos; } diff --git a/src/patch.cpp b/src/patch.cpp index 884c4bc5..efb0e3ce 100644 --- a/src/patch.cpp +++ b/src/patch.cpp @@ -219,7 +219,7 @@ void PatchManager::cleanAutosave() { } -static bool isPatchLegacyPre2(std::string path) { +static bool isPatchLegacyV1(std::string path) { FILE* f = std::fopen(path.c_str(), "rb"); if (!f) return false; @@ -239,7 +239,7 @@ void PatchManager::load(std::string path) { system::removeRecursively(asset::autosavePath); system::createDirectories(asset::autosavePath); - if (isPatchLegacyPre2(path)) { + if (isPatchLegacyV1(path)) { // Copy the .vcv file directly to "patch.json". system::copy(path, system::join(asset::autosavePath, "patch.json")); } @@ -425,7 +425,6 @@ json_t* PatchManager::toJson() { void PatchManager::fromJson(json_t* rootJ) { clear(); - legacy = 0; // version std::string version; @@ -436,18 +435,6 @@ void PatchManager::fromJson(json_t* rootJ) { INFO("Patch was made with Rack v%s, current Rack version is v%s", version.c_str(), APP_VERSION.c_str()); } - // Detect old patches with ModuleWidget::params/inputs/outputs indices. - if (string::startsWith(version, "0.3.") || string::startsWith(version, "0.4.") || string::startsWith(version, "0.5.") || version == "" || version == "dev") { - // Use ModuleWidget::params/inputs/outputs indices instead of Module. - legacy = 1; - } - else if (string::startsWith(version, "0.6.")) { - legacy = 2; - } - if (legacy) { - INFO("Loading patch using legacy mode %d", legacy); - } - // path json_t* pathJ = json_object_get(rootJ, "path"); if (pathJ) @@ -481,11 +468,6 @@ void PatchManager::fromJson(json_t* rootJ) { } -bool PatchManager::isLegacy(int level) { - return legacy && legacy <= level; -} - - void PatchManager::log(std::string msg) { warningLog += msg; warningLog += "\n";