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

54 lines
2.1 KiB
Lua

-- DAN_SELECT paint surface: selection cursor breathing loop and arrow chips,
-- sampled from the cabinet's own clips.
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.get_texture("dan_select/box/cursor")
self.t_arrow_r = tex.get_texture("dan_select/box/arrow_r")
self.t_arrow_l = tex.get_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