kwsch / pkNX

Pokémon (Nintendo Switch) ROM Editor & Randomizer
https://projectpokemon.org/home/forums/topic/48647-pknx-nintendo-switch-rom-editor-randomizer/
GNU General Public License v3.0
339 stars 106 forks source link

Add ruby text support #327

Closed abcboy101 closed 1 year ago

abcboy101 commented 1 year ago

When the language is set to Japanese, PLA and SV use ruby text to display the pronunciation of kanji:

Screenshot

This adds support for displaying the ruby text in the text editor in a human-readable/editable format using the syntax {base text|ruby text}, instead of as just a long string of hex:

Diagram

Ruby text uses VAR FF01. In text from PLA and SV, the first parameter (codepoints in base) ranges from 1-12, and the second parameter (codepoints in annotation) range from 1-16. {CHECK IT OUT|チェケラ} and {防衛衛衛衛衛衛衛|ぼうえいえいえいえいえいえいえい} are the most extreme cases in-game. Ruby is only used in Japanese, though there's one line in SV in Traditional Chinese that accidentally kept it.

Note that the base text is included twice, once in the variable and again directly afterward. In PLA and SV, these are always the same as each other. I suspect that the one in the variable is only used to calculate positioning/spacing, and the subsequent text is what actually renders the base text and moves the cursor. I did add a second syntax for {base text from variable|ruby text|base text afterward} just in case though, since I didn't want to throw an exception or silently drop it while reading in game text.

In terms of backwards compatibility, this syntax does mean that { now needs to be escaped, but since it's not used in game text outside of mainland China's version of Pokémon Quest, I don't think it should be a big issue.