WoWInterface SVN zz_BuffInfo

Compare Revisions

  • This comparison shows the changes necessary to convert path
    /trunk
    from Rev 6 to Rev 7
    Reverse comparison

Rev 6 → Rev 7

zz_BuffInfo/core.lua
0,0 → 1,112
local name, addon = ...
local parentName = addon['parentName'] or "BrokerPack"
local childName = "zz_BuffInfo"
local defaults = {}
 
local delayOOC = 0.75
local delayIC = 0.5
local delay = delayOOC
local GetTime = GetTime
local g = GetTime()
-- name, rank, icon, cost, isFunnel, powerType, castTime, minRange, maxRange = GetSpellInfo(spellId or spellName)
local auras = {
-- monk
[115295] = {GetSpellInfo(115295)}, -- schutz
[124275] = {GetSpellInfo(124275)}, -- leichte staffelung
[124274] = {GetSpellInfo(124274)}, -- moderate staffelung
[124273] = {GetSpellInfo(124273)}, -- schwere staffelung
-- warrior
[112048] = {GetSpellInfo(112048)}, -- schildbarriere
}
 
local function updateDisplay(self,event,...)
delay = event == "PLAYER_REGEN_ENABLED" and delayOOC or delayIC
end
-- name, rank, icon, count, debuffType, duration, expirationTime, unitCaster, isStealable, shouldConsolidate, spellId, canApplyAura, isBossDebuff, value1, value2, value3
local types = {"HARMFUL", "HELPFUL"}
local aurainfo
local buttons = {}
local checked = {}
local function addText(b)
local n = 1
while(b['vText'..n]) do
n = n + 1
end
b['vText'..n] = b:CreateFontString()
b['vText'..n]:SetWidth(200); b['vText'..n]:SetHeight(8)
b['vText'..n]:SetPoint("TOPLEFT", b, "TOPRIGHT", 0,-((n-1) * 8)+2)
b['vText'..n]:SetFontObject("GameFontNormalSmall")
b['vText'..n]:SetJustifyH("LEFT")
b['vText'..n]:SetTextColor(1,1,1,1)
end
local lastbutton
local function createButton(spellId)
local b = CreateFrame("Button", "BuffInfo_"..auras[spellId][1], UIParent, "ActionButtonTemplate")
b:SetSize(24,24)
_G[format("%sIcon",b:GetName())]:SetTexture(auras[spellId][3])
 
for i = 1,3 do
addText(b)
end
b['spellId'] = spellId
buttons[#buttons + 1] = b
return b
end
 
local function getButton(spellId)
for _, b in pairs(buttons) do
if(b['spellId'] == spellId) then return b end
end
return createButton(spellId)
end
 
local function updateAura(spellId, aurainfo)
local b = getButton(spellId)
if(aurainfo[1]) then
b:Show()
for n = 1, 3 do
b['vText'..n]:SetText(aurainfo[13 + n])
end
checked[spellId] = true
b:ClearAllPoints()
if(not lastbutton) then
b:SetPoint("CENTER",UIParent,"CENTER")
lastbutton = b
else
b:SetPoint("TOPLEFT", lastbutton, "BOTTOMLEFT",0,-4)
end
elseif(not checked[spellId]) then
b:Hide()
end
end
 
local function OnUpdate(self,event)
local g = GetTime()
if(self['nextUpdate'] > g) then return end
self['nextUpdate'] = g + delay
wipe(checked)
lastbutton = nil
for spellId, aura in pairs(auras) do
for _, itype in ipairs(types) do
aurainfo = {UnitAura("player", aura[1],nil,itype)}
-- print(aurainfo[1],aura[1],aurainfo[14],aurainfo[15],aurainfo[16])
updateAura(spellId,aurainfo)
if(aurainfo[1]) then
checked[spellId] = true
end
end
end
end
 
local function init()
options = addon['InitConfig'](addon, childName, true, {
['name'] = childName,
['type'] = "launcher",
['icon'] = "Interface\\Icons\\spell_holy_powerwordshield",
})
db = addon['db']['profile'][childName]
addon['RegisterFunc']({"PLAYER_REGEN_ENABLED", "PLAYER_REGEN_DISABLED"},"OnEvent", updateDisplay)
addon['RegisterFunc'](nil,"OnUpdate", OnUpdate)['nextUpdate'] = GetTime()
end
 
addon['startup'](addon, name, childName, init, true, defaults)
\ No newline at end of file