Compare commits
No commits in common. "73d29ae6ee997cda1b0f5b2981e7ce88c731e86b" and "2f4690b6c9b4677766e45b941b5d851c7bb7e71a" have entirely different histories.
73d29ae6ee
...
2f4690b6c9
3 changed files with 3 additions and 107 deletions
|
@ -1,19 +1,3 @@
|
||||||
# PRESENCODE SOURCE FILE
|
|
||||||
# Copyright (c) 2024 JeremyStarTM & Contributors
|
|
||||||
# Licensed under the GNU Affero General Public License v3
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of the
|
|
||||||
# License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
var core: Core
|
var core: Core
|
||||||
|
|
|
@ -1,19 +1,3 @@
|
||||||
# PRESENCODE SOURCE FILE
|
|
||||||
# Copyright (c) 2024 JeremyStarTM & Contributors
|
|
||||||
# Licensed under the GNU Affero General Public License v3
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of the
|
|
||||||
# License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
extends Node
|
extends Node
|
||||||
|
|
||||||
# Presencode version
|
# Presencode version
|
||||||
|
@ -28,7 +12,6 @@ const version_float: float = float(version)
|
||||||
var path: String = ""
|
var path: String = ""
|
||||||
var is_file: bool = true
|
var is_file: bool = true
|
||||||
var manifest: Dictionary = {}
|
var manifest: Dictionary = {}
|
||||||
var entrypoint: Script = null
|
|
||||||
|
|
||||||
# Access methods
|
# Access methods
|
||||||
var reader: ZIPReader = ZIPReader.new()
|
var reader: ZIPReader = ZIPReader.new()
|
||||||
|
@ -69,30 +52,21 @@ func load_presentation(load_path: String) -> String:
|
||||||
if diraccess == null:
|
if diraccess == null:
|
||||||
return core.misc.stringify_variables("Can't open directory: %error_string% (%error%)", { "error": DirAccess.get_open_error(), "error_string": error_string(DirAccess.get_open_error()) }, true)
|
return core.misc.stringify_variables("Can't open directory: %error_string% (%error%)", { "error": DirAccess.get_open_error(), "error_string": error_string(DirAccess.get_open_error()) }, true)
|
||||||
|
|
||||||
# Check if required files are present
|
|
||||||
var output: String = check_required_files()
|
var output: String = check_required_files()
|
||||||
if output != "": return output
|
if output != "": return output
|
||||||
|
|
||||||
# Parse manifest.json
|
|
||||||
output = parse_manifest()
|
output = parse_manifest()
|
||||||
if output != "": return output
|
if output != "": return output
|
||||||
|
|
||||||
# Validate manifest.json
|
|
||||||
var output_array: Array[String] = check_manifest()
|
var output_array: Array[String] = check_manifest()
|
||||||
if output_array != []: return core.misc.format_stringarray(output_array, "- ", "", "\n", "\n")
|
if output_array != []: return core.misc.format_stringarray(output_array, "- ", "", "\n", "\n")
|
||||||
|
|
||||||
# Load and inject entrypoint
|
|
||||||
output = load_entrypoint()
|
|
||||||
if output != "": return output
|
|
||||||
|
|
||||||
inject_entrypoint()
|
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
func check_required_files() -> String:
|
func check_required_files() -> String:
|
||||||
logger.verb("Checking for required files")
|
logger.verb("Checking for required files")
|
||||||
# Define variables
|
# Define variables
|
||||||
var files_present: Dictionary = { "manifest": false, "slides": false, "src": false }
|
var files_present: Dictionary = { "manifest": false, "slides": false }
|
||||||
var files: PackedStringArray = PackedStringArray([])
|
var files: PackedStringArray = PackedStringArray([])
|
||||||
|
|
||||||
# Update 'files' appropriately
|
# Update 'files' appropriately
|
||||||
|
@ -107,7 +81,7 @@ func check_required_files() -> String:
|
||||||
for file in files:
|
for file in files:
|
||||||
if file == "manifest.json": files_present["manifest"] = true
|
if file == "manifest.json": files_present["manifest"] = true
|
||||||
elif file.begins_with("slides/"): files_present["slides"] = true
|
elif file.begins_with("slides/"): files_present["slides"] = true
|
||||||
elif file.begins_with("src/"): files_present["src"] = true
|
elif file.begins_with("src/"): pass
|
||||||
elif file.begins_with("assets/"): pass
|
elif file.begins_with("assets/"): pass
|
||||||
else: logger.warn(core.misc.stringify_variables("Unknown file/directory %file% inside presentation directory, ignoring", { "file": file }))
|
else: logger.warn(core.misc.stringify_variables("Unknown file/directory %file% inside presentation directory, ignoring", { "file": file }))
|
||||||
|
|
||||||
|
@ -115,7 +89,6 @@ func check_required_files() -> String:
|
||||||
if !files_present["manifest"]:
|
if !files_present["manifest"]:
|
||||||
return "The presentation manifest is missing. Make sure it is named 'manifest.json'"
|
return "The presentation manifest is missing. Make sure it is named 'manifest.json'"
|
||||||
if !files_present["slides"]: return "The 'slides' directory is missing. You can't have a presentation without slides, dingus!"
|
if !files_present["slides"]: return "The 'slides' directory is missing. You can't have a presentation without slides, dingus!"
|
||||||
if !files_present["src"]: return "The 'src' directory is missing. You can't have a code-based presentation without code, dingus!"
|
|
||||||
|
|
||||||
return ""
|
return ""
|
||||||
|
|
||||||
|
@ -173,43 +146,3 @@ func check_manifest() -> Array[String]:
|
||||||
}, manifest, self)
|
}, manifest, self)
|
||||||
|
|
||||||
return schema.evaluate()
|
return schema.evaluate()
|
||||||
|
|
||||||
func load_entrypoint() -> String:
|
|
||||||
logger.verb("Loading entrypoint")
|
|
||||||
|
|
||||||
if is_file:
|
|
||||||
if !reader.file_exists("src/" + manifest["entrypoint"]):
|
|
||||||
return "Specified entrypoint file could not be located at src/" + manifest["entrypoint"]
|
|
||||||
|
|
||||||
# Workaround (we can't load resources from buffer. why? idk)
|
|
||||||
# -> Remove temporary file (if exists)
|
|
||||||
if FileAccess.file_exists("user://entrypoint.gd"):
|
|
||||||
DirAccess.remove_absolute("user://entrypoint.gd")
|
|
||||||
# -> Write entrypoint file (buffer from ZIPReader) into temporary file
|
|
||||||
var file: FileAccess = FileAccess.open("user://entrypoint.gd", FileAccess.WRITE)
|
|
||||||
if file == null:
|
|
||||||
return core.misc.stringify_variables("Can't write temporary entrypoint: %error_string% (%error%)", { "error": FileAccess.get_open_error(), "error_string": error_string(FileAccess.get_open_error()) })
|
|
||||||
file.store_buffer(reader.read_file("src/" + manifest["entrypoint"]))
|
|
||||||
file.close()
|
|
||||||
# -> Load temporary file
|
|
||||||
entrypoint = ResourceLoader.load("user://entrypoint.gd")
|
|
||||||
else:
|
|
||||||
if !FileAccess.file_exists(path + "/src/" + manifest["entrypoint"]):
|
|
||||||
return "Specified entrypoint file could not be located at src/" + manifest["entrypoint"]
|
|
||||||
|
|
||||||
# Load entrypoint
|
|
||||||
entrypoint = ResourceLoader.load(path + "/src/" + manifest["entrypoint"])
|
|
||||||
|
|
||||||
return ""
|
|
||||||
|
|
||||||
func inject_entrypoint() -> void:
|
|
||||||
logger.verb("Injecting entrypoint")
|
|
||||||
|
|
||||||
# Instantiate new Node
|
|
||||||
var entrypoint_node: Node = Node.new()
|
|
||||||
# Give the new node a name and the entrypoint script
|
|
||||||
entrypoint_node.name = "Entrypoint"
|
|
||||||
entrypoint_node.set_script(entrypoint)
|
|
||||||
|
|
||||||
# Add to SceneTree
|
|
||||||
get_tree().root.add_child(entrypoint_node)
|
|
||||||
|
|
|
@ -1,19 +1,3 @@
|
||||||
# PRESENCODE SOURCE FILE
|
|
||||||
# Copyright (c) 2024 JeremyStarTM & Contributors
|
|
||||||
# Licensed under the GNU Affero General Public License v3
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU Affero General Public License as
|
|
||||||
# published by the Free Software Foundation, either version 3 of the
|
|
||||||
# License, or (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program is distributed in the hope that it will be useful,
|
|
||||||
# but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
# GNU Affero General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU Affero General Public License
|
|
||||||
# along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
extends NinePatchRect
|
extends NinePatchRect
|
||||||
|
|
||||||
# CORE
|
# CORE
|
||||||
|
@ -39,7 +23,6 @@ var splashes: Array[String] = [
|
||||||
"this was blatantly ripped off from Minecraft",
|
"this was blatantly ripped off from Minecraft",
|
||||||
"Trans rights are human rights!",
|
"Trans rights are human rights!",
|
||||||
"// TODO",
|
"// TODO",
|
||||||
"# TODO",
|
|
||||||
"UwU",
|
"UwU",
|
||||||
"open source :)",
|
"open source :)",
|
||||||
"i use presencode btw",
|
"i use presencode btw",
|
||||||
|
@ -53,11 +36,7 @@ var splashes: Array[String] = [
|
||||||
"Now in 2D!",
|
"Now in 2D!",
|
||||||
"very bad",
|
"very bad",
|
||||||
"beta and alpha males are overrated, i'm a release male",
|
"beta and alpha males are overrated, i'm a release male",
|
||||||
"uses .pcar files!",
|
"uses .pcar files!"
|
||||||
"licensed under the GNU AGPL v3!",
|
|
||||||
"## @experimental",
|
|
||||||
"Welcome!",
|
|
||||||
"Godot 4 + [s]0.1 + 0.2[/s] 24 = Godot 4.2!"
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# Threads
|
# Threads
|
||||||
|
|
Loading…
Reference in a new issue