75 lines
3.4 KiB
Lua
75 lines
3.4 KiB
Lua
-- YataiDON-HSS: DAN_SELECT paint surface (ROUND 57, r57-dani-leftovers).
|
|
--
|
|
-- The ROUND 53/54 referral closed: DAN_SELECT never had a Lua hook, so the
|
|
-- selection cursor's 60-frame breathing loop and the two arrow chips lived as
|
|
-- inline C++ sample tables (dan_select.cpp ROUND 17). The engine now hands
|
|
-- the draw to this class when it loads (DanNavigator::load_paint_surface),
|
|
-- keeping WHEN (selected-chip x, ms since the last ribbon step) in C++ and
|
|
-- WHAT here, sampled from the cabinet's own clips through anim/sampler:
|
|
--
|
|
-- anim/dan_cursor : dani_select.nulm #267 (cursor_big), track #259@0 alpha,
|
|
-- 60-frame loop -- the dense export (29 rows) replaces the
|
|
-- C++ every-5th-frame 12-point table (real floor 0.25 at
|
|
-- f29; the coarse table said 0.301 at f30).
|
|
-- anim/dan_arrow : dani_select.nulm #263 (arrow_right), track #261@0 --
|
|
-- tx 0->10 over f0..60, alpha 1 to f30 then out at f60,
|
|
-- labels arrow_on=0 / arrow_off=61. Non-looping: plays on
|
|
-- a move and parks invisible. arrrow_left (#266) is the
|
|
-- same authored clip mirrored, so one export drives both
|
|
-- (outward = +drift right / -drift left).
|
|
--
|
|
-- FAIL-SOFT both ways: if this file or a table is missing/malformed the
|
|
-- engine keeps its inline tables; if only a table is missing, the NULL clip's
|
|
-- nils fall through to the same constants the C++ uses.
|
|
DanSelect = {}
|
|
DanSelect.__index = DanSelect
|
|
|
|
local _ok, anim = pcall(require, "anim/sampler")
|
|
if not _ok then anim = { safe = function()
|
|
local n = {}
|
|
n.at = function() return nil end; n.get = function() return nil end
|
|
n.label = function() return nil end; n.has = function() return false end
|
|
n.first = function() return 0 end; n.last = function() return 0 end
|
|
return n
|
|
end } end
|
|
|
|
local CUR = anim.safe("anim/dan_cursor")
|
|
local ARW = anim.safe("anim/dan_arrow")
|
|
local ARW_OFF = ARW:label("arrow_off") or 61
|
|
|
|
function DanSelect.new()
|
|
-- No real clip data at all -> hand the whole draw back to the engine's
|
|
-- inline tables (returning nil leaves fn_draw_cursor invalid, C++ side).
|
|
if not CUR:has("#259@0") and not ARW:has("#261@0") then return nil end
|
|
local self = setmetatable({}, DanSelect)
|
|
self.t_cursor = tex.load_texture("dan_select/box/cursor")
|
|
self.t_arrow_r = tex.load_texture("dan_select/box/arrow_r")
|
|
self.t_arrow_l = tex.load_texture("dan_select/box/arrow_l")
|
|
return self
|
|
end
|
|
|
|
-- pos: selected chip x (the textures' own json positions carry the rest);
|
|
-- now_ms: engine clock; moved_ms: ms since the last ribbon step (-1 = never).
|
|
function DanSelect:draw_cursor(pos, now_ms, moved_ms)
|
|
if self.t_cursor then
|
|
local f = (now_ms * 0.06) % 60
|
|
local a = CUR:get("#259@0", f, "a") or 1
|
|
tex.draw_texture(self.t_cursor, { x = pos, fade = a })
|
|
end
|
|
if moved_ms and moved_ms >= 0 then
|
|
local f = moved_ms * 0.06
|
|
if f <= (ARW_OFF - 1) then
|
|
local drift = ARW:get("#261@0", f, "tx") or 0
|
|
local a = ARW:get("#261@0", f, "a") or 0
|
|
if a > 0 then
|
|
if self.t_arrow_r then
|
|
tex.draw_texture(self.t_arrow_r, { x = pos + drift, fade = a })
|
|
end
|
|
if self.t_arrow_l then
|
|
tex.draw_texture(self.t_arrow_l, { x = pos - drift, fade = a })
|
|
end
|
|
end
|
|
end
|
|
end
|
|
end
|