mirror of
https://github.com/Kunsi/scheduled-plugin-pretalx-broadcast-tools.git
synced 2024-12-22 00:02:44 +00:00
add clock option
This commit is contained in:
parent
5af59372e3
commit
234cfff15a
4 changed files with 86 additions and 3 deletions
13
node.json
13
node.json
|
@ -24,6 +24,12 @@
|
|||
"name": "font_day",
|
||||
"type": "font",
|
||||
"default": "silkscreen.ttf"
|
||||
}, {
|
||||
"title": "Clock",
|
||||
"ui_width": 6,
|
||||
"name": "font_clock",
|
||||
"type": "font",
|
||||
"default": "silkscreen.ttf"
|
||||
}, {
|
||||
"title": "all other text",
|
||||
"ui_width": 6,
|
||||
|
@ -45,6 +51,13 @@
|
|||
"name": "show_track",
|
||||
"type": "boolean",
|
||||
"default": true
|
||||
}, {
|
||||
"title": "Clock format",
|
||||
"ui_width": 4,
|
||||
"name": "clock_format",
|
||||
"type": "string",
|
||||
"default": "%H:%M",
|
||||
"hint": "strftime() format specifier"
|
||||
}, {
|
||||
"title": "Schedule",
|
||||
"type": "section"
|
||||
|
|
7
service
7
service
|
@ -24,7 +24,11 @@ def idle(seconds, event_start, event_tz):
|
|||
end = time.time() + seconds
|
||||
log("sleeping for {} seconds".format(seconds))
|
||||
while time.time() < end:
|
||||
send_data = {"day": "??", "time": int(time.time())}
|
||||
send_data = {
|
||||
"clock": "??",
|
||||
"day": "??",
|
||||
"time": int(time.time()),
|
||||
}
|
||||
if event_start is not None:
|
||||
event_now = datetime.now(event_tz)
|
||||
utc_now = datetime.now(pytz.utc)
|
||||
|
@ -38,6 +42,7 @@ def idle(seconds, event_start, event_tz):
|
|||
log("Day0: {}".format(day_zero.isoformat()))
|
||||
log("NOW: {}".format(event_now.isoformat()))
|
||||
|
||||
send_data["clock"] = event_now.strftime(config["clock_format"])
|
||||
send_data["day"] = day_info.days
|
||||
|
||||
for k, v in send_data.items():
|
||||
|
|
26
tile.js
26
tile.js
|
@ -11,6 +11,7 @@ var config = {
|
|||
<option value="next_talk">Next Talk</option>
|
||||
<option value="room">Room Name</option>
|
||||
<option value="day">Day</option>
|
||||
<option value="clock">Clock</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class='col-xs-3'>
|
||||
|
@ -60,7 +61,7 @@ var config = {
|
|||
</div>
|
||||
</template>
|
||||
<template v-if='mode == "room"'>
|
||||
<h4>room options</h4>
|
||||
<h4>Room options</h4>
|
||||
<div class='row'>
|
||||
<div class='col-xs-3'>
|
||||
Alignment<br/>
|
||||
|
@ -79,6 +80,26 @@ var config = {
|
|||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-if='mode == "clock"'>
|
||||
<h4>Clock options</h4>
|
||||
<div class='row'>
|
||||
<div class='col-xs-3'>
|
||||
Alignment<br/>
|
||||
<select class='btn btn-default' v-model="clock_align">
|
||||
<option value="left">Align left</option>
|
||||
<option value="center">Align centered</option>
|
||||
<option value="right">Align right</option>
|
||||
</select>
|
||||
</div>
|
||||
<div class='col-xs-3'>
|
||||
<input
|
||||
type="checkbox"
|
||||
v-model="clock_animate"
|
||||
class='form-check-input'/>
|
||||
Fade in and out
|
||||
</div>
|
||||
</div>
|
||||
</template>
|
||||
<template v-if='mode == "day"'>
|
||||
<h4>Day options</h4>
|
||||
<div class='row'>
|
||||
|
@ -122,6 +143,9 @@ var config = {
|
|||
room_align: ChildTile.config_value('room_align', 'left'),
|
||||
room_animate: ChildTile.config_value('room_animate', true),
|
||||
|
||||
clock_align: ChildTile.config_value('clock_align', 'left'),
|
||||
clock_animate: ChildTile.config_value('clock_animate', true),
|
||||
|
||||
day_align: ChildTile.config_value('day_align', 'left'),
|
||||
day_template: ChildTile.config_value('day_template', 'Day %d'),
|
||||
day_animate: ChildTile.config_value('day_animate', false),
|
||||
|
|
43
tile.lua
43
tile.lua
|
@ -4,6 +4,7 @@ local json = require "json"
|
|||
local helper = require "helper"
|
||||
local anims = require(api.localized "anims")
|
||||
|
||||
local font_clock
|
||||
local font_day
|
||||
local font_room
|
||||
local font_talk
|
||||
|
@ -18,6 +19,7 @@ local room_next_talks = {}
|
|||
local current_room
|
||||
local day = 0
|
||||
local time = 0
|
||||
local clock = "??"
|
||||
local show_language = true
|
||||
local show_track = true
|
||||
|
||||
|
@ -35,6 +37,8 @@ function M.data_trigger(path, data)
|
|||
log("received data '" .. data .. "' on " .. path)
|
||||
if path == "day" then
|
||||
day = tonumber(data)
|
||||
elseif path == "clock" then
|
||||
clock = data
|
||||
elseif path == "time" then
|
||||
time = tonumber(data)
|
||||
end
|
||||
|
@ -45,6 +49,7 @@ function M.updated_config_json(config)
|
|||
show_language = config.show_language
|
||||
show_track = config.show_track
|
||||
|
||||
font_clock = resource.load_font(api.localized(config.font_clock.asset_name))
|
||||
font_day = resource.load_font(api.localized(config.font_day.asset_name))
|
||||
font_room = resource.load_font(api.localized(config.font_room.asset_name))
|
||||
font_talk = resource.load_font(api.localized(config.font_talk.asset_name))
|
||||
|
@ -375,6 +380,40 @@ local function view_room(starts, ends, config, x1, y1, x2, y2)
|
|||
end
|
||||
end
|
||||
|
||||
local function view_clock(starts, ends, config, x1, y1, x2, y2)
|
||||
local font_size = config.font_size or 70
|
||||
local align = config.clock_align or "left"
|
||||
local animate = config.clock_animate or true
|
||||
local default_color = {helper.parse_rgb(config.color or "#ffffff")}
|
||||
local r,g,b = helper.parse_rgb(config.color or "#ffffff")
|
||||
|
||||
local a = anims.Area(x2 - x1, y2 - y1)
|
||||
|
||||
local S = starts
|
||||
local E = ends
|
||||
|
||||
local function text(...)
|
||||
return a.add(anims.moving_font(S, E, ...))
|
||||
end
|
||||
|
||||
local x = 0
|
||||
local w = font_clock:width(clock, font_size)
|
||||
if align == "right" then
|
||||
x = a.width - w
|
||||
elseif align == "center" then
|
||||
x = (a.width - w) / 2
|
||||
end
|
||||
text(font_clock, x, 0, clock, font_size, rgba(default_color,1))
|
||||
|
||||
for now in api.frame_between(starts, ends) do
|
||||
if animate then
|
||||
a.draw(now, x1, y1, x2, y2)
|
||||
else
|
||||
font_clock:write(x1+x, y1, current_room, font_size, r,g,b,1)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
local function view_day(starts, ends, config, x1, y1, x2, y2)
|
||||
local font_size = config.font_size or 70
|
||||
local align = config.day_align or "left"
|
||||
|
@ -419,6 +458,7 @@ function M.task(starts, ends, config, x1, y1, x2, y2)
|
|||
|
||||
room = view_room,
|
||||
day = view_day,
|
||||
clock = view_clock,
|
||||
})[config.mode or 'all_talks'](starts, ends, config, x1, y1, x2, y2)
|
||||
end
|
||||
|
||||
|
@ -426,7 +466,8 @@ function M.can_show(config)
|
|||
local mode = config.mode or 'all_talks'
|
||||
-- these can always play
|
||||
if mode == "day" or
|
||||
mode == "all_talks"
|
||||
mode == "all_talks" or
|
||||
mode == "clock"
|
||||
then
|
||||
return true
|
||||
end
|
||||
|
|
Loading…
Reference in a new issue