This repository has been archived by the owner on Jul 3, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathnode.lua
65 lines (57 loc) · 1.77 KB
/
node.lua
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
util.init_hosted()
gl.setup(NATIVE_WIDTH, NATIVE_HEIGHT)
node.alias("now-serving")
local font
local logo_asset_name
local logo
local queue_on = true
local serving = ''
node.event("content_update", function(filename, file)
if filename == "config.json" then
if CONFIG.auto_resolution then
gl.setup(NATIVE_WIDTH, NATIVE_HEIGHT)
else
gl.setup(CONFIG.width, CONFIG.height)
end
font = CONFIG.font
if CONFIG.logo.asset_name ~= logo_asset_name then
logo_asset_name = CONFIG.logo.asset_name
logo = resource.load_image(logo_asset_name, TRUE)
end
end
end)
util.data_mapper {
["serving"] = function(value)
serving = value
end;
["queue"] = function(value)
if value == "true" then
queue_on = true
else
queue_on = false
end
end
}
local function centerText(text, size, y)
local font_scale = WIDTH / 1920
local width = font:width(text, size * font_scale)
local x = (WIDTH / 2) - (width / 2);
font:write(x, y * font_scale, text, size * font_scale, CONFIG.font_colour.rgba())
end
function node.render()
CONFIG.background_colour.clear()
local margin = 50
local logo_height = 100
local logo_w, logo_h = logo:size()
local logo_ratio = logo_w / logo_h
util.draw_correct(logo, WIDTH - (margin + (logo_ratio * logo_height)), margin, WIDTH - margin, margin + logo_height)
if queue_on then
centerText(CONFIG.queue_on_text, 150, 250)
centerText(serving, 400, 460)
else
centerText(CONFIG.queue_off_text_1, 75, 300)
centerText(CONFIG.queue_off_text_2, 75, 400)
centerText(CONFIG.queue_off_text_3, 75, 500)
centerText(CONFIG.queue_off_text_4, 75, 600)
end
end