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.

106 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-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. // Persistent state, serialized to settings.json.
  20. /** vcvrack.com user token */
  21. extern std::string token;
  22. /** Whether the window is maximized */
  23. extern bool windowMaximized;
  24. /** Size of window in pixels */
  25. extern math::Vec windowSize;
  26. /** Position in window in pixels */
  27. extern math::Vec windowPos;
  28. /** Rack zoom level, log2. E.g. 100% = 0, 200% = 1, 50% = -1. */
  29. extern float zoom;
  30. static const float zoomMax = 2.f;
  31. static const float zoomMin = -2.f;
  32. /** Reverse the zoom scroll direction */
  33. extern bool invertZoom;
  34. /** Opacity of cables in the range [0, 1] */
  35. extern float cableOpacity;
  36. /** Straightness of cables in the range [0, 1]. Unitless and arbitrary. */
  37. extern float cableTension;
  38. extern float rackBrightness;
  39. extern float haloBrightness;
  40. /** Allows rack to hide and lock the cursor position when dragging knobs etc. */
  41. extern bool allowCursorLock;
  42. enum KnobMode {
  43. KNOB_MODE_LINEAR,
  44. KNOB_MODE_SCALED_LINEAR,
  45. KNOB_MODE_ROTARY_ABSOLUTE,
  46. KNOB_MODE_ROTARY_RELATIVE,
  47. };
  48. extern KnobMode knobMode;
  49. extern bool knobScroll;
  50. extern float knobLinearSensitivity;
  51. extern float knobScrollSensitivity;
  52. extern float sampleRate;
  53. extern int threadCount;
  54. extern bool tooltips;
  55. extern bool cpuMeter;
  56. extern bool lockModules;
  57. extern int frameSwapInterval;
  58. extern float autosaveInterval;
  59. extern bool skipLoadOnLaunch;
  60. extern std::list<std::string> recentPatchPaths;
  61. extern std::vector<NVGcolor> cableColors;
  62. extern bool autoCheckUpdates;
  63. extern bool showTipsOnLaunch;
  64. extern int tipIndex;
  65. enum ModuleBrowserSort {
  66. MODULE_BROWSER_SORT_UPDATED,
  67. MODULE_BROWSER_SORT_LAST_USED,
  68. MODULE_BROWSER_SORT_MOST_USED,
  69. MODULE_BROWSER_SORT_BRAND,
  70. MODULE_BROWSER_SORT_NAME,
  71. MODULE_BROWSER_SORT_RANDOM,
  72. };
  73. extern ModuleBrowserSort moduleBrowserSort;
  74. extern float moduleBrowserZoom;
  75. // pluginSlug -> moduleSlugs
  76. extern std::map<std::string, std::set<std::string>> moduleWhitelist;
  77. struct ModuleUsage {
  78. int count = 0;
  79. double lastTime = NAN;
  80. };
  81. // pluginSlug, moduleSlug -> ModuleUsage
  82. extern std::map<std::string, std::map<std::string, ModuleUsage>> moduleUsages;
  83. ModuleUsage* getModuleUsage(const std::string& pluginSlug, const std::string& moduleSlug);
  84. void init();
  85. json_t* toJson();
  86. void fromJson(json_t* rootJ);
  87. void save(std::string path = "");
  88. void load(std::string path = "");
  89. } // namespace settings
  90. } // namespace rack