Browse Source

Add settings::cableAutoRotate and cableColorsReset().

tags/v2.5.0
Andrew Belt 9 months ago
parent
commit
7b7f539e58
3 changed files with 26 additions and 8 deletions
  1. +2
    -0
      include/settings.hpp
  2. +4
    -1
      src/app/RackWidget.cpp
  3. +20
    -7
      src/settings.cpp

+ 2
- 0
include/settings.hpp View File

@@ -77,6 +77,7 @@ extern float autosaveInterval;
extern bool skipLoadOnLaunch;
extern std::list<std::string> recentPatchPaths;
extern std::vector<NVGcolor> cableColors;
extern bool cableAutoRotate;
extern bool autoCheckUpdates;
extern bool verifyHttpsCerts;
extern bool showTipsOnLaunch;
@@ -117,6 +118,7 @@ struct PluginWhitelist {
extern std::map<std::string, PluginWhitelist> moduleWhitelist;

bool isModuleWhitelisted(const std::string& pluginSlug, const std::string& moduleSlug);
void cableColorsReset();

PRIVATE void init();
PRIVATE void destroy();


+ 4
- 1
src/app/RackWidget.cpp View File

@@ -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())


+ 20
- 7
src/settings.cpp View File

@@ -53,13 +53,8 @@ bool preferDarkPanels = false;
float autosaveInterval = 15.0;
bool skipLoadOnLaunch = false;
std::list<std::string> recentPatchPaths;
std::vector<NVGcolor> 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<NVGcolor> 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);


Loading…
Cancel
Save