box-of-eases/main.lua
2021-09-19 14:37:46 +03:00

114 lines
No EOL
2.3 KiB
Lua

local default_G = {}
for k, v in pairs(_G) do
table.insert(default_G, k)
end
love.graphics.setDefaultFilter('nearest', 'nearest')
interfaceFont = love.graphics.newFont('Inter-Regular.otf', 20)
ease = require 'ease'
slider = require 'slider'
dropdown = require 'dropdown'
graph = require 'graph'
button = require 'button'
tooltips = require 'tooltips'
modes = {
preview = 1,
mix = 2,
multiply = 3,
create = 4
}
function createUI()
dropdown.createDropdowns()
slider.createSliders()
button.createButtons()
end
require 'util' -- exports into global table
-- rendering constants
padding = 16
outerpadding = 22
margin = 6
dropdownWidth = 186
lineWidth = 2
fontHeight = love.graphics.getFont():getHeight()
-- global for convinience's sake
mode = nil
function love.load()
love.graphics.setFont(interfaceFont)
fontHeight = love.graphics.getFont():getHeight()
createUI()
end
function love.update(dt)
graph.update(dt)
slider.update(dt)
dropdown.update(dt)
button.update(dt)
tooltips.update(dt)
end
function love.draw()
local sw, sh = love.graphics.getDimensions()
local mx, my = love.mouse.getPosition()
-- this is fine to do since all textures are already loaded with nearest
love.graphics.setDefaultFilter('linear', 'linear')
love.graphics.setLineWidth(2)
love.graphics.setColor(0.09, 0.09, 0.12, 1)
love.graphics.rectangle('fill', 0, 0, sw, sh)
love.graphics.setColor(0.08, 0.08, 0.1, 1)
love.graphics.rectangle('line', 0, 0, sw, sh)
love.graphics.setColor(0.2, 0.2, 0.3, 1)
love.graphics.print('Box of Eases by oatmealine', outerpadding, sh - fontHeight - outerpadding)
tooltips.prerender()
button.render()
slider.render()
dropdown.render()
graph.render()
tooltips.render()
end
function love.mousepressed(x, y, m)
if dropdown.mousepressed(x, y, m) then return end
button.mousepressed(x, y, m)
end
function love.mousereleased(x, y, m)
if dropdown.mousereleased(x, y, m) then return end
end
function love.wheelmoved(x, y)
if y == 0 then return end
if dropdown.wheelmoved(x, y) then return end
end
function love.keypressed(key)
if key == 'f6' then -- print all globals
for k, v in pairs(_G) do
for _, g in ipairs(default_G) do
if g == k then goto continue end
end
print(k, v)
::continue::
end
end
end