Use string.format in newdash, fix slideshow when no files provided

master
informatic 2017-01-24 18:58:00 +01:00
parent 615c9e5dee
commit 862d977fce
2 changed files with 13 additions and 17 deletions

View File

@ -13,7 +13,6 @@ local headerFont = love.graphics.newFont('fonts/Lato-Regular.ttf', 40)
local valueFont = love.graphics.newFont('fonts/Lato-Light.ttf', 45) local valueFont = love.graphics.newFont('fonts/Lato-Light.ttf', 45)
local atFont = love.graphics.newFont('fonts/Lato-Light.ttf', 35) local atFont = love.graphics.newFont('fonts/Lato-Light.ttf', 35)
local weatherGlyphs = { local weatherGlyphs = {
snow = "", snow = "",
mist = "", mist = "",
@ -39,7 +38,7 @@ function node:render()
end end
love.graphics.setFont(tempFont) love.graphics.setFont(tempFont)
love.graphics.printf(tostring(self.state.temperature) .. "°", 350, 390, 270, 'center') love.graphics.printf(string.format("%d°", self.state.temperature), 350, 390, 270, 'center')
love.graphics.setFont(headerFont) love.graphics.setFont(headerFont)
love.graphics.printf("Ambient:", 720, 380, 160, 'right') love.graphics.printf("Ambient:", 720, 380, 160, 'right')
@ -48,30 +47,25 @@ function node:render()
love.graphics.setFont(valueFont) love.graphics.setFont(valueFont)
if self.state.insideTemperature then if self.state.insideTemperature then
love.graphics.printf(tostring(self.state.insideTemperature) .. "° / " .. tostring(self.state.insideHumidity) .. "%RH", 900, 378, 400, 'left') love.graphics.printf(string.format("%d° / %d%%RH", self.state.insideTemperature, self.state.insideHumidity), 900, 378, 400, 'left')
else else
love.graphics.printf("?!", 900, 378, 400, 'left') love.graphics.printf("?!", 900, 378, 400, 'left')
end end
love.graphics.printf("ON or OFF?", 900, 438, 400, 'left') love.graphics.printf("ON or OFF?", 900, 438, 400, 'left')
love.graphics.printf("ON or OFF?", 900, 498, 400, 'left') love.graphics.printf("ON or OFF?", 900, 498, 400, 'left')
--love.graphics.setFont(atFont)
--love.graphics.printf(os.date("Last update: %Y/%m/%d %H:%M", self.state.lastUpdate), 0, love.graphics.getHeight() - 60, love.graphics.getWidth(), 'center')
--if self.state.insideTemperature then
-- love.graphics.printf("Room: " .. tostring(self.state.insideTemperature) .. "° / " .. tostring(self.state.insideHumidity) .. "%RH", 0, love.graphics.getHeight() - 100, love.graphics.getWidth(), 'center')
--end
love.graphics.setFont(headerFont) love.graphics.setFont(headerFont)
love.graphics.printf("at hackerspace:", 50, 593, 300, 'left') love.graphics.printf("at hackerspace:", 50, 593, 300, 'left')
love.graphics.setFont(atFont) love.graphics.setFont(atFont)
if self.state.at then if self.state.at then
users = lume.map(self.state.at.users, function(v) return v.login end) users = lume.map(self.state.at.users, function(v) return v.login end)
if self.state.at.unknown > 0 then if self.state.at.unknown > 0 then
users[#users + 1] = tostring(self.state.at.unknown) .. " unknown creatures" users[#users + 1] = string.format("%d unknown creatures", self.state.at.unknown)
end end
if self.state.at.kektops > 0 then if self.state.at.kektops > 0 then
users[#users + 1] = tostring(self.state.at.kektops) .. " kektops" users[#users + 1] = string.format("%d kektops", self.state.at.kektops)
end end
if self.state.at.esps > 0 then if self.state.at.esps > 0 then
users[#users + 1] = tostring(self.state.at.esps) .. " ESPs" users[#users + 1] = string.format("%d ESPs", self.state.at.esps)
end end
end end

View File

@ -8,12 +8,14 @@ function node:init(config)
end end
function node:loadImage() function node:loadImage()
local files = self:processFiles(self.files) if self.files then
if files ~= nil then local files = self:processFiles(self.files)
if self.fileName then if files ~= nil then
self.fileName = files[(lume.find(files, self.fileName) or 1) % #files + 1] if self.fileName then
else self.fileName = files[(lume.find(files, self.fileName) or 1) % #files + 1]
self.fileName = files[1] else
self.fileName = files[1]
end
end end
end end