@@ -17,6 +17,7 @@ extern std::string APP_VERSION; | |||||
extern std::string APP_VERSION_UPDATE; | extern std::string APP_VERSION_UPDATE; | ||||
extern std::string API_URL; | extern std::string API_URL; | ||||
extern std::string API_VERSION; | extern std::string API_VERSION; | ||||
extern std::string ABI_VERSION; | |||||
static const float SVG_DPI = 75.0; | static const float SVG_DPI = 75.0; | ||||
static const float MM_PER_IN = 25.4; | static const float MM_PER_IN = 25.4; | ||||
@@ -22,9 +22,15 @@ std::string user(std::string filename); | |||||
std::string plugin(plugin::Plugin *plugin, std::string filename); | std::string plugin(plugin::Plugin *plugin, std::string filename); | ||||
// Set these before calling init() to override the default paths | |||||
extern std::string systemDir; | extern std::string systemDir; | ||||
extern std::string userDir; | extern std::string userDir; | ||||
extern std::string pluginsPath; | |||||
extern std::string settingsPath; | |||||
extern std::string autosavePath; | |||||
extern std::string templatePath; | |||||
} // namespace asset | } // namespace asset | ||||
} // namespace rack | } // namespace rack |
@@ -43,8 +43,8 @@ void Scene::step() { | |||||
double time = glfwGetTime(); | double time = glfwGetTime(); | ||||
if (time - lastAutosaveTime >= settings::autosavePeriod) { | if (time - lastAutosaveTime >= settings::autosavePeriod) { | ||||
lastAutosaveTime = time; | lastAutosaveTime = time; | ||||
APP->patch->save(asset::user("autosave.vcv")); | |||||
settings::save(asset::user("settings.json")); | |||||
APP->patch->save(asset::autosavePath); | |||||
settings::save(asset::settingsPath); | |||||
} | } | ||||
} | } | ||||
@@ -13,6 +13,7 @@ std::string APP_VERSION = TOSTRING(VERSION); | |||||
std::string APP_VERSION_UPDATE; | std::string APP_VERSION_UPDATE; | ||||
std::string API_URL = "https://api.vcvrack.com"; | std::string API_URL = "https://api.vcvrack.com"; | ||||
std::string API_VERSION = "1"; | std::string API_VERSION = "1"; | ||||
std::string ABI_VERSION = "1"; | |||||
static void checkVersion() { | static void checkVersion() { | ||||
@@ -3,6 +3,7 @@ | |||||
#include <settings.hpp> | #include <settings.hpp> | ||||
#include <string.hpp> | #include <string.hpp> | ||||
#include <plugin/Plugin.hpp> | #include <plugin/Plugin.hpp> | ||||
#include <app/common.hpp> | |||||
#if defined ARCH_MAC | #if defined ARCH_MAC | ||||
#include <CoreFoundation/CoreFoundation.h> | #include <CoreFoundation/CoreFoundation.h> | ||||
@@ -102,6 +103,20 @@ void init() { | |||||
system::createDirectory(systemDir); | system::createDirectory(systemDir); | ||||
system::createDirectory(userDir); | system::createDirectory(userDir); | ||||
// Set paths | |||||
if (settings::devMode) { | |||||
pluginsPath = userDir + "/plugins"; | |||||
settingsPath = userDir + "/settings.json"; | |||||
autosavePath = userDir + "/autosave.vcv"; | |||||
templatePath = userDir + "/template.vcv"; | |||||
} | |||||
else { | |||||
pluginsPath = userDir + "/plugins-v" + app::ABI_VERSION; | |||||
settingsPath = userDir + "/settings-v" + app::ABI_VERSION + ".json"; | |||||
autosavePath = userDir + "/autosave-v" + app::ABI_VERSION + ".vcv"; | |||||
templatePath = userDir + "/template-v" + app::ABI_VERSION + ".vcv"; | |||||
} | |||||
} | } | ||||
@@ -124,6 +139,11 @@ std::string plugin(plugin::Plugin *plugin, std::string filename) { | |||||
std::string systemDir; | std::string systemDir; | ||||
std::string userDir; | std::string userDir; | ||||
std::string pluginsPath; | |||||
std::string settingsPath; | |||||
std::string autosavePath; | |||||
std::string templatePath; | |||||
} // namespace asset | } // namespace asset | ||||
} // namespace rack | } // namespace rack |
@@ -8,6 +8,7 @@ | |||||
#include <bridge.hpp> | #include <bridge.hpp> | ||||
#include <settings.hpp> | #include <settings.hpp> | ||||
#include <engine/Engine.hpp> | #include <engine/Engine.hpp> | ||||
#include <app/common.hpp> | |||||
#include <app/Scene.hpp> | #include <app/Scene.hpp> | ||||
#include <plugin.hpp> | #include <plugin.hpp> | ||||
#include <app.hpp> | #include <app.hpp> | ||||
@@ -113,7 +114,7 @@ int main(int argc, char *argv[]) { | |||||
// Load settings | // Load settings | ||||
try { | try { | ||||
settings::load(asset::user("settings.json")); | |||||
settings::load(asset::settingsPath); | |||||
} | } | ||||
catch (UserException &e) { | catch (UserException &e) { | ||||
std::string msg = e.what(); | std::string msg = e.what(); | ||||
@@ -179,11 +180,11 @@ int main(int argc, char *argv[]) { | |||||
// Destroy app | // Destroy app | ||||
if (!settings::headless) { | if (!settings::headless) { | ||||
APP->patch->save(asset::user("autosave.vcv")); | |||||
APP->patch->save(asset::autosavePath); | |||||
} | } | ||||
INFO("Destroying app"); | INFO("Destroying app"); | ||||
appDestroy(); | appDestroy(); | ||||
settings::save(asset::user("settings.json")); | |||||
settings::save(asset::settingsPath); | |||||
// Destroy environment | // Destroy environment | ||||
INFO("Destroying environment"); | INFO("Destroying environment"); | ||||
@@ -2,6 +2,7 @@ | |||||
#include <asset.hpp> | #include <asset.hpp> | ||||
#include <system.hpp> | #include <system.hpp> | ||||
#include <app.hpp> | #include <app.hpp> | ||||
#include <app/common.hpp> | |||||
#include <app/Scene.hpp> | #include <app/Scene.hpp> | ||||
#include <app/RackWidget.hpp> | #include <app/RackWidget.hpp> | ||||
#include <history.hpp> | #include <history.hpp> | ||||
@@ -35,7 +36,7 @@ void PatchManager::init(std::string path) { | |||||
// To prevent launch crashes, if Rack crashes between now and 15 seconds from now, the "skipAutosaveOnLaunch" property will remain in settings.json, so that in the next launch, the broken autosave will not be loaded. | // To prevent launch crashes, if Rack crashes between now and 15 seconds from now, the "skipAutosaveOnLaunch" property will remain in settings.json, so that in the next launch, the broken autosave will not be loaded. | ||||
bool oldSkipLoadOnLaunch = settings::skipLoadOnLaunch; | bool oldSkipLoadOnLaunch = settings::skipLoadOnLaunch; | ||||
settings::skipLoadOnLaunch = true; | settings::skipLoadOnLaunch = true; | ||||
settings::save(asset::user("settings.json")); | |||||
settings::save(asset::settingsPath); | |||||
settings::skipLoadOnLaunch = false; | settings::skipLoadOnLaunch = false; | ||||
if (oldSkipLoadOnLaunch && osdialog_message(OSDIALOG_INFO, OSDIALOG_YES_NO, "Rack has recovered from a crash, possibly caused by a faulty module in your patch. Clear your patch and start over?")) { | if (oldSkipLoadOnLaunch && osdialog_message(OSDIALOG_INFO, OSDIALOG_YES_NO, "Rack has recovered from a crash, possibly caused by a faulty module in your patch. Clear your patch and start over?")) { | ||||
this->path = ""; | this->path = ""; | ||||
@@ -43,7 +44,7 @@ void PatchManager::init(std::string path) { | |||||
} | } | ||||
// Load autosave | // Load autosave | ||||
if (load(asset::user("autosave.vcv"))) { | |||||
if (load(asset::autosavePath)) { | |||||
return; | return; | ||||
} | } | ||||
@@ -56,7 +57,7 @@ void PatchManager::reset() { | |||||
APP->scene->rackScroll->reset(); | APP->scene->rackScroll->reset(); | ||||
path = ""; | path = ""; | ||||
if (load(asset::user("template.vcv"))) { | |||||
if (load(asset::templatePath)) { | |||||
return; | return; | ||||
} | } | ||||
@@ -145,7 +146,7 @@ void PatchManager::saveTemplateDialog() { | |||||
if (!osdialog_message(OSDIALOG_INFO, OSDIALOG_OK_CANCEL, "Overwrite template patch?")) | if (!osdialog_message(OSDIALOG_INFO, OSDIALOG_OK_CANCEL, "Overwrite template patch?")) | ||||
return; | return; | ||||
save(asset::user("template.vcv")); | |||||
save(asset::templatePath); | |||||
} | } | ||||
bool PatchManager::load(std::string path) { | bool PatchManager::load(std::string path) { | ||||
@@ -261,19 +261,18 @@ void init() { | |||||
loadPlugin(""); | loadPlugin(""); | ||||
// Get user plugins directory | // Get user plugins directory | ||||
std::string pluginsDir = asset::user("plugins"); | |||||
mkdir(pluginsDir.c_str(), 0755); | |||||
mkdir(asset::pluginsPath.c_str(), 0755); | |||||
// Extract packages and load plugins | // Extract packages and load plugins | ||||
extractPackages(pluginsDir); | |||||
loadPlugins(pluginsDir); | |||||
extractPackages(asset::pluginsPath); | |||||
loadPlugins(asset::pluginsPath); | |||||
// If Fundamental wasn't loaded, copy the bundled Fundamental package and load it | // If Fundamental wasn't loaded, copy the bundled Fundamental package and load it | ||||
std::string fundamentalSrc = asset::system("Fundamental.zip"); | std::string fundamentalSrc = asset::system("Fundamental.zip"); | ||||
std::string fundamentalDir = asset::user("plugins/Fundamental"); | |||||
std::string fundamentalDir = asset::pluginsPath + "/Fundamental"; | |||||
if (!settings::devMode && !getPlugin("Fundamental") && system::isFile(fundamentalSrc)) { | if (!settings::devMode && !getPlugin("Fundamental") && system::isFile(fundamentalSrc)) { | ||||
INFO("Extracting bundled Fundamental package"); | INFO("Extracting bundled Fundamental package"); | ||||
extractZip(fundamentalSrc.c_str(), pluginsDir.c_str()); | |||||
extractZip(fundamentalSrc.c_str(), asset::pluginsPath.c_str()); | |||||
loadPlugin(fundamentalDir); | loadPlugin(fundamentalDir); | ||||
} | } | ||||
@@ -473,7 +472,7 @@ void syncUpdate(Update *update) { | |||||
INFO("Downloading plugin %s %s %s", update->pluginSlug.c_str(), update->version.c_str(), arch.c_str()); | INFO("Downloading plugin %s %s %s", update->pluginSlug.c_str(), update->version.c_str(), arch.c_str()); | ||||
// Download zip | // Download zip | ||||
std::string pluginDest = asset::user("plugins/" + update->pluginSlug + ".zip"); | |||||
std::string pluginDest = asset::pluginsPath + "/" + update->pluginSlug + ".zip"; | |||||
if (!network::requestDownload(downloadUrl, pluginDest, &update->progress)) { | if (!network::requestDownload(downloadUrl, pluginDest, &update->progress)) { | ||||
WARN("Plugin %s download was unsuccessful", update->pluginSlug.c_str()); | WARN("Plugin %s download was unsuccessful", update->pluginSlug.c_str()); | ||||
return; | return; | ||||