Fix resource loading issues (archives only)
This commit is contained in:
parent
e9343318c0
commit
61e82ac9e3
10 changed files with 54 additions and 253 deletions
|
@ -1,34 +0,0 @@
|
||||||
[remap]
|
|
||||||
|
|
||||||
importer="texture"
|
|
||||||
type="CompressedTexture2D"
|
|
||||||
uid="uid://bqf0yuaaxgrdr"
|
|
||||||
path="res://.godot/imported/Icon.png-93ca016a3d581ee8be85859272221470.ctex"
|
|
||||||
metadata={
|
|
||||||
"vram_texture": false
|
|
||||||
}
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://assets/images/Icon.png"
|
|
||||||
dest_files=["res://.godot/imported/Icon.png-93ca016a3d581ee8be85859272221470.ctex"]
|
|
||||||
|
|
||||||
[params]
|
|
||||||
|
|
||||||
compress/mode=0
|
|
||||||
compress/high_quality=false
|
|
||||||
compress/lossy_quality=0.7
|
|
||||||
compress/hdr_compression=1
|
|
||||||
compress/normal_map=0
|
|
||||||
compress/channel_pack=0
|
|
||||||
mipmaps/generate=false
|
|
||||||
mipmaps/limit=-1
|
|
||||||
roughness/mode=0
|
|
||||||
roughness/src_normal=""
|
|
||||||
process/fix_alpha_border=true
|
|
||||||
process/premult_alpha=false
|
|
||||||
process/normal_map_invert_y=false
|
|
||||||
process/hdr_as_srgb=false
|
|
||||||
process/hdr_clamp_exposure=false
|
|
||||||
process/size_limit=0
|
|
||||||
detect_3d/compress_to=1
|
|
|
@ -1,34 +0,0 @@
|
||||||
[remap]
|
|
||||||
|
|
||||||
importer="texture"
|
|
||||||
type="CompressedTexture2D"
|
|
||||||
uid="uid://btrjvej7kesqp"
|
|
||||||
path="res://.godot/imported/IconRound.png-1afd952ea59d10fc5e3b0a78c073f524.ctex"
|
|
||||||
metadata={
|
|
||||||
"vram_texture": false
|
|
||||||
}
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://docs/static/assets/images/IconRound.png"
|
|
||||||
dest_files=["res://.godot/imported/IconRound.png-1afd952ea59d10fc5e3b0a78c073f524.ctex"]
|
|
||||||
|
|
||||||
[params]
|
|
||||||
|
|
||||||
compress/mode=0
|
|
||||||
compress/high_quality=false
|
|
||||||
compress/lossy_quality=0.7
|
|
||||||
compress/hdr_compression=1
|
|
||||||
compress/normal_map=0
|
|
||||||
compress/channel_pack=0
|
|
||||||
mipmaps/generate=false
|
|
||||||
mipmaps/limit=-1
|
|
||||||
roughness/mode=0
|
|
||||||
roughness/src_normal=""
|
|
||||||
process/fix_alpha_border=true
|
|
||||||
process/premult_alpha=false
|
|
||||||
process/normal_map_invert_y=false
|
|
||||||
process/hdr_as_srgb=false
|
|
||||||
process/hdr_clamp_exposure=false
|
|
||||||
process/size_limit=0
|
|
||||||
detect_3d/compress_to=1
|
|
|
@ -1,34 +0,0 @@
|
||||||
[remap]
|
|
||||||
|
|
||||||
importer="texture"
|
|
||||||
type="CompressedTexture2D"
|
|
||||||
uid="uid://cvhgvybvn011m"
|
|
||||||
path="res://.godot/imported/IconText.png-ba84e8aaca79c24529b5915da9118cd4.ctex"
|
|
||||||
metadata={
|
|
||||||
"vram_texture": false
|
|
||||||
}
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://assets/images/IconText.png"
|
|
||||||
dest_files=["res://.godot/imported/IconText.png-ba84e8aaca79c24529b5915da9118cd4.ctex"]
|
|
||||||
|
|
||||||
[params]
|
|
||||||
|
|
||||||
compress/mode=0
|
|
||||||
compress/high_quality=false
|
|
||||||
compress/lossy_quality=0.7
|
|
||||||
compress/hdr_compression=1
|
|
||||||
compress/normal_map=0
|
|
||||||
compress/channel_pack=0
|
|
||||||
mipmaps/generate=false
|
|
||||||
mipmaps/limit=-1
|
|
||||||
roughness/mode=0
|
|
||||||
roughness/src_normal=""
|
|
||||||
process/fix_alpha_border=true
|
|
||||||
process/premult_alpha=false
|
|
||||||
process/normal_map_invert_y=false
|
|
||||||
process/hdr_as_srgb=false
|
|
||||||
process/hdr_clamp_exposure=false
|
|
||||||
process/size_limit=0
|
|
||||||
detect_3d/compress_to=1
|
|
|
@ -1,34 +0,0 @@
|
||||||
[remap]
|
|
||||||
|
|
||||||
importer="texture"
|
|
||||||
type="CompressedTexture2D"
|
|
||||||
uid="uid://dt4kldhfyob1h"
|
|
||||||
path="res://.godot/imported/IconRound_192x192.png-35fb3db21886e26e465df99404de1b9b.ctex"
|
|
||||||
metadata={
|
|
||||||
"vram_texture": false
|
|
||||||
}
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://assets/images/web/IconRound_192x192.png"
|
|
||||||
dest_files=["res://.godot/imported/IconRound_192x192.png-35fb3db21886e26e465df99404de1b9b.ctex"]
|
|
||||||
|
|
||||||
[params]
|
|
||||||
|
|
||||||
compress/mode=0
|
|
||||||
compress/high_quality=false
|
|
||||||
compress/lossy_quality=0.7
|
|
||||||
compress/hdr_compression=1
|
|
||||||
compress/normal_map=0
|
|
||||||
compress/channel_pack=0
|
|
||||||
mipmaps/generate=false
|
|
||||||
mipmaps/limit=-1
|
|
||||||
roughness/mode=0
|
|
||||||
roughness/src_normal=""
|
|
||||||
process/fix_alpha_border=true
|
|
||||||
process/premult_alpha=false
|
|
||||||
process/normal_map_invert_y=false
|
|
||||||
process/hdr_as_srgb=false
|
|
||||||
process/hdr_clamp_exposure=false
|
|
||||||
process/size_limit=0
|
|
||||||
detect_3d/compress_to=1
|
|
|
@ -1,34 +0,0 @@
|
||||||
[remap]
|
|
||||||
|
|
||||||
importer="texture"
|
|
||||||
type="CompressedTexture2D"
|
|
||||||
uid="uid://dgeydjomrd7nt"
|
|
||||||
path="res://.godot/imported/IconRound_512x512.png-5a9260cdeed5622a5196eddf4da6277a.ctex"
|
|
||||||
metadata={
|
|
||||||
"vram_texture": false
|
|
||||||
}
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://assets/images/web/IconRound_512x512.png"
|
|
||||||
dest_files=["res://.godot/imported/IconRound_512x512.png-5a9260cdeed5622a5196eddf4da6277a.ctex"]
|
|
||||||
|
|
||||||
[params]
|
|
||||||
|
|
||||||
compress/mode=0
|
|
||||||
compress/high_quality=false
|
|
||||||
compress/lossy_quality=0.7
|
|
||||||
compress/hdr_compression=1
|
|
||||||
compress/normal_map=0
|
|
||||||
compress/channel_pack=0
|
|
||||||
mipmaps/generate=false
|
|
||||||
mipmaps/limit=-1
|
|
||||||
roughness/mode=0
|
|
||||||
roughness/src_normal=""
|
|
||||||
process/fix_alpha_border=true
|
|
||||||
process/premult_alpha=false
|
|
||||||
process/normal_map_invert_y=false
|
|
||||||
process/hdr_as_srgb=false
|
|
||||||
process/hdr_clamp_exposure=false
|
|
||||||
process/size_limit=0
|
|
||||||
detect_3d/compress_to=1
|
|
|
@ -14,6 +14,23 @@ Reads Presencode presentation archives and directories.
|
||||||
- type `string`
|
- type `string`
|
||||||
- mandatory `yes`
|
- mandatory `yes`
|
||||||
- description `The path to a file`
|
- description `The path to a file`
|
||||||
|
### `read_resource`
|
||||||
|
- return type `Resource`
|
||||||
|
- description `Reads a resource from the presentation archive/directory. Returns an empty Resource if the file could not be read.`
|
||||||
|
- arguments
|
||||||
|
- `path`
|
||||||
|
- type `string`
|
||||||
|
- mandatory `yes`
|
||||||
|
- description `The path to a resource`
|
||||||
|
### `read_resource_unsafe`
|
||||||
|
- return type `Resource`
|
||||||
|
- description `Reads a resource from the presentation archive/directory. Returns an empty Resource if the file could not be read.`
|
||||||
|
- warning `Loads resources directly, which can lead to missing resources when the presentation is loaded from an archive.`
|
||||||
|
- arguments
|
||||||
|
- `path`
|
||||||
|
- type `string`
|
||||||
|
- mandatory `yes`
|
||||||
|
- description `The path to a resource`
|
||||||
### `get_topic`
|
### `get_topic`
|
||||||
- return type `String`
|
- return type `String`
|
||||||
- description `Get the presentation topic`
|
- description `Get the presentation topic`
|
||||||
|
|
|
@ -1,34 +0,0 @@
|
||||||
[remap]
|
|
||||||
|
|
||||||
importer="texture"
|
|
||||||
type="CompressedTexture2D"
|
|
||||||
uid="uid://dp6kkiretv01v"
|
|
||||||
path="res://.godot/imported/foxxo.jpg-ef4c7ba004a3455efe7e3e1605964ac9.ctex"
|
|
||||||
metadata={
|
|
||||||
"vram_texture": false
|
|
||||||
}
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://example/images/foxxo.jpg"
|
|
||||||
dest_files=["res://.godot/imported/foxxo.jpg-ef4c7ba004a3455efe7e3e1605964ac9.ctex"]
|
|
||||||
|
|
||||||
[params]
|
|
||||||
|
|
||||||
compress/mode=0
|
|
||||||
compress/high_quality=false
|
|
||||||
compress/lossy_quality=0.7
|
|
||||||
compress/hdr_compression=1
|
|
||||||
compress/normal_map=0
|
|
||||||
compress/channel_pack=0
|
|
||||||
mipmaps/generate=false
|
|
||||||
mipmaps/limit=-1
|
|
||||||
roughness/mode=0
|
|
||||||
roughness/src_normal=""
|
|
||||||
process/fix_alpha_border=true
|
|
||||||
process/premult_alpha=false
|
|
||||||
process/normal_map_invert_y=false
|
|
||||||
process/hdr_as_srgb=false
|
|
||||||
process/hdr_clamp_exposure=false
|
|
||||||
process/size_limit=0
|
|
||||||
detect_3d/compress_to=1
|
|
|
@ -1,15 +0,0 @@
|
||||||
[remap]
|
|
||||||
|
|
||||||
importer="import_gif_to_sprite_frames"
|
|
||||||
type="SpriteFrames"
|
|
||||||
uid="uid://bghv86mpnhh6"
|
|
||||||
path="res://.godot/imported/mario.gif-f119460dcfd983f3b74edf3b7b56592c.tres"
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://example/images/mario.gif"
|
|
||||||
dest_files=["res://.godot/imported/mario.gif-f119460dcfd983f3b74edf3b7b56592c.tres"]
|
|
||||||
|
|
||||||
[params]
|
|
||||||
|
|
||||||
frames_per_second=30
|
|
|
@ -1,34 +0,0 @@
|
||||||
[remap]
|
|
||||||
|
|
||||||
importer="texture"
|
|
||||||
type="CompressedTexture2D"
|
|
||||||
uid="uid://jwvaqrhaf1t"
|
|
||||||
path="res://.godot/imported/meme.jpg-9a7233508d56192f29bdb233352ed64b.ctex"
|
|
||||||
metadata={
|
|
||||||
"vram_texture": false
|
|
||||||
}
|
|
||||||
|
|
||||||
[deps]
|
|
||||||
|
|
||||||
source_file="res://example/images/meme.jpg"
|
|
||||||
dest_files=["res://.godot/imported/meme.jpg-9a7233508d56192f29bdb233352ed64b.ctex"]
|
|
||||||
|
|
||||||
[params]
|
|
||||||
|
|
||||||
compress/mode=0
|
|
||||||
compress/high_quality=false
|
|
||||||
compress/lossy_quality=0.7
|
|
||||||
compress/hdr_compression=1
|
|
||||||
compress/normal_map=0
|
|
||||||
compress/channel_pack=0
|
|
||||||
mipmaps/generate=false
|
|
||||||
mipmaps/limit=-1
|
|
||||||
roughness/mode=0
|
|
||||||
roughness/src_normal=""
|
|
||||||
process/fix_alpha_border=true
|
|
||||||
process/premult_alpha=false
|
|
||||||
process/normal_map_invert_y=false
|
|
||||||
process/hdr_as_srgb=false
|
|
||||||
process/hdr_clamp_exposure=false
|
|
||||||
process/size_limit=0
|
|
||||||
detect_3d/compress_to=1
|
|
|
@ -104,6 +104,43 @@ func read_file(path: String) -> PackedByteArray:
|
||||||
|
|
||||||
# Read a resource from the presentation archive/directory
|
# Read a resource from the presentation archive/directory
|
||||||
func read_resource(path: String) -> Resource:
|
func read_resource(path: String) -> Resource:
|
||||||
|
if !is_open:
|
||||||
|
logger.warn("No presentation is currently opened")
|
||||||
|
return null
|
||||||
|
if directorypath == "":
|
||||||
|
var resource_bytes: PackedByteArray = read_file(path)
|
||||||
|
if resource_bytes.size() == 0:
|
||||||
|
logger.warn("Resource could not be read")
|
||||||
|
return null
|
||||||
|
var split_path: Array = path.split("/")
|
||||||
|
var file = FileAccess.open(misc.get_temporary_dir() + "/" + str(split_path[split_path.size()-1]), FileAccess.WRITE)
|
||||||
|
if file == null:
|
||||||
|
logger.warn("Resource could not be read, FileAccess[1] failed: " + str(FileAccess.get_open_error()))
|
||||||
|
return null
|
||||||
|
file.store_buffer(resource_bytes)
|
||||||
|
file.close()
|
||||||
|
var resource: Resource = null
|
||||||
|
if path.ends_with(".ttf") or path.ends_with(".otf") or path.ends_with(".woff") or path.ends_with(".woff2"):
|
||||||
|
resource = FontFile.new()
|
||||||
|
resource.load_dynamic_font(misc.get_temporary_dir() + "/" + str(split_path[split_path.size()-1]))
|
||||||
|
else:
|
||||||
|
resource = ResourceLoader.load(misc.get_temporary_dir() + "/" + str(split_path[split_path.size()-1]))
|
||||||
|
if resource == null:
|
||||||
|
logger.warn("Resource could not be read, resource is null")
|
||||||
|
return null
|
||||||
|
return resource
|
||||||
|
else:
|
||||||
|
if !FileAccess.file_exists(directorypath + "/" + path):
|
||||||
|
logger.error("Requested resource is missing in presentation directory")
|
||||||
|
return null
|
||||||
|
var resource: Resource = ResourceLoader.load(directorypath + "/" + path)
|
||||||
|
if resource == null:
|
||||||
|
logger.warn("Resource could not be read, resource is null")
|
||||||
|
return null
|
||||||
|
return resource
|
||||||
|
|
||||||
|
# Read a resource from the presentation archive/directory (unsafe)
|
||||||
|
func read_resource_unsafe(path: String) -> Resource:
|
||||||
if !is_open:
|
if !is_open:
|
||||||
logger.warn("No presentation is currently opened")
|
logger.warn("No presentation is currently opened")
|
||||||
return null
|
return null
|
||||||
|
|
Loading…
Reference in a new issue