Files
YataiDON14/Scripts/result/result_background.lua
T
2026-10-02 14:07:44 +08:00

74 lines
3.5 KiB
Lua

local function draw_background_tiles(player_num, width, fade)
local screen_h = tex.get_screen_height()
local screen_w = tex.get_screen_width()
local x = 0
if player_num == 3 then -- TWO_PLAYER
local bg1 = tex.get_texture("result/background/background_1p")
local bg2 = tex.get_texture("result/background/background_2p")
local ft1 = tex.get_texture("result/background/footer_1p")
local ft2 = tex.get_texture("result/background/footer_2p")
local info = tex.get_texture_info("background", "footer_1p")
local fh = info and info.height or 0
while x < width do
if bg1 then tex.draw_texture(bg1, { x = x, y = -screen_h / 2, fade = fade }) end
if bg2 then tex.draw_texture(bg2, { x = x, y = screen_h / 2, fade = fade }) end
if ft1 then tex.draw_texture(ft1, { x = x, y = -(fh / 2), fade = fade }) end
if ft2 then tex.draw_texture(ft2, { x = x, y = screen_h - fh / 2, fade = fade }) end
x = x + screen_w / 5
end
elseif player_num == 4 then -- DAN: the parent's 256x720 tile is drawn at 0.75 (540 tall) here,
-- so the parent's two rows at -h/2 and +h/2 leave a band at 180..360 uncovered (the
-- previous screen shows through: the engine does not clear between frames).
-- Stack rows until the 720-tall canvas is covered; footers keep the parent's placement
-- but use the drawn height.
local bg = tex.get_texture("result/background/background_4p")
local ft = tex.get_texture("result/background/footer_4p")
local bi = tex.get_texture_info("background", "background_4p")
local fi = tex.get_texture_info("background", "footer_4p")
local bh = (bi and bi.y2 and bi.y2[1]) or screen_h
local fh = (fi and fi.y2 and fi.y2[1]) or 0
if bh <= 0 then bh = screen_h end
while x < width do
if bg then
local y = -screen_h / 2
while y < screen_h do
tex.draw_texture(bg, { x = x, y = y, fade = fade })
y = y + bh
end
end
if ft then tex.draw_texture(ft, { x = x, y = -(fh / 2), fade = fade }) end
if ft then tex.draw_texture(ft, { x = x, y = screen_h - fh / 2, fade = fade }) end
x = x + screen_w / 5
end
else
local ps = tostring(player_num) .. "p"
local bg = tex.get_texture("result/background/background_" .. ps)
local ft = tex.get_texture("result/background/footer_" .. ps)
local info = tex.get_texture_info("background", "footer_" .. ps)
local fh = info and info.height or 0
while x < width do
if bg then tex.draw_texture(bg, { x = x, y = -screen_h / 2, fade = fade }) end
if bg then tex.draw_texture(bg, { x = x, y = screen_h / 2, fade = fade }) end
if ft then tex.draw_texture(ft, { x = x, y = -(fh / 2), fade = fade }) end
if ft then tex.draw_texture(ft, { x = x, y = screen_h - fh / 2, fade = fade }) end
x = x + screen_w / 5
end
end
end
ResultBackground = {}
ResultBackground.__index = ResultBackground
function ResultBackground.new(player_num, width)
local self = setmetatable({}, ResultBackground)
self.player_num = player_num
self.width = width
return self
end
function ResultBackground:draw()
draw_background_tiles(self.player_num, self.width, 1.0)
local rt = tex.get_texture("result/background/result_text")
if rt then tex.draw_texture(rt) end
end