Repository navigation
Write the port's own text in the game's message font - #64
Merged
Merged
Conversation
GameTextEncode turns UTF-8 into the s16 codes ClsMes draws, by the PAL font's table read off every language's gaiji.img and checked against every message file on the disc. GameTextFile lays texts out as a message file for ClsMes::SetBuff, and GameText draws one piece of text as the menus draw their help line, for labels, values and help in the Options screen.
SetMesWinTbl now takes nothing past MES_WIN_LINE_MAX laid-out characters, where retail writes on over the window, and GameText::Set reports a text that did not fit (its end never laid out) rather than drawing part of it. DrawMesWin draws a line past the ten line_pos entries in the block layout instead of reading beyond them. GameTextFile::Set refuses an id outside s16 and a message that would start beyond the file's s16 offsets, leaving the file as it was.
SetColour's new layout can overflow the window where a value code now prints more digits; Set reported the old count and never laid the text out again. Set now retries while nothing is laid out, and SetColour records the failure. Say plainly that every message in a file must start within its s16 offsets.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
The port's own menus need to show text in the game's own font. This adds that, as the base for the new Options screen and, later, for moving the localisations to JSON. Three commits on current
port. Nothing underps2/changes.What it is
gaiji.img's letter grid, and -0x287 to -0x254 areœ ¡ ¿ ß Œ Ç çand the accented lettersDrawGaijiFontbuilds by drawing an accent over a base letter. I read the table offgaiji.imgin everymeswin/mes_tex_N.pakand checked it by decoding every.meson the disc (about 670 files). All seven packs draw the same characters in the same cells, so one table serves every language, and each language's text uses only its own accents. It agrees withMakeMesWinTbl_value's digits and the PALNameRegistCodeJtoEtable.GameTextEncode/GameTextDecode(port/src/gametext.cpp) turn UTF-8 into those codes and back. Typographic quotes and dashes become the font's own. A character the font lacks, or a byte that isn't UTF-8, becomes?and is counted.{N}writes code N as it is (control codes, icons, colours), and{{a{. Every message on the disc decodes and encodes back to the same codes.GameTextFilelays texts out as a message file forClsMes::SetBuff. That is where JSON localisation would plug in later.GameTextis one piece of text drawn the way the menus draw their help line (CommonMenuMes2underInitMenuMesSet): the menu font, white with a black edge, shown whole.Setthe text,SetColouraFontColor, thenDraw(x, y, alpha)from a menu's draw function.Widthreturns the width, for right-aligning a value. Each holds its ownClsMes, so labels, values and a help line are one each.Limits
ClsMeshas fixed tables: 720 laid-out glyphs and ten line positions.SetMesWinTblwrote past the 720-entry table without a check. APC_OVERRIDEcopy now stops at 720; apart from that one check it is retail's body, character for character. AGameTextthat doesn't fit returns -1 and draws nothing.DrawMesWinreadline_pos[10]for an eleventh line. It now draws such a line as it draws a line with no position entry; lines 0 to 9 draw exactly as before.GameTextFilerefuses an id outside s16, and a file whose offsets don't fit in s16, instead of dropping messages.Testing
Windows (Debug, clang 23): 109 of 109. Linux (clang 23): a clean build;
ctest102 of 102 on RADV and on lavapipe;git clang-formatclean;truncations.py --checkpasses; Doxygen gives no new warning; the two recorded replays (a debug item grant, a dungeon floor) run to the end. The eightGameTexttests are pure table tests (no game data), about half a second together. macOS is not built here.Shown in the title's Options screen through a temporary hook, not part of this PR, as it will be used: "PC Settings" in gold beside the header, a label with a right-aligned value, and a line of French, German and Spanish accents.
Things you may want different
option.pac's sprite labels. The Options PR uses it for every row, which you and Dylan preferred.GameText.GameTextFileis the seam for that.