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.

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