Create OutputLine class for convenience

This commit is contained in:
Dusk 2024-02-18 19:33:11 +01:00
parent ab35815fc5
commit 8950d352ba
2 changed files with 13 additions and 24 deletions

View File

@ -72,12 +72,12 @@ def write_translated(outfile, origfile, translation_file_paths):
if amount <= 0: if amount <= 0:
break break
if structure[0][3] == 'Line_ContinueAfterTyping': if structure[0].type == 'Line_ContinueAfterTyping':
amount += 1 amount += 1
_printed_line += structure[0][2] _printed_line += structure[0].text_jp
outfile.write( outfile.write(
unidecode(structure.pop(0)[1]).replace("\\", "¥") unidecode(structure.pop(0).text_en).replace("\\", "¥")
) )
amount -= 1 amount -= 1

View File

@ -3,6 +3,11 @@
import os import os
import config 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): def get_functions_from_file(filepath: str):
""" """
@ -98,27 +103,11 @@ def parse_to_structure(filename: str):
function_name = token[0] function_name = token[0]
if function_name == "OutputLine": if function_name == "OutputLine":
text_jp = token[2][1:-1] structure.append(OutputLine(
text_en = token[4][1:-1] text_jp=token[2][1:-1].replace('\\', ''),
line_type = token[-1] text_en=token[4][1:-1].replace('\\', ''),
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
])
elif ( elif (
function_name == "OutputLineAll" function_name == "OutputLineAll"