Browse Source

Deprecate "disabled" module manifest property. Add "hidden" property which hides module from Module Browser but allows it to be loaded from patches.

tags/v2.0.0
Andrew Belt 3 years ago
parent
commit
14dc8e8e57
4 changed files with 22 additions and 7 deletions
  1. +5
    -0
      include/plugin/Model.hpp
  2. +6
    -0
      src/app/ModuleBrowser.cpp
  3. +11
    -0
      src/plugin/Model.cpp
  4. +0
    -7
      src/plugin/Plugin.cpp

+ 5
- 0
include/plugin/Model.hpp View File

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


+ 6
- 0
src/app/ModuleBrowser.cpp View File

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


+ 11
- 0
src/plugin/Model.cpp View File

@@ -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;
}
}




+ 0
- 7
src/plugin/Plugin.cpp View File

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


Loading…
Cancel
Save