mirror of
https://github.com/bryanthaboi/gen1recomp
synced 2026-10-09 10:01:50 -04:00
Print Gold and Silver's Pokédex heights and weights in metric units
The #DEX page prints the US cart's height in feet and inches, with the foot and inch tiles, and its weight in pounds; the localized carts print metres and kilograms ("TAI ???m", "PDS ???kg"). A mod can now give a species its metric height and weight the way it can on Red/Blue: mod.content.pokemon:patch(id, { dexEntry = { heightM = ..., weightKg = ... } }). src/core/gen2/PokedexText.lua copies them onto the #DEX entry beside the cart's own values, and the page then prints them with one decimal and a comma, right-aligned before the "m" and "kg" labels, "???" until the species is caught; the printout draws the same body, and the plain page drawn without the cache's dex sheet prints the metric values as it prints the imperial ones. The Gen 2 pokemon schema declares the dexEntry fields the #DEX page reads.
The Pokédex resolves the "m" and "kg" labels when it opens (PokedexMenu.new) rather than on every frame.
This commit is contained in:
@@ -39,4 +39,41 @@ check(has("???") and has("lb") and not has("GR. ???m"), "an entry without metric
|
||||
|
||||
Font.draw = fontDraw
|
||||
|
||||
local PokedexText = require("src.core.gen2.PokedexText")
|
||||
local data = {
|
||||
gen2Pokedex = { entries = { CHIKORITA = { dex = 152, kind = "LEAF", height = 211, weight = 141 } } },
|
||||
pokemon = { CHIKORITA = { dexEntry = { heightM = 0.9, weightKg = 6.4 } } },
|
||||
}
|
||||
PokedexText.apply(data)
|
||||
local entry = data.gen2Pokedex.entries.CHIKORITA
|
||||
check(entry.heightM == 0.9 and entry.weightKg == 6.4 and entry.height == 211,
|
||||
"a mod's metric values reach the #DEX entry beside the US cart's")
|
||||
|
||||
local PokedexMenu = require("src.ui.gen2.PokedexMenu")
|
||||
local texts, tiles
|
||||
local menu = setmetatable({ page = 1, metricLabels = { "m", "kg" } }, { __index = PokedexMenu })
|
||||
function menu:text(str, tx, ty) texts[#texts + 1] = { tostring(str), tx, ty } end
|
||||
function menu:tile(id, tx, ty) tiles[#tiles + 1] = { id, tx, ty } end
|
||||
for _, name in ipairs({ "fill", "border", "blank", "drawPic", "drawFootprint" }) do menu[name] = function() end end
|
||||
function menu:cursorVisible() return false end
|
||||
function menu:monName() return "CHIKORITA" end
|
||||
local function at(str, tx, ty)
|
||||
for _, t in ipairs(texts) do if t[1] == str and t[2] == tx and t[3] == ty then return true end end
|
||||
return false
|
||||
end
|
||||
texts, tiles = {}, {}
|
||||
menu:drawEntryBody({ species = "CHIKORITA", caught = true }, entry)
|
||||
check(at("0,9", 14, 7) and at("m", 17, 7) and at("6,4", 14, 9) and at("kg", 17, 9),
|
||||
"a caught Gen 2 entry prints its metric height and weight right-aligned before the unit")
|
||||
local footTile = false
|
||||
for _, t in ipairs(tiles) do if t[2] == 14 and t[3] == 7 then footTile = true end end
|
||||
check(not footTile and not at("lb", 17, 9), "a metric Gen 2 entry prints neither the foot mark nor the pound label")
|
||||
texts, tiles = {}, {}
|
||||
menu:drawEntryBody({ species = "CHIKORITA", caught = false }, entry)
|
||||
check(at("???", 14, 7) and at("???", 14, 9), "a seen Gen 2 entry prints the metric unknown masks")
|
||||
texts, tiles = {}, {}
|
||||
menu:drawEntryBody({ species = "CHIKORITA", caught = true },
|
||||
{ dex = 152, kind = "LEAF", height = 211, weight = 141 })
|
||||
check(at("lb", 17, 9) and not at("m", 17, 7), "an entry without metric values keeps the US fields")
|
||||
|
||||
T.finish("pokedex metric units")
|
||||
|
||||
Reference in New Issue
Block a user