moved the textinbox to a separate function, adjusted margin
This commit is contained in:
parent
96b1e750e4
commit
266bf10d13
24
code/ui.lua
24
code/ui.lua
@ -5,6 +5,30 @@ function addElement(self)
|
|||||||
self.id = #UIElement
|
self.id = #UIElement
|
||||||
end
|
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/button"
|
||||||
require "code/ui/dialog"
|
require "code/ui/dialog"
|
||||||
require "code/ui/prompt"
|
require "code/ui/prompt"
|
||||||
|
@ -53,28 +53,13 @@ function Prompt:textinput(text)
|
|||||||
end
|
end
|
||||||
|
|
||||||
function Prompt:draw()
|
function Prompt:draw()
|
||||||
local c1, c2, c3, a = love.graphics.getColor()
|
drawTextBox(
|
||||||
local text = self.name .. ": " .. self.input
|
self.name .. ": " .. self.input,
|
||||||
local width = locale_font:getWidth(text)
|
self.pos.x,
|
||||||
local height = locale_font:getHeight(text)
|
|
||||||
local margin = 10
|
|
||||||
love.graphics.setColor(unpack(self.color))
|
|
||||||
love.graphics.rectangle("fill",
|
|
||||||
self.pos.x-margin-1,
|
|
||||||
self.pos.y-1,
|
|
||||||
width+margin*2+2,
|
|
||||||
height+margin+2
|
|
||||||
)
|
|
||||||
love.graphics.setColor(unpack(self.background_color))
|
|
||||||
love.graphics.rectangle("fill",
|
|
||||||
self.pos.x-margin,
|
|
||||||
self.pos.y,
|
self.pos.y,
|
||||||
width+margin*2,
|
self.color,
|
||||||
height+margin
|
self.background_color
|
||||||
)
|
)
|
||||||
love.graphics.setColor(unpack(self.color))
|
|
||||||
love.graphics.print(text, self.pos.x, self.pos.y)
|
|
||||||
love.graphics.setColor(c1,c2,c3,a)
|
|
||||||
end
|
end
|
||||||
|
|
||||||
function Prompt:activate()
|
function Prompt:activate()
|
||||||
|
Loading…
Reference in New Issue
Block a user