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.

63 lines
1.5KB

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