Broker_ConsolidatedBuffs/Broker_ConsolidatedBuffs.lua

86 lines
2.5 KiB
Lua
Raw Normal View History

2014-11-01 00:25:03 +00:00
local addonName, addonNS = ...
local ldb = LibStub("LibDataBroker-1.1")
local defaults = {}
defaults.statIcons = { -- thanks ElvUI/modules/auras/consolidatedBuffs.lua
[1] = "Interface\\Icons\\Spell_Magic_GreaterBlessingofKings", -- Stats
[2] = "Interface\\Icons\\Spell_Holy_WordFortitude", -- Stamina
[3] = "Interface\\Icons\\INV_Misc_Horn_02", --Attack Power
[4] = "Interface\\Icons\\INV_Helmet_08", --Haste
[5] = "Interface\\Icons\\Spell_Holy_MagicalSentry", --Spell Power
[6] = "Interface\\Icons\\ability_monk_prideofthetiger", -- Critical Strike
[7] = "Interface\\Icons\\Spell_Holy_GreaterBlessingofKings", --Mastery
[8] = "Interface\\Icons\\spell_warlock_focusshadow", --Multistrike
[9] = "Interface\\Icons\\Spell_Holy_MindVision" --Versatility
}
2014-11-01 00:25:03 +00:00
local BrokerConsolidatedBuffs = ldb:NewDataObject("Broker_ConsolidatedBuffs", {
type = "data source",
2014-11-01 15:51:19 +00:00
text = "0/"..NUM_LE_RAID_BUFF_TYPES,
2014-11-01 00:25:03 +00:00
value = 1,
2014-11-01 12:02:38 +00:00
icon = "Interface\\AddOns\\Broker_ConsolidatedBuffs\\BuffConsolidation", -- I can't use the default because is a combination texture :(
2014-11-01 00:25:03 +00:00
label = "ConsolidatedBuffs",
OnTooltipShow = function(tooltip)
2014-11-01 15:51:19 +00:00
tooltip:AddLine(CONSOLIDATE_BUFFS_TEXT)
2014-11-01 00:25:03 +00:00
tooltip:AddLine(" ")
for i = 1, NUM_LE_RAID_BUFF_TYPES do
local name, rank, texture, duration, expiration, spellId, slot = GetRaidBuffTrayAuraInfo(i)
local r, g, b
if name then
r, g, b = 0, 1, 0
else
r, g, b = 1, 0, 0
end
tooltip:AddLine("\124T"..defaults.statIcons[i]..":0\124t ".._G["RAID_BUFF_"..i], r, g, b)
2014-11-01 00:25:03 +00:00
end
end,
OnClick = function(button)
local missing = ""
for i = 1, NUM_LE_RAID_BUFF_TYPES do
if not GetRaidBuffTrayAuraInfo(i) then
missing = missing .. _G["RAID_BUFF_"..i] ..", "
end
end
if missing ~= "" then
local channel = "SAY"
if IsInGroup(LE_PARTY_CATEGORY_INSTANCE) then
channel = "INSTANCE_CHAT"
elseif IsInRaid() then
channel = "RAID"
elseif IsInGroup() then
channel = "PARTY"
end
SendChatMessage(ADDON_MISSING..": "..strsub(missing, 0, strlen(missing)-2), channel)
2014-11-01 00:25:03 +00:00
end
end
})
local function updateBuffs(self, event, unitID)
if (unitID == "player" or event == "PLAYER_ENTERING_WORLD") then
local c = 0
for i = 1, NUM_LE_RAID_BUFF_TYPES do
if GetRaidBuffTrayAuraInfo(i) then
c = c + 1
end
end
BrokerConsolidatedBuffs.text = c.."/"..NUM_LE_RAID_BUFF_TYPES
end
end
local frame = CreateFrame("Frame")
frame:RegisterEvent("UNIT_AURA")
frame:RegisterEvent("PLAYER_ENTERING_WORLD")
frame:SetScript("OnEvent", updateBuffs)