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.

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