2017-01-12 21:16:52 +00:00
|
|
|
class = require('vendor.30log')
|
|
|
|
inspect = require('vendor.inspect')
|
|
|
|
lume = require('vendor.lume')
|
|
|
|
|
|
|
|
Node = require('core.node')
|
|
|
|
ThreadNode = require('core.thread-node')
|
|
|
|
NodeManager = require('core.node-manager')
|
2017-01-08 00:11:19 +00:00
|
|
|
|
2017-01-08 21:24:13 +00:00
|
|
|
local config = require('config')
|
2017-01-07 18:35:38 +00:00
|
|
|
|
2017-01-12 21:16:52 +00:00
|
|
|
local push = require('vendor.push')
|
2017-01-17 17:36:07 +00:00
|
|
|
|
2017-01-12 21:16:52 +00:00
|
|
|
local lurker = require('vendor.lurker')
|
2017-01-17 17:36:07 +00:00
|
|
|
lurker.quiet = true
|
|
|
|
lurker.interval = 3
|
2017-01-12 21:16:52 +00:00
|
|
|
|
2017-01-17 17:36:07 +00:00
|
|
|
local debugGraph = require('vendor.debugGraph')
|
|
|
|
local fpsGraph = debugGraph:new('fps', 0, 0)
|
|
|
|
local memGraph = debugGraph:new('mem', 0, 30)
|
2017-01-07 18:35:38 +00:00
|
|
|
|
2017-01-16 20:51:04 +00:00
|
|
|
local gameWidth, gameHeight = config.renderWidth, config.renderHeight
|
2017-01-08 00:11:19 +00:00
|
|
|
local windowWidth, windowHeight = love.window.getDesktopDimensions()
|
|
|
|
windowWidth, windowHeight = windowWidth*.5, windowHeight*.5 --make the window a bit smaller than the screen itself
|
|
|
|
|
2017-01-12 21:16:52 +00:00
|
|
|
if config.environment == 'dev' then
|
2017-01-08 00:11:19 +00:00
|
|
|
push:setupScreen(gameWidth, gameHeight, windowWidth, windowHeight, {fullscreen = false, resizable = true})
|
|
|
|
else
|
|
|
|
push:setupScreen(gameWidth, gameHeight, gameWidth, gameHeight, {fullscreen = true})
|
|
|
|
end
|
|
|
|
|
|
|
|
function love.resize(w, h)
|
|
|
|
push:resize(w, h)
|
2017-01-12 21:16:52 +00:00
|
|
|
manager:resize(w, h)
|
2017-01-08 00:11:19 +00:00
|
|
|
end
|
|
|
|
|
2017-01-07 18:35:38 +00:00
|
|
|
function love.load()
|
2017-01-12 21:16:52 +00:00
|
|
|
manager = NodeManager(config)
|
|
|
|
manager:load()
|
|
|
|
manager:resize(push:getWidth(), push:getHeight())
|
2017-01-08 21:24:13 +00:00
|
|
|
|
2017-01-08 00:11:19 +00:00
|
|
|
love.mouse.setVisible( false )
|
2017-01-08 18:16:30 +00:00
|
|
|
end
|
|
|
|
|
2017-01-08 00:11:19 +00:00
|
|
|
function getw() return push:getWidth() end
|
|
|
|
function geth() return push:getHeight() end
|
|
|
|
|
2017-01-07 18:35:38 +00:00
|
|
|
function love.draw()
|
2017-01-08 00:11:19 +00:00
|
|
|
push:start()
|
|
|
|
|
|
|
|
-- Patch love.graphics.getWidth/Height to account for push
|
|
|
|
oldw, oldh = love.graphics.getWidth, love.graphics.getHeight
|
|
|
|
love.graphics.getWidth, love.graphics.getHeight = getw, geth
|
|
|
|
|
2017-01-12 21:16:52 +00:00
|
|
|
manager:render()
|
2017-01-07 18:35:38 +00:00
|
|
|
|
|
|
|
-- Draw graphs
|
|
|
|
love.graphics.setColor(255, 255, 255, 128)
|
2017-01-08 00:11:19 +00:00
|
|
|
|
|
|
|
-- love.graphics.setNewFont(10)
|
|
|
|
-- love.graphics.print(inspect(state), 0, 60, 0)
|
2017-01-07 18:35:38 +00:00
|
|
|
|
|
|
|
fpsGraph:draw()
|
|
|
|
memGraph:draw()
|
2017-01-08 00:11:19 +00:00
|
|
|
|
|
|
|
love.graphics.getWidth, love.graphics.getHeight = oldw, oldh
|
|
|
|
push:finish()
|
2017-01-07 18:35:38 +00:00
|
|
|
end
|
|
|
|
|
2017-01-16 23:22:23 +00:00
|
|
|
function love.keypressed( key, scancode, isrepeat )
|
|
|
|
if key == "right" then
|
|
|
|
-- Cycle to next state
|
|
|
|
manager.stateTime = 2137
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2017-01-07 18:35:38 +00:00
|
|
|
function love.update(dt)
|
2017-01-12 21:16:52 +00:00
|
|
|
manager:update(dt)
|
2017-01-07 18:35:38 +00:00
|
|
|
|
|
|
|
-- Update the graphs
|
|
|
|
fpsGraph:update(dt)
|
|
|
|
memGraph:update(dt)
|
2017-01-08 18:16:30 +00:00
|
|
|
lurker.update()
|
2017-01-07 18:35:38 +00:00
|
|
|
end
|
2017-01-12 21:16:52 +00:00
|
|
|
|
|
|
|
function lurker.preswap(f)
|
|
|
|
if f == 'config.lua' then
|
|
|
|
print('config reloaded, notifying nodemanager')
|
|
|
|
package.loaded['config'] = nil
|
|
|
|
manager.config = require('config');
|
|
|
|
manager:configChanged();
|
|
|
|
elseif f:match('_thread.lua') then
|
|
|
|
return false
|
|
|
|
end
|
|
|
|
end
|