forked from GanYiZhong/YataiDON14
223 lines
8.9 KiB
Lua
223 lines
8.9 KiB
Lua
-- YataiDONJuuyon entry screen. PyTaikoGreen's Entry with juu-yon's look (scenes/entry.tscn,
|
|
-- scenes/main_menu.tscn, scenes/objects/bumpin_panel.tscn, scenes/objects/control_banner.tscn):
|
|
-- * SELECT_SIDE = Taiko 14's player_entry.swg (stage, drum holes, 太鼓を叩いてスタート signs);
|
|
-- * SELECT_MODE = juu-yon's "Main Menu" (boards: Scripts/entry/box.lua);
|
|
-- * header TaikoText "Player Entry" / "Main Menu" in the BannerTop; control banner at the bottom.
|
|
-- Numbers: Graphics/entry/MAPPING.md "Round 2". No engine change.
|
|
Entry = {}
|
|
Entry.__index = Entry
|
|
|
|
local SS = tex.get_screen_scale()
|
|
-- juu-yon's outline widths look too heavy at this skin's 960 px (user, 2026-09-27): every text
|
|
-- outline is drawn at OUTLINE_K of the juu-yon value.
|
|
local OUTLINE_K = 0.6
|
|
local WHITE, BLACK, DARK = { 255, 255, 255 }, { 0, 0, 0 }, { 27, 27, 27 }
|
|
local function rgba(c) return { c[1], c[2], c[3], 255 } end
|
|
|
|
-- keyed str -> colours -> size / outline radius (no key string built per lookup)
|
|
local text_cache = {}
|
|
local function raw_text(str, size, fill, outline, radius_px)
|
|
if not str or str == "" then return nil end
|
|
local k2 = ((fill[1] * 256 + fill[2]) * 256 + fill[3]) * 16777216
|
|
+ (outline[1] * 256 + outline[2]) * 256 + outline[3]
|
|
local k3 = size * 4096 + radius_px * 16
|
|
local by_str = text_cache[str]
|
|
local by_col = by_str and by_str[k2]
|
|
local t = by_col and by_col[k3]
|
|
if t == nil then
|
|
t = text.create_raw_text(str, size, rgba(fill), rgba(outline), false, radius_px * OUTLINE_K / SS, 2.0) or false
|
|
if not by_str then by_str = {}; text_cache[str] = by_str end
|
|
if not by_col then by_col = {}; by_str[k2] = by_col end
|
|
by_col[k3] = t
|
|
end
|
|
return t or nil
|
|
end
|
|
|
|
-- draw params reused call to call (tex.draw_texture / text:draw read them on the spot)
|
|
local DRAW_C = {}
|
|
local function draw_c(t, cx, cy, fade)
|
|
if t then
|
|
DRAW_C.x, DRAW_C.y, DRAW_C.fade = math.floor(cx - t.width / 2 + 0.5), math.floor(cy - t.height / 2 + 0.5), fade
|
|
t:draw(DRAW_C)
|
|
end
|
|
end
|
|
local XY_P = {}
|
|
local function XY(x, y) XY_P.x, XY_P.y = x, y; return XY_P end
|
|
|
|
-- TaikoText: second outline (outer), first outline, white fill (radius = outline_size / 2)
|
|
local function taiko_text(str, size, first_size, first_col, second_size, second_col, cx, cy, fade)
|
|
local o = raw_text(str, size, second_col, second_col, second_size / 2)
|
|
local i = raw_text(str, size, WHITE, first_col, first_size / 2)
|
|
draw_c(o, cx, cy, fade)
|
|
draw_c(i, cx, cy, fade)
|
|
return i
|
|
end
|
|
|
|
function Entry.new()
|
|
local self = setmetatable({}, Entry)
|
|
|
|
self.bg_flicker = tex.get_animation(1, "entry")
|
|
self.side_select_fade = tex.get_animation(0, "entry")
|
|
self.bg_flicker:start()
|
|
|
|
self.bg_bg = tex.get_texture("entry/background/bg")
|
|
self.ss_footer = tex.get_texture("entry/side_select/footer")
|
|
|
|
self.taiko_guide = tex.get_texture("song_select/jy_select/taiko")
|
|
self.t14 = {}
|
|
for _, name in ipairs({ "floor", "hole_panel", "hole_front", "header_bar", "bottom_bar", "sign_1p", "sign_2p" }) do
|
|
self.t14[name] = tex.get_texture("entry/t14_entry/" .. name)
|
|
end
|
|
self.sign_ms = tex.get_current_ms()
|
|
self.start_ms = tex.get_current_ms()
|
|
self.side_frame_ms = -1
|
|
return self
|
|
end
|
|
|
|
function Entry:update(current_ms)
|
|
self.bg_flicker:update(current_ms)
|
|
self.side_select_fade:update(current_ms)
|
|
end
|
|
|
|
function Entry:start_side_select()
|
|
self.side_select_fade:start()
|
|
self.sign_ms = tex.get_current_ms()
|
|
end
|
|
function Entry:restart_side_select()
|
|
self.side_select_fade:restart()
|
|
self.sign_ms = tex.get_current_ms()
|
|
end
|
|
function Entry:get_side_select_fade() return self.side_select_fade.attribute end
|
|
|
|
-- menu_bg.tscn (gradient + mainmenu/back.png), shared by entry.tscn and main_menu.tscn
|
|
function Entry:draw_background()
|
|
tex.draw_texture(self.bg_bg)
|
|
end
|
|
|
|
-- Taiko 14 player_entry.swg: the red stage with both drum holes, and per side the 太鼓を叩いてスタート sign
|
|
-- that drops in, squashes and bobs. Positions are the swg's 640x480 px (K scales them), times 60 fps frames.
|
|
local K = tex.get_screen_width() / 640
|
|
local T14_BACK, T14_BAND = { 168, 21, 0 }, { 220, 21, 0 }
|
|
local SIGN_X, SIGN_Y, SIGN_W, SIGN_H = { 20, 340 }, 69, 280, 168
|
|
local SIGN_START = 2
|
|
|
|
local function t14_at(t, x, y, o)
|
|
if not t then return end
|
|
o = o or {}
|
|
local sx, sy = o.sx or 1, o.sy or 1
|
|
local w, h = (o.w or 0) * K, (o.h or 0) * K
|
|
tex.draw_texture(t, { x = x * K, y = y * K, frame = o.frame or 0, x2 = w * (sx - 1), y2 = h * (sy - 1),
|
|
fade = o.fade })
|
|
end
|
|
|
|
-- the sign: falls in over 10 frames, squashes (0.9 x 1.2) and springs back, then bobs
|
|
local function sign_pose(e)
|
|
if e < 10 then
|
|
local p = e / 10
|
|
return -174 + (69 + 174) * (1 - (1 - p) * (1 - p)), 1, 1
|
|
elseif e < 17 then
|
|
local p = (e - 10) / 7
|
|
return SIGN_Y + 12 * math.sin(math.pi * p), 1 - 0.1 * p, 1 + 0.2 * p
|
|
elseif e < 26 then
|
|
local p = (e - 17) / 9
|
|
return SIGN_Y + 2 * (1 - p), 0.9 + 0.1 * p, 1.2 - 0.2 * p
|
|
end
|
|
return SIGN_Y - 3 * math.sin(math.pi * 2 * ((e - 26) % 120) / 120), 1, 1
|
|
end
|
|
|
|
function Entry:draw_t14_stage()
|
|
local W, H = tex.get_screen_width(), tex.get_screen_height()
|
|
tex.draw_rect(0, 0, W, H, T14_BACK[1], T14_BACK[2], T14_BACK[3], 255)
|
|
t14_at(self.t14.floor, 0, 0)
|
|
tex.draw_rect(0, 337 * K, W, 48 * K, T14_BAND[1], T14_BAND[2], T14_BAND[3], 255)
|
|
t14_at(self.t14.hole_panel, 0, 296)
|
|
t14_at(self.t14.hole_panel, 320, 296)
|
|
end
|
|
|
|
function Entry:draw_side_select()
|
|
self.side_frame_ms = tex.get_current_ms()
|
|
self:draw_t14_stage()
|
|
local e = (tex.get_current_ms() - self.sign_ms) / (1000 / 60)
|
|
for i, name in ipairs({ "sign_1p", "sign_2p" }) do
|
|
local y, sx, sy = sign_pose(e)
|
|
local x = SIGN_X[i] + SIGN_W * (1 - sx) / 2
|
|
t14_at(self.t14[name], x, y + SIGN_H * (1 - sy),
|
|
{ frame = SIGN_START, sx = sx, sy = sy, w = SIGN_W, h = SIGN_H })
|
|
end
|
|
t14_at(self.t14.hole_front, 0, 343.9)
|
|
t14_at(self.t14.hole_front, 320, 343.9)
|
|
end
|
|
|
|
-- juu-yon joins by hitting your own drum: there are no 1P / cancel / 2P buttons.
|
|
function Entry:draw_side_select_buttons(side) end
|
|
|
|
-- touch: each sign stands for its player's drum (side 0 = P1, 2 = P2)
|
|
function Entry:side_at(x, y)
|
|
for i = 1, 2 do
|
|
local bx, by = SIGN_X[i] * K, (SIGN_Y - 6) * K
|
|
if x >= bx and x < bx + SIGN_W * K and y >= by and y < by + (SIGN_H + 12) * K then
|
|
return (i == 1) and 0 or 2
|
|
end
|
|
end
|
|
return nil
|
|
end
|
|
-- waiting for a drum: the same stage and signs
|
|
function Entry:draw_waiting() self:draw_side_select() end
|
|
|
|
-- BannerTop + ControlBanner chrome (side_select/footer.png), then per half either the join label
|
|
-- (ControlLabelP1/P2, font 32, outline 18) or, once that player is in, the select_taiko drum guide.
|
|
function Entry:draw_footer(p1_joined, p2_joined)
|
|
if (tex.get_current_ms() - self.side_frame_ms) < 100 then
|
|
t14_at(self.t14.bottom_bar, 0, 0)
|
|
return
|
|
end
|
|
tex.draw_texture(self.ss_footer)
|
|
if p1_joined then
|
|
self:draw_drum_guide()
|
|
else
|
|
local t = raw_text(tex.skin_text("jy_taiko_start_p1"), 32, WHITE, BLACK, 9)
|
|
draw_c(t, 476 / 2, (606.656 + 720) / 2)
|
|
end
|
|
if not p2_joined then
|
|
local t = raw_text(tex.skin_text("jy_taiko_start_p2"), 32, WHITE, BLACK, 9)
|
|
draw_c(t, (484.16 + 960) / 2, (606.656 + 720) / 2)
|
|
end
|
|
end
|
|
|
|
local DECIDE_IN, DECIDE_OUT = { 240, 22, 8 }, { 67, 8, 1 }
|
|
local SIDE_IN, SIDE_OUT = { 65, 125, 173 }, { 16, 21, 59 }
|
|
local ENTRY_COL, MENU_COL = { 248, 72, 40 }, { 255, 39, 55 }
|
|
|
|
-- control_banner.tscn Player1 > TaikoP1 (224, 568) 192x192 + ControlLabels (see song_select.lua)
|
|
function Entry:draw_drum_guide()
|
|
local tx, ty = 224, 568
|
|
if self.taiko_guide then tex.draw_texture(self.taiko_guide, XY(tx, ty)) end
|
|
taiko_text(tex.skin_text("jy_ui_decide"), 36, 24, DECIDE_IN, 36, DECIDE_OUT, tx + 96, ty + 68)
|
|
taiko_text(tex.skin_text("jy_ui_left"), 36, 24, SIDE_IN, 36, SIDE_OUT, tx - 8, ty + 80)
|
|
taiko_text(tex.skin_text("jy_ui_right"), 36, 24, SIDE_IN, 36, SIDE_OUT, tx + 200, ty + 80)
|
|
end
|
|
|
|
-- BannerTop/TaikoText (32, 40)-(240, 80), font 42, outlines 28 / 42: "Player Entry" (first outline
|
|
-- (0.973, 0.282, 0.157)) while the curtain is shown, "Main Menu" ((1, 0.153, 0.216)) after.
|
|
function Entry:draw_player_entry()
|
|
local in_side = (tex.get_current_ms() - self.side_frame_ms) < 100
|
|
if in_side then
|
|
t14_at(self.t14.header_bar, 0, 0)
|
|
return
|
|
end
|
|
local key = in_side and "jy_player_entry" or "jy_main_menu"
|
|
local col = in_side and ENTRY_COL or MENU_COL
|
|
local s = tex.skin_text(key)
|
|
local i = raw_text(s, 42, WHITE, col, 14)
|
|
if i then taiko_text(s, 42, 28, col, 42, DARK, 32 + i.width / 2, 44) end
|
|
end
|
|
|
|
do
|
|
local T14_HC = require("global.t14_herecome")
|
|
local draw_player_entry = Entry.draw_player_entry
|
|
function Entry:draw_player_entry(...)
|
|
if draw_player_entry then draw_player_entry(self, ...) end
|
|
T14_HC.entry()
|
|
end
|
|
end
|