Merge pull request #1 from Dairyman/master

Adding GetRaidBuffInfo
This commit is contained in:
Sergio Álvarez 2014-12-29 16:33:26 +01:00
commit 8439462411
1 changed files with 58 additions and 41 deletions

View File

@ -1,4 +1,8 @@
-- Upvalues
local _G = _G
local bit, strsub, strlen, select, max = bit, strsub, strlen, select, max
local addonName, addonNS = ... local addonName, addonNS = ...
local LQT = LibStub('LibQTip-1.0') local LQT = LibStub('LibQTip-1.0')
local LDB = LibStub("LibDataBroker-1.1") local LDB = LibStub("LibDataBroker-1.1")
@ -109,8 +113,8 @@ end
local BrokerConsolidatedBuffs = LDB:NewDataObject("Broker_ConsolidatedBuffs", { local BrokerConsolidatedBuffs = LDB:NewDataObject("Broker_ConsolidatedBuffs", {
type = "data source", type = "data source",
text = "0/"..NUM_LE_RAID_BUFF_TYPES, text = "0/".._G.NUM_LE_RAID_BUFF_TYPES,
value = "0/"..NUM_LE_RAID_BUFF_TYPES, value = "0/".._G.NUM_LE_RAID_BUFF_TYPES,
icon = "Interface\\AddOns\\Broker_ConsolidatedBuffs\\BuffConsolidation", -- I can't use the default because is a combination texture :( icon = "Interface\\AddOns\\Broker_ConsolidatedBuffs\\BuffConsolidation", -- I can't use the default because is a combination texture :(
label = "ConsolidatedBuffs", label = "ConsolidatedBuffs",
@ -118,20 +122,26 @@ local BrokerConsolidatedBuffs = LDB:NewDataObject("Broker_ConsolidatedBuffs", {
local tooltip = LQT:Acquire("Broker_ConsolidatedBuffsTooltip", 3, "LEFT", "LEFT", "LEFT") local tooltip = LQT:Acquire("Broker_ConsolidatedBuffsTooltip", 3, "LEFT", "LEFT", "LEFT")
self.tooltip = tooltip self.tooltip = tooltip
tooltip:AddHeader(CONSOLIDATE_BUFFS_TEXT) tooltip:AddHeader(_G.CONSOLIDATE_BUFFS_TEXT)
tooltip:AddLine(" ") tooltip:AddLine(" ")
tooltip:AddHeader(STATISTICS, ALL_CLASSES, PETS)--CONSOLIDATE_BUFFS_TEXT) tooltip:AddHeader(_G.STATISTICS, _G.ALL_CLASSES, _G.PETS)--CONSOLIDATE_BUFFS_TEXT)
tooltip:AddSeparator() tooltip:AddSeparator()
--tooltip:AddLine(" ") --tooltip:AddLine(" ")
for i = 1, NUM_LE_RAID_BUFF_TYPES do local buffmask = _G.GetRaidBuffInfo() or 0
local name, rank, texture, duration, expiration, spellId, slot = GetRaidBuffTrayAuraInfo(i) local mask = 1
for i = 1, _G.NUM_LE_RAID_BUFF_TYPES do
local name, rank, texture, duration, expiration, spellId, slot = _G.GetRaidBuffTrayAuraInfo(i)
local c local c
if name then if name then
c = "FF00FF00" c = "FF00FF00"
else else
c = "FFFF0000" if bit.band(buffmask, mask) > 0 then
c = "FFFF0000"
else
c = "FF888888"
end
end end
local classes = "" local classes = ""
@ -143,14 +153,16 @@ local BrokerConsolidatedBuffs = LDB:NewDataObject("Broker_ConsolidatedBuffs", {
pets = pets ..", ".. defaults[i][3][ii] pets = pets ..", ".. defaults[i][3][ii]
end end
tooltip:AddLine( tooltip:AddLine(
"\124T"..defaults[i][1]..":0\124t \124c"..c.._G["RAID_BUFF_"..i].."\124r", "\124T"..defaults[i][1]..":0\124t \124c"..c.._G["RAID_BUFF_"..i]:gsub("-\n", "").."\124r",
strsub(classes, 2), strsub(classes, 2),
strsub(pets, 2) strsub(pets, 2)
) )
--tooltip:AddLine(" ") --tooltip:AddLine(" ")
--tooltip:AddLine("\124T"..defaults[i][1]..":0\124t \124c"..c.._G["RAID_BUFF_"..i].."\124r "..list) --tooltip:AddLine("\124T"..defaults[i][1]..":0\124t \124c"..c.._G["RAID_BUFF_"..i]:gsub("-\n", "").."\124r "..list)
--tooltip:AddLine(" "..list) --tooltip:AddLine(" "..list)
mask = bit.lshift(mask, 1)
end end
tooltip:SmartAnchorTo(self) tooltip:SmartAnchorTo(self)
@ -164,23 +176,26 @@ local BrokerConsolidatedBuffs = LDB:NewDataObject("Broker_ConsolidatedBuffs", {
OnClick = function(button) OnClick = function(button)
local missing = "" local missing = ""
local buffmask = _G.GetRaidBuffInfo() or 0
local mask = 1
for i = 1, NUM_LE_RAID_BUFF_TYPES do for i = 1, _G.NUM_LE_RAID_BUFF_TYPES do
if not GetRaidBuffTrayAuraInfo(i) then if not _G.GetRaidBuffTrayAuraInfo(i) and bit.band(buffmask, mask) > 0 then
missing = missing .. _G["RAID_BUFF_"..i] ..", " missing = missing .. _G["RAID_BUFF_"..i]:gsub("-\n", "") ..", "
end end
mask = bit.lshift(mask, 1)
end end
if missing ~= "" then if missing ~= "" then
local channel = "SAY" local channel = "SAY"
if IsInGroup(LE_PARTY_CATEGORY_INSTANCE) then if _G.IsInGroup(_G.LE_PARTY_CATEGORY_INSTANCE) then
channel = "INSTANCE_CHAT" channel = "INSTANCE_CHAT"
elseif IsInRaid() then elseif _G.IsInRaid() then
channel = "RAID" channel = "RAID"
elseif IsInGroup() then elseif _G.IsInGroup() then
channel = "PARTY" channel = "PARTY"
end end
SendChatMessage(ADDON_MISSING..": "..strsub(missing, 0, strlen(missing)-2), channel) _G.SendChatMessage(_G.ADDON_MISSING..": "..strsub(missing, 0, strlen(missing)-2), channel)
end end
end end
}) })
@ -189,14 +204,16 @@ local BrokerConsolidatedBuffs = LDB:NewDataObject("Broker_ConsolidatedBuffs", {
local function updateBuffs(self, event, unitID) local function updateBuffs(self, event, unitID)
if (unitID == "player" or event == "PLAYER_ENTERING_WORLD") then if (unitID == "player" or event == "PLAYER_ENTERING_WORLD") then
local c = 0 local c = 0
for i = 1, NUM_LE_RAID_BUFF_TYPES do for i = 1, _G.NUM_LE_RAID_BUFF_TYPES do
if GetRaidBuffTrayAuraInfo(i) then if _G.GetRaidBuffTrayAuraInfo(i) then
c = c + 1 c = c + 1
end end
end end
BrokerConsolidatedBuffs.text = c.."/"..NUM_LE_RAID_BUFF_TYPES local buffcount = select(2, _G.GetRaidBuffInfo())
BrokerConsolidatedBuffs.value = c.."/"..NUM_LE_RAID_BUFF_TYPES -- for ElvUI datatexts
BrokerConsolidatedBuffs.text = c.."/"..max(c, buffcount)
BrokerConsolidatedBuffs.value = c.."/"..max(c, buffcount) -- for ElvUI datatexts
end end
end end