mirror of
https://github.com/bryanthaboi/gen1recomp
synced 2026-10-07 17:31:35 -04:00
5528a92a59
Since v0.3.29, Menu:draw sets the black text color only inside its title branch, where the title's white backing is drawn. A menu without a title, such as the Red/Blue/Yellow main menu (CONTINUE, NEW GAME, OPTION), printed its choices in whatever color was current: the white the box's fill and the previous frame leave behind. Tile glyphs are black on transparent and come out black whatever the color, so English never showed it, but a translation's TTF font draws in the current color and printed every choice white on white; only the tile cursor stayed visible. The choices are now drawn after an unconditional black, as before v0.3.29, with or without a title.
47 lines
1.7 KiB
Lua
47 lines
1.7 KiB
Lua
-- A Menu without a title (the main menu's CONTINUE / NEW GAME / OPTION, the
|
|
-- START menu) draws its choices in black. The color used to be set only in
|
|
-- the title branch, so the choices took the white left by the box and the
|
|
-- previous frame: invisible as tiles never showed it, but a translation's
|
|
-- TTF font draws in the current color and printed every choice white on white.
|
|
--
|
|
-- luajit tests/engine/menu_labels_black_without_title.lua
|
|
|
|
package.path = "./?.lua;./?/init.lua;" .. package.path
|
|
|
|
local T = require("tests.modkit")
|
|
local Font = require("src.render.Font")
|
|
local Menu = require("src.ui.Menu")
|
|
|
|
local drawn = {}
|
|
local stockDraw = Font.draw
|
|
Font.draw = function(text, x, y)
|
|
local r, g, b, a = love.graphics.getColor()
|
|
drawn[#drawn + 1] = { text = text, color = ("%s,%s,%s,%s"):format(r, g, b, a) }
|
|
return 0
|
|
end
|
|
|
|
local function colorsOf(menu)
|
|
drawn = {}
|
|
love.graphics.setColor(1, 1, 1, 1)
|
|
menu:draw()
|
|
local out = {}
|
|
for _, d in ipairs(drawn) do out[d.text] = d.color end
|
|
return out
|
|
end
|
|
|
|
local items = { { label = "CONTINUE" }, { label = "NEW GAME" }, { label = "OPTION" } }
|
|
local plain = colorsOf(Menu.new({}, items, { tx = 0, ty = 0 }))
|
|
for _, it in ipairs(items) do
|
|
T.eq(plain[it.label], "0,0,0,1", it.label .. " is drawn black in a menu without a title")
|
|
end
|
|
|
|
local titled = colorsOf(Menu.new({}, { { label = "RED" } }, { tx = 0, ty = 0, title = "NAME" }))
|
|
T.eq(titled.NAME, "0,0,0,1", "a title is drawn black")
|
|
T.eq(titled.RED, "0,0,0,1", "and so are the choices under it")
|
|
|
|
local r, g, b, a = love.graphics.getColor()
|
|
T.eq(("%s,%s,%s,%s"):format(r, g, b, a), "1,1,1,1", "the menu still hands white back to the next draw")
|
|
|
|
Font.draw = stockDraw
|
|
T.finish("menu_labels_black_without_title")
|