Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion librecomp/include/librecomp/mods.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,7 @@ namespace recomp {
std::vector<std::string> authors;
std::vector<Dependency> dependencies;
bool runtime_toggleable;
bool enabled_by_default;
};

struct ModManifest {
Expand All @@ -237,6 +238,7 @@ namespace recomp {
Version minimum_recomp_version;
Version version;
bool runtime_toggleable;
bool enabled_by_default = true;

std::vector<NativeLibraryManifest> native_libraries;
std::unique_ptr<ModFileHandle> file_handle;
Expand Down Expand Up @@ -476,7 +478,8 @@ namespace recomp {
.version = manifest.version,
.authors = manifest.authors,
.dependencies = manifest.dependencies,
.runtime_toggleable = is_runtime_toggleable()
.runtime_toggleable = is_runtime_toggleable(),
.enabled_by_default = manifest.enabled_by_default
};
}
private:
Expand Down
7 changes: 7 additions & 0 deletions librecomp/src/mod_manifest.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -169,6 +169,7 @@ const std::string short_description_key = "short_description";
const std::string version_key = "version";
const std::string authors_key = "authors";
const std::string minimum_recomp_version_key = "minimum_recomp_version";
const std::string enabled_by_default_key = "enabled_by_default";
const std::string dependencies_key = "dependencies";
const std::string native_libraries_key = "native_libraries";
const std::string config_schema_key = "config_schema";
Expand Down Expand Up @@ -573,6 +574,12 @@ recomp::mods::ModOpenError recomp::mods::parse_manifest(ModManifest& ret, const
return current_error;
}

// Enabled by default (optional)
current_error = try_get<json::boolean_t>(ret.enabled_by_default, manifest_json, enabled_by_default_key, false, error_param);
if (current_error != ModOpenError::Good) {
return current_error;
}

// Dependencies (optional)
std::vector<std::string> dep_strings{};
current_error = try_get_vec<json::string_t>(dep_strings, manifest_json, dependencies_key, false, error_param);
Expand Down
7 changes: 5 additions & 2 deletions librecomp/src/mods.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -862,8 +862,11 @@ void recomp::mods::ModContext::load_mods_config() {

// Enable mods that are specified in the configuration or mods that are considered new.
for (size_t i = 0; i < opened_mods.size(); i++) {
const std::string &mod_id = opened_mods[i].manifest.mod_id;
if (!opened_mod_is_known[i] || (config_enabled_mods.find(mod_id) != config_enabled_mods.end())) {
const ModHandle& mod = opened_mods[i];
const std::string &mod_id = mod.manifest.mod_id;
bool is_default_enabled = !opened_mod_is_known[i] && mod.manifest.enabled_by_default;
bool is_manually_enabled = config_enabled_mods.contains(mod_id);
if (is_default_enabled || is_manually_enabled) {
enable_mod(mod_id, true, false);
}
}
Expand Down
Loading