mirror of
				https://github.com/N64Recomp/N64ModernRuntime.git
				synced 2025-10-30 08:02:29 +00:00 
			
		
		
		
	Add default enabled state to mod manifest
This commit is contained in:
		
							parent
							
								
									234ed4a95e
								
							
						
					
					
						commit
						8658fdf0de
					
				
					 3 changed files with 16 additions and 3 deletions
				
			
		| 
						 | 
				
			
			@ -220,6 +220,7 @@ namespace recomp {
 | 
			
		|||
            std::vector<std::string> authors;
 | 
			
		||||
            std::vector<Dependency> dependencies;
 | 
			
		||||
            bool runtime_toggleable;
 | 
			
		||||
            bool enabled_by_default;
 | 
			
		||||
        };
 | 
			
		||||
 | 
			
		||||
        struct ModManifest {
 | 
			
		||||
| 
						 | 
				
			
			@ -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;
 | 
			
		||||
| 
						 | 
				
			
			@ -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:
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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";
 | 
			
		||||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -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);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		
		Reference in a new issue