From 688790b5dc0ea8f51a99e42a00c7510b9bd87aa6 Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Wed, 4 Dec 2024 14:23:42 +0100 Subject: next commit --- extractor/grf.gd | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'extractor/grf.gd') 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)) -- cgit v1.2.3