summaryrefslogtreecommitdiff
path: root/extractor
diff options
context:
space:
mode:
authorDaniel Weipert <git@mail.dweipert.de>2024-12-15 14:23:25 +0100
committerDaniel Weipert <git@mail.dweipert.de>2024-12-15 14:23:25 +0100
commita14e88ff4d0d87841a44254e2bff1784da6e8b48 (patch)
tree0507cb8117da7943805a6479aef4526edb2db4dd /extractor
parentca4d1945598863d0ce297f4272317e5dd5797f88 (diff)
next commit
Diffstat (limited to 'extractor')
-rw-r--r--extractor/grf.gd9
-rw-r--r--extractor/sprite_format.gd17
2 files changed, 24 insertions, 2 deletions
diff --git a/extractor/grf.gd b/extractor/grf.gd
index fa7021a..e017bc8 100644
--- a/extractor/grf.gd
+++ b/extractor/grf.gd
@@ -217,11 +217,16 @@ func convert(destination: String = "res://data"):
#DirAccess.make_dir_recursive_absolute(base_file_directory_path)
- if file_path.ends_with(".spr") and file_path.contains("cursors"):
+ var player_head_path_part = "¸Ó¸®Åë"
+ var player_body_path_part = "¸öÅë"
+
+ if file_path.ends_with(".spr") and file_path.contains(player_body_path_part) and file_path.contains("NIGHT_WATCH"):
var sprite = SpriteFormat.from_bytes(file_entry.get_contents(file_access))
+ print(file_path, (sprite.palette_image_count), sprite.version)
sprite.save_to_file(base_file_directory_path)
- elif file_path.ends_with(".act") and file_path.contains("cursors"):
+ elif file_path.ends_with(".act") and file_path.contains(player_body_path_part):
+ continue
if not FileAccess.file_exists("%s/000.png.import" % base_file_directory_path):
continue
diff --git a/extractor/sprite_format.gd b/extractor/sprite_format.gd
index 46b20c1..879a45f 100644
--- a/extractor/sprite_format.gd
+++ b/extractor/sprite_format.gd
@@ -73,6 +73,8 @@ static func from_bytes(bytes: PackedByteArray) -> SpriteFormat:
processed_palette_images += 1
palette_image_offset += data.get_byte_length()
+ assert(sprite_format.palette_image_data.size() == sprite_format.palette_image_count)
+
sprite_format.rgba_image_data = [] as Array[RGBAImageData]
var rgba_image_offset = palette_image_offset
var processed_rgba_images = 0
@@ -94,6 +96,8 @@ static func from_bytes(bytes: PackedByteArray) -> SpriteFormat:
processed_rgba_images += 1
rgba_image_offset += data.get_byte_length()
+ assert(sprite_format.rgba_image_data.size() == sprite_format.rgba_image_count)
+
sprite_format.palette = [] as Array[PaletteColor]
var palette_offset = rgba_image_offset
while palette_offset < bytes.size():
@@ -127,6 +131,19 @@ func save_to_file(base_dir: String = ""):
var path = "%s/%s.png" % [base_dir, str(idx).pad_zeros(3)]
image.save_png(path)
+
+ for idx in rgba_image_data.size():
+ var data: RGBAImageData = rgba_image_data[idx]
+ var image = Image.create_from_data(
+ data.width,
+ data.height,
+ false,
+ Image.FORMAT_RGBA8,
+ data.data
+ )
+
+ var path = "%s/%s.png" % [base_dir, str(idx).pad_zeros(3)]
+ image.save_png(path)
func files_exist() -> bool: