mirror of
https://github.com/edubart/otclient.git
synced 2025-04-30 17:49:21 +02:00

* Split game module into game and game_interface * Move core_lib to corelib * Move miniwindow to corelib * Introduce init.lua script for initializing the client, giving much more flexibility * OTClient is no longer Application derived and is much simpler
36 lines
842 B
Lua
36 lines
842 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:getPercentPixels()
|
|
return 100 / self:getWidth()
|
|
end
|
|
|
|
function UIProgressBar:updateBackground()
|
|
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
|