diff --git a/.gitignore b/.gitignore index 1c77761..bc551f5 100644 --- a/.gitignore +++ b/.gitignore @@ -2,7 +2,8 @@ .godot/ android/ -addons/ +addons/* +!addons/export_custom_manifest/ reports/ .DS_Store export/ diff --git a/addons/export_custom_manifest/export_custom_manifest.gd b/addons/export_custom_manifest/export_custom_manifest.gd new file mode 100644 index 0000000..48de7bd --- /dev/null +++ b/addons/export_custom_manifest/export_custom_manifest.gd @@ -0,0 +1,40 @@ +class_name ExportCustomManifest +extends EditorExportPlugin + +const MANIFEST_FILENAME := "manifest.json" +const MANIFEST_PATH = "res://web/" + MANIFEST_FILENAME + +var _features: PackedStringArray +var _export_dir: String + + +func _get_name() -> String: + return "ExportCustomManifest" + + +func copy_manifest(dest_path: String) -> void: + var error := DirAccess.copy_absolute(MANIFEST_PATH, dest_path) + + if error != OK: + push_error( + ( + "Failed to copy manifest. Error code: %d\nSource: %s\nDestination: %s" + % [error, MANIFEST_PATH, dest_path] + ) + ) + else: + print("Custom manifest.json copied successfully to: %s" % dest_path) + + +func _export_begin(features: PackedStringArray, _is_debug: bool, path: String, _flags: int) -> void: + _features = features + _export_dir = path.get_base_dir() + + +func _export_end() -> void: + if "web" not in _features: + return + + var dest_manifest_path := _export_dir.path_join("index." + MANIFEST_FILENAME) + + copy_manifest(dest_manifest_path) diff --git a/addons/export_custom_manifest/plugin.cfg b/addons/export_custom_manifest/plugin.cfg new file mode 100644 index 0000000..ab9c279 --- /dev/null +++ b/addons/export_custom_manifest/plugin.cfg @@ -0,0 +1,7 @@ +[plugin] + +name="Export Custom Manifest" +description="" +author="Joshua Folkken" +version="1.0.0" +script="plugin.gd" diff --git a/addons/export_custom_manifest/plugin.gd b/addons/export_custom_manifest/plugin.gd new file mode 100644 index 0000000..73cfe95 --- /dev/null +++ b/addons/export_custom_manifest/plugin.gd @@ -0,0 +1,13 @@ +@tool +extends EditorPlugin + +var export_plugin: EditorExportPlugin + + +func _enter_tree() -> void: + export_plugin = ExportCustomManifest.new() + add_export_plugin(export_plugin) + + +func _exit_tree() -> void: + remove_export_plugin(export_plugin) diff --git a/project.godot b/project.godot index 5a2ad69..e98354c 100644 --- a/project.godot +++ b/project.godot @@ -11,7 +11,7 @@ config_version=5 [application] config/name="Tic Tac Toe" -config/version="0.53.0" +config/version="0.54.0" run/main_scene="res://scenes/main.tscn" config/features=PackedStringArray("4.3", "GL Compatibility") config/icon="res://icon.svg" @@ -32,7 +32,7 @@ window/stretch/mode="canvas_items" [editor_plugins] -enabled=PackedStringArray("res://addons/gut/plugin.cfg", "res://addons/gdUnit4/plugin.cfg") +enabled=PackedStringArray("res://addons/export_custom_manifest/plugin.cfg", "res://addons/gdUnit4/plugin.cfg", "res://addons/gut/plugin.cfg") [gdunit4] diff --git a/web/manifest.json b/web/manifest.json new file mode 100644 index 0000000..700cf22 --- /dev/null +++ b/web/manifest.json @@ -0,0 +1,25 @@ +{ + "background_color": "#000000", + "display": "fullscreen", + "icons": [ + { + "sizes": "144x144", + "src": "index.144x144.png", + "type": "image/png" + }, + { + "sizes": "180x180", + "src": "index.180x180.png", + "type": "image/png" + }, + { + "sizes": "512x512", + "src": "index.512x512.png", + "type": "image/png", + "purpose": "any maskable" + } + ], + "name": "Tic Tac Toe", + "orientation": "landscape", + "start_url": "./index.html" +}