Files
PyTaikoGreen/Scripts/global/news_telop.lua
T
2026-12-05 15:13:55 -05:00

34 lines
1.1 KiB
Lua

local NewsTelop = {}
local S = tex.get_screen_scale()
local BAR_BOTTOM_OFFSET = 77 * S
local BAR_HEIGHT = 20 * S
local FONT_SIZE = math.floor(20 * S)
local SPEED = 100 * S -- pixels per second
local WHITE = { 255, 255, 255, 255 }
local BLACK = { 0, 0, 0, 255 }
local message, label, start_ms
local params = { x = 0, y = 0 }
function NewsTelop.draw()
local screen = tex.current_screen()
if screen ~= "TITLE" then return end
local news = network and network.news and network.news() or ""
if news == "" then return end
local now = tex.get_current_ms()
if news ~= message then
message = news
label = text.create_raw_text((news:gsub("[\r\n]+", "\227\128\128")), FONT_SIZE, WHITE, BLACK, false, 0)
start_ms = now
end
local width = tex.get_screen_width()
local y = tex.get_screen_height() - BAR_BOTTOM_OFFSET
tex.draw_rect(0, y, width, BAR_HEIGHT, 0, 0, 0, 255)
params.x = width - ((now - start_ms) / 1000 * SPEED) % (width + label.width)
params.y = y + (BAR_HEIGHT - label.height) / 2
label:draw(params)
end
return NewsTelop