tibia-client/modules/corelib/ui/uiprogressbar.lua

37 lines
855 B
Lua
Raw Normal View History

2012-06-26 00:13:30 +02:00
-- @docclass
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
2012-06-08 22:58:24 +02:00
function UIProgressBar:getPercentPixels()
return 100 / self:getWidth()
end
function UIProgressBar:updateBackground()
2012-06-08 22:58:24 +02:00
local width = math.round(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