@@ -52,10 +52,19 @@ const REQUIRED_MOD_FILES = ["mod_main.gd", "manifest.json"]
5252const REQUIRED_META_TAGS = [
5353 "id" ,
5454 "name" ,
55- "version" ,
56- "compatible_game_version" ,
57- "authors" ,
55+ "version_number" ,
56+ "website_url" ,
5857 "description" ,
58+ "dependencies" ,
59+ "extra" ,
60+ ]
61+
62+ # Required keys in manifest's `json.extra.godot`
63+ const REQUIRED_MANIFEST_KEYS_EXTRA = [
64+ "id" ,
65+ "incompatibilities" ,
66+ "authors" ,
67+ "compatible_game_version" ,
5968]
6069
6170# Set to true to require using "--enable-mods" to enable them
@@ -338,19 +347,20 @@ func _check_mod_files(mod_id):
338347
339348# Load meta data into mod_data, from a mod's manifest.json file
340349func _load_meta_data (mod_id ):
341- mod_log (str ("Loading meta_data for -> " , mod_id ), LOG_NAME )
350+ mod_log (str ("Loading meta_data (manifest.json) for -> " , mod_id ), LOG_NAME )
342351 var mod = mod_data [mod_id ]
343352
344353 # Load meta data file
345354 var meta_path = mod .required_files_path ["manifest.json" ]
346355 var meta_data = _get_json_as_dict (meta_path )
347356
348- dev_log (str (mod_id , " loaded meta data -> " , meta_data ), LOG_NAME )
357+ dev_log (str (mod_id , " loaded manifest data -> " , meta_data ), LOG_NAME )
349358
350- # Check if the meta data has all required fields
359+ # Check if the manifest data has all required fields
351360 var missing_fields = _check_meta_file (meta_data )
352361 if (missing_fields .size () > 0 ):
353- mod_log (str ("ERROR - " , mod_id , " " , missing_fields , " are required in manifest.json." ), LOG_NAME )
362+ for missing_field in missing_fields :
363+ mod_log (str ("ERROR - " , mod_id , " - Missing a required field in manifest.json: '" , missing_field , "'" ), LOG_NAME )
354364 # Flag mod - so it's not loaded later
355365 mod .is_loadable = false
356366 # Continue with the next mod
@@ -360,14 +370,27 @@ func _load_meta_data(mod_id):
360370 mod .meta_data = meta_data
361371
362372
363- # Make sure the meta file has all required fields
373+ # Ensure manifest.json has all required keys
364374func _check_meta_file (meta_data ):
365- var missing_fields = REQUIRED_META_TAGS
375+ var missing_keys_root = REQUIRED_MANIFEST_KEYS_ROOT .duplicate ()
376+ var missing_keys_extra = REQUIRED_MANIFEST_KEYS_EXTRA .duplicate ()
366377
367378 for key in meta_data :
368- if (REQUIRED_META_TAGS .has (key )):
379+ if (REQUIRED_MANIFEST_KEYS_ROOT .has (key )):
369380 # remove the entry from missing fields if it is there
370- missing_fields .erase (key )
381+ missing_keys_root .erase (key )
382+
383+ if meta_data .has ("extra" ) && meta_data .extra .has ("godot" ):
384+ for godot_key in meta_data :
385+ if (REQUIRED_MANIFEST_KEYS_EXTRA .has (godot_key )):
386+ missing_keys_extra .erase (godot_key )
387+
388+ # Combine both arrays, and reformat the "extra" keys
389+ var missing_fields = missing_keys_root
390+ if missing_keys_extra .size () > 0 :
391+ for godot_key in missing_keys_extra :
392+ var formatted_key = str ("extra.godot." , godot_key )
393+ missing_fields .push_back (formatted_key )
371394
372395 return missing_fields
373396
0 commit comments