Mothback/code/ui.lua

48 lines
1.1 KiB
Lua

UIElement = {}
function addElement(self)
table.insert(UIElement,self)
self.id = #UIElement
end
function drawTextBox(text,x,y,style)
local style = style or {}
local c1, c2, c3, a = love.graphics.getColor()
local width = locale_font:getWidth(text)
local height = locale_font:getHeight(text)
local color = style.color or {1,1,1,1}
local background_color = style.background_color or {0,0,0,1}
local margin = style.margin or 5
local rotation = style.rotation or 0
local sx = style.sx or 1
local sy = style.sy or style.sx
local lines = 1
for i in text:gmatch("\n") do
lines = lines + 1
end
love.graphics.setColor(unpack(color))
love.graphics.rectangle("fill",
x-1,
y-1,
width+margin*2+2,
height*lines+margin*2+2
)
love.graphics.setColor(unpack(background_color))
love.graphics.rectangle("fill",
x,
y,
width+margin*2,
height*lines+margin*2
)
love.graphics.setColor(unpack(color))
love.graphics.print(text, x+margin, y+margin)
love.graphics.setColor(c1,c2,c3,a)
end
require "code/ui/button"
require "code/ui/dialog"
require "code/ui/prompt"