diff options
Diffstat (limited to 'extractor/grf.gd')
-rw-r--r-- | extractor/grf.gd | 12 |
1 files changed, 8 insertions, 4 deletions
diff --git a/extractor/grf.gd b/extractor/grf.gd index 1e17264..3739c8c 100644 --- a/extractor/grf.gd +++ b/extractor/grf.gd @@ -9,7 +9,7 @@ class Header: ## Byte Length: 15 ## Master of Magic - var signature: String + var signature: String = "Master of Magic" ## Byte Length: 15 var encryption: PackedByteArray @@ -138,6 +138,7 @@ class FileEntry: return contents + @warning_ignore("shadowed_variable") static func from_bytes_with_filename(bytes: PackedByteArray, file_name: String): var file_entry = FileEntry.new() @@ -188,12 +189,15 @@ static func open(path: String): return grf -func write(): +func extract(destination: String = "res://data"): for file_entry in file_entries: var file_path: String = file_entry.get_file_path() - var base_directory = DirAccess.open("res://data") + var base_directory = DirAccess.open(destination) base_directory.make_dir_recursive("extracted/" + file_path.get_base_dir()) - var file = FileAccess.open("res://data/extracted/%s" % [file_path], FileAccess.WRITE_READ) + var file = FileAccess.open("%s/extracted/%s" % [destination, file_path], FileAccess.WRITE_READ) file.store_buffer(file_entry.get_contents(file_access)) + + # TODO: write pngs for sprites (and .tres files maybe if necessary) + # TODO: (also maybe write .tres files for action data files(whatever they are)) |