2021-09-17 22:25:14 +00:00
|
|
|
local default_G = {}
|
|
|
|
for k, v in pairs(_G) do
|
|
|
|
table.insert(default_G, k)
|
|
|
|
end
|
|
|
|
|
2021-09-18 10:02:25 +00:00
|
|
|
love.graphics.setDefaultFilter('nearest', 'nearest')
|
2021-09-19 19:36:33 +00:00
|
|
|
|
|
|
|
local fontSize = 20
|
|
|
|
interfaceFont = love.graphics.newFont('assets/fonts/Inter-Regular.otf', fontSize)
|
|
|
|
|
|
|
|
local fontCache = {}
|
|
|
|
|
|
|
|
function getFont(size, italic)
|
|
|
|
if fontCache[size] and fontCache[size][italic] then return fontCache[size][italic] end
|
|
|
|
|
|
|
|
fontCache[size] = fontCache[size] or {}
|
|
|
|
fontCache[size][italic] = love.graphics.newFont('assets/fonts/Inter-' .. (italic and 'Italic' or 'Regular') .. '.otf', math.floor(fontSize * size))
|
|
|
|
return fontCache[size][italic]
|
|
|
|
end
|
2021-09-18 10:02:25 +00:00
|
|
|
|
2021-09-19 12:16:40 +00:00
|
|
|
ease = require 'src.ease'
|
2021-09-17 19:24:26 +00:00
|
|
|
|
2021-09-19 12:16:40 +00:00
|
|
|
slider = require 'src.slider'
|
|
|
|
dropdown = require 'src.dropdown'
|
|
|
|
graph = require 'src.graph'
|
|
|
|
button = require 'src.button'
|
|
|
|
tooltips = require 'src.tooltips'
|
2021-09-17 19:24:26 +00:00
|
|
|
|
2021-09-18 22:11:44 +00:00
|
|
|
modes = {
|
|
|
|
preview = 1,
|
|
|
|
mix = 2,
|
2021-09-19 10:16:27 +00:00
|
|
|
multiply = 3,
|
|
|
|
create = 4
|
2021-09-18 22:11:44 +00:00
|
|
|
}
|
|
|
|
|
2021-09-18 00:05:13 +00:00
|
|
|
function createUI()
|
|
|
|
dropdown.createDropdowns()
|
|
|
|
slider.createSliders()
|
2021-09-19 10:32:12 +00:00
|
|
|
button.createButtons()
|
2021-09-18 00:05:13 +00:00
|
|
|
end
|
|
|
|
|
2021-09-19 12:16:40 +00:00
|
|
|
require 'src.util' -- exports into global table
|
2021-09-17 19:24:26 +00:00
|
|
|
|
|
|
|
-- rendering constants
|
|
|
|
|
2021-09-18 01:01:45 +00:00
|
|
|
padding = 16
|
2021-09-17 22:51:42 +00:00
|
|
|
outerpadding = 22
|
|
|
|
margin = 6
|
2021-09-18 10:42:45 +00:00
|
|
|
dropdownWidth = 186
|
2021-09-18 10:21:53 +00:00
|
|
|
lineWidth = 2
|
2021-09-18 00:05:13 +00:00
|
|
|
fontHeight = love.graphics.getFont():getHeight()
|
2021-09-17 19:24:26 +00:00
|
|
|
|
2021-09-19 18:20:22 +00:00
|
|
|
screenshot = false
|
|
|
|
screenshotCanvas = nil
|
|
|
|
screenshotsize = 512
|
|
|
|
|
2021-09-18 00:05:13 +00:00
|
|
|
-- global for convinience's sake
|
2021-09-17 22:38:04 +00:00
|
|
|
|
2021-09-18 00:05:13 +00:00
|
|
|
mode = nil
|
2021-09-17 19:24:26 +00:00
|
|
|
|
|
|
|
function love.load()
|
2021-09-18 10:11:19 +00:00
|
|
|
love.graphics.setFont(interfaceFont)
|
2021-09-18 00:05:13 +00:00
|
|
|
fontHeight = love.graphics.getFont():getHeight()
|
|
|
|
createUI()
|
2021-09-17 19:24:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function love.update(dt)
|
2021-09-17 22:34:16 +00:00
|
|
|
graph.update(dt)
|
2021-09-18 00:05:13 +00:00
|
|
|
slider.update(dt)
|
2021-09-17 22:25:14 +00:00
|
|
|
dropdown.update(dt)
|
2021-09-19 10:32:12 +00:00
|
|
|
button.update(dt)
|
2021-09-19 10:56:48 +00:00
|
|
|
tooltips.update(dt)
|
2021-09-17 19:24:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function love.draw()
|
|
|
|
local sw, sh = love.graphics.getDimensions()
|
|
|
|
local mx, my = love.mouse.getPosition()
|
2021-09-17 22:38:04 +00:00
|
|
|
|
2021-09-19 18:20:22 +00:00
|
|
|
if screenshot then
|
|
|
|
love.graphics.setCanvas(screenshotCanvas)
|
|
|
|
sw, sh = screenshotsize, screenshotsize
|
|
|
|
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)
|
|
|
|
graph.render()
|
|
|
|
love.graphics.setCanvas()
|
|
|
|
|
|
|
|
--[[
|
|
|
|
-- for seeing what gets drawn to it
|
|
|
|
love.graphics.setColor(1, 1, 1)
|
|
|
|
love.graphics.draw(screenshotCanvas)
|
|
|
|
|
|
|
|
return
|
|
|
|
]]
|
|
|
|
|
|
|
|
local ss = screenshotCanvas:newImageData(0, 1, 0, 0, screenshotsize, screenshotsize)
|
|
|
|
ss:encode('png', 'screenshot ' .. os.date('%Y-%m-%d %H-%m') .. '.png')
|
|
|
|
love.system.openURL('file://' .. love.filesystem.getSaveDirectory())
|
|
|
|
|
|
|
|
screenshot = false
|
|
|
|
end
|
|
|
|
|
|
|
|
love.graphics.setCanvas()
|
|
|
|
|
2021-09-19 11:25:23 +00:00
|
|
|
-- this is fine to do since all textures are already loaded with nearest
|
|
|
|
love.graphics.setDefaultFilter('linear', 'linear')
|
|
|
|
|
2021-09-18 10:21:53 +00:00
|
|
|
love.graphics.setLineWidth(2)
|
|
|
|
|
2021-09-17 19:24:26 +00:00
|
|
|
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)
|
2021-09-17 22:38:04 +00:00
|
|
|
|
2021-09-18 11:02:08 +00:00
|
|
|
love.graphics.setColor(0.2, 0.2, 0.3, 1)
|
2021-09-18 00:05:13 +00:00
|
|
|
love.graphics.print('Box of Eases by oatmealine', outerpadding, sh - fontHeight - outerpadding)
|
2021-09-17 22:38:04 +00:00
|
|
|
|
2021-09-19 10:56:48 +00:00
|
|
|
tooltips.prerender()
|
|
|
|
|
2021-09-19 10:32:12 +00:00
|
|
|
button.render()
|
|
|
|
|
2021-09-18 00:05:13 +00:00
|
|
|
slider.render()
|
2021-09-17 22:38:04 +00:00
|
|
|
|
2021-09-17 22:25:14 +00:00
|
|
|
dropdown.render()
|
2021-09-17 22:38:04 +00:00
|
|
|
|
2021-09-17 22:34:16 +00:00
|
|
|
graph.render()
|
2021-09-19 10:56:48 +00:00
|
|
|
|
|
|
|
tooltips.render()
|
2021-09-17 19:24:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function love.mousepressed(x, y, m)
|
2021-09-17 22:25:14 +00:00
|
|
|
if dropdown.mousepressed(x, y, m) then return end
|
2021-09-19 11:37:46 +00:00
|
|
|
button.mousepressed(x, y, m)
|
2021-09-17 19:24:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function love.mousereleased(x, y, m)
|
2021-09-17 22:25:14 +00:00
|
|
|
if dropdown.mousereleased(x, y, m) then return end
|
2021-09-17 19:24:26 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
function love.wheelmoved(x, y)
|
|
|
|
if y == 0 then return end
|
2021-09-17 22:38:04 +00:00
|
|
|
|
2021-09-17 22:25:14 +00:00
|
|
|
if dropdown.wheelmoved(x, y) then return end
|
2021-09-19 16:18:32 +00:00
|
|
|
graph.wheelmoved(x, y)
|
2021-09-17 22:25:14 +00:00
|
|
|
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
|
2021-09-17 19:24:26 +00:00
|
|
|
end
|
2021-09-17 22:25:14 +00:00
|
|
|
print(k, v)
|
|
|
|
::continue::
|
2021-09-17 19:24:26 +00:00
|
|
|
end
|
|
|
|
end
|
2021-09-17 22:25:14 +00:00
|
|
|
end
|