57 lines
1.1 KiB
Lua
57 lines
1.1 KiB
Lua
VER = '0.1'
|
|
|
|
return function(con)
|
|
|
|
love.keyboard.setKeyRepeat(true)
|
|
|
|
require 'src.mouse' (con)
|
|
require 'src.fs' ()
|
|
require 'src.async'
|
|
|
|
local w, h, f
|
|
function love.resize(x, y)
|
|
w, h = math.max(32, x), math.max(32, y)
|
|
f = love.graphics.setNewFont('src/hack.ttf', math.min(w, h) / 32)
|
|
local cw, ch = f:getWidth 'A', f:getHeight 'A'
|
|
collectgarbage 'collect'
|
|
con.resz(w, h, cw, ch)
|
|
end
|
|
love.resize(love.graphics.getDimensions())
|
|
love.window.setMode(w, h, {
|
|
resizable = true,
|
|
minwidth = 32,
|
|
minheight = 32
|
|
})
|
|
|
|
love.textinput = con.type
|
|
love.keypressed = con.keydown
|
|
|
|
local sf = (love.getVersion() or love._version_major)
|
|
== 0 and 1 or 255
|
|
|
|
function love.draw()
|
|
love.graphics.setColor(100 / sf, 255 / sf, 0)
|
|
con.forText(function(l, x, y)
|
|
if not (
|
|
l == '\n'
|
|
or l == '\r'
|
|
or l == '\v'
|
|
or l == '\t'
|
|
)
|
|
then love.graphics.print(l, x * con.cw, y * con.ch + con.oy)
|
|
end
|
|
end)
|
|
end
|
|
|
|
function loadapp(name, ...)
|
|
local succ, msg = pcall(require, 'A.'.. name)
|
|
if not succ then
|
|
con.println('ERROR: '.. msg)
|
|
print(msg)
|
|
else
|
|
msg({...}, con)
|
|
end
|
|
end
|
|
|
|
end
|