Add method for module widgets to persist their black/silver screws

This commit is contained in:
falkTX 2022-09-17 01:14:51 +01:00
parent f5ff42b8d6
commit a808190e9a
4 changed files with 70 additions and 12 deletions

View file

@ -23,6 +23,42 @@
#include <string>
namespace rack {
namespace asset {
bool forceBlackScrew = false;
bool forceSilverScrew = false;
void updateForcingBlackSilverScrewMode(std::string slug) {
forceBlackScrew = (
// arable instruments
slug == "Joni"
// axioma
|| slug == "TheBifurcator"
|| slug == "Tesseract"
|| slug == "Ikeda"
|| slug == "Rhodonea"
// parable instruments
|| slug == "Neil"
// rackwindows
|| slug == "bitshiftgain"
|| slug == "capacitor"
|| slug == "capacitor_stereo"
|| slug == "chorus"
|| slug == "console"
|| slug == "console_mm"
|| slug == "distance"
|| slug == "golem"
|| slug == "holt"
|| slug == "hombre"
|| slug == "interstage"
|| slug == "monitoring"
|| slug == "mv"
|| slug == "rasp"
|| slug == "reseq"
|| slug == "tape"
|| slug == "tremolo"
|| slug == "vibrato"
);
}
}
namespace settings {
bool darkMode = true;
int rateLimit = 0;
@ -1217,17 +1253,14 @@ NSVGimage* nsvgParseFromFileCardinal(const char* const filename, const char* con
NSVGshape* shapesOrig;
NSVGshape* shapesMOD;
// Special case for light/dark screws
if (std::strncmp(filename + (filenamelen-16), "/ScrewSilver.svg", 16) == 0)
if (filenamelen < 18)
{
const std::string blackfilename = std::string(filename).substr(0, filenamelen-10) + "Black.svg";
hasDarkMode = true;
shapesOrig = shapesMOD = nullptr;
handleMOD = nsvgParseFromFile(blackfilename.c_str(), units, dpi);
goto postparse;
}
if (std::strncmp(filename + (filenamelen-15), "/ScrewBlack.svg", 15) == 0)
// Special case for light/dark screws
if (std::strncmp(filename + (filenamelen-15), "/ScrewBlack.svg", 15) == 0 && filename[filenamelen-16] != '.')
{
const std::string silverfilename = std::string(filename).substr(0, filenamelen-9) + "Silver.svg";
hasLightMode = true;
@ -1236,6 +1269,15 @@ NSVGimage* nsvgParseFromFileCardinal(const char* const filename, const char* con
goto postparse;
}
if (std::strncmp(filename + (filenamelen-16), "/ScrewSilver.svg", 16) == 0 && filename[filenamelen-17] != '.')
{
const std::string blackfilename = std::string(filename).substr(0, filenamelen-10) + "Black.svg";
hasDarkMode = true;
shapesOrig = shapesMOD = nullptr;
handleMOD = nsvgParseFromFile(blackfilename.c_str(), units, dpi);
goto postparse;
}
#if 0
// Special case for GlueTheGiant
if (std::strstr(filename, "/GlueTheGiant/res/") != nullptr)