WoWInterface SVN oUF_AuraBars

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /
    from Rev 23 to Rev 22
    Reverse comparison

Rev 23 → Rev 22

trunk/oUF_AuraBars/oUF_AuraBars.lua
17,8 → 17,10
- <element>.spellTimeObject, <element>.spellNameObject
Objects passed by CreateFontObject(). These will ignore the
following options:
<element>.spellTimeFont, <element>.spellTimeSize
<element>.spellNameFont, <element>.spellNameSize
<element>.spellTimeFont
<element>.spellTimeSize
<element>.spellNameFont
<element>.spellNameSize
- <element>.spellTimeFont, <element>.spellTimeSize,
<element>.spellNameFont, <element>.spellNameSize
Options to control the texts on the statusbars.
53,9 → 55,13
assert(oUF, 'oUF_AuraBars was unable to locate oUF install.')
 
--[[
AuraBars.
]]--
 
--[[
Shortens an spell name to a given length
]]--
local function ShortenedSpellName(spellName, length)
local function ShortenedSpellName(spellName,length)
return string.len(spellName) > length and string.gsub(spellName, '%s?(.)%S+%s', '%1. ') or spellName
end
 
63,11 → 69,11
Rounds a number to a given number of decimal places.
]]--
local function Round(number, decimalPlaces)
if decimalPlaces and decimalPlaces > 0 then
if decimalPlaces and (decimalPlaces > 0) then
local mult = 10^decimalPlaces
return math.floor(number * mult + .5) / mult
return math.floor(number * mult + 0.5) / mult
end
return math.floor(num + .5)
return math.floor(num + 0.5)
end
 
