| @@ -43,6 +43,11 @@ struct Model { | |||||
| std::string manualUrl; | std::string manualUrl; | ||||
| std::string modularGridUrl; | 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() {} | virtual ~Model() {} | ||||
| /** Creates a Module. */ | /** Creates a Module. */ | ||||
| virtual engine::Module* createModule() { | virtual engine::Module* createModule() { | ||||
| @@ -52,6 +52,9 @@ static void fuzzySearchInit() { | |||||
| for (plugin::Plugin* plugin : plugin::plugins) { | for (plugin::Plugin* plugin : plugin::plugins) { | ||||
| // Iterate model in plugin | // Iterate model in plugin | ||||
| for (plugin::Model* model : plugin->models) { | for (plugin::Model* model : plugin->models) { | ||||
| if (model->hidden) | |||||
| continue; | |||||
| // Get search fields for model | // Get search fields for model | ||||
| std::string tagStr; | std::string tagStr; | ||||
| for (int tagId : model->tagIds) { | for (int tagId : model->tagIds) { | ||||
| @@ -531,6 +534,9 @@ struct ModuleBrowser : widget::OpaqueWidget { | |||||
| // Iterate models in plugin | // Iterate models in plugin | ||||
| int modelIndex = 0; | int modelIndex = 0; | ||||
| for (plugin::Model* model : plugin->models) { | 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. | // Don't show module if plugin whitelist exists but the module is not in it. | ||||
| if (pluginIt != settings::moduleWhitelist.end()) { | if (pluginIt != settings::moduleWhitelist.end()) { | ||||
| auto moduleIt = std::find(pluginIt->second.begin(), pluginIt->second.end(), model->slug); | auto moduleIt = std::find(pluginIt->second.begin(), pluginIt->second.end(), model->slug); | ||||
| @@ -54,6 +54,17 @@ void Model::fromJson(json_t* rootJ) { | |||||
| json_t* modularGridUrlJ = json_object_get(rootJ, "modularGridUrl"); | json_t* modularGridUrlJ = json_object_get(rootJ, "modularGridUrl"); | ||||
| if (modularGridUrlJ) | if (modularGridUrlJ) | ||||
| modularGridUrl = json_string_value(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; | |||||
| } | |||||
| } | } | ||||
| @@ -116,13 +116,6 @@ void Plugin::fromJson(json_t* rootJ) { | |||||
| size_t moduleId; | size_t moduleId; | ||||
| json_t* moduleJ; | json_t* moduleJ; | ||||
| json_array_foreach(modulesJ, moduleId, 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 | // Get model slug | ||||
| json_t* modelSlugJ = json_object_get(moduleJ, "slug"); | json_t* modelSlugJ = json_object_get(moduleJ, "slug"); | ||||
| if (!modelSlugJ) { | if (!modelSlugJ) { | ||||