/trunk/DotIt/libs
local major = "SBar-0.1" |
local major = "SBar-0.1" |
local minor = 1 |
local DEBUG = true |
local tinsert = table.insert |
maintexture:SetWidth(f:GetWidth()) |
return f |
end |
local function createVerticalBar(data, duration, start, barheight, maxtime, text, icon, pos, color, colorzero, maxneg, loflag, texture) |
local function createVerticalBar(data, duration, start, barheight, maxtime, text, icon, pos, color, colorzero, maxneg, loflag, texture, onhide) |
local tmptime |
if not scaleinfo.frame:IsShown() then |
scaleinfo.frame:Show() |
for ch in string.gmatch(string.upper(text), ".") do |
-- first element |
local fobj = barf:CreateFontString() |
setFont(font) |
setFont(fobj) |
barfon[count] = fobj |
fobj:SetText(ch) |
if count == 0 then |
fobj:SetPoint("TOPLEFT", barf, "TOPLEFT", barf:GetWidth()/2 - fobj:GetStringWidth()/2 , -1*scaleinfo.height - 5) |
fobj:SetPoint("CENTER", barf, "CENTER") |
if not icon then |
fobj:SetPoint("TOP", barf, "TOP", 0, -1) |
else |
if scaleinfo.iconpos then |
fobj:SetPoint("TOP", barf, "TOP", 0, -1 - scaleinfo.height) |
else |
fobj:SetPoint("TOP", barf, "TOP", 0, -1) |
end |
end |
else |
fobj:SetPoint("TOPLEFT", barfon[count-1], "BOTTOMLEFT", 0, 0) |
end |
else |
baric:SetPoint("TOPRIGHT", barf, "TOPRIGHT", 0, 0) |
end |
if not icon then |
end |
if onhide then |
barf:SetScript("OnHide", onhide) |
end |
tinsert(bars, { data = data, frame = barf, tex = bart, texg = bartg, dur = duration, start = start, pos = pos, text = barfon, icon = baric } ) |
end |
-- |
local function createHorizontalBar(data, duration, start, barwidth, maxtime, text, icon, pos, color, colorzero, maxneg, loflag, texture) |
local function createHorizontalBar(data, duration, start, barwidth, maxtime, text, icon, pos, color, colorzero, maxneg, loflag, texture, onhide) |
-- |
local tmptime |
if not scaleinfo.frame:IsShown() then |
local barfon = barf:CreateFontString() |
setFont(barfon) |
barfon:SetText(text) |
barfon:SetPoint("BOTTOMRIGHT", barf, "BOTTOMRIGHT", -1 * scaleinfo.height - 5 , scaleinfo.height/2 - barfon:GetStringWidth()/2) |
barfon:SetPoint("CENTER", barf, "CENTER") |
-- normal texture |
local bart = barf:CreateTexture(nil, "BACKGROUND") |
bart:SetTexture(texture or default.texture) |
baric:SetWidth(scaleinfo.height) |
if scaleinfo.iconpos then |
baric:SetPoint("TOPRIGHT", barf, "TOPRIGHT", baric:GetWidth(), 0) |
barfon:SetPoint("RIGHT", barf, "RIGHT", -1) |
else |
baric:SetPoint("TOPRIGHT", barf, "TOPRIGHT", 0, 0) |
barfon:SetPoint("RIGHT", barf, "RIGHT", -1*scaleinfo.height, 0 ) |
end |
if not icon then |
barfon:SetPoint("RIGHT", barf, "RIGHT", -1) |
end |
if onhide then |
barf:SetScript("OnHide", onhide) |
end |
tinsert(bars, { data = data, frame = barf, tex = bart, texg = bartg, dur = duration, start = start, pos = pos, text = barfon, icon = baric } ) |
end |
-- @param color The color for the positive side of the bar (color_def). |
-- @param colorzero The color for the negative side of the bar (color_def). |
-- @see color_def |
function sbar:CreateBar(data, duration, start, text, icon, pos, color, colorzero, texture) |
function sbar:CreateBar(data, duration, start, text, icon, pos, color, colorzero, texture, onhide) |
argcheck(duration, 2, "number") |
argcheck(start, 3, "number") |
argcheck(text, 4, "string", "nil") |
argcheck(color, 7, "table") |
argcheck(colorzero, 8, "table") |
argcheck(texture, 9, "string", "nil") |
argcheck(onhide, 10, "function", "nil") |
local scale |
if scaleinfo.horizontal then |
createHorizontalBar(data, duration, start, scaleinfo.size, scaleinfo.maxtime, text, icon, pos, color, colorzero, scaleinfo.maxneg, scaleinfo.loflag, texture) |
createHorizontalBar(data, duration, start, scaleinfo.size, scaleinfo.maxtime, text, icon, pos, color, colorzero, scaleinfo.maxneg, scaleinfo.loflag, texture, onhide) |
else |
createVerticalBar(data, duration, start, scaleinfo.size, scaleinfo.maxtime, text, icon, pos, color, colorzero, scaleinfo.maxneg, scaleinfo.loflag, texture) |
createVerticalBar(data, duration, start, scaleinfo.size, scaleinfo.maxtime, text, icon, pos, color, colorzero, scaleinfo.maxneg, scaleinfo.loflag, texture, onhide) |
end |
self:UpdateFrameLevel() |
end |