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.5KB

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