otclient/modules/core_lib/widgets/uiprogressbar.lua
Eduardo Bart 33458a3e39 modules changes
* speedup widget destruction checks
* rework outfit module using grid layout and the new design
* fixes in console, terminal, textmessage modules
2012-03-22 18:47:52 -03:00

32 lines
752 B
Lua

UIProgressBar = extends(UIWidget)
function UIProgressBar.create()
local progressbar = UIProgressBar.internalCreate()
progressbar:setFocusable(false)
progressbar:setPhantom(true)
progressbar.percent = 0
progressbar:updateBackground()
return progressbar
end
function UIProgressBar:setPercent(percent)
self.percent = math.max(math.min(percent, 100), 0)
self:updateBackground()
end
function UIProgressBar:getPercent()
return self.percent
end
function UIProgressBar:updateBackground()
local width = math.max((self.percent * self:getWidth())/100, 1)
local height = self:getHeight()
self:setBackgroundSize({width=width, height=height})
end
function UIProgressBar:onGeometryChange(oldRect, newRect)
self:updateBackground()
end