diff options
Diffstat (limited to 'extractor/sprite_format.gd')
-rw-r--r-- | extractor/sprite_format.gd | 10 |
1 files changed, 6 insertions, 4 deletions
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: |