Browse Source

Remove PatchManager::isLegacy().

tags/v2.0.0
Andrew Belt 4 years ago
parent
commit
ec14e18bec
3 changed files with 15 additions and 24 deletions
  1. +0
    -3
      include/patch.hpp
  2. +13
    -1
      src/app/RackWidget.cpp
  3. +2
    -20
      src/patch.cpp

+ 0
- 3
include/patch.hpp View File

@@ -10,8 +10,6 @@ namespace rack {
struct PatchManager { struct PatchManager {
/** The currently loaded patch file path */ /** The currently loaded patch file path */
std::string path; std::string path;
/** Enables certain compatibility behavior based on the value */
int legacy = 0;
std::string warningLog; std::string warningLog;


PatchManager(); PatchManager();
@@ -47,7 +45,6 @@ struct PatchManager {


json_t* toJson(); json_t* toJson();
void fromJson(json_t* rootJ); void fromJson(json_t* rootJ);
bool isLegacy(int level);
void log(std::string msg); void log(std::string msg);
}; };




+ 13
- 1
src/app/RackWidget.cpp View File

@@ -224,6 +224,18 @@ void RackWidget::mergeJson(json_t* rootJ) {
} }


void RackWidget::fromJson(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 // modules
json_t* modulesJ = json_object_get(rootJ, "modules"); json_t* modulesJ = json_object_get(rootJ, "modules");
if (!modulesJ) if (!modulesJ)
@@ -255,7 +267,7 @@ void RackWidget::fromJson(json_t* rootJ) {
double x = 0.0, y = 0.0; double x = 0.0, y = 0.0;
json_unpack(posJ, "[F, F]", &x, &y); json_unpack(posJ, "[F, F]", &x, &y);
math::Vec pos = math::Vec(x, y); math::Vec pos = math::Vec(x, y);
if (APP->patch->isLegacy(1)) {
if (legacyV05) {
// In <=v0.5, positions were in pixel units // In <=v0.5, positions were in pixel units
moduleWidget->box.pos = pos; moduleWidget->box.pos = pos;
} }


+ 2
- 20
src/patch.cpp View File

@@ -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"); FILE* f = std::fopen(path.c_str(), "rb");
if (!f) if (!f)
return false; return false;
@@ -239,7 +239,7 @@ void PatchManager::load(std::string path) {
system::removeRecursively(asset::autosavePath); system::removeRecursively(asset::autosavePath);
system::createDirectories(asset::autosavePath); system::createDirectories(asset::autosavePath);


if (isPatchLegacyPre2(path)) {
if (isPatchLegacyV1(path)) {
// Copy the .vcv file directly to "patch.json". // Copy the .vcv file directly to "patch.json".
system::copy(path, system::join(asset::autosavePath, "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) { void PatchManager::fromJson(json_t* rootJ) {
clear(); clear();
legacy = 0;


// version // version
std::string 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()); 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 // path
json_t* pathJ = json_object_get(rootJ, "path"); json_t* pathJ = json_object_get(rootJ, "path");
if (pathJ) 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) { void PatchManager::log(std::string msg) {
warningLog += msg; warningLog += msg;
warningLog += "\n"; warningLog += "\n";


Loading…
Cancel
Save