Files
gen1recomp/tests/engine/gen2_trainer_card_text_palette_test.lua
T
2026-08-26 12:04:06 -04:00

70 lines
2.4 KiB
Lua

-- TrainerCard had two palette gaps: its own text drew through flat
-- Chrome.print/cursor, fixed with a print/:cursor pair routed through
-- printThrough/cursorThrough via self:colorsAt; and drawPanel() painted
-- the screen with a flat white rectangle before anything else, leaving the
-- NAME/ID/MONEY/STATUS/BADGES interiors white, fixed by routing that fill
-- through Chrome.paletteFill.
package.path = "./?.lua;./?/init.lua;" .. package.path
local T = require("tests.harness")
love = require("tests.love_stub")
require("src.core.Logger").warn = function() end
local GbcPalette = require("src.render.GbcPalette")
local TrainerCard = require("src.ui.gen2.TrainerCard")
GbcPalette.available = function() return true end
GbcPalette.setCustomRamp({ { 255, 0, 255 }, { 200, 0, 200 }, { 100, 0, 100 },
{ 0, 0, 0 } })
local calls
local function spy(name)
local original = GbcPalette[name]
GbcPalette[name] = function(...)
calls[name] = (calls[name] or 0) + 1
return original(...)
end
end
local function fakeCard()
return {
colorsAt = function() return { { 255, 255, 255 }, { 200, 0, 200 },
{ 100, 0, 100 }, { 0, 0, 0 } } end,
}
end
do
calls = {}
spy("resolve"); spy("use"); spy("with")
TrainerCard.print(fakeCard(), "NAME/", 2, 2)
T.check((calls.resolve or 0) > 0 or (calls.use or 0) > 0 or (calls.with or 0) > 0,
"TrainerCard:print() reaches the GbcPalette seam via self:colorsAt")
end
do
calls = {}
spy("resolve"); spy("use"); spy("with")
TrainerCard.cursor(fakeCard(), 18, 15)
T.check((calls.resolve or 0) > 0 or (calls.use or 0) > 0 or (calls.with or 0) > 0,
"TrainerCard:cursor() reaches the GbcPalette seam via self:colorsAt")
end
-- drawPanel() painted the whole screen with a flat white rectangle before
-- drawing the card, and self:frame only draws border tiles, so panel
-- interiors stayed white regardless of the picked palette. drawCard is
-- stubbed here to isolate that base fill from the print/cursor seam
-- covered above.
do
local fake = { styled = function() return true end, page = 1,
drawCard = function() end }
calls = {}
spy("resolve"); spy("use"); spy("with")
TrainerCard.drawPanel(fake)
T.check((calls.resolve or 0) > 0 or (calls.use or 0) > 0 or (calls.with or 0) > 0,
"TrainerCard:drawPanel()'s base fill reaches the GbcPalette seam")
end
T.finish()