diff options
author | Daniel Weipert <git@mail.dweipert.de> | 2024-12-04 14:23:42 +0100 |
---|---|---|
committer | Daniel Weipert <git@mail.dweipert.de> | 2024-12-04 14:23:42 +0100 |
commit | 688790b5dc0ea8f51a99e42a00c7510b9bd87aa6 (patch) | |
tree | 71c04c9f401c67caf5c1ea3f56c7360ac1d14b86 /extractor/grf.gd | |
parent | 2bf6b303fc062a800afb784877d989686287a2a7 (diff) |
next commit
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)) |