Files
PyTaikoGreen/Scripts/global/indicator.lua
2026-07-17 13:03:07 -04:00

72 lines
3.1 KiB
Lua

Indicator = {}
Indicator.__index = Indicator
Indicator.State = {
SKIP = 0,
SIDE = 1,
SELECT = 2,
WAIT = 3,
}
function Indicator.new(state)
local self = setmetatable({}, Indicator)
self.state = state
self.background = tex.load_texture("global/indicator/background")
self.text = tex.load_texture("global/indicator/text")
self.drum_face = tex.load_texture("global/indicator/drum_face")
self.drum_kat = tex.load_texture("global/indicator/drum_kat")
self.drum_don = tex.load_texture("global/indicator/drum_don")
self.blue_arrow = tex.load_texture("global/indicator/blue_arrow")
self.don_fade = tex.get_animation(6, "global")
self.blue_arrow_move = tex.get_animation(7, "global")
self.blue_arrow_fade = tex.get_animation(8, "global")
self.select_text = text.create_text("indicator_text", { 255, 255, 255, 255 }, { 0, 0, 0, 0 }, false, 0, -5)
local text_config = tex.get_skin_config("indicator_text")
local bg_info = tex.get_texture_info("indicator", "background")
self.text_offset_x = text_config.x
self.bg_half_height = bg_info.height / 2
self.kat_offset_x = tex.get_skin_config("indicator_kat_offset").x
self.face_offset_x = tex.get_skin_config("indicator_face_offset").x
self.don_offset_x = tex.get_skin_config("indicator_don_offset").x
return self
end
function Indicator:update(current_ms)
self.don_fade:update(current_ms)
self.blue_arrow_move:update(current_ms)
self.blue_arrow_fade:update(current_ms)
end
function Indicator:draw(x, y, fade)
fade = fade or 1.0
local state_val = self.state
tex.draw_texture(self.background, { x = x, y = y, fade = fade })
tex.draw_texture(self.text, { color = { 0, 0, 0, 255 }, frame = state_val, x = x, y = y, fade = fade })
local text_y = y + self.bg_half_height - (self.select_text.height / 2)
self.select_text:draw({ x = x, y = text_y, fade = fade })
tex.draw_texture(self.drum_face, { x = x, y = y, fade = fade, index = state_val })
if self.state == Indicator.State.SELECT then
local kat_fade = math.min(fade, self.don_fade.attribute)
local arrow_fade = math.min(fade, self.blue_arrow_fade.attribute)
tex.draw_texture(self.drum_kat, { x = x, y = y, fade = kat_fade })
tex.draw_texture(self.drum_kat, { mirror = "horizontal", x = x + self.kat_offset_x, y = y, fade = kat_fade })
tex.draw_texture(self.drum_face, { x = x + self.face_offset_x, y = y, fade = fade })
tex.draw_texture(self.drum_don, { x = x + self.don_offset_x, y = y, fade = kat_fade, index = state_val })
tex.draw_texture(self.blue_arrow, { x = x - self.blue_arrow_move.attribute, y = y, fade = arrow_fade })
tex.draw_texture(self.blue_arrow,
{ mirror = "horizontal", x = x + self.blue_arrow_move.attribute, y = y, fade = arrow_fade, index = 1 })
else
tex.draw_texture(self.drum_don, { x = x, y = y, fade = math.min(fade, self.don_fade.attribute), index = state_val })
end
end