3,104
edits
(I hadn't realized the wiki had an icon for the Drake. Added that.) |
No edit summary |
||
Line 45: | Line 45: | ||
while i < len(text): | while i < len(text): | ||
if text[i] == '\x0e': | if text[i] == '\x0e': | ||
i += 1 | |||
tag = text[i:i+2] | |||
extra_size = ord(text[i+2]) // 2 | |||
i += 3 | |||
if tag == '\x00\x00': | |||
if include_ruby: | if include_ruby: | ||
furigana = text[i + | kanji_count = ord(text[i]) // 2 | ||
furigana_count = ord(text[i+1]) // 2 | |||
furigana = text[i+2 : i+2 + furigana_count] | |||
kanji = text[i+2 + furigana_count : i+2 + furigana_count + kanji_count] | |||
out += f"<ruby>{kanji}<rt>{furigana}</rt></ruby>" | out += f"<ruby>{kanji}<rt>{furigana}</rt></ruby>" | ||
i += kanji_count | |||
i += extra_size | |||
i += | |||
continue | continue | ||
if | if tag == '\x00\x02': | ||
if include_textsize: | if include_textsize: | ||
out += f"[text size: {hex(ord(text[i | out += f"[text size: {hex(ord(text[i]))}]" | ||
i += | i += extra_size | ||
continue | continue | ||
if | if tag == '\x00\x03': | ||
if text[i | if text[i] == '\uffff': | ||
# out += "[white]" | # out += "[white]" | ||
if color: | if color: | ||
out += f"}}}}" | out += f"}}}}" | ||
color = False | color = False | ||
elif ord(text[i | elif ord(text[i]) in colors: | ||
# out += "[orange]" | # out += "[orange]" | ||
if color: | if color: | ||
out += f"}}}}" | out += f"}}}}" | ||
out += f"{{{{color|2={colors[ord(text[i | out += f"{{{{color|2={colors[ord(text[i])]}|" | ||
color = True | color = True | ||
else: | else: | ||
out += f"[unknown color: {hex(ord(text[i | out += f"[unknown color: {hex(ord(text[i]))}]" | ||
i += | i += extra_size | ||
continue | continue | ||
if | if tag == '\x00\x04': | ||
out += textbox_separator | out += textbox_separator | ||
i += | i += extra_size | ||
continue | continue | ||
if text[i : i + | if tag[0] == '\x01': | ||
detail = ord(text[i | name_len = ord(text[i]) // 2 | ||
var_name = text[i+1 : i+1 + name_len] | |||
assert(text[i+1 + name_len : i+1 + name_len + 2] == "\u0100\u0000") | |||
if include_variables: | |||
out += f"[variable: {hex(ord(text[i-2]))} \"{var_name}\"]" | |||
else: | |||
out += "_" | |||
i += extra_size | |||
continue | |||
if tag == '\x07\x01': | |||
detail = ord(text[i]) | |||
assert(detail & 0x00FF == 0xcd) | assert(detail & 0x00FF == 0xcd) | ||
button_id = (detail & 0xFF00) >> 8 | button_id = (detail & 0xFF00) >> 8 | ||
out += f"[button: {buttons[button_id] if button_id < len(buttons) else hex(button_id)}]" | out += f"[button: {buttons[button_id] if button_id < len(buttons) else hex(button_id)}]" | ||
i += | i += extra_size | ||
continue | continue | ||
if | if tag == '\x15\x00': | ||
if include_sound: | if include_sound: | ||
detail = ord(text[i | detail = ord(text[i]) | ||
high = | high = detail >> 8 | ||
low = detail & 0x00FF | low = detail & 0x00FF | ||
character = characters[high] | character = characters[high] | ||
out += f"[{character} thinking sound]" | out += f"[{character} thinking sound]" | ||
i += extra_size | |||
i += | |||
continue | continue | ||
if | if tag == '\x15\x01': | ||
if include_lookat: | if include_lookat: | ||
detail = ord(text[i | detail = ord(text[i]) | ||
character_name = characters[detail >> 8] | |||
target = characters[detail & 0x00FF] | |||
target = characters[ | |||
out += f"[look at: {character_name} -> {target}]" | out += f"[look at: {character_name} -> {target}]" | ||
i += extra_size | |||
i += | |||
continue | continue | ||
if | if tag == '\x17\x01': | ||
if include_pauses: | if include_pauses: | ||
out += f"[pause: {ord(text[i])}]" | |||
out += f"[pause: { | i += extra_size | ||
i += | |||
continue | continue | ||
if | if tag == '\x17\x02': | ||
detail = ord(text[i]) | |||
high = | high = detail >> 8 | ||
low = | low = detail & 0x00FF | ||
if low == 0x19: | if low == 0x19: | ||
character_name = characters[high] | character_name = characters[high] | ||
Line 165: | Line 151: | ||
out += f"(speaker mismatch, should be {characters[high]}) " | out += f"(speaker mismatch, should be {characters[high]}) " | ||
i += | i += extra_size | ||
continue | |||
if tag == '\x17\x03': | |||
if include_autoadvance: | |||
out += f"[advance automatically]" | |||
i += extra_size | |||
continue | continue | ||
if | if tag == '\x17\x04': | ||
name_len = ord(text[i]) // 2 | |||
sound_name = text[i+1 : i+1 + name_len] | |||
if include_sound: | if include_sound: | ||
out += "\"]" | out += f"[sound: \"{sound_name}\", {ord(text[i+1 + name_len]) >> 8}]" | ||
i += | i += extra_size | ||
continue | continue | ||
out += f"[ | out += f"[unknown tag: {ord(tag[0])}, {ord(tag[1])}: \"{text[i:i+extra_size]}\"]" | ||
i += | i += extra_size | ||
continue | continue | ||