--[[
80,9 → 86,9
local h = math.floor(timeInSec / 3600)
local m = math.floor((timeInSec - (3600 * h)) / 60)
local s = math.floor(timeInSec - ((3600 * h) + (60 * m)))
if h > 0 then
if(h > 0) then
return h .. ":" .. m .. "h"
elseif m > 0 then
elseif(m > 0) then
return m .. "m"
else
return s .. "s"
91,7 → 97,7
--[[
Creates a bar to represent an aura
]]--
local function CreateAuraBar(oUF, anchor)
local function CreateAuraBar(oUF , anchor)
local auraBarParent = oUF.AuraBars
 
-- the main bar
99,57 → 105,57
statusBar:SetHeight(auraBarParent.auraBarHeight or 20)
statusBar:SetWidth((auraBarParent.auraBarWidth or auraBarParent:GetWidth()) - (statusBar:GetHeight() + auraBarParent.gap or 0))
statusBar:SetStatusBarTexture(auraBarParent.auraBarTexture or [[Interface\TargetingFrame\UI-StatusBar]])
statusBar:SetStatusBarColor(0, .5, 0)
statusBar:SetAlpha(auraBarParent.fgalpha or 1)
statusBar:SetStatusBarColor(0.0, 0.5, 0.0)
statusBar:SetAlpha(auraBarParent.fgalpha or 1.0)
 
-- the background
statusBar.bg = statusBar:CreateTexture(nil, "BORDER")
statusBar.bg:SetAllPoints(statusBar)
statusBar.bg:SetTexture(auraBarParent.auraBarTexture or [[Interface\TargetingFrame\UI-StatusBar]])
statusBar.bg:SetVertexColor(.5, 1, .5)
statusBar.bg:SetAlpha(auraBarParent.bgalpha or 1)
statusBar.bg:SetVertexColor(0.5,1.0,0.5)
statusBar.bg:SetAlpha(auraBarParent.bgalpha or 1.0)
 
if auraBarParent.down == true then
if auraBarParent == anchor then -- Root frame so indent for icon
statusBar:SetPoint('TOPLEFT', anchor, 'BOTTOMLEFT', (statusBar:GetHeight() + auraBarParent.gap or 0), 0)
if(auraBarParent.down == true) then
if(auraBarParent == anchor) then -- Root frame so indent for icon
statusBar:SetPoint("TOPLEFT", anchor, "BOTTOMLEFT", (statusBar:GetHeight() + auraBarParent.gap or 0), 0)
else
statusBar:SetPoint('TOPLEFT', anchor, 'BOTTOMLEFT', 0, (-auraBarParent.spacing or 0))
statusBar:SetPoint("TOPLEFT", anchor, "BOTTOMLEFT", 0, (-auraBarParent.spacing or 0))
end
else
if auraBarParent == anchor then -- Root frame so indent for icon
statusBar:SetPoint('BOTTOMLEFT', anchor, 'TOPLEFT', (statusBar:GetHeight() + auraBarParent.gap or 0), 0)
if(auraBarParent == anchor) then -- Root frame so indent for icon
statusBar:SetPoint("BOTTOMLEFT", anchor, "TOPLEFT", (statusBar:GetHeight() + auraBarParent.gap or 0), 0)
else
statusBar:SetPoint('BOTTOMLEFT', anchor, 'TOPLEFT', 0, (auraBarParent.spacing or 0))
statusBar:SetPoint("BOTTOMLEFT", anchor, "TOPLEFT", 0, (auraBarParent.spacing or 0))
end
end
 
statusBar.icon = statusBar:CreateTexture(nil, 'BACKGROUND')
statusBar.icon:SetHeight(statusBar:GetHeight())
statusBar.icon:SetWidth(statusBar:GetHeight())
statusBar.icon:SetTexCoord(.07, .93, .07, .93)
statusBar.icon:SetTexCoord(0.07, 0.93, 0.07, 0.93)
statusBar.icon:SetPoint'TOP'
statusBar.icon:SetPoint('LEFT', auraBarParent)
 
statusBar.spelltime = statusBar:CreateFontString(nil, 'ARTWORK')
statusBar.spelltime = statusBar:CreateFontString(nil, "ARTWORK")
if auraBarParent.spellTimeObject then
statusBar.spelltime:SetFontObject(auraBarParent.spellTimeObject)
else
statusBar.spelltime:SetFont(auraBarParent.spellTimeFont or [[Fonts\FRIZQT__.TTF]], auraBarParent.spellTimeSize or 10)
end
statusBar.spelltime:SetTextColor(1 ,1, 1)
statusBar.spelltime:SetJustifyH'RIGHT'
statusBar.spelltime:SetJustifyV'CENTER'
statusBar.spelltime:SetTextColor(1.0,1.0,1.0)
statusBar.spelltime:SetJustifyH("RIGHT")
statusBar.spelltime:SetJustifyV("CENTER")
statusBar.spelltime:SetPoint'RIGHT'
 
statusBar.spellname = statusBar:CreateFontString(nil, 'ARTWORK')
statusBar.spellname = statusBar:CreateFontString(nil, "ARTWORK")
if auraBarParent.spellNameObject then
statusBar.spellname:SetFontObject(auraBarParent.spellNameObject)
else
statusBar.spellname:SetFont(auraBarParent.spellNameFont or [[Fonts\FRIZQT__.TTF]], auraBarParent.spellNameSize or 10)
end
statusBar.spellname:SetTextColor(1, 1, 1)
statusBar.spellname:SetJustifyH'LEFT'
statusBar.spellname:SetJustifyV'CENTER'
statusBar.spellname:SetTextColor(1.0, 1.0, 1.0)
statusBar.spellname:SetJustifyH("LEFT")
statusBar.spellname:SetJustifyV("CENTER")
statusBar.spellname:SetPoint'LEFT'
statusBar.spellname:SetPoint('RIGHT', statusBar.spelltime, 'LEFT')
 
168,9 → 174,9
local bars = auraBars.bars
local timenow = GetTime()
 
for index = 1, #bars do
for index = 1, #(bars) do
local bar = bars[index]
if not bar:IsVisible() then
if(not bar:IsVisible()) then
break
end
if bar.aura.noTime then
187,7 → 193,7
Default filter
]]--
local function DefaultFilter(name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable)
if unitCaster == 'player' then
if(unitCaster == "player") then
return true
end
end
202,17 → 208,17
monitoring it's remaining time.
]]--
local function Update(self, event, unit)
if self.unit ~= unit then return end
local helpOrHarm = UnitIsFriend('player', unit) and 'HELPFUL' or 'HARMFUL'
if(self.unit ~= unit) then return end
local helpOrHarm = UnitIsFriend("player",unit) and "HELPFUL" or "HARMFUL"
 
