Serge Bazanski | 18c1a26 | 2022-07-07 14:24:53 +0200 | [diff] [blame] | 1 | local node = ThreadNode:extend('nodes.at', { |
| 2 | threadFile = 'nodes/at_thread.lua', |
| 3 | threadChannel = 'at', |
| 4 | |
| 5 | api = 'http://at.hackerspace.pl/api', |
| 6 | }) |
| 7 | |
| 8 | local bigFont = love.graphics.newFont('fonts/Lato-Light.ttf', 80) |
| 9 | local textFont = love.graphics.newFont('fonts/Lato-Light.ttf', 50) |
| 10 | local smallFont = love.graphics.newFont('fonts/Lato-Light.ttf', 30) |
| 11 | |
| 12 | function node:render() |
| 13 | love.graphics.setColor( 0, 0, 0 ) |
| 14 | love.graphics.rectangle("fill", 0, 0, love.graphics.getWidth(), love.graphics.getHeight()) |
| 15 | |
| 16 | if self.state then |
| 17 | love.graphics.setColor( 1.0, 1.0, 1.0, 0.4 ) |
| 18 | love.graphics.setFont(bigFont) |
| 19 | love.graphics.printf('Currently at hackerspace:', 50, 100, love.graphics.getWidth() - 100, 'center') |
| 20 | |
| 21 | usersList = (table.concat(lume.map(self.state.users, function(v) return v.login end), ', ') or 'nobody...') .. '\n' |
| 22 | |
| 23 | if self.state.unknown > 0 then |
| 24 | usersList = usersList .. '\n...and ' .. tostring(self.state.unknown) .. ' unknown creatures' |
| 25 | end |
| 26 | |
| 27 | if self.state.kektops > 0 then |
| 28 | usersList = usersList .. '\n...and ' .. tostring(self.state.kektops) .. ' kektops' |
| 29 | end |
| 30 | |
| 31 | if self.state.esps > 0 then |
| 32 | usersList = usersList .. '\n...and ' .. tostring(self.state.esps) .. ' ESPs' |
| 33 | end |
| 34 | |
| 35 | love.graphics.setColor( 1.0, 1.0, 1.0 ) |
| 36 | love.graphics.setFont(textFont) |
| 37 | love.graphics.printf(usersList, 50, 220, love.graphics.getWidth() - 100, 'center') |
| 38 | else |
| 39 | love.graphics.setColor( 1.0, 1.0, 1.0, 0.4 ) |
| 40 | |
| 41 | love.graphics.setFont(smallFont) |
| 42 | love.graphics.printf("Loading at...", 0, love.graphics.getHeight() - 200, love.graphics.getWidth(), 'center') |
| 43 | end |
| 44 | end |
| 45 | |
| 46 | return node |