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.

112 lines
2.8KB

  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. /** Rack zoom level, log2. E.g. 100% = 0, 200% = 1, 50% = -1. */
  30. extern float zoom;
  31. static const float zoomMax = 2.f;
  32. static const float zoomMin = -2.f;
  33. /** Reverse the zoom scroll direction */
  34. extern bool invertZoom;
  35. /** Ratio between UI pixel and physical screen pixel.
  36. 0 for auto.
  37. */
  38. extern float pixelRatio;
  39. /** Opacity of cables in the range [0, 1] */
  40. extern float cableOpacity;
  41. /** Straightness of cables in the range [0, 1]. Unitless and arbitrary. */
  42. extern float cableTension;
  43. extern float rackBrightness;
  44. extern float haloBrightness;
  45. /** Allows rack to hide and lock the cursor position when dragging knobs etc. */
  46. extern bool allowCursorLock;
  47. enum KnobMode {
  48. KNOB_MODE_LINEAR,
  49. KNOB_MODE_SCALED_LINEAR,
  50. KNOB_MODE_ROTARY_ABSOLUTE,
  51. KNOB_MODE_ROTARY_RELATIVE,
  52. };
  53. extern KnobMode knobMode;
  54. extern bool knobScroll;
  55. extern float knobLinearSensitivity;
  56. extern float knobScrollSensitivity;
  57. extern float sampleRate;
  58. extern int threadCount;
  59. extern bool tooltips;
  60. extern bool cpuMeter;
  61. extern bool lockModules;
  62. extern int frameSwapInterval;
  63. extern float autosaveInterval;
  64. extern bool skipLoadOnLaunch;
  65. extern std::list<std::string> recentPatchPaths;
  66. extern std::vector<NVGcolor> cableColors;
  67. extern bool autoCheckUpdates;
  68. extern bool showTipsOnLaunch;
  69. extern int tipIndex;
  70. extern bool discordUpdateActivity;
  71. enum BrowserSort {
  72. BROWSER_SORT_UPDATED,
  73. BROWSER_SORT_LAST_USED,
  74. BROWSER_SORT_MOST_USED,
  75. BROWSER_SORT_BRAND,
  76. BROWSER_SORT_NAME,
  77. BROWSER_SORT_RANDOM,
  78. };
  79. extern BrowserSort browserSort;
  80. extern float browserZoom;
  81. struct ModuleInfo {
  82. bool enabled = true;
  83. bool favorite = false;
  84. int added = 0;
  85. double lastAdded = NAN;
  86. };
  87. // pluginSlug -> (moduleSlug -> ModuleInfo)
  88. extern std::map<std::string, std::map<std::string, ModuleInfo>> moduleInfos;
  89. /** Returns a ModuleInfo if exists for the given slugs.
  90. */
  91. ModuleInfo* getModuleInfo(const std::string& pluginSlug, const std::string& moduleSlug);
  92. void init();
  93. json_t* toJson();
  94. void fromJson(json_t* rootJ);
  95. void save(std::string path = "");
  96. void load(std::string path = "");
  97. } // namespace settings
  98. } // namespace rack