diff --git a/include/plugin/Model.hpp b/include/plugin/Model.hpp index 2bfaff47..030b9aff 100644 --- a/include/plugin/Model.hpp +++ b/include/plugin/Model.hpp @@ -43,6 +43,11 @@ struct Model { std::string manualUrl; std::string modularGridUrl; + /** Hides model from the Module Browser but able to be loaded from a patch file. + Useful for deprecating modules without breaking old patches. + */ + bool hidden = false; + virtual ~Model() {} /** Creates a Module. */ virtual engine::Module* createModule() { diff --git a/src/app/ModuleBrowser.cpp b/src/app/ModuleBrowser.cpp index 55074788..6b450e58 100644 --- a/src/app/ModuleBrowser.cpp +++ b/src/app/ModuleBrowser.cpp @@ -52,6 +52,9 @@ static void fuzzySearchInit() { for (plugin::Plugin* plugin : plugin::plugins) { // Iterate model in plugin for (plugin::Model* model : plugin->models) { + if (model->hidden) + continue; + // Get search fields for model std::string tagStr; for (int tagId : model->tagIds) { @@ -531,6 +534,9 @@ struct ModuleBrowser : widget::OpaqueWidget { // Iterate models in plugin int modelIndex = 0; for (plugin::Model* model : plugin->models) { + if (model->hidden) + continue; + // Don't show module if plugin whitelist exists but the module is not in it. if (pluginIt != settings::moduleWhitelist.end()) { auto moduleIt = std::find(pluginIt->second.begin(), pluginIt->second.end(), model->slug); diff --git a/src/plugin/Model.cpp b/src/plugin/Model.cpp index e4348a15..323ca3e3 100644 --- a/src/plugin/Model.cpp +++ b/src/plugin/Model.cpp @@ -54,6 +54,17 @@ void Model::fromJson(json_t* rootJ) { json_t* modularGridUrlJ = json_object_get(rootJ, "modularGridUrl"); if (modularGridUrlJ) modularGridUrl = json_string_value(modularGridUrlJ); + + // hidden + json_t* hiddenJ = json_object_get(rootJ, "hidden"); + // Use `disabled` as an alias which was deprecated in Rack 2.0 + if (!hiddenJ) + hiddenJ = json_object_get(rootJ, "disabled"); + if (hiddenJ) { + // Don't un-hide Model if already hidden by C++ + if (json_boolean_value(hiddenJ)) + hidden = true; + } } diff --git a/src/plugin/Plugin.cpp b/src/plugin/Plugin.cpp index 6cdae4ef..698e67fe 100644 --- a/src/plugin/Plugin.cpp +++ b/src/plugin/Plugin.cpp @@ -116,13 +116,6 @@ void Plugin::fromJson(json_t* rootJ) { size_t moduleId; json_t* moduleJ; json_array_foreach(modulesJ, moduleId, moduleJ) { - // Check if model is disabled - json_t* disabledJ = json_object_get(moduleJ, "disabled"); - if (disabledJ) { - if (json_boolean_value(disabledJ)) - continue; - } - // Get model slug json_t* modelSlugJ = json_object_get(moduleJ, "slug"); if (!modelSlugJ) {