From e2b37668ff9fd135f15a22ba3c3ae8e3377a7696 Mon Sep 17 00:00:00 2001 From: Chris Bloomfield <43499897+ithinkandicode@users.noreply.github.com> Date: Sun, 15 Jan 2023 07:04:49 +0000 Subject: [PATCH 1/4] docs: update example manifest.json --- README.md | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/README.md b/README.md index 520ded59..e5f398e3 100644 --- a/README.md +++ b/README.md @@ -37,19 +37,22 @@ Mods you create must have the following 2 files: ```json { - "id": "AuthorName-ModName", - "name": "Mod Name", - "version": "1.0.0", - "compatible_game_version": ["0.6.1.6"], - "authors": ["AuthorName"], - "description": "Mod description goes here", - "website_url": "", - "dependencies": [ - "Add IDs of other mods here, if your mod needs them to work" - ], - "incompatibilities": [ - "Add IDs of other mods here, if your mod conflicts with them" - ] + "name": "Invasion", + "version": "0.6.0", + "description": "Adds content from Space Gladiators", + "website_url": "https://github.com/BrotatoMods/Brotato-Invasion-Mod", + "dependencies": [ + "Dami-ContentLoader", + "Darkly77-BFX" + ], + "extra": { + "godot": { + "id": "Darkly77-Invasion", + "incompatibilities": [], + "authors": ["Darkly77"], + "compatible_game_version": ["0.6.1.6"], + } + } } ``` From 68f441a60e32ad37e3db7e485a01fad2f4154103 Mon Sep 17 00:00:00 2001 From: Chris Bloomfield <43499897+ithinkandicode@users.noreply.github.com> Date: Sun, 15 Jan 2023 07:25:04 +0000 Subject: [PATCH 2/4] update manifest key validation to match Thunderstore requirements --- loader/mod_loader.gd | 52 +++++++++++++++++++++++++++++++------------- 1 file changed, 37 insertions(+), 15 deletions(-) diff --git a/loader/mod_loader.gd b/loader/mod_loader.gd index 101b3164..05f6319d 100644 --- a/loader/mod_loader.gd +++ b/loader/mod_loader.gd @@ -49,13 +49,21 @@ const UNPACKED_DIR = "res://mods-unpacked/" const REQUIRED_MOD_FILES = ["ModMain.gd", "_meta.json"] # Required keys in a mod's _meta.json file -const REQUIRED_META_TAGS = [ - "id", +const REQUIRED_MANIFEST_KEYS_ROOT = [ "name", - "version", - "compatible_game_version", - "authors", + "version_number", + "website_url", "description", + "dependencies", + "extra", +] + +# Required keys in manifest's `json.extra.godot` +const REQUIRED_MANIFEST_KEYS_EXTRA = [ + "id", + "incompatibilities", + "authors", + "compatible_game_version", ] # Set to true to require using "--enable-mods" to enable them @@ -332,21 +340,22 @@ func _check_mod_files(mod_id): mod_log(str("ERROR - ", mod_id, " cannot be loaded due to missing required files"), LOG_NAME) -# Load meta data into mod_data, from a mod's _meta.json file +# Load meta data into mod_data, from a mod's manifest.json file func _load_meta_data(mod_id): - mod_log(str("Loading meta_data for -> ", mod_id), LOG_NAME) + mod_log(str("Loading meta_data (manifest.json) for -> ", mod_id), LOG_NAME) var mod = mod_data[mod_id] # Load meta data file - var meta_path = mod.required_files_path["_meta.json"] + var meta_path = mod.required_files_path["manifest.json"] var meta_data = _get_json_as_dict(meta_path) - dev_log(str(mod_id, " loaded meta data -> ", meta_data), LOG_NAME) + dev_log(str(mod_id, " loaded manifest data -> ", meta_data), LOG_NAME) - # Check if the meta data has all required fields + # Check if the manifest data has all required fields var missing_fields = _check_meta_file(meta_data) if(missing_fields.size() > 0): - mod_log(str("ERROR - ", mod_id, " ", missing_fields, " are required in _meta.json."), LOG_NAME) + for missing_field in missing_fields: + mod_log(str("ERROR - ", mod_id, " - Missing a required field in manifest.json: '", missing_field, "'"), LOG_NAME) # Flag mod - so it's not loaded later mod.is_loadable = false # Continue with the next mod @@ -356,14 +365,27 @@ func _load_meta_data(mod_id): mod.meta_data = meta_data -# Make sure the meta file has all required fields +# Ensure manifest.json has all required keys func _check_meta_file(meta_data): - var missing_fields = REQUIRED_META_TAGS + var missing_keys_root = REQUIRED_MANIFEST_KEYS_ROOT.duplicate() + var missing_keys_extra = REQUIRED_MANIFEST_KEYS_EXTRA.duplicate() for key in meta_data: - if(REQUIRED_META_TAGS.has(key)): + if(REQUIRED_MANIFEST_KEYS_ROOT.has(key)): # remove the entry from missing fields if it is there - missing_fields.erase(key) + missing_keys_root.erase(key) + + if meta_data.has("extra") && meta_data.extra.has("godot"): + for godot_key in meta_data: + if(REQUIRED_MANIFEST_KEYS_EXTRA.has(godot_key)): + missing_keys_extra.erase(godot_key) + + # Combine both arrays, and reformat the "extra" keys + var missing_fields = missing_keys_root + if missing_keys_extra.size() > 0: + for godot_key in missing_keys_extra: + var formatted_key = str("extra.godot.", godot_key) + missing_fields.push_back(formatted_key) return missing_fields From 0b4dd630c99c1a9300afe78ca9870ac5d7a4abea Mon Sep 17 00:00:00 2001 From: Chris Bloomfield <43499897+ithinkandicode@users.noreply.github.com> Date: Sun, 15 Jan 2023 07:38:03 +0000 Subject: [PATCH 3/4] docs: generic manifest.json --- README.md | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/README.md b/README.md index e5f398e3..b13928da 100644 --- a/README.md +++ b/README.md @@ -37,19 +37,20 @@ Mods you create must have the following 2 files: ```json { - "name": "Invasion", - "version": "0.6.0", - "description": "Adds content from Space Gladiators", - "website_url": "https://github.com/BrotatoMods/Brotato-Invasion-Mod", + "name": "ModName", + "version": "1.0.0", + "description": "Mod description goes here", + "website_url": "https://github.com/example/repo", "dependencies": [ - "Dami-ContentLoader", - "Darkly77-BFX" + "Add IDs of other mods here, if your mod needs them to work" ], "extra": { "godot": { - "id": "Darkly77-Invasion", - "incompatibilities": [], - "authors": ["Darkly77"], + "id": "AuthorName-ModName", + "incompatibilities": [ + "Add IDs of other mods here, if your mod conflicts with them" + ], + "authors": ["AuthorName"], "compatible_game_version": ["0.6.1.6"], } } From c311da6f5000d5f75c325b662cd7271d77605ed5 Mon Sep 17 00:00:00 2001 From: Chris Bloomfield <43499897+ithinkandicode@users.noreply.github.com> Date: Sun, 15 Jan 2023 08:14:11 +0000 Subject: [PATCH 4/4] fix manifest keys const not being renamed in a previous commit --- loader/mod_loader.gd | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/loader/mod_loader.gd b/loader/mod_loader.gd index cc9c6dd9..dd7eaefa 100644 --- a/loader/mod_loader.gd +++ b/loader/mod_loader.gd @@ -49,8 +49,7 @@ const UNPACKED_DIR = "res://mods-unpacked/" const REQUIRED_MOD_FILES = ["mod_main.gd", "manifest.json"] # Required keys in a mod's manifest.json file -const REQUIRED_META_TAGS = [ - "id", +const REQUIRED_MANIFEST_KEYS_ROOT = [ "name", "version_number", "website_url",