upgrade notificationtags/v0.6.0
@@ -150,7 +150,8 @@ void openBrowser(std::string url); | |||||
// logger.cpp | // logger.cpp | ||||
//////////////////// | //////////////////// | ||||
extern FILE *gLogFile; | |||||
void loggerInit(); | |||||
void loggerDestroy(); | |||||
void debug(const char *format, ...); | void debug(const char *format, ...); | ||||
void info(const char *format, ...); | void info(const char *format, ...); | ||||
void warn(const char *format, ...); | void warn(const char *format, ...); | ||||
@@ -114,6 +114,7 @@ void ModuleWidget::fromJson(json_t *rootJ) { | |||||
json_t *paramJ; | json_t *paramJ; | ||||
json_array_foreach(paramsJ, i, paramJ) { | json_array_foreach(paramsJ, i, paramJ) { | ||||
if (legacy && legacy <= 1) { | if (legacy && legacy <= 1) { | ||||
// Legacy 1 mode | |||||
// The index in the array we're iterating is the index of the ParamWidget in the params vector. | // The index in the array we're iterating is the index of the ParamWidget in the params vector. | ||||
if (i < params.size()) { | if (i < params.size()) { | ||||
// Create upgraded version of param JSON object | // Create upgraded version of param JSON object | ||||
@@ -9,27 +9,6 @@ | |||||
namespace rack { | namespace rack { | ||||
static std::string newVersion = ""; | |||||
#if defined(RELEASE) | |||||
static void checkVersion() { | |||||
json_t *resJ = requestJson(METHOD_GET, gApiHost + "/version", NULL); | |||||
if (resJ) { | |||||
json_t *versionJ = json_object_get(resJ, "version"); | |||||
if (versionJ) { | |||||
const char *version = json_string_value(versionJ); | |||||
if (version && strlen(version) > 0 && version != gApplicationVersion) { | |||||
newVersion = version; | |||||
} | |||||
} | |||||
json_decref(resJ); | |||||
} | |||||
} | |||||
#endif | |||||
RackScene::RackScene() { | RackScene::RackScene() { | ||||
scrollWidget = new RackScrollWidget(); | scrollWidget = new RackScrollWidget(); | ||||
{ | { | ||||
@@ -46,12 +25,6 @@ RackScene::RackScene() { | |||||
gToolbar = new Toolbar(); | gToolbar = new Toolbar(); | ||||
addChild(gToolbar); | addChild(gToolbar); | ||||
scrollWidget->box.pos.y = gToolbar->box.size.y; | scrollWidget->box.pos.y = gToolbar->box.size.y; | ||||
// Check for new version | |||||
#if defined(RELEASE) | |||||
std::thread versionThread(checkVersion); | |||||
versionThread.detach(); | |||||
#endif | |||||
} | } | ||||
void RackScene::step() { | void RackScene::step() { | ||||
@@ -68,17 +41,6 @@ void RackScene::step() { | |||||
Scene::step(); | Scene::step(); | ||||
zoomWidget->box.size = gRackWidget->box.size.mult(zoomWidget->zoom); | zoomWidget->box.size = gRackWidget->box.size.mult(zoomWidget->zoom); | ||||
// Version popup message | |||||
if (!newVersion.empty()) { | |||||
std::string versionMessage = stringf("Rack %s is available.\n\nYou have Rack %s.\n\nWould you like to download the new version on the website?", newVersion.c_str(), gApplicationVersion.c_str()); | |||||
if (osdialog_message(OSDIALOG_INFO, OSDIALOG_YES_NO, versionMessage.c_str())) { | |||||
std::thread t(openBrowser, "https://vcvrack.com/"); | |||||
t.detach(); | |||||
windowClose(); | |||||
} | |||||
newVersion = ""; | |||||
} | |||||
} | } | ||||
void RackScene::draw(NVGcontext *vg) { | void RackScene::draw(NVGcontext *vg) { | ||||
@@ -225,8 +225,6 @@ void RackWidget::fromJson(json_t *rootJ) { | |||||
json_t *versionJ = json_object_get(rootJ, "version"); | json_t *versionJ = json_object_get(rootJ, "version"); | ||||
if (versionJ) { | if (versionJ) { | ||||
version = json_string_value(versionJ); | version = json_string_value(versionJ); | ||||
if (!version.empty() && gApplicationVersion != version) | |||||
message += stringf("This patch was created with Rack %s. Saving it will convert it to a Rack %s patch.\n\n", version.c_str(), gApplicationVersion.c_str()); | |||||
} | } | ||||
// Detect old patches with ModuleWidget::params/inputs/outputs indices. | // Detect old patches with ModuleWidget::params/inputs/outputs indices. | ||||
@@ -234,6 +232,7 @@ void RackWidget::fromJson(json_t *rootJ) { | |||||
int legacy = 0; | int legacy = 0; | ||||
if (startsWith(version, "0.3.") || startsWith(version, "0.4.") || startsWith(version, "0.5.") || version == "" || version == "dev") { | if (startsWith(version, "0.3.") || startsWith(version, "0.4.") || startsWith(version, "0.5.") || version == "" || version == "dev") { | ||||
legacy = 1; | legacy = 1; | ||||
message += "This patch was created with Rack 0.5 or earlier. Saving it will convert it to a Rack 0.6+ patch.\n\n"; | |||||
} | } | ||||
if (legacy) { | if (legacy) { | ||||
info("Loading patch using legacy mode %d", legacy); | info("Loading patch using legacy mode %d", legacy); | ||||
@@ -246,9 +245,10 @@ void RackWidget::fromJson(json_t *rootJ) { | |||||
size_t moduleId; | size_t moduleId; | ||||
json_t *moduleJ; | json_t *moduleJ; | ||||
json_array_foreach(modulesJ, moduleId, moduleJ) { | json_array_foreach(modulesJ, moduleId, moduleJ) { | ||||
// Set legacy property | |||||
if (legacy) | |||||
json_object_set_new(moduleJ, "legacy", json_integer(legacy)); | |||||
// Add "legacy" property if in legacy mode | |||||
if (legacy) { | |||||
json_object_set(moduleJ, "legacy", json_integer(legacy)); | |||||
} | |||||
json_t *pluginSlugJ = json_object_get(moduleJ, "plugin"); | json_t *pluginSlugJ = json_object_get(moduleJ, "plugin"); | ||||
if (!pluginSlugJ) continue; | if (!pluginSlugJ) continue; | ||||
@@ -259,7 +259,7 @@ void RackWidget::fromJson(json_t *rootJ) { | |||||
Model *model = pluginGetModel(pluginSlug, modelSlug); | Model *model = pluginGetModel(pluginSlug, modelSlug); | ||||
if (!model) { | if (!model) { | ||||
message += stringf("Could not find module \"%s\" in plugin \"%s\"\n", modelSlug.c_str(), pluginSlug.c_str()); | |||||
message += stringf("Could not find module \"%s\" of plugin \"%s\"\n", modelSlug.c_str(), pluginSlug.c_str()); | |||||
continue; | continue; | ||||
} | } | ||||
@@ -292,6 +292,8 @@ void RackWidget::fromJson(json_t *rootJ) { | |||||
Port *outputPort = NULL; | Port *outputPort = NULL; | ||||
Port *inputPort = NULL; | Port *inputPort = NULL; | ||||
if (legacy && legacy <= 1) { | if (legacy && legacy <= 1) { | ||||
// Legacy 1 mode | |||||
// The index of the "ports" array is the index of the Port in the `outputs` and `inputs` vector. | |||||
outputPort = outputModuleWidget->outputs[outputId]; | outputPort = outputModuleWidget->outputs[outputId]; | ||||
inputPort = inputModuleWidget->inputs[inputId]; | inputPort = inputModuleWidget->inputs[inputId]; | ||||
} | } | ||||
@@ -14,11 +14,7 @@ using namespace rack; | |||||
int main(int argc, char* argv[]) { | int main(int argc, char* argv[]) { | ||||
randomInit(); | randomInit(); | ||||
#ifdef RELEASE | |||||
std::string logFilename = assetLocal("log.txt"); | |||||
gLogFile = fopen(logFilename.c_str(), "w"); | |||||
#endif | |||||
loggerInit(); | |||||
info("Rack %s", gApplicationVersion.c_str()); | info("Rack %s", gApplicationVersion.c_str()); | ||||
@@ -64,10 +60,7 @@ int main(int argc, char* argv[]) { | |||||
bridgeDestroy(); | bridgeDestroy(); | ||||
engineDestroy(); | engineDestroy(); | ||||
pluginDestroy(); | pluginDestroy(); | ||||
#ifdef RELEASE | |||||
fclose(gLogFile); | |||||
#endif | |||||
loggerDestroy(); | |||||
return 0; | return 0; | ||||
} | } |
@@ -1,49 +1,66 @@ | |||||
#include "util/common.hpp" | #include "util/common.hpp" | ||||
#include "asset.hpp" | |||||
#include <stdarg.h> | #include <stdarg.h> | ||||
namespace rack { | namespace rack { | ||||
FILE *gLogFile = stderr; | |||||
static FILE *logFile = stderr; | |||||
static auto startTime = std::chrono::high_resolution_clock::now(); | |||||
void loggerInit() { | |||||
#ifdef RELEASE | |||||
std::string logFilename = assetLocal("log.txt"); | |||||
gLogFile = fopen(logFilename.c_str(), "w"); | |||||
#endif | |||||
} | |||||
void loggerDestroy() { | |||||
#ifdef RELEASE | |||||
fclose(gLogFile); | |||||
#endif | |||||
} | |||||
static void printTimestamp() { | |||||
} | |||||
static void printLog(const char *type, const char *format, va_list args) { | |||||
auto nowTime = std::chrono::high_resolution_clock::now(); | |||||
int duration = std::chrono::duration_cast<std::chrono::milliseconds>(nowTime - startTime).count(); | |||||
printTimestamp(); | |||||
fprintf(logFile, "[%s %.03f] ", duration / 1000.0, type); | |||||
vfprintf(logFile, format, args); | |||||
fprintf(logFile, "\n"); | |||||
fflush(logFile); | |||||
} | |||||
void debug(const char *format, ...) { | void debug(const char *format, ...) { | ||||
va_list args; | va_list args; | ||||
va_start(args, format); | va_start(args, format); | ||||
fprintf(gLogFile, "[debug] "); | |||||
vfprintf(gLogFile, format, args); | |||||
fprintf(gLogFile, "\n"); | |||||
fflush(gLogFile); | |||||
printLog("debug", format, args); | |||||
va_end(args); | va_end(args); | ||||
} | } | ||||
void info(const char *format, ...) { | void info(const char *format, ...) { | ||||
va_list args; | va_list args; | ||||
va_start(args, format); | va_start(args, format); | ||||
fprintf(gLogFile, "[info] "); | |||||
vfprintf(gLogFile, format, args); | |||||
fprintf(gLogFile, "\n"); | |||||
fflush(gLogFile); | |||||
printLog("info", format, args); | |||||
va_end(args); | va_end(args); | ||||
} | } | ||||
void warn(const char *format, ...) { | void warn(const char *format, ...) { | ||||
va_list args; | va_list args; | ||||
va_start(args, format); | va_start(args, format); | ||||
fprintf(gLogFile, "[warning] "); | |||||
vfprintf(gLogFile, format, args); | |||||
fprintf(gLogFile, "\n"); | |||||
fflush(gLogFile); | |||||
printLog("warn", format, args); | |||||
va_end(args); | va_end(args); | ||||
} | } | ||||
void fatal(const char *format, ...) { | void fatal(const char *format, ...) { | ||||
va_list args; | va_list args; | ||||
va_start(args, format); | va_start(args, format); | ||||
fprintf(gLogFile, "[fatal] "); | |||||
vfprintf(gLogFile, format, args); | |||||
fprintf(gLogFile, "\n"); | |||||
fflush(gLogFile); | |||||
printLog("fatal", format, args); | |||||
va_end(args); | va_end(args); | ||||
} | } | ||||