Skip to content

Commit

Permalink
Merge pull request #157 from joshuafolkken/156-export-custom-manifest
Browse files Browse the repository at this point in the history
export custom manifest - add maskable purpose for android #156
  • Loading branch information
joshuafolkken authored Sep 18, 2024
2 parents 2f1784f + ecfb433 commit f8f0fb4
Show file tree
Hide file tree
Showing 6 changed files with 89 additions and 3 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,8 @@
.godot/
android/

addons/
addons/*
!addons/export_custom_manifest/
reports/
.DS_Store
export/
Expand Down
40 changes: 40 additions & 0 deletions addons/export_custom_manifest/export_custom_manifest.gd
Original file line number Diff line number Diff line change
@@ -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)
7 changes: 7 additions & 0 deletions addons/export_custom_manifest/plugin.cfg
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
[plugin]

name="Export Custom Manifest"
description=""
author="Joshua Folkken"
version="1.0.0"
script="plugin.gd"
13 changes: 13 additions & 0 deletions addons/export_custom_manifest/plugin.gd
Original file line number Diff line number Diff line change
@@ -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)
4 changes: 2 additions & 2 deletions project.godot
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand All @@ -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]

Expand Down
25 changes: 25 additions & 0 deletions web/manifest.json
Original file line number Diff line number Diff line change
@@ -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"
}

0 comments on commit f8f0fb4

Please sign in to comment.