Different glyph sets depending on the time of day in weather node.
parent
862d977fce
commit
46f60205a5
|
@ -3,6 +3,7 @@ return {
|
||||||
transitionTime = 0.5,
|
transitionTime = 0.5,
|
||||||
showProgress = true,
|
showProgress = true,
|
||||||
nodes = {
|
nodes = {
|
||||||
|
{'nodes.weather'},
|
||||||
{'nodes.newdash', displayTime=10},
|
{'nodes.newdash', displayTime=10},
|
||||||
{'nodes.misery', displayTime = 7},
|
{'nodes.misery', displayTime = 7},
|
||||||
{'nodes.slideshow', files={'images/pig.png'}, displayTime=5},
|
{'nodes.slideshow', files={'images/pig.png'}, displayTime=5},
|
||||||
|
|
|
@ -9,15 +9,51 @@ local weatherFont = love.graphics.newFont('fonts/weathericons-regular-webfont.tt
|
||||||
local textFont = love.graphics.newFont('fonts/Lato-Thin.ttf', 300)
|
local textFont = love.graphics.newFont('fonts/Lato-Thin.ttf', 300)
|
||||||
local smallFont = love.graphics.newFont('fonts/Lato-Light.ttf', 30)
|
local smallFont = love.graphics.newFont('fonts/Lato-Light.ttf', 30)
|
||||||
|
|
||||||
local weatherGlyphs = {
|
local weatherGlyphs = {}
|
||||||
snow = "",
|
|
||||||
mist = "",
|
local weatherGlyphsSet = {
|
||||||
clear = "",
|
day = {
|
||||||
-- clouds = "",
|
snow = "",
|
||||||
clouds = "", -- x---DDD
|
mist = "",
|
||||||
drizzle = "",
|
clear = "",
|
||||||
|
-- clouds = "",
|
||||||
|
clouds = "", -- x---DDD
|
||||||
|
drizzle = "",
|
||||||
|
},
|
||||||
|
night = {
|
||||||
|
snow = "",
|
||||||
|
mist = "",
|
||||||
|
clear = "",
|
||||||
|
clouds = "",
|
||||||
|
drizzle = "",
|
||||||
|
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function node:timeOfDay()
|
||||||
|
local sunRise = tonumber(os.date("%H%M", self.state.sunRise))
|
||||||
|
local sunSet = tonumber(os.date("%H%M", self.state.sunSet))
|
||||||
|
local now = tonumber(os.date("%H%M"))
|
||||||
|
if sunRise == nil or sunSet == nil then
|
||||||
|
return weatherGlyphsSet["day"] -- smth gone wrong. assume daylight
|
||||||
|
end
|
||||||
|
if now < sunSet and now > sunRise then
|
||||||
|
print('day')
|
||||||
|
return weatherGlyphsSet["day"]
|
||||||
|
else
|
||||||
|
print('night')
|
||||||
|
return weatherGlyphsSet["night"]
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
function node:beforeEnter()
|
||||||
|
if self.state then
|
||||||
|
weatherGlyphs = self:timeOfDay()
|
||||||
|
else
|
||||||
|
weatherGlyphs = weatherGlyphsSet["day"] -- do not know sunraise and sunset yet. assume daylight
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
function node:render()
|
function node:render()
|
||||||
love.graphics.setColor( 0, 0, 0 )
|
love.graphics.setColor( 0, 0, 0 )
|
||||||
love.graphics.rectangle("fill", 0, 0, love.graphics.getWidth(), love.graphics.getHeight())
|
love.graphics.rectangle("fill", 0, 0, love.graphics.getWidth(), love.graphics.getHeight())
|
||||||
|
@ -34,7 +70,7 @@ function node:render()
|
||||||
end
|
end
|
||||||
|
|
||||||
love.graphics.setFont(textFont)
|
love.graphics.setFont(textFont)
|
||||||
love.graphics.printf(tostring(self.state.temperature) .. "°", 600, 150, 650, 'center')
|
love.graphics.printf(tostring(math.floor(self.state.temperature + 0.5)) .. "°", 600, 150, 650, 'center')
|
||||||
|
|
||||||
love.graphics.setFont(smallFont)
|
love.graphics.setFont(smallFont)
|
||||||
love.graphics.printf(os.date("Last update: %Y/%m/%d %H:%M", self.state.lastUpdate), 0, love.graphics.getHeight() - 60, love.graphics.getWidth(), 'center')
|
love.graphics.printf(os.date("Last update: %Y/%m/%d %H:%M", self.state.lastUpdate), 0, love.graphics.getHeight() - 60, love.graphics.getWidth(), 'center')
|
||||||
|
|
|
@ -21,6 +21,8 @@ if c == 200 then
|
||||||
weather = data.weather[1].main:lower(),
|
weather = data.weather[1].main:lower(),
|
||||||
temperature = data.main.temp,
|
temperature = data.main.temp,
|
||||||
lastUpdate = data.dt,
|
lastUpdate = data.dt,
|
||||||
|
sunRise = data.sys.sunrise,
|
||||||
|
sunSet = data.sys.sunset,
|
||||||
insideTemperature = insideData[1],
|
insideTemperature = insideData[1],
|
||||||
insideHumidity = insideData[2],
|
insideHumidity = insideData[2],
|
||||||
})
|
})
|
||||||
|
|
Loading…
Reference in New Issue