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.

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