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.

72 lines
1.9KB

  1. #pragma once
  2. #include <jansson.h>
  3. #include <common.hpp>
  4. namespace rack {
  5. /** Handles the Rack patch file state */
  6. namespace patch {
  7. /** Handles the Rack patch file state. */
  8. struct Manager {
  9. struct Internal;
  10. Internal* internal;
  11. /** The currently loaded patch file path */
  12. std::string path;
  13. /** Path to autosave dir */
  14. std::string autosavePath;
  15. /** Path to user template patch */
  16. std::string templatePath;
  17. /** Path to factory template patch */
  18. std::string factoryTemplatePath;
  19. PRIVATE Manager();
  20. PRIVATE ~Manager();
  21. PRIVATE void launch(std::string pathArg);
  22. /** Clears the patch. */
  23. void clear();
  24. /** Saves the patch and nothing else. */
  25. void save(std::string path);
  26. void saveDialog();
  27. void saveAsDialog(bool setPath = true);
  28. void saveTemplateDialog();
  29. void saveAutosave();
  30. /** Delete and re-create autosave dir. */
  31. void clearAutosave();
  32. /** Clean up nonexistent module patch storage dirs in autosave dir. */
  33. void cleanAutosave();
  34. /** Loads a patch and nothing else.
  35. Returns whether the patch was loaded successfully.
  36. */
  37. void load(std::string path);
  38. /** Loads the template patch file. */
  39. void loadTemplate();
  40. void loadTemplateDialog();
  41. bool hasAutosave();
  42. /** Loads the patch from the autosave folder. */
  43. void loadAutosave();
  44. /** Loads a patch, sets the current path, and updates the recent patches. */
  45. void loadAction(std::string path);
  46. void loadDialog();
  47. void loadPathDialog(std::string path);
  48. /** Asks the user to reload the current patch. */
  49. void revertDialog();
  50. void pushRecentPath(std::string path);
  51. /** Disconnects all cables. */
  52. void disconnectDialog();
  53. json_t* toJson();
  54. void fromJson(json_t* rootJ);
  55. /** Checks if the JSON patch object contains modules not found in the loaded plugins, and launches a dialog box asking the user to cancel loading.
  56. Returns whether the user requests to cancel loading the patch.
  57. */
  58. bool checkUnavailableModulesJson(json_t* rootJ);
  59. };
  60. } // namespace patch
  61. } // namespace rack