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.

66 lines
1.5KB

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