diff --git a/src/orig.py b/src/orig.py index df9ffdd..2bc44ac 100755 --- a/src/orig.py +++ b/src/orig.py @@ -72,12 +72,12 @@ def write_translated(outfile, origfile, translation_file_paths): if amount <= 0: break - if structure[0][3] == 'Line_ContinueAfterTyping': + if structure[0].type == 'Line_ContinueAfterTyping': amount += 1 - _printed_line += structure[0][2] + _printed_line += structure[0].text_jp outfile.write( - unidecode(structure.pop(0)[1]).replace("\\", "¥") + unidecode(structure.pop(0).text_en).replace("\\", "¥") ) amount -= 1 diff --git a/src/parser.py b/src/parser.py index e839a65..8f9afef 100755 --- a/src/parser.py +++ b/src/parser.py @@ -3,6 +3,11 @@ import os import config +class OutputLine(): + def __init__(self, text_jp: str, text_en: str, type: str): + self.text_jp = text_jp + self.text_en = text_en + self.type = type def get_functions_from_file(filepath: str): """ @@ -98,27 +103,11 @@ def parse_to_structure(filename: str): function_name = token[0] if function_name == "OutputLine": - text_jp = token[2][1:-1] - text_en = token[4][1:-1] - line_type = token[-1] - - dialogue = text_en.replace('\\', '') - - if line_type == "Line_Normal": - dialogue += "\\" - elif line_type == "Line_WaitForInput": - dialogue += "@" - elif line_type == "Line_ContinueAfterTyping": - pass - else: - raise Exception("Unhandled output termination") - - structure.append([ - "OutputLine", - dialogue, - text_jp, - line_type - ]) + structure.append(OutputLine( + text_jp=token[2][1:-1].replace('\\', ''), + text_en=token[4][1:-1].replace('\\', ''), + type=token[-1], + )) elif ( function_name == "OutputLineAll"