| @@ -1,6 +1,6 @@ | |||||
| /* | /* | ||||
| * DISTRHO Cardinal Plugin | * DISTRHO Cardinal Plugin | ||||
| * Copyright (C) 2021 Filipe Coelho <falktx@falktx.com> | |||||
| * Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com> | |||||
| * | * | ||||
| * This program is free software; you can redistribute it and/or | * This program is free software; you can redistribute it and/or | ||||
| * modify it under the terms of the GNU General Public License as | * modify it under the terms of the GNU General Public License as | ||||
| @@ -190,9 +190,9 @@ void saveDialog(const std::string& path) | |||||
| #endif | #endif | ||||
| } | } | ||||
| void saveAsDialog() | |||||
| { | |||||
| #ifndef HEADLESS | #ifndef HEADLESS | ||||
| static void saveAsDialog(const bool uncompressed) | |||||
| { | |||||
| std::string dir; | std::string dir; | ||||
| if (! APP->patch->path.empty()) | if (! APP->patch->path.empty()) | ||||
| dir = system::getDirectory(APP->patch->path); | dir = system::getDirectory(APP->patch->path); | ||||
| @@ -208,7 +208,22 @@ void saveAsDialog() | |||||
| FileBrowserOptions opts; | FileBrowserOptions opts; | ||||
| opts.startDir = dir.c_str(); | opts.startDir = dir.c_str(); | ||||
| opts.saving = ui->saving = true; | opts.saving = ui->saving = true; | ||||
| ui->savingUncompressed = true; | |||||
| ui->openFileBrowser(opts); | ui->openFileBrowser(opts); | ||||
| } | |||||
| #endif | |||||
| void saveAsDialog() | |||||
| { | |||||
| #ifndef HEADLESS | |||||
| saveAsDialog(false); | |||||
| #endif | |||||
| } | |||||
| void saveAsDialogUncompressed() | |||||
| { | |||||
| #ifndef HEADLESS | |||||
| saveAsDialog(true); | |||||
| #endif | #endif | ||||
| } | } | ||||
| @@ -1,6 +1,6 @@ | |||||
| /* | /* | ||||
| * DISTRHO Cardinal Plugin | * DISTRHO Cardinal Plugin | ||||
| * Copyright (C) 2021 Filipe Coelho <falktx@falktx.com> | |||||
| * Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com> | |||||
| * | * | ||||
| * This program is free software; you can redistribute it and/or | * This program is free software; you can redistribute it and/or | ||||
| * modify it under the terms of the GNU General Public License as | * modify it under the terms of the GNU General Public License as | ||||
| @@ -48,6 +48,7 @@ void loadTemplateDialog(); | |||||
| void revertDialog(); | void revertDialog(); | ||||
| void saveDialog(const std::string& path); | void saveDialog(const std::string& path); | ||||
| void saveAsDialog(); | void saveAsDialog(); | ||||
| void saveAsDialogUncompressed(); | |||||
| void appendSelectionContextMenu(rack::ui::Menu* menu); | void appendSelectionContextMenu(rack::ui::Menu* menu); | ||||
| bool connectToRemote(); | bool connectToRemote(); | ||||
| @@ -1,6 +1,6 @@ | |||||
| /* | /* | ||||
| * DISTRHO Cardinal Plugin | * DISTRHO Cardinal Plugin | ||||
| * Copyright (C) 2021 Filipe Coelho <falktx@falktx.com> | |||||
| * Copyright (C) 2021-2022 Filipe Coelho <falktx@falktx.com> | |||||
| * | * | ||||
| * This program is free software; you can redistribute it and/or | * This program is free software; you can redistribute it and/or | ||||
| * modify it under the terms of the GNU General Public License as | * modify it under the terms of the GNU General Public License as | ||||
| @@ -18,6 +18,7 @@ | |||||
| #include <app/Scene.hpp> | #include <app/Scene.hpp> | ||||
| #include <asset.hpp> | #include <asset.hpp> | ||||
| #include <context.hpp> | #include <context.hpp> | ||||
| #include <engine/Engine.hpp> | |||||
| #include <helpers.hpp> | #include <helpers.hpp> | ||||
| #include <patch.hpp> | #include <patch.hpp> | ||||
| #include <settings.hpp> | #include <settings.hpp> | ||||
| @@ -748,11 +749,31 @@ protected: | |||||
| if (saving) | if (saving) | ||||
| { | { | ||||
| const bool uncompressed = savingUncompressed; | |||||
| savingUncompressed = false; | |||||
| if (rack::system::getExtension(sfilename) != ".vcv") | if (rack::system::getExtension(sfilename) != ".vcv") | ||||
| sfilename += ".vcv"; | sfilename += ".vcv"; | ||||
| try { | try { | ||||
| context->patch->save(sfilename); | |||||
| if (uncompressed) | |||||
| { | |||||
| context->engine->prepareSave(); | |||||
| if (json_t* const rootJ = context->patch->toJson()) | |||||
| { | |||||
| if (FILE* const file = std::fopen(sfilename.c_str(), "w")) | |||||
| { | |||||
| json_dumpf(rootJ, file, JSON_INDENT(2)); | |||||
| std::fclose(file); | |||||
| } | |||||
| json_decref(rootJ); | |||||
| } | |||||
| } | |||||
| else | |||||
| { | |||||
| context->patch->save(sfilename); | |||||
| } | |||||
| } | } | ||||
| catch (rack::Exception& e) { | catch (rack::Exception& e) { | ||||
| std::string message = rack::string::f("Could not save patch: %s", e.what()); | std::string message = rack::string::f("Could not save patch: %s", e.what()); | ||||
| @@ -142,6 +142,7 @@ class CardinalBaseUI : public UI { | |||||
| public: | public: | ||||
| CardinalPluginContext* const context; | CardinalPluginContext* const context; | ||||
| bool saving; | bool saving; | ||||
| bool savingUncompressed; | |||||
| // for 3rd party modules | // for 3rd party modules | ||||
| std::function<void(char* path)> filebrowseraction; | std::function<void(char* path)> filebrowseraction; | ||||
| @@ -151,6 +152,7 @@ public: | |||||
| : UI(width, height), | : UI(width, height), | ||||
| context(getRackContextFromPlugin(getPluginInstancePointer())), | context(getRackContextFromPlugin(getPluginInstancePointer())), | ||||
| saving(false), | saving(false), | ||||
| savingUncompressed(false), | |||||
| filebrowseraction(), | filebrowseraction(), | ||||
| filebrowserhandle(nullptr) | filebrowserhandle(nullptr) | ||||
| { | { | ||||
| @@ -111,6 +111,10 @@ struct FileButton : MenuButton { | |||||
| patchUtils::saveAsDialog(); | patchUtils::saveAsDialog(); | ||||
| })); | })); | ||||
| menu->addChild(createMenuItem("Export uncompressed json...", "", []() { | |||||
| patchUtils::saveAsDialogUncompressed(); | |||||
| })); | |||||
| #ifdef HAVE_LIBLO | #ifdef HAVE_LIBLO | ||||
| if (patchUtils::isRemoteConnected()) { | if (patchUtils::isRemoteConnected()) { | ||||
| menu->addChild(createMenuItem("Deploy to MOD", "F7", []() { | menu->addChild(createMenuItem("Deploy to MOD", "F7", []() { | ||||