Files
gen1recomp/tests/engine/prize_menu_scroll_pages_test.lua
thibautbus f07ebfe423 Route remaining Gen2 UI text through translations
CELADON_TM/MON and GOLDENROD_TM/MON stored each Game Corner row as one
hand-padded "NAME    COST" literal; a translated name of a different length
than the English original shifted or overlapped the price that used to be
right-aligned by the padding alone. Split each row into a translatable name
and the existing numeric cost field, print them as two separate calls (the
cost right-aligned against a fixed priceRight column per counter, the same
column-aware approach MartMenu.printPriceOpaque already uses), and clamp the
name to the tile budget before the price column with Font.split (glyph-aware,
so a <PK><MN> macro or multi-byte UTF-8 character -- including one whose
expansion straddles the clamp boundary -- is never cut mid-sequence).

TEXTS (SlotMachine.lua) kept a hand-typed English line array next to each
entry's Strings.source() template; derive the array from source once at load
instead, and cache localizedLines()'s parsed split per source table so the
bet/result screens do not re-run the same gmatch split every draw() call.

ContestMenu.TEXT.alreadyCaught's line split now uses the same gmatch loop
the rest of this file's line-parsing already uses (an anchored ^(.-)\n(.*)$
match assumed exactly one \n and left a nil hole when a translation merges
the two lines into one clause).

Four of PrizeMenu.TEXTS' Game Corner vendor messages (Celadon's and
Goldenrod's prize-vendor intros, Goldenrod's quit line, and the coin
vendor's no-COIN-CASE refusal) used \f where the real cart text
(poke-corpus GoldSilver, e.g. gs.CeladonGameCornerPrizeRoom.
CeladonPrizeRoom_PrizeVendorIntroText) ends in \v: a plain page clear
instead of a scroll, so the vendor's last line appeared alone with no
lead-in instead of continuing under the previous one. Found and confirmed
against the corpus while auditing this branch for the same class of bug as
CenterPcMenu.lua's \n-vs-\v fix.
2026-09-01 21:52:55 +02:00

33 lines
1.6 KiB
Lua

-- PrizeMenu.TEXTS' Game Corner vendor messages used \f (paragraph/clear)
-- where the real cart text ends in \v (cont/scroll), for four separate
-- messages (Celadon and Goldenrod's prize-vendor intros, Goldenrod's
-- quit line, and the coin vendor's no-COIN-CASE refusal) -- confirmed
-- against poke-corpus's GoldSilver English text (gs.CeladonGameCornerPrizeRoom.
-- CeladonPrizeRoom_PrizeVendorIntroText and siblings, which all end
-- <LINE>...<CONT>..., not <PARA>). CommonText.pages() renders \f as an
-- unrelated fresh page (no continuity) and \v as a scroll (the previous
-- line stays visible on top); with \f, the vendor's last line used to
-- appear alone with no lead-in.
package.path = "./?.lua;./?/init.lua;" .. package.path
local T = require("tests.harness")
local CommonText = require("src.core.gen2.CommonText")
local function lastPageScrolls(text, expectedTop, expectedBottom)
local pages = CommonText.pages(text)
local last = pages[#pages]
T.eq(last[1], expectedTop, "the scrolled-up line is the previous page's bottom row")
T.eq(last[2], expectedBottom, "the new line lands under it")
end
lastPageScrolls("Welcome!\fWe exchange your\ncoins for fabulous\vprizes!",
"coins for fabulous", "prizes!")
lastPageScrolls("Welcome!\fWe exchange your\ngame coins for\vfabulous prizes!",
"game coins for", "fabulous prizes!")
lastPageScrolls("OK. Please save\nyour coins and\vcome again!",
"your coins and", "come again!")
lastPageScrolls("Do you need game\ncoins?\fOh, you don't have\na COIN CASE for\vyour coins.",
"a COIN CASE for", "your coins.")
T.finish("prize_menu_scroll_pages_test")