mirror of
				https://github.com/N64Recomp/N64ModernRuntime.git
				synced 2025-10-30 08:02:29 +00:00 
			
		
		
		
	Add default enabled state to mod manifest (#104)
	
		
			
	
		
	
	
		
	
		
			Some checks are pending
		
		
	
	
		
			
				
	
				validate / ubuntu (arm64, Debug) (push) Waiting to run
				
			
		
			
				
	
				validate / ubuntu (arm64, Release) (push) Waiting to run
				
			
		
			
				
	
				validate / ubuntu (x64, Debug) (push) Waiting to run
				
			
		
			
				
	
				validate / ubuntu (x64, Release) (push) Waiting to run
				
			
		
			
				
	
				validate / windows (x64, Debug) (push) Waiting to run
				
			
		
			
				
	
				validate / windows (x64, Release) (push) Waiting to run
				
			
		
			
				
	
				validate / macos (arm64, Debug) (push) Waiting to run
				
			
		
			
				
	
				validate / macos (arm64, Release) (push) Waiting to run
				
			
		
			
				
	
				validate / macos (x64, Debug) (push) Waiting to run
				
			
		
			
				
	
				validate / macos (x64, Release) (push) Waiting to run
				
			
		
		
	
	
				
					
				
			
		
			Some checks are pending
		
		
	
	validate / ubuntu (arm64, Debug) (push) Waiting to run
				
			validate / ubuntu (arm64, Release) (push) Waiting to run
				
			validate / ubuntu (x64, Debug) (push) Waiting to run
				
			validate / ubuntu (x64, Release) (push) Waiting to run
				
			validate / windows (x64, Debug) (push) Waiting to run
				
			validate / windows (x64, Release) (push) Waiting to run
				
			validate / macos (arm64, Debug) (push) Waiting to run
				
			validate / macos (arm64, Release) (push) Waiting to run
				
			validate / macos (x64, Debug) (push) Waiting to run
				
			validate / macos (x64, Release) (push) Waiting to run
				
			This commit is contained in:
		
							parent
							
								
									234ed4a95e
								
							
						
					
					
						commit
						d2f9a32b90
					
				
					 3 changed files with 16 additions and 3 deletions
				
			
		|  | @ -220,6 +220,7 @@ namespace recomp { | ||||||
|             std::vector<std::string> authors; |             std::vector<std::string> authors; | ||||||
|             std::vector<Dependency> dependencies; |             std::vector<Dependency> dependencies; | ||||||
|             bool runtime_toggleable; |             bool runtime_toggleable; | ||||||
|  |             bool enabled_by_default; | ||||||
|         }; |         }; | ||||||
| 
 | 
 | ||||||
|         struct ModManifest { |         struct ModManifest { | ||||||
|  | @ -237,6 +238,7 @@ namespace recomp { | ||||||
|             Version minimum_recomp_version; |             Version minimum_recomp_version; | ||||||
|             Version version; |             Version version; | ||||||
|             bool runtime_toggleable; |             bool runtime_toggleable; | ||||||
|  |             bool enabled_by_default = true; | ||||||
| 
 | 
 | ||||||
|             std::vector<NativeLibraryManifest> native_libraries; |             std::vector<NativeLibraryManifest> native_libraries; | ||||||
|             std::unique_ptr<ModFileHandle> file_handle; |             std::unique_ptr<ModFileHandle> file_handle; | ||||||
|  | @ -476,7 +478,8 @@ namespace recomp { | ||||||
|                     .version = manifest.version, |                     .version = manifest.version, | ||||||
|                     .authors = manifest.authors, |                     .authors = manifest.authors, | ||||||
|                     .dependencies = manifest.dependencies, |                     .dependencies = manifest.dependencies, | ||||||
|                     .runtime_toggleable = is_runtime_toggleable() |                     .runtime_toggleable = is_runtime_toggleable(), | ||||||
|  |                     .enabled_by_default = manifest.enabled_by_default | ||||||
|                 }; |                 }; | ||||||
|             } |             } | ||||||
|         private: |         private: | ||||||
|  |  | ||||||
|  | @ -169,6 +169,7 @@ const std::string short_description_key = "short_description"; | ||||||
| const std::string version_key = "version"; | const std::string version_key = "version"; | ||||||
| const std::string authors_key = "authors"; | const std::string authors_key = "authors"; | ||||||
| const std::string minimum_recomp_version_key = "minimum_recomp_version"; | 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 dependencies_key = "dependencies"; | ||||||
| const std::string native_libraries_key = "native_libraries"; | const std::string native_libraries_key = "native_libraries"; | ||||||
| const std::string config_schema_key = "config_schema"; | 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; |         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)
 |     // Dependencies (optional)
 | ||||||
|     std::vector<std::string> dep_strings{}; |     std::vector<std::string> dep_strings{}; | ||||||
|     current_error = try_get_vec<json::string_t>(dep_strings, manifest_json, dependencies_key, false, error_param); |     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.
 |     // Enable mods that are specified in the configuration or mods that are considered new.
 | ||||||
|     for (size_t i = 0; i < opened_mods.size(); i++) { |     for (size_t i = 0; i < opened_mods.size(); i++) { | ||||||
|         const std::string &mod_id = opened_mods[i].manifest.mod_id; |         const ModHandle& mod = opened_mods[i]; | ||||||
|         if (!opened_mod_is_known[i] || (config_enabled_mods.find(mod_id) != config_enabled_mods.end())) { |         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); |             enable_mod(mod_id, true, false); | ||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
		Loading…
	
	Add table
		
		Reference in a new issue
	
	 Wiseguy
						Wiseguy