Compare commits
4 Commits
dac8c577dd
...
23359f2fef
Author | SHA1 | Date | |
---|---|---|---|
23359f2fef | |||
54ed370d87 | |||
02f5c8fa55 | |||
a70b7bf633 |
@ -5,7 +5,7 @@
|
|||||||
|
|
||||||
## Recursively creates virtual file systems.
|
## Recursively creates virtual file systems.
|
||||||
static func create_meta_accessor(file_accessors:Array[VFileAccess])->VFileAccess:
|
static func create_meta_accessor(file_accessors:Array[VFileAccess])->VFileAccess:
|
||||||
var vfiler := VFileAccess.new()
|
var vfiler := VFileAccess.new("")
|
||||||
|
|
||||||
vfiler._get_stuff = func()->Variant: return file_accessors
|
vfiler._get_stuff = func()->Variant: return file_accessors
|
||||||
|
|
||||||
|
18
vfs.gd
18
vfs.gd
@ -101,6 +101,24 @@ func load_supported(path:String, ext_override:String = "")->Variant:
|
|||||||
return result
|
return result
|
||||||
|
|
||||||
|
|
||||||
|
## Like load_supported, but expects [param path] to not have an extension.
|
||||||
|
## Instead, [param extensions] can contain multiple extensions, which will be
|
||||||
|
## appended and checked to exist. This allows for prioritizing one format
|
||||||
|
## over another or loosely defining a file id and allowing the engine to
|
||||||
|
## find a first match.
|
||||||
|
func load_any_supported(base_path:String, extensions:Array[String] = [])->Variant:
|
||||||
|
var _append_ext := func _append_ext(ext:String)->String:
|
||||||
|
return (base_path + ext) \
|
||||||
|
if ext.begins_with(".") \
|
||||||
|
else (base_path + "." + ext)
|
||||||
|
var try_paths:Array = extensions.map(_append_ext)
|
||||||
|
for path:String in try_paths:
|
||||||
|
if not file_exists(path): continue
|
||||||
|
return load_supported(path)
|
||||||
|
push_error("Could not find any file for '%s'.%s!" % [base_path, extensions])
|
||||||
|
return null
|
||||||
|
|
||||||
|
|
||||||
## [param parse] Callable(buffer:PackedByteArray)->Variant
|
## [param parse] Callable(buffer:PackedByteArray)->Variant
|
||||||
func load_and_parse(path:String, parse:Callable)->Variant:
|
func load_and_parse(path:String, parse:Callable)->Variant:
|
||||||
var abs_path:String = get_absolute_path(path)
|
var abs_path:String = get_absolute_path(path)
|
||||||
|
@ -30,7 +30,7 @@ static func load_mp3(buffer:PackedByteArray)->AudioStreamMP3:
|
|||||||
|
|
||||||
static func load_ogg(buffer:PackedByteArray)->AudioStreamOggVorbis:
|
static func load_ogg(buffer:PackedByteArray)->AudioStreamOggVorbis:
|
||||||
var sfx := AudioStreamOggVorbis.new()
|
var sfx := AudioStreamOggVorbis.new()
|
||||||
sfx.data = buffer
|
sfx.load_from_buffer(buffer)
|
||||||
return sfx
|
return sfx
|
||||||
|
|
||||||
static func load_txt(buffer:PackedByteArray)->String:
|
static func load_txt(buffer:PackedByteArray)->String:
|
||||||
|
Loading…
Reference in New Issue
Block a user