moved the textinbox to a separate function, adjusted margin

This commit is contained in:
lustlion
2022-03-11 14:38:52 +01:00
parent 96b1e750e4
commit 266bf10d13
2 changed files with 29 additions and 20 deletions

View File

@@ -5,6 +5,30 @@ function addElement(self)
self.id = #UIElement
end
function drawTextBox(text,x,y,color,background_color)
local c1, c2, c3, a = love.graphics.getColor()
local width = locale_font:getWidth(text)
local height = locale_font:getHeight(text)
local margin = 5
love.graphics.setColor(unpack(color))
love.graphics.rectangle("fill",
x-1,
y-1,
width+margin*2+2,
height+margin*2+2
)
love.graphics.setColor(unpack(background_color))
love.graphics.rectangle("fill",
x,
y,
width+margin*2,
height+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"