improvement to drawTextBox to account for newlines.
used drawTextBox in editor palette
This commit is contained in:
11
code/ui.lua
11
code/ui.lua
@@ -6,23 +6,30 @@ function addElement(self)
|
||||
end
|
||||
|
||||
function drawTextBox(text,x,y,color,background_color)
|
||||
local color = color or {1,1,1,1}
|
||||
local background_color = background_color or {0,0,0,1}
|
||||
local c1, c2, c3, a = love.graphics.getColor()
|
||||
local width = locale_font:getWidth(text)
|
||||
local height = locale_font:getHeight(text)
|
||||
local margin = 5
|
||||
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+margin*2+2
|
||||
height*lines+margin*2+2
|
||||
)
|
||||
love.graphics.setColor(unpack(background_color))
|
||||
love.graphics.rectangle("fill",
|
||||
x,
|
||||
y,
|
||||
width+margin*2,
|
||||
height+margin*2
|
||||
height*lines+margin*2
|
||||
)
|
||||
love.graphics.setColor(unpack(color))
|
||||
love.graphics.print(text, x+margin, y+margin)
|
||||
|
||||
Reference in New Issue
Block a user