You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

60 lines
1.4KB

  1. #pragma once
  2. #include <jansson.h>
  3. #include <common.hpp>
  4. namespace rack {
  5. struct PatchManager {
  6. /** The currently loaded patch file path */
  7. std::string path;
  8. /** Path to autosave folder */
  9. std::string autosavePath;
  10. /** Path to user template patch */
  11. std::string templatePath;
  12. /** Path to factory template patch */
  13. std::string factoryTemplatePath;
  14. /** Append to this while loading/saving a patch to display messages to the user after success. */
  15. std::string warningLog;
  16. PatchManager();
  17. ~PatchManager();
  18. void launch(std::string pathArg);
  19. /** Clears the patch. */
  20. void clear();
  21. /** Saves the patch and nothing else. */
  22. void save(std::string path);
  23. void saveDialog();
  24. void saveAsDialog();
  25. void saveTemplateDialog();
  26. void saveAutosave();
  27. void cleanAutosave();
  28. /** Loads a patch and nothing else.
  29. Returns whether the patch was loaded successfully.
  30. */
  31. void load(std::string path);
  32. /** Loads the template patch. */
  33. void loadTemplate();
  34. void loadTemplateDialog();
  35. bool hasAutosave();
  36. void loadAutosave();
  37. /** Loads a patch, sets the current path, and updates the recent patches. */
  38. void loadAction(std::string path);
  39. void loadDialog();
  40. void loadPathDialog(std::string path);
  41. /** Asks the user to reload the current patch. */
  42. void revertDialog();
  43. void pushRecentPath(std::string path);
  44. /** Disconnects all cables. */
  45. void disconnectDialog();
  46. json_t* toJson();
  47. void fromJson(json_t* rootJ);
  48. void log(std::string msg);
  49. };
  50. } // namespace rack