summaryrefslogtreecommitdiff
path: root/extractor/sprite_format.gd
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-12-12 02:12:52 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-12-12 02:12:52 +0100
commita22381eff3bf2286ee27f4d15ddf4c431ea063be (patch)
tree965bdcf12e5e0cf63c88cbba1bd5a52ba474f81f /extractor/sprite_format.gd
parente3c185e05823e30eccd7728ceda2ee57cc66fd4d (diff)
next commit
Diffstat (limited to 'extractor/sprite_format.gd')
-rw-r--r--extractor/sprite_format.gd10
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: