75 lines
2.5 KiB
Lua
75 lines
2.5 KiB
Lua
-- the parent skin's copy of a script: the second match on package.path (the first is this file)
|
|
local function load_parent(name)
|
|
local seen = false
|
|
for tmpl in package.path:gmatch("[^;]+") do
|
|
local chunk = loadfile((tmpl:gsub("%?", name)))
|
|
if chunk then
|
|
if seen then return chunk end
|
|
seen = true
|
|
end
|
|
end
|
|
end
|
|
|
|
assert(load_parent("game/papamama"), "game/papamama: the parent skin has no papamama script")()
|
|
|
|
-- The cabinet's board art carries no lettering, so both lines are skin text. Centre and size are in the
|
|
-- board's own pixels (1008x528); texture.json puts the board's rest left/top at (462, 552).
|
|
local BOARD_W, BOARD_H = 1008, 528
|
|
local BOARD_CX, BOARD_CY = 462 + BOARD_W / 2, 552 + BOARD_H / 2 -- where center = true anchors it
|
|
local CAPTIONS = {
|
|
{ key = "papamama_title", x = 504, y = 78, size = 70, fill = { 214, 26, 26, 255 },
|
|
rim = { 255, 255, 255, 255 }, thickness = 5 },
|
|
{ key = "papamama_body", x = 504, y = 152, size = 42, fill = { 40, 30, 20, 255 },
|
|
rim = { 255, 255, 255, 255 }, thickness = 4 },
|
|
}
|
|
|
|
-- mirrors the parent's BOARD segments so the text squashes with the board (keep in sync)
|
|
local function ease_out(p) return 1 - (1 - p) * (1 - p) end
|
|
local function ease_in(p) return p * p end
|
|
local BOARD = {
|
|
{ 417, 0, 1.045, ease_out },
|
|
{ 83, 1.045, 1, ease_in },
|
|
{ 9067, 1, 1 },
|
|
{ 67, 1, 1.047, ease_out },
|
|
{ 317, 1.047, 0, ease_in },
|
|
}
|
|
|
|
local function board_scale(t)
|
|
for _, s in ipairs(BOARD) do
|
|
if t < s[1] then
|
|
local p = t / s[1]
|
|
return s[2] + (s[3] - s[2]) * (s[4] and s[4](p) or p)
|
|
end
|
|
t = t - s[1]
|
|
end
|
|
return nil
|
|
end
|
|
|
|
local parent_new = Papamama.new
|
|
function Papamama.new()
|
|
local self = parent_new()
|
|
self.captions = {}
|
|
for i, c in ipairs(CAPTIONS) do
|
|
local s = tex.skin_text(c.key)
|
|
if s ~= "" then
|
|
self.captions[i] = { cfg = c,
|
|
text = text.create_raw_text(s, c.size, c.fill, c.rim, false, c.thickness, 2.0) }
|
|
end
|
|
end
|
|
return self
|
|
end
|
|
|
|
local parent_draw = Papamama.draw
|
|
function Papamama:draw()
|
|
parent_draw(self)
|
|
local s = board_scale(self.t)
|
|
if not s or s <= 0 then return end
|
|
for _, c in pairs(self.captions) do
|
|
c.text:draw({
|
|
x = BOARD_CX + (c.cfg.x - BOARD_W / 2) * s - c.text.width * s / 2,
|
|
y = BOARD_CY + (c.cfg.y - BOARD_H / 2) * s - c.text.height * s / 2,
|
|
scale = s,
|
|
})
|
|
end
|
|
end
|