2012-01-10 23:13:40 +01:00
|
|
|
UIProgressBar = extends(UIWidget)
|
|
|
|
|
|
|
|
function UIProgressBar.create()
|
|
|
|
local progressbar = UIProgressBar.internalCreate()
|
|
|
|
progressbar:setFocusable(false)
|
|
|
|
progressbar:setPhantom(true)
|
2012-01-11 13:48:34 +01:00
|
|
|
progressbar.percent = 0
|
|
|
|
progressbar:setBackgroundSize({width = 1, height = 1})
|
2012-01-10 23:13:40 +01:00
|
|
|
return progressbar
|
|
|
|
end
|
|
|
|
|
|
|
|
function UIProgressBar:setPercent(percent)
|
|
|
|
self:setBackgroundHeight(self:getHeight())
|
2012-01-11 13:48:34 +01:00
|
|
|
local width = (percent * self:getWidth())/100
|
|
|
|
if width == 0 then width = 1 end
|
|
|
|
self:setBackgroundWidth(width)
|
2012-01-10 23:13:40 +01:00
|
|
|
self.percent = percent
|
|
|
|
end
|
|
|
|
|
|
|
|
function UIProgressBar:getPercent()
|
|
|
|
return self.percent
|
|
|
|
end
|