From a22381eff3bf2286ee27f4d15ddf4c431ea063be Mon Sep 17 00:00:00 2001 From: Daniel Weipert Date: Thu, 12 Dec 2024 02:12:52 +0100 Subject: next commit --- extractor/sprite_format.gd | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'extractor/sprite_format.gd') diff --git a/extractor/sprite_format.gd b/extractor/sprite_format.gd index fab0873..46b20c1 100644 --- a/extractor/sprite_format.gd +++ b/extractor/sprite_format.gd @@ -108,10 +108,11 @@ static func from_bytes(bytes: PackedByteArray) -> SpriteFormat: return sprite_format -func save_to_file(): - assert(filepath != "") +func save_to_file(base_dir: String = ""): + if base_dir == "": + assert(filepath != "") + base_dir = filepath.substr(0, filepath.length() - 4) # cut off .spr - var base_dir = filepath.substr(0, filepath.length() - 4) # cut off .spr DirAccess.make_dir_recursive_absolute(base_dir) for idx in palette_image_data.size(): @@ -124,7 +125,8 @@ func save_to_file(): data.get_rgba_data(palette) ) - image.save_png("%s/%s.png" % [base_dir, str(idx).pad_zeros(3)]) + var path = "%s/%s.png" % [base_dir, str(idx).pad_zeros(3)] + image.save_png(path) func files_exist() -> bool: -- cgit v1.2.3