From 09cf37e928617ff98800d9b1095bb9fe6340f8fd Mon Sep 17 00:00:00 2001 From: KANAjetzt <41547570+KANAjetzt@users.noreply.github.com> Date: Wed, 8 Mar 2023 14:27:08 +0100 Subject: [PATCH] feat: :sparkles: Added `to_json()` function (#175) Can be used to retrieve the Manifest values as JSON, in the manifest.json format. Will be used in the Mod Tool. --- addons/mod_loader/classes/mod_manifest.gd | 24 +++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/addons/mod_loader/classes/mod_manifest.gd b/addons/mod_loader/classes/mod_manifest.gd index c4967ccc..02dbc40a 100644 --- a/addons/mod_loader/classes/mod_manifest.gd +++ b/addons/mod_loader/classes/mod_manifest.gd @@ -120,6 +120,30 @@ func get_as_dict() -> Dictionary: } +# Returns the Manifest values as JSON, in the manifest.json format +func to_json() -> String: + return JSON.print({ + "name": name, + "namespace": namespace, + "version_number": version_number, + "description": description, + "website_url": website_url, + "dependencies": dependencies, + "extra": { + "godot":{ + "authors": authors, + "compatible_game_version": compatible_game_version, + "compatible_mod_loader_version": compatible_mod_loader_version, + "incompatibilities": incompatibilities, + "tags": tags, + "config_defaults": config_defaults, + "description_rich": description_rich, + "image": image, + } + } + }) + + # Handles deprecation of the single string value in the compatible_mod_loader_version. func _handle_compatible_mod_loader_version(godot_details: Dictionary) -> Array: var link_manifest_docs := "https://github.com/GodotModding/godot-mod-loader/wiki/Mod-Files#manifestjson"