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.

97 lines
2.4KB

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