mirror of
https://github.com/bryanthaboi/gen1recomp
synced 2026-10-08 09:42:55 -04:00
Cut Ruby and Sapphire's starter category by characters
The starter selection labels a starter with its category's first 11 characters (pokeruby/src/starter_choose.c:522), but cut the string at 11 bytes. An English category fits, but a translated one can be written in multi-byte UTF-8: a Japanese category, three bytes a character, was cut in the middle of its fourth character, and an accented letter can be cut the same way. The label now keeps 11 characters (FrlgFont.truncate).
This commit is contained in:
@@ -19,8 +19,9 @@ function Policy.labelRect(man, selection)
|
||||
return c[1] * 8 + 4, c[2] * 8, (c[1] + 13) * 8 + 4, (c[2] + 4) * 8
|
||||
end
|
||||
|
||||
-- pokeruby/src/starter_choose.c:522
|
||||
function Policy.categoryText(category, pokemon)
|
||||
return category:sub(1, 11) .. " " .. pokemon
|
||||
return require("src.ui.game3.frlg_font").truncate(category, 11) .. " " .. pokemon
|
||||
end
|
||||
|
||||
-- pokeruby/src/sprite.c:1302
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env luajit
|
||||
-- pokeruby/src/starter_choose.c:522
|
||||
|
||||
package.path = "./?.lua;./?/init.lua;" .. package.path
|
||||
|
||||
local T = require("tests.harness")
|
||||
local eq = T.eq
|
||||
|
||||
local Policy = require("src.ui.game3.rs.starter_choose_policy")
|
||||
|
||||
T.suite("rs starter category")
|
||||
|
||||
eq(Policy.categoryText("WOOD GECKO", "POKéMON"), "WOOD GECKO POKéMON", "a short category is kept whole")
|
||||
eq(Policy.categoryText("ABCDEFGHIJKLMN", "POKéMON"), "ABCDEFGHIJK POKéMON", "a long category keeps 11 characters")
|
||||
eq(Policy.categoryText("もりトカゲ", "ポケモン"), "もりトカゲ ポケモン", "a 15-byte Japanese category is kept whole")
|
||||
eq(Policy.categoryText("ぬまうお", "ポケモン"), "ぬまうお ポケモン", "a 12-byte Japanese category is kept whole")
|
||||
eq(Policy.categoryText("もりトカゲポケモンのなかま", "ポケモン"), "もりトカゲポケモンのな ポケモン",
|
||||
"a Japanese category keeps 11 whole characters")
|
||||
eq(Policy.categoryText("ÉCLAIRÉCLAIRÉ", "POKéMON"), "ÉCLAIRÉCLAI POKéMON", "accented letters count as one character")
|
||||
|
||||
T.finish("rs starter category")
|
||||
Reference in New Issue
Block a user