summaryrefslogtreecommitdiffstats
path: root/nodes/newdash.lua
blob: 37c7a1e9ac3169d59ec62bacbfc00fca10fba0df (plain)
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
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
local node = ThreadNode:extend('nodes.newdash', {
  threadFile = 'nodes/newdash_thread.lua',
  threadChannel = 'newdash',

  updateInterval = 60,
})

local weatherFont = love.graphics.newFont('fonts/weathericons-regular-webfont.ttf', 165)
local tempFont = love.graphics.newFont('fonts/Lato-Light.ttf', 120)
local timeFont = love.graphics.newFont('fonts/Lato-Thin.ttf', 330)
local dateFont = love.graphics.newFont('fonts/Lato-Light.ttf', 90)
local headerFont = love.graphics.newFont('fonts/Lato-Regular.ttf', 40)
local valueFont = love.graphics.newFont('fonts/Lato-Light.ttf', 45)
local atFont = love.graphics.newFont('fonts/Lato-Light.ttf', 35)


local weatherGlyphs = {
  snow = "",
  mist = "",
  clear = "",
  -- clouds = "",
  clouds = "", -- x---DDD
  drizzle = "",
}

function node:render()
  love.graphics.setColor( 0, 0, 0 )
  love.graphics.rectangle("fill", 0, 0, love.graphics.getWidth(), love.graphics.getHeight())

  if self.state then
    love.graphics.setColor( 255, 255, 255 )

    if weatherGlyphs[self.state.weather] then
      love.graphics.setFont(weatherFont)
      love.graphics.print(weatherGlyphs[self.state.weather], 100, 340)
    else
      love.graphics.setFont(atFont)
      love.graphics.print(self.state.weather, 100, 370)
    end

    love.graphics.setFont(tempFont)
    love.graphics.printf(tostring(self.state.temperature) .. "°", 350, 390, 270, 'center')

    love.graphics.setFont(headerFont)
    love.graphics.printf("Ambient:", 720, 380, 160, 'right')
    love.graphics.printf("Exhaust:", 720, 440, 160, 'right')
    love.graphics.printf("Lights:", 720, 500, 160, 'right')

    love.graphics.setFont(valueFont)
    if self.state.insideTemperature then
      love.graphics.printf(tostring(self.state.insideTemperature) .. "° / " .. tostring(self.state.insideHumidity) .. "%RH", 900, 378, 400, 'left')
    else
      love.graphics.printf("?!", 900, 378, 400, 'left')
    end
    love.graphics.printf("ON or OFF?", 900, 438, 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.printf("at hackerspace:", 50, 593, 300, 'left')
    love.graphics.setFont(atFont)
    if self.state.at then
      users = lume.map(self.state.at.users, function(v) return v.login end)
      if self.state.at.unknown > 0 then
        users[#users + 1] = tostring(self.state.at.unknown) .. " unknown creatures"
      end
      if self.state.at.kektops > 0 then
        users[#users + 1] = tostring(self.state.at.kektops) .. " kektops"
      end
      if self.state.at.esps > 0 then
        users[#users + 1] = tostring(self.state.at.esps) .. " ESPs"
      end
    end

    usersList = (table.concat(users, ', ') or 'nobody...')

    love.graphics.printf(usersList, 350, 598, 900, 'left')
  else
    love.graphics.setColor(255, 255, 255, 150)
    love.graphics.setFont(valueFont)
    love.graphics.printf("Loading...", 0, 530, love.graphics.getWidth(), "center")
  end

  love.graphics.setColor( 255, 255, 255 )
  love.graphics.setFont(timeFont)
  love.graphics.printf(os.date("%H:%M"), 50, -10, 850, 'center')
  love.graphics.setFont(dateFont)
  love.graphics.printf(os.date("%Y\n%m/%d"), 960, 80, 270, 'center')

end

return node