| @@ -36,6 +36,10 @@ | |||
| namespace rack { | |||
| namespace asset { | |||
| void updateForcingBlackSilverScrewMode(std::string slug); | |||
| } | |||
| struct CardinalPluginModelHelper : plugin::Model { | |||
| virtual app::ModuleWidget* createModuleWidgetFromEngineLoad(engine::Module* m) = 0; | |||
| virtual void removeCachedModuleWidget(engine::Module* m) = 0; | |||
| @@ -47,6 +51,11 @@ struct CardinalPluginModel : CardinalPluginModelHelper | |||
| std::unordered_map<engine::Module*, TModuleWidget*> widgets; | |||
| std::unordered_map<engine::Module*, bool> widgetNeedsDeletion; | |||
| CardinalPluginModel(const std::string slug) | |||
| { | |||
| this->slug = slug; | |||
| } | |||
| engine::Module* createModule() override | |||
| { | |||
| engine::Module* const m = new TModule; | |||
| @@ -67,6 +76,7 @@ struct CardinalPluginModel : CardinalPluginModelHelper | |||
| } | |||
| tm = dynamic_cast<TModule*>(m); | |||
| } | |||
| asset::updateForcingBlackSilverScrewMode(slug); | |||
| app::ModuleWidget* const tmw = new TModuleWidget(tm); | |||
| DISTRHO_CUSTOM_SAFE_ASSERT_RETURN(m != nullptr ? m->model->name.c_str() : "null", tmw->module == m, nullptr); | |||
| tmw->setModel(this); | |||
| @@ -81,6 +91,7 @@ struct CardinalPluginModel : CardinalPluginModelHelper | |||
| TModule* const tm = dynamic_cast<TModule*>(m); | |||
| DISTRHO_SAFE_ASSERT_RETURN(tm != nullptr, nullptr); | |||
| asset::updateForcingBlackSilverScrewMode(slug); | |||
| TModuleWidget* const tmw = new TModuleWidget(tm); | |||
| DISTRHO_SAFE_ASSERT_RETURN(tmw->module == m, nullptr); | |||
| tmw->setModel(this); | |||
| @@ -107,11 +118,9 @@ struct CardinalPluginModel : CardinalPluginModelHelper | |||
| }; | |||
| template <class TModule, class TModuleWidget> | |||
| CardinalPluginModel<TModule, TModuleWidget>* createModel(std::string slug) | |||
| CardinalPluginModel<TModule, TModuleWidget>* createModel(const std::string slug) | |||
| { | |||
| CardinalPluginModel<TModule, TModuleWidget>* const o = new CardinalPluginModel<TModule, TModuleWidget>(); | |||
| o->slug = slug; | |||
| return o; | |||
| return new CardinalPluginModel<TModule, TModuleWidget>(slug); | |||
| } | |||
| } | |||
| @@ -1 +1 @@ | |||
| Subproject commit f93a357f1643b831d60e28a3ac51575007aa4c5f | |||
| Subproject commit a2de62d0c3b9f764ce6b42441366788d1e52bfcc | |||
| @@ -31,6 +31,9 @@ | |||
| namespace rack { | |||
| namespace asset { | |||
| extern bool forceBlackScrew; | |||
| extern bool forceSilverScrew; | |||
| std::string userDir; // ignored | |||
| std::string systemDir; // points to plugin resources dir (or installed/local Rack dir) | |||
| std::string bundlePath; // points to plugin manifests dir (or empty) | |||
| @@ -50,10 +53,14 @@ std::string user(std::string filename) { | |||
| // get system resource, trimming "res/" prefix if we are loaded as a plugin bundle | |||
| std::string system(std::string filename) { | |||
| /**/ if (forceBlackScrew && string::endsWith(filename, "/ScrewBlack.svg")) | |||
| filename = filename.substr(0, filename.size()-15) + "/./ScrewBlack.svg"; | |||
| else if (forceSilverScrew && string::endsWith(filename, "/ScrewSilver.svg")) | |||
| filename = filename.substr(0, filename.size()-16) + "/./ScrewSilver.svg"; | |||
| return system::join(systemDir, bundlePath.empty() ? filename : trim(filename)); | |||
| } | |||
| // get plugin resource | |||
| // get plugin resource path | |||
| std::string plugin(plugin::Plugin* plugin, std::string filename) { | |||
| DISTRHO_SAFE_ASSERT_RETURN(plugin != nullptr, {}); | |||
| return system::join(plugin->path, filename); | |||
| @@ -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) | |||