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.

107 lines
2.7KB

  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-level globals. */
  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. /** 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. enum ModuleBrowserSort {
  67. MODULE_BROWSER_SORT_UPDATED,
  68. MODULE_BROWSER_SORT_LAST_USED,
  69. MODULE_BROWSER_SORT_MOST_USED,
  70. MODULE_BROWSER_SORT_BRAND,
  71. MODULE_BROWSER_SORT_NAME,
  72. MODULE_BROWSER_SORT_RANDOM,
  73. };
  74. extern ModuleBrowserSort moduleBrowserSort;
  75. extern float moduleBrowserZoom;
  76. // pluginSlug -> moduleSlugs
  77. extern std::map<std::string, std::set<std::string>> moduleWhitelist;
  78. struct ModuleUsage {
  79. int count = 0;
  80. double lastTime = NAN;
  81. };
  82. // pluginSlug, moduleSlug -> ModuleUsage
  83. extern std::map<std::string, std::map<std::string, ModuleUsage>> moduleUsages;
  84. ModuleUsage* getModuleUsage(const std::string& pluginSlug, const std::string& moduleSlug);
  85. void init();
  86. json_t* toJson();
  87. void fromJson(json_t* rootJ);
  88. void save(std::string path = "");
  89. void load(std::string path = "");
  90. } // namespace settings
  91. } // namespace rack