-- Create a table of auras to display
local auras = {}
local lastAuraIndex = 0
for index = 1, 40 do
local name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable = UnitAura(unit, index, helpOrHarm)
if not name then break end
if(not name) then break end
 
if (self.AuraBars.filter or DefaultFilter)(name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable) then
if((self.AuraBars.filter or DefaultFilter)(name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable)) then
lastAuraIndex = lastAuraIndex + 1
auras[lastAuraIndex] = {}
auras[lastAuraIndex].name = name
224,10 → 230,10
auras[lastAuraIndex].expirationTime = expirationTime
auras[lastAuraIndex].unitCaster = unitCaster
auras[lastAuraIndex].isStealable = isStealable
auras[lastAuraIndex].noTime = (duration == 0 and expirationTime == 0)
auras[lastAuraIndex].noTime = ( duration == 0 and expirationTime == 0)
end
end
 
 
if self.AuraBars.sort then
table.sort(auras, type(self.AuraBars.sort) == 'function' and self.AuraBars.sort or sort)
end
237,10 → 243,13
for index = 1 , lastAuraIndex do
local aura = auras[index]
local bar = bars[index]
 
if not bar then
bar = CreateAuraBar(self, index == 1 and self.AuraBars or bars[index - 1])
 
if(bar == nil) and (index == 1) then
bar = CreateAuraBar(self,self.AuraBars) -- Relative to anchor
bars[index] = bar
elseif(bar == nil) then
bar = CreateAuraBar(self,bars[index - 1]) -- Relative to previous bar
bars[index] = bar
end
 
-- Backup the details of the aura onto the bar, so the OnUpdate function can use it
266,14 → 275,21
 
bar.icon:SetTexture(bar.aura.icon)
 
bar.spellname:SetText(bar.aura.count > 1 and string.format("%s [%d]", ShortenedSpellName(bar.aura.name, 20), bar.aura.count) or ShortenedSpellName(bar.aura.name, 20))
local spellText
if(bar.aura.count > 1) then
spellText = string.format("%s [%d]", ShortenedSpellName(aura.name,20), bar.aura.count)
else
spellText = ShortenedSpellName(bar.aura.name,20)
end
 
bar.spellname:SetText(spellText)
bar.spelltime:SetText(not bar.noTime and FormatTime(bar.aura.expirationTime-GetTime()))
 
-- Colour bars
local r, g, b = .2, .6, 1 -- Colour for buffs (This is Magic Blue)
local r, g, b = 0.2, 0.6, 1.0 -- Colour for buffs (This is Magic Blue)
local bgMod = 0.5
if helpOrHarm == 'HARMFUL' then
local debuffType = bar.aura.debuffType and bar.aura.debuffType or 'none'
if(helpOrHarm == "HARMFUL") then
local debuffType = bar.aura.debuffType and bar.aura.debuffType or "none"
r, g, b = DebuffTypeColor[debuffType].r, DebuffTypeColor[debuffType].g, DebuffTypeColor[debuffType].b
end
bar:SetStatusBarColor(r, g, b)
282,7 → 298,7
end
 
-- Hide unused bars.
for index = lastAuraIndex + 1, #bars do
for index = lastAuraIndex + 1, #(bars) do
bars[index]:Hide()
end
end
291,10 → 307,10
Enable function for oUF
]]--
local function Enable(self)
if self.AuraBars then
self:RegisterEvent('UNIT_AURA', Update)
if(self.AuraBars) then
self:RegisterEvent("UNIT_AURA", Update)
self.AuraBars.bars = self.AuraBars.bars or {}
self.AuraBars:SetScript('OnUpdate', UpdateBars)
self.AuraBars:SetScript("OnUpdate", UpdateBars)
return true -- Ensure we get an update when the parent frame is displayed
end
end
304,10 → 320,10
]]--
local function Disable(self)
local auraFrame = self.AuraBars
if auraFrame then
self:UnregisterEvent('UNIT_AURA', Update)
auraFrame:SetScript'OnUpdate'
if(auraFrame) then
self:UnregisterEvent("UNIT_AURA", Update)
auraFrame:SetScript("OnUpdate",nil)
end
end
 
oUF:AddElement('AuraBars', Update, Enable, Disable)
\ No newline at end of file +oUF:AddElement("AuraBars", Update, Enable, Disable) \ No newline at end of file