diff options
Diffstat (limited to 'extractor/grf.gd')
-rw-r--r-- | extractor/grf.gd | 49 |
1 files changed, 41 insertions, 8 deletions
diff --git a/extractor/grf.gd b/extractor/grf.gd index a723fdc..5b7046f 100644 --- a/extractor/grf.gd +++ b/extractor/grf.gd @@ -156,7 +156,7 @@ class FileEntry: var file_access: FileAccess -static func open(path: String): +static func open(path: String) -> GRF: var grf = GRF.new() grf.file_access = FileAccess.open(path, FileAccess.ModeFlags.READ) @@ -190,10 +190,13 @@ static func open(path: String): return grf +signal extracted_file(index: int) + func extract(destination: String = "user://client_data"): DirAccess.make_dir_recursive_absolute(destination) - for file_entry in file_entries: + for idx in file_entries.size(): + var file_entry := file_entries[idx] var file_path: String = file_entry.get_file_path() var base_directory = DirAccess.open(destination) @@ -201,6 +204,8 @@ func extract(destination: String = "user://client_data"): var file = FileAccess.open("%s/%s" % [destination, file_path], FileAccess.WRITE_READ) file.store_buffer(file_entry.get_contents(file_access)) + + extracted_file.emit(idx) func convert(destination: String = "res://client_data"): @@ -220,17 +225,40 @@ func convert(destination: String = "res://client_data"): #DirAccess.make_dir_recursive_absolute(base_file_directory_path) + # BMP + if file_path.ends_with(".bmp"): + #continue + if not FileAccess.file_exists("%s/%s" % [destination, file_path]): + continue + + # load existing bmp files, so language specific overwrites are kept + + var texture: CompressedTexture2D = load("%s/%s" % [destination, file_path]) + if not texture: + # TODO: check if .godot/imported file is there (alrdy sufficient?) + continue + + var texture_image := texture.get_image() + texture_image.decompress() + var image := BMPTexture.convert_image( + texture_image, + [Color.MAGENTA] + ) + image.save_png("%s/%s" % [destination, file_path.replace(".bmp", ".png")]) + + + continue # Sprite.spr and Action.act - var player_head_path_part = "¸Ó¸®Åë" - var player_body_path_part = "¸öÅë" + var player_head_path_part = "머리통" + var player_body_path_part = "몸통" - if file_path.ends_with(".spr") and file_path.contains(player_head_path_part): + if file_path.ends_with(".spr"): #and (file_path.contains(player_head_path_part) or file_path.contains(player_body_path_part)): continue var sprite = SpriteFormat.from_bytes(file_entry.get_contents(file_access)) sprite.save_to_file(base_file_directory_path) - elif file_path.ends_with(".act") and file_path.contains(player_head_path_part): #or file_path.contains(player_body_path_part): + elif file_path.ends_with(".act") and file_path.contains("cursors"): #and (file_path.contains(player_head_path_part) or file_path.contains(player_body_path_part)): #continue if not FileAccess.file_exists("%s/000.png.import" % base_file_directory_path): continue @@ -245,6 +273,7 @@ func convert(destination: String = "res://client_data"): ResourceSaver.save(scene, "%s/actions.tscn" % base_file_directory_path) + continue # Map.rsw and .gnd and .gat if file_path.ends_with(".rsw") and (file_path.contains("pay_dun") or file_path.contains("iz_int") or file_path.contains("int_land")): @@ -257,5 +286,9 @@ func convert(destination: String = "res://client_data"): static func decode_string(bytes: PackedByteArray): - # TODO: use iconv to decode EUC-KR - return bytes.get_string_from_ascii() + Engine.print_error_messages = false + var string := bytes.get_string_from_multibyte_char("EUC-KR") + Engine.print_error_messages = true + if string.is_empty(): + return bytes.get_string_from_ascii() + return string |