2026-05-21 00:49:54 +00:00
|
|
|
local ui = {}
|
|
|
|
|
|
|
|
|
|
ui.theme = {
|
|
|
|
|
bg = {0.13, 0.13, 0.14},
|
|
|
|
|
panel = {0.17, 0.17, 0.19},
|
2026-05-22 01:38:35 +00:00
|
|
|
border = {0.28, 0.28, 0.30}, -- also known as outline
|
2026-05-21 00:49:54 +00:00
|
|
|
borderwidth = 3,
|
|
|
|
|
text = {0.90, 0.90, 0.90},
|
2026-05-22 01:38:35 +00:00
|
|
|
text_dim = {0.50, 0.50, 0.55}, -- low-key forgot
|
|
|
|
|
accent = {0.27, 0.52, 0.90}, -- low-key also forgot
|
2026-05-21 00:49:54 +00:00
|
|
|
hover = {0.22, 0.22, 0.25},
|
2026-05-22 01:38:35 +00:00
|
|
|
active = {0.20, 0.40, 0.75}, -- i low-key forgot again
|
2026-05-21 00:49:54 +00:00
|
|
|
}
|
|
|
|
|
|
2026-05-22 01:38:35 +00:00
|
|
|
ui.events = {}
|
|
|
|
|
|
|
|
|
|
function ui.emit(event)
|
|
|
|
|
ui.events[event] = true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ui.on(event)
|
|
|
|
|
return ui.events[event] == true
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ui.flush()
|
|
|
|
|
ui.events = {}
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
function ui.panel(x, y, w, h) -- this thingy magic panel creator makes a ui with outline. (x pos, y pos, width, height)
|
2026-05-21 00:49:54 +00:00
|
|
|
love.graphics.setColor(ui.theme.panel)
|
|
|
|
|
love.graphics.rectangle("fill", x, y, w, h)
|
|
|
|
|
love.graphics.setColor(ui.theme.border)
|
|
|
|
|
love.graphics.setLineWidth(ui.theme.borderwidth)
|
|
|
|
|
love.graphics.rectangle("line", x, y, w, h)
|
|
|
|
|
end
|
|
|
|
|
|
2026-05-22 01:38:35 +00:00
|
|
|
function ui.button(x, y, w, h, text)
|
|
|
|
|
local mousex, mousey = love.mouse.getPosition()
|
|
|
|
|
local hovered = mousex > x and mousex < x + w and mousey > y and mousey < y + h -- calculaters if its touching the box
|
|
|
|
|
if hovered then
|
|
|
|
|
love.graphics.setColor(ui.theme.hover)
|
|
|
|
|
love.graphics.rectangle("fill", x, y , w, h)
|
|
|
|
|
love.graphics.setColor(ui.theme.border)
|
|
|
|
|
love.graphics.setLineWidth(ui.theme.borderwidth)
|
|
|
|
|
love.graphics.rectangle("line", x, y ,w, h)
|
|
|
|
|
love.graphics.setColor(ui.theme.text)
|
|
|
|
|
love.graphics.printf(text, x, y + h/2-7, w, "center")
|
|
|
|
|
else
|
|
|
|
|
-- makes a panel and then just adds text to it
|
|
|
|
|
ui.panel(x, y, w, h)
|
|
|
|
|
love.graphics.setColor(ui.theme.text)
|
|
|
|
|
love.graphics.printf(text, x, y + h/2-7, w, "center")
|
|
|
|
|
end
|
2026-05-21 00:49:54 +00:00
|
|
|
|
2026-05-22 01:38:35 +00:00
|
|
|
if hovered and love.mouse.isDown(1) then
|
|
|
|
|
ui.emit(text) -- uses button label as event name for now, change later to avoid same ID stuff
|
|
|
|
|
end
|
|
|
|
|
|
|
|
|
|
return hovered -- returns hovered
|
2026-05-21 00:49:54 +00:00
|
|
|
end
|
|
|
|
|
|
2026-05-22 01:38:35 +00:00
|
|
|
|
2026-05-21 00:49:54 +00:00
|
|
|
return ui
|