make rotation work without needing to restart
This commit is contained in:
parent
ab1f68a712
commit
e7f671fc33
1 changed files with 16 additions and 2 deletions
18
node.lua
18
node.lua
|
@ -4,6 +4,8 @@ local json = require "json"
|
|||
local services = {}
|
||||
local host_width = 0
|
||||
local time_width = 0
|
||||
local rotate_before = nil
|
||||
local transform = nil
|
||||
|
||||
local c_hard = {}
|
||||
c_hard[0] = resource.create_colored_texture(0, 0.6, 0, 1)
|
||||
|
@ -23,7 +25,6 @@ c_text[2] = {1, 1, 1}
|
|||
c_text[3] = {1, 1, 1}
|
||||
|
||||
gl.setup(NATIVE_WIDTH, NATIVE_HEIGHT)
|
||||
local transform = util.screen_transform(CONFIG.rotate)
|
||||
|
||||
util.file_watch("services.json", function(content)
|
||||
services = json.decode(content)
|
||||
|
@ -40,9 +41,22 @@ local white = resource.create_colored_texture(1,1,1,1)
|
|||
local base_time = N.base_time or 0
|
||||
|
||||
function node.render()
|
||||
if rotate_before ~= CONFIG.rotate then
|
||||
transform = util.screen_transform(CONFIG.rotate)
|
||||
rotate_before = CONFIG.rotate
|
||||
|
||||
if rotate_before == 90 or rotate_before == 270 then
|
||||
real_width = NATIVE_HEIGHT
|
||||
real_height = NATIVE_WIDTH
|
||||
else
|
||||
real_width = NATIVE_WIDTH
|
||||
real_height = NATIVE_HEIGHT
|
||||
end
|
||||
end
|
||||
|
||||
transform()
|
||||
CONFIG.background_color.clear()
|
||||
CONFIG.font:write(NATIVE_WIDTH/2-time_width/2, 10, services.prettytime, 30, 1,1,1,1)
|
||||
CONFIG.font:write(real_width/2-time_width/2, 10, services.prettytime, 30, 1,1,1,1)
|
||||
|
||||
local y = 50
|
||||
for idx, serv in ipairs(services.services) do
|
||||
|
|
Loading…
Reference in a new issue