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.

108 lines
2.6KB

  1. #pragma once
  2. #include <vector>
  3. #include <set>
  4. #include <map>
  5. #include <list>
  6. #include <tuple>
  7. #include <jansson.h>
  8. #include <common.hpp>
  9. #include <math.hpp>
  10. #include <color.hpp>
  11. namespace rack {
  12. /** Process-scope globals, most of which are persisted across launches */
  13. namespace settings {
  14. // Runtime state, not serialized.
  15. /** Path to settings.json */
  16. extern std::string settingsPath;
  17. extern bool devMode;
  18. extern bool headless;
  19. extern bool isPlugin;
  20. // Persistent state, serialized to settings.json.
  21. /** vcvrack.com user token */
  22. extern std::string token;
  23. /** Whether the window is maximized */
  24. extern bool windowMaximized;
  25. /** Size of window in pixels */
  26. extern math::Vec windowSize;
  27. /** Position in window in pixels */
  28. extern math::Vec windowPos;
  29. /** Reverse the zoom scroll direction */
  30. extern bool invertZoom;
  31. /** Ratio between UI pixel and physical screen pixel.
  32. 0 for auto.
  33. */
  34. extern float pixelRatio;
  35. /** Opacity of cables in the range [0, 1] */
  36. extern float cableOpacity;
  37. /** Straightness of cables in the range [0, 1]. Unitless and arbitrary. */
  38. extern float cableTension;
  39. extern float rackBrightness;
  40. extern float haloBrightness;
  41. /** Allows rack to hide and lock the cursor position when dragging knobs etc. */
  42. extern bool allowCursorLock;
  43. enum KnobMode {
  44. KNOB_MODE_LINEAR,
  45. KNOB_MODE_SCALED_LINEAR,
  46. KNOB_MODE_ROTARY_ABSOLUTE,
  47. KNOB_MODE_ROTARY_RELATIVE,
  48. };
  49. extern KnobMode knobMode;
  50. extern bool knobScroll;
  51. extern float knobLinearSensitivity;
  52. extern float knobScrollSensitivity;
  53. extern float sampleRate;
  54. extern int threadCount;
  55. extern bool tooltips;
  56. extern bool cpuMeter;
  57. extern bool lockModules;
  58. extern int frameSwapInterval;
  59. extern float autosaveInterval;
  60. extern bool skipLoadOnLaunch;
  61. extern std::list<std::string> recentPatchPaths;
  62. extern std::vector<NVGcolor> cableColors;
  63. extern bool autoCheckUpdates;
  64. extern bool showTipsOnLaunch;
  65. extern int tipIndex;
  66. extern bool discordUpdateActivity;
  67. enum BrowserSort {
  68. BROWSER_SORT_UPDATED,
  69. BROWSER_SORT_LAST_USED,
  70. BROWSER_SORT_MOST_USED,
  71. BROWSER_SORT_BRAND,
  72. BROWSER_SORT_NAME,
  73. BROWSER_SORT_RANDOM,
  74. };
  75. extern BrowserSort browserSort;
  76. extern float browserZoom;
  77. struct ModuleInfo {
  78. bool enabled = true;
  79. bool favorite = false;
  80. int added = 0;
  81. double lastAdded = NAN;
  82. };
  83. // pluginSlug -> (moduleSlug -> ModuleInfo)
  84. extern std::map<std::string, std::map<std::string, ModuleInfo>> moduleInfos;
  85. /** Returns a ModuleInfo if exists for the given slugs.
  86. */
  87. ModuleInfo* getModuleInfo(const std::string& pluginSlug, const std::string& moduleSlug);
  88. void init();
  89. json_t* toJson();
  90. void fromJson(json_t* rootJ);
  91. void save(std::string path = "");
  92. void load(std::string path = "");
  93. } // namespace settings
  94. } // namespace rack