Files
YataiDONNijiiro/Scripts/dan_select/dan_select.lua
T
GanYiZhongandClaude Opus 5.5 525a9f36ff dan select: extend the parent's DanSelect instead of replacing it
The dan boxes moved to PyTaikoGreen's Scripts/dan_select/dan_select.lua, which
this skin's dan_select.lua shadowed, so no dan box was drawn. Load the parent's
script first and add only the clip-sampled cursor/arrows on top of it.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-10-05 01:35:05 +08:00

75 lines
2.8 KiB
Lua

-- DAN_SELECT paint surface: selection cursor breathing loop and arrow chips,
-- sampled from the cabinet's own clips. The dan boxes themselves are drawn by the
-- parent skin's dan_select.lua, which is loaded first and extended here.
-- the parent skin's copy of this script: the second match on package.path (the first is this file)
local function load_parent(name)
local seen = false
for tmpl in package.path:gmatch("[^;]+") do
local chunk = loadfile((tmpl:gsub("%?", name)))
if chunk then
if seen then return chunk end
seen = true
end
end
end
local parent = load_parent("dan_select/dan_select")
if parent then parent() end
if not DanSelect then
DanSelect = {}
DanSelect.__index = DanSelect
end
local parent_new = DanSelect.new
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
-- No real clip data at all -> no draw_cursor: the engine draws the cursor from its
-- inline tables (the boxes are still drawn by the parent's DanSelect).
local HAS_CLIPS = CUR:has("#259@0") or ARW:has("#261@0")
function DanSelect.new()
local self = parent_new and parent_new() or 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).
local function draw_cursor(self, 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
if HAS_CLIPS then DanSelect.draw_cursor = draw_cursor end