diff --git a/include/settings.hpp b/include/settings.hpp index 75375335..db8456c4 100644 --- a/include/settings.hpp +++ b/include/settings.hpp @@ -77,6 +77,7 @@ extern float autosaveInterval; extern bool skipLoadOnLaunch; extern std::list recentPatchPaths; extern std::vector cableColors; +extern bool cableAutoRotate; extern bool autoCheckUpdates; extern bool verifyHttpsCerts; extern bool showTipsOnLaunch; @@ -117,6 +118,7 @@ struct PluginWhitelist { extern std::map moduleWhitelist; bool isModuleWhitelisted(const std::string& pluginSlug, const std::string& moduleSlug); +void cableColorsReset(); PRIVATE void init(); PRIVATE void destroy(); diff --git a/src/app/RackWidget.cpp b/src/app/RackWidget.cpp index d5dae358..7b60bb4b 100644 --- a/src/app/RackWidget.cpp +++ b/src/app/RackWidget.cpp @@ -1523,7 +1523,10 @@ NVGcolor RackWidget::getNextCableColor() { if (settings::cableColors.empty()) return color::WHITE; - int id = internal->nextCableColorId++; + int id = internal->nextCableColorId; + if (settings::cableAutoRotate) { + internal->nextCableColorId++; + } if (id >= (int) settings::cableColors.size()) id = 0; if (internal->nextCableColorId >= (int) settings::cableColors.size()) diff --git a/src/settings.cpp b/src/settings.cpp index 384071e9..b964e8cf 100644 --- a/src/settings.cpp +++ b/src/settings.cpp @@ -53,13 +53,8 @@ bool preferDarkPanels = false; float autosaveInterval = 15.0; bool skipLoadOnLaunch = false; std::list recentPatchPaths; -std::vector cableColors = { - color::fromHexString("#f3374b"), // red - color::fromHexString("#ffb437"), // yellow - color::fromHexString("#00b56e"), // green - color::fromHexString("#3695ef"), // blue - color::fromHexString("#8b4ade"), // purple -}; +bool cableAutoRotate = true; +std::vector cableColors; bool autoCheckUpdates = true; bool verifyHttpsCerts = true; bool showTipsOnLaunch = true; @@ -99,8 +94,20 @@ bool isModuleWhitelisted(const std::string& pluginSlug, const std::string& modul } +void cableColorsReset() { + cableColors = { + color::fromHexString("#f3374b"), // red + color::fromHexString("#ffb437"), // yellow + color::fromHexString("#00b56e"), // green + color::fromHexString("#3695ef"), // blue + color::fromHexString("#8b4ade"), // purple + }; +} + + void init() { settingsPath = asset::user("settings.json"); + cableColorsReset(); } @@ -186,6 +193,8 @@ json_t* toJson() { } json_object_set_new(rootJ, "cableColors", cableColorsJ); + json_object_set_new(rootJ, "cableAutoRotate", json_boolean(cableAutoRotate)); + json_object_set_new(rootJ, "autoCheckUpdates", json_boolean(autoCheckUpdates)); json_object_set_new(rootJ, "verifyHttpsCerts", json_boolean(verifyHttpsCerts)); @@ -410,6 +419,10 @@ void fromJson(json_t* rootJ) { } } + json_t* cableAutoRotateJ = json_object_get(rootJ, "cableAutoRotate"); + if (cableAutoRotateJ) + cableAutoRotate = json_boolean_value(cableAutoRotateJ); + json_t* autoCheckUpdatesJ = json_object_get(rootJ, "autoCheckUpdates"); if (autoCheckUpdatesJ) autoCheckUpdates = json_boolean_value(autoCheckUpdatesJ);