Прогрессбар-фича

This commit is contained in:
igor 2018-01-06 12:49:29 +03:00
parent 1f1516ceae
commit 833c1eb406
2 changed files with 3 additions and 3 deletions

View File

@ -319,7 +319,7 @@
url="https://raw.githubusercontent.com/IgorTimofeev/OpenComputers/master/lib/GUI.lua",
type="Library",
preloadFile=true,
version=2.08,
version=2.09,
},
{
path="/lib/rayEngine.lua",

View File

@ -797,7 +797,7 @@ end
----------------------------------------- ProgressBar Object -----------------------------------------
local function drawProgressBar(object)
local activeWidth = math.floor(object.value * object.width / 100)
local activeWidth = math.floor(math.min(object.value, 100) / 100 * object.width)
if object.thin then
buffer.text(object.x, object.y, object.colors.passive, string.rep("", object.width))
buffer.text(object.x, object.y, object.colors.active, string.rep("", activeWidth))
@ -807,7 +807,7 @@ local function drawProgressBar(object)
end
if object.showValue then
local stringValue = tostring((object.valuePrefix or "") .. object.value .. (object.valuePostfix or ""))
local stringValue = (object.valuePrefix or "") .. object.value .. (object.valuePostfix or "")
buffer.text(math.floor(object.x + object.width / 2 - unicode.len(stringValue) / 2), object.y + 1, object.colors.value, stringValue)
end