Files
YataiDONNijiiro/Scripts/global/indicator.lua
2026-09-30 15:29:22 -04:00

64 lines
2.2 KiB
Lua

-- Control-guide panel (drum + arrows) shown while a screen asks for input.
Indicator = {}
Indicator.__index = Indicator
Indicator.State = {
SKIP = 0,
SIDE = 1,
SELECT = 2,
WAIT = 3,
}
local FRAME_STEP = 2 -- arcade frames per baked frame
local ARCADE_FPS = 60
function Indicator.new(state)
local self = setmetatable({}, Indicator)
self.state = state
self.background = tex.get_texture("global/indicator/background")
self.frame_count = tex.get_texture_info("indicator", "background").frame_count
self.t0 = tex.get_current_ms()
return self
end
function Indicator:update(current_ms) end
local SPLIT, DECIDE_END = math.floor(420 / FRAME_STEP), math.floor(650 / FRAME_STEP) -- cells 210..324 = both sticks + 決定
__hss_costume_panel = __hss_costume_panel or {}
__hss_entry_guide = __hss_entry_guide or nil -- { ms, phase = "side" | "mode", count } from the entry scripts
local dd_ok, dan_doors = pcall(require, "song_select/dan_doors")
function Indicator:draw(x, y, fade)
fade = fade or 1.0
if dd_ok and not dan_doors.drawn_this_frame() and dan_doors.draw() then return end
-- costume menu hides the guide (its title box overlaps this panel)
local now = tex.get_current_ms()
for _, t in pairs(__hss_costume_panel) do
if now - t < 100 then return end
end
-- entry phases (from entry.lua): TaikoSelect hides the guide, multi-board ModeSelect shows "all"
local g = __hss_entry_guide
local show_all = false
if g and now - g.ms < 100 then
if g.phase == "side" then return end
show_all = (g.phase == "mode") and (g.count or 1) > 1
end
local elapsed = tex.get_current_ms() - self.t0
local frame
if (y or 0) >= 1 or show_all then
frame = math.floor(elapsed / 1000 * ARCADE_FPS / FRAME_STEP) % SPLIT
if (y or 0) >= 1 then y = y - 1 end
else
local n = DECIDE_END - SPLIT
frame = SPLIT + math.floor(elapsed / 1000 * ARCADE_FPS / FRAME_STEP) % n
end
tex.draw_texture(self.background, { frame = frame, x = x, y = y, fade = fade })
end
-- DAN_SELECT's top draw slot: plays the shutter's open half.
function Indicator:draw_top()
if dd_ok then dan_doors.draw_open() end
end