require("global/guide_panel") Entry = {} Entry.__index = Entry function Entry.new() local self = setmetatable({}, Entry) __hss_entry_reset = true self.bg_flicker = tex.get_animation(1, "entry") self.side_select_fade = tex.get_animation(0, "entry") self.bg_flicker:start() self.text_cancel = text.create_text("entry_cancel", { 255, 255, 255, 255 }, { 40, 24, 12, 255 }, false, 3, 0) self.text_credit_p = { text.create_text("entry_credit_1p", { 0, 0, 0, 255 }, { 255, 255, 255, 255 }, false, 7.0 / tex.get_screen_scale(), 0), text.create_text("entry_credit_2p", { 0, 0, 0, 255 }, { 255, 255, 255, 255 }, false, 7.0 / tex.get_screen_scale(), 0), } local CREDIT_BORDER = 7.0 / tex.get_screen_scale() self.text_credit_msg = text.create_text("entry_credit_start", { 255, 255, 255, 255 }, { 0, 0, 0, 255 }, false, CREDIT_BORDER, 0) self.text_credit_msg_hl = text.create_text("entry_credit_start", { 255, 255, 255, 255 }, { 255, 236, 67, 255 }, false, CREDIT_BORDER, 0) self.bg_bg = tex.get_texture("entry/background/bg") self.bg_tower = tex.get_texture("entry/background/tower") self.bg_shops_center = tex.get_texture("entry/background/shops_center") self.bg_people = tex.get_texture("entry/background/people") self.bg_shops_left = tex.get_texture("entry/background/shops_left") self.bg_shops_right = tex.get_texture("entry/background/shops_right") self.bg_lights = tex.get_texture("entry/background/lights") self.bg_street_lit = tex.get_texture("entry/background/street_lit") self.bg_glow = tex.get_texture("entry/background/glow") self.bg_twinkle = tex.get_texture("entry/background/twinkle") self.bg_t0 = tex.get_current_ms() self.cr_pill = tex.get_texture("entry/side_select/credit_pill") self.cr_flash = tex.get_texture("entry/side_select/credit_flash") self.cr_t0 = tex.get_current_ms() self.cr_blink_t0 = self.cr_t0 self.cr_side = 1 self.cr_frame = 0 self.cr_seen_frame = nil self.cr_decide_t0 = nil self.cr_decide_row = nil self.cr_pending_decide = nil -- side select box (entry/banapass_entry.nulm), shown after an online login local function ss(name) return tex.get_texture("entry/side_select/" .. name) end self.box = { panel = ss("box_panel"), button = { [0] = ss("button_left"), [1] = ss("button_none"), [2] = ss("button_right") }, ring = ss("select_ring"), glow = ss("select_glow"), decide_ring = ss("decide_ring"), flash = ss("decide_flash"), none_ring = ss("none_ring"), none_glow = ss("none_glow"), none_decide_ring = ss("none_decide_ring"), none_flash = ss("none_decide_flash"), } local function raw(key, size, color, outline, border) local str = tex.skin_text(key) if str == "" then return nil end return text.create_raw_text(str, size, color, outline, false, border / tex.get_screen_scale(), 0) end self.box_question = raw("entry_side_question", 46, { 255, 255, 255, 255 }, { 0, 0, 0, 255 }, 5.5) self.box_label = { [0] = raw("entry_side_left", 40, { 0, 0, 0, 255 }, { 0, 0, 0, 255 }, 0), [1] = raw("entry_side_none", 32, { 0, 0, 0, 255 }, { 0, 0, 0, 255 }, 0), [2] = raw("entry_side_right", 40, { 0, 0, 0, 255 }, { 0, 0, 0, 255 }, 0), } self.box_ms = nil -- last frame the box was drawn (a decide then belongs to it, not the rows) self.box_decide = nil -- { t0, side } self.guide = GuidePanel.new() self.any_joined = false return self end function Entry:draw_control_guide() if not self.guide then return end if self.any_joined then return end self.guide:draw(GuidePanel.Loop.DECIDE, 0, 0, 1.0) end function Entry:update(current_ms) self.bg_flicker:update(current_ms) self.side_select_fade:update(current_ms) self.cr_frame = (self.cr_frame or 0) + 1 end function Entry:start_side_select() self.side_select_fade:start() self:restart_credit() end function Entry:restart_side_select() self.side_select_fade:restart() self:restart_credit() end function Entry:restart_credit() local now = tex.get_current_ms() self.cr_t0 = now self.cr_blink_t0 = now self.cr_side = 1 self.cr_decide_t0 = nil self.cr_decide_row = nil self.cr_seen_frame = nil self.cr_pending_decide = nil end function Entry:get_side_select_fade() return self.side_select_fade.attribute end local function lerp(f, f0, f1, v0, v1) if f <= f0 then return v0 end if f >= f1 then return v1 end return v0 + (v1 - v0) * (f - f0) / (f1 - f0) end local CREDIT_CX = 960 local ROW_CY = { 432 + 72, 432 + 248 } local LABEL_INK_X = CREDIT_CX - 443 local MSG_INK_X = CREDIT_CX + 190 local TEXT_INK_DY = 0.5 local PAD5 = 9 local PAD_LABEL = 2 local CANCEL_CX, CANCEL_CY = 960, 838 local ROW_LOOP_F0, ROW_LOOP_LEN = 5, 120 local DIM_UNSELECTED = 0.72 local DECIDE_FLASH_F = 24 local BG_LIT_END = 19 local ENTRY_BG_LEN = 360 -- the four twinkles: texture index, frame, start frame, scale at birth / peak / death. Each swells in -- over 30 frames on a squared curve, then drifts out over 89 more. local ENTRY_TWINKLES = { { 0, 0, 0, 0.5, 1.0, 1.5 }, { 1, 0, 120, 0.25, 0.5, 1.0 }, { 2, 1, 90, 0.5, 1.0, 1.5 }, { 3, 1, 219, 0.25, 0.5, 1.0 }, } local function twinkle_pose(tw, f) local t = f - tw[3] if t < 0 or t > 119 then return nil end if t < 30 then local u = (t / 30) ^ 2 return tw[4] + (tw[5] - tw[4]) * u, u end local u = (t - 30) / 89 return tw[5] + (tw[6] - tw[5]) * (1 - (1 - u) ^ 2), (1 - u) ^ 2 end function Entry:draw_background() local f = ((tex.get_current_ms() - self.bg_t0) * 0.06) % ENTRY_BG_LEN -- arcade frames @ 60 fps tex.draw_texture(self.bg_bg) if self.bg_twinkle then for i = 1, #ENTRY_TWINKLES do local tw = ENTRY_TWINKLES[i] local s, a = twinkle_pose(tw, f) if a and a > 0.002 then tex.draw_texture(self.bg_twinkle, { index = tw[1], frame = tw[2], center = true, scale = s, fade = a }) end end end if self.bg_glow then local ga = 1 - 0.5 * (1 - math.abs(f % 120 - 60) / 60) for i = 0, 1 do tex.draw_texture(self.bg_glow, { index = i, frame = i, fade = ga }) end end if self.bg_street_lit then local lf = (tex.get_current_ms() - self.bg_t0) * 0.06 -- monotonic, NOT wrapped if lf < BG_LIT_END then local la = lerp(lf, 5, 19, 1, 0) if la > 0.002 then tex.draw_texture(self.bg_street_lit, { fade = la }) end end end end -- banapass_entry.nulm sprite 47 at the screen centre: panel at y +19, question c35, buttons 6 / 10 / 14 at y +260 local BOX_CX, BOX_CY = 960, 540 local BOX_W, BOX_H = 1200, 896 local QUESTION_CY = BOX_CY + 109 + 48 local BUTTON_Y = BOX_CY + 260 local BUTTON_DX = { [0] = -304, [1] = 0, [2] = 304 } local BUTTON_SIZE = { [0] = { 304, 144 }, [1] = { 336, 128 }, [2] = { 304, 144 } } local LABEL_DY = 5 -- label boxes sit 5 px under the button centre local GLOW_MS, DECIDE_MS, BOX_OUT_MS = 1000, 517, 317 local function clamp01(v) return math.max(0, math.min(1, v)) end local function put(t, w, h, cx, cy, fade) if t then tex.draw_texture(t, { x = cx - w / 2, y = cy - h / 2, fade = fade }) end end -- touch: the side button (0 / 1 / 2) under a canvas point function Entry:side_at(x, y) for i = 0, 2 do local w, h = BUTTON_SIZE[i][1], BUTTON_SIZE[i][2] if math.abs(x - (BOX_CX + BUTTON_DX[i])) < w / 2 and math.abs(y - BUTTON_Y) < h / 2 then return i end end return nil end function Entry:draw_box_panel(fade) put(self.box.panel, BOX_W, BOX_H, BOX_CX, BOX_CY + 19, fade) local q = self.box_question if q then q:draw({ x = BOX_CX - q.width / 2, y = QUESTION_CY - q.height / 2, fade = fade }) end end -- buttons, the selection on `side` (21 / 28: steady ring + glow pulsing 1 -> 0 -> 1 a second) and, after a -- decide `dt` ms ago, the white ring and flash blinking three times (21 depth 2, 31 / 34) function Entry:draw_box_buttons(side, fade, dt) local b = self.box for i = 0, 2 do local w, h = BUTTON_SIZE[i][1], BUTTON_SIZE[i][2] local x = BOX_CX + BUTTON_DX[i] put(b.button[i], w, h, x, BUTTON_Y, fade) local l = self.box_label[i] if l then l:draw({ x = x - l.width / 2, y = BUTTON_Y + LABEL_DY - l.height / 2, fade = fade }) end end local w, h = BUTTON_SIZE[side][1], BUTTON_SIZE[side][2] local x = BOX_CX + BUTTON_DX[side] local none = side == 1 local ph = ((tex.get_current_ms() - self.cr_t0) % GLOW_MS) / GLOW_MS local glow = ph < 0.45 and (1 - ph / 0.45) ^ 2 or 1 - (1 - math.min(1, (ph - 0.45) / 0.47)) ^ 2 put(none and b.none_ring or b.ring, w, h, x, BUTTON_Y, fade) put(none and b.none_glow or b.glow, w, h, x, BUTTON_Y, fade * glow) if dt then local t = (dt % 167) / 167 local blink = dt < DECIDE_MS and (1 - math.abs(t * 2 - 1)) or 0 put(none and b.none_decide_ring or b.decide_ring, w, h, x, BUTTON_Y, fade * blink) put(none and b.none_flash or b.flash, w, h, x, BUTTON_Y, fade * blink * 0.9) end end function Entry:draw_side_select() self.box_ms = tex.get_current_ms() self:draw_box_panel(self.side_select_fade.attribute) end -- after the decide the engine leaves side select: the box blinks, then fades out (sprite 48 `out`) function Entry:draw_box_decide() local d = self.box_decide if not d then return end local dt = tex.get_current_ms() - d.t0 local fade = 1 - clamp01((dt - DECIDE_MS) / BOX_OUT_MS) if fade <= 0 then self.box_decide = nil return end self:draw_box_panel(fade) self:draw_box_buttons(d.side, fade, dt) end -- One player row. `row` is 1 (upper, 1P) or 2 (lower, 2P); `f` is the row timeline frame. function Entry:draw_credit_row(row, f, a) if a <= 0.002 then return end tex.draw_texture(self.cr_pill, { index = row - 1, fade = a }) local cy = ROW_CY[row] local lbl = self.text_credit_p[row] if lbl then lbl:draw({ x = LABEL_INK_X - PAD_LABEL, y = cy + TEXT_INK_DY - lbl.height / 2, fade = a }) end -- fill alpha and the outline copy colour multiply, both read from the export local ma = (f < 80) and lerp(f, 70, 80, 1, 0) or lerp(f, 80, 90, 0, 1) local yellow = lerp(f, 64, 65, 0, 1) - lerp(f, 94, 95, 0, 1) -- 0 = black outline, 1 = (256,236,67) local msg = self.text_credit_msg if msg and ma > 0.002 then local x = MSG_INK_X - msg.width / 2 local y = cy + TEXT_INK_DY - msg.height / 2 msg:draw({ x = x, y = y, fade = a * ma }) if yellow > 0.001 and self.text_credit_msg_hl then self.text_credit_msg_hl:draw({ x = x, y = y, fade = a * ma * yellow }) end end end function Entry:draw_credit(a, sel, blink_f, flash_row, flash_a, loop_rows) for row = 1, 2 do local armed = (row == sel) local ra = (sel == nil or sel == 0 or armed) and a or (a * DIM_UNSELECTED) local rf = (armed or loop_rows) and blink_f or ROW_LOOP_F0 self:draw_credit_row(row, rf, ra) end local now = tex.get_current_ms() if sel and sel > 0 then local pulse = 0.08 + 0.10 * math.sin((now - self.cr_blink_t0) * 0.006) tex.draw_texture(self.cr_flash, { index = sel - 1, fade = a * pulse }) end if flash_row and flash_a and flash_a > 0.002 then tex.draw_texture(self.cr_flash, { index = flash_row - 1, fade = a * flash_a }) end end -- the 1P / 2P rows; arcade = waiting for a drum (both rows blink), else the side select cursor after an -- online login (`side` 0 / 1 / 2 = 1P / none / 2P) function Entry:draw_credit_rows(side, arcade) local now = tex.get_current_ms() __hss_entry_guide = { ms = now, phase = "side" } if side ~= self.cr_side then self.cr_side = side self.cr_blink_t0 = now -- a newly armed row restarts its attract cycle end self.cr_seen_frame = self.cr_frame self.cr_decide_t0 = nil local fi = math.min(15, 5 + (now - self.cr_t0) * 0.06) local a = (fi - 5) / 10 local sel = (not arcade) and ((side == 0 and 1) or (side == 2 and 2) or 0) or nil local blink_f = ROW_LOOP_F0 + ((now - self.cr_blink_t0) * 0.06) % ROW_LOOP_LEN self:draw_credit(a, sel, blink_f, nil, nil, arcade) -- depth 28 > depth 23: the guide sits OVER the credit rows. self:draw_control_guide() YD_ENTRY_CREDIT_MS = now end function Entry:draw_side_select_buttons(side) __hss_entry_guide = { ms = tex.get_current_ms(), phase = "side" } self:draw_box_buttons(side, self.side_select_fade.attribute, nil) end function Entry:draw_waiting() self:draw_credit_rows(1, true) end function Entry:draw_footer(p1_joined, p2_joined) YD_ENTRY_BOTH_JOINED = (p1_joined == true and p2_joined == true) self.any_joined = (p1_joined == true or p2_joined == true) end function Entry:draw_player_entry() self:draw_credit_decide() self:draw_box_decide() end function Entry:decide_side_select(side) local now = tex.get_current_ms() if self.box_ms and now - self.box_ms < 100 then self.box_decide = { t0 = now, side = side } return end self.cr_pending_decide = (side == 2) and 2 or 1 end function Entry:draw_credit_decide() local now = tex.get_current_ms() if self.cr_seen_frame ~= nil and self.cr_decide_t0 == nil then if self.cr_frame > self.cr_seen_frame then self.cr_seen_frame = nil if self.cr_pending_decide then -- the engine told us which row entered (drum join or side select) self.cr_decide_t0 = now self.cr_decide_row = self.cr_pending_decide self.cr_pending_decide = nil elseif self.cr_side == 0 or self.cr_side == 2 then -- cursor model: side 1 is 「つかわない」 -- cancelled, not decided. self.cr_decide_t0 = now self.cr_decide_row = (self.cr_side == 0) and 1 or 2 end end end if self.cr_decide_t0 == nil then return end local t = (now - self.cr_decide_t0) * 0.06 -- frames since decide local blink = math.min(t, DECIDE_FLASH_F) % 8 local flash_a = 0.8 * ((blink < 4) and blink / 4 or (8 - blink) / 4) local fade_f = 16 + math.max(0, t - (DECIDE_FLASH_F + 1)) -- fade_out starts after local a = 1 - (math.min(fade_f, 35) - 16) / 19 if a <= 0.002 then self.cr_decide_t0 = nil return end self:draw_credit(a, nil, ROW_LOOP_F0, self.cr_decide_row, flash_a) YD_ENTRY_CREDIT_MS = now end