From 17b1386504e4570bb9b94e417eedba99a8c74d3b Mon Sep 17 00:00:00 2001 From: shagu Date: Wed, 23 Nov 2016 21:51:20 +0100 Subject: [PATCH] raid: show hots and buffs on raidframes --- modules/config.lua | 3 ++ modules/gui.lua | 3 ++ modules/raid.lua | 108 +++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 114 insertions(+) diff --git a/modules/config.lua b/modules/config.lua index e87a4c16..d201e810 100644 --- a/modules/config.lua +++ b/modules/config.lua @@ -45,6 +45,9 @@ function pfUI:LoadConfig() pfUI:UpdateConfig("unitframes", "raid", "clickcast_shift", "") pfUI:UpdateConfig("unitframes", "raid", "clickcast_alt", "") pfUI:UpdateConfig("unitframes", "raid", "clickcast_ctrl", "") + pfUI:UpdateConfig("unitframes", "raid", "buffs_buffs", "0") + pfUI:UpdateConfig("unitframes", "raid", "buffs_hots", "0") + pfUI:UpdateConfig("unitframes", "raid", "buffs_classonly", "0") pfUI:UpdateConfig("bars", nil, "icon_size", "18") pfUI:UpdateConfig("panel", "left", "left", "guild") pfUI:UpdateConfig("panel", "left", "center", "durability") diff --git a/modules/gui.lua b/modules/gui.lua index 6d9a55c6..71ed2d23 100644 --- a/modules/gui.lua +++ b/modules/gui.lua @@ -656,6 +656,9 @@ pfUI:RegisterModule("gui", function () pfUI.gui:CreateConfig(pfUI.gui.uf, "Click-cast on Raidframe (Shift)", pfUI_config.unitframes.raid, "clickcast_shift") pfUI.gui:CreateConfig(pfUI.gui.uf, "Click-cast on Raidframe (Alt)", pfUI_config.unitframes.raid, "clickcast_alt") pfUI.gui:CreateConfig(pfUI.gui.uf, "Click-cast on Raidframe (Ctrl)", pfUI_config.unitframes.raid, "clickcast_ctrl") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Show Buffs on Raidframes", pfUI_config.unitframes.raid, "buffs_buffs") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Show Hots on Raidframes", pfUI_config.unitframes.raid, "buffs_hots") + pfUI.gui:CreateConfig(pfUI.gui.uf, "Only display Hots of my class", pfUI_config.unitframes.raid, "buffs_classonly") -- actionbar pfUI.gui.bar = pfUI.gui:CreateConfigTab("ActionBar") diff --git a/modules/raid.lua b/modules/raid.lua index f97a629c..32704739 100644 --- a/modules/raid.lua +++ b/modules/raid.lua @@ -10,9 +10,87 @@ pfUI:RegisterModule("raid", function () pfUI.uf.raid = CreateFrame("Button","pfRaid",UIParent) pfUI.uf.raid:Hide() + function pfUI.uf.raid:AddIcon(frame, pos, icon) + local iconsize = 10 + if not frame.hp then return end + local frame = frame.hp.bar + if pos > floor(frame:GetWidth() / iconsize) then return end + + if not frame.icon then frame.icon = {} end + + for i=1,6 do + if not frame.icon[i] then + frame.icon[i] = CreateFrame("Frame", frame) + frame.icon[i]:SetPoint("TOPLEFT", frame, "TOPLEFT", (i-1)*iconsize, 0) + frame.icon[i]:SetWidth(iconsize) + frame.icon[i]:SetHeight(iconsize) + frame.icon[i]:SetAlpha(.7) + frame.icon[i]:SetParent(frame) + frame.icon[i].tex = frame.icon[i]:CreateTexture("OVERLAY") + frame.icon[i].tex:SetAllPoints(frame.icon[i]) + frame.icon[i].tex:SetTexCoord(.08, .92, .08, .92) + end + end + frame.icon[pos].tex:SetTexture(icon) + frame.icon[pos]:Show() + end + + function pfUI.uf.raid:HideIcon(frame, pos) + if not frame or not frame.hp or not frame.hp.bar then return end + + local frame = frame.hp.bar + if frame.icon and frame.icon[pos] then + frame.icon[pos]:Hide() + end + end + + function pfUI.uf.raid:SetupBuffFilter() + if pfUI.uf.raid.buffs then return end + + local _, myclass = UnitClass("player") + + pfUI.uf.raid.buffs = {} + + -- [[ DRUID ]] + if myclass == "DRUID" and pfUI_config.unitframes.raid.buffs_buffs == "1" then + -- Gift of the Wild + table.insert(pfUI.uf.raid.buffs, "Interface\\Icons\\Spell_Nature_Regeneration") + + -- Thorns + table.insert(pfUI.uf.raid.buffs, "Interface\\Icons\\Spell_Nature_Thorns") + end + + if (pfUI_config.unitframes.raid.buffs_classonly ~= "1" or myclass == "DRUID") and pfUI_config.unitframes.raid.buffs_hots == "1" then + -- Regrowth + table.insert(pfUI.uf.raid.buffs, "Interface\\Icons\\Spell_Nature_ResistNature") + + -- Rejuvenation + table.insert(pfUI.uf.raid.buffs, "Interface\\Icons\\Spell_Nature_Rejuvenation") + end + + + -- [[ PRIEST ]] + if myclass == "PRIEST" and pfUI_config.unitframes.raid.buffs_buffs == "1" then + -- Prayer Of Fortitude" + table.insert(pfUI.uf.raid.buffs, "Interface\\Icons\\Spell_Holy_WordFortitude") + table.insert(pfUI.uf.raid.buffs, "Interface\\Icons\\Spell_Holy_PrayerOfFortitude") + + -- Prayer of Spirit + table.insert(pfUI.uf.raid.buffs, "Interface\\Icons\\Spell_DivineSpirit") + table.insert(pfUI.uf.raid.buffs, "Interface\\Icons\\Spell_Holy_PrayerofSpirit") + end + + if (pfUI_config.unitframes.raid.buffs_classonly ~= "1" or myclass == "PRIEST") and pfUI_config.unitframes.raid.buffs_hots == "1" then + -- Renew + table.insert(pfUI.uf.raid.buffs, "Interface\\Icons\\Spell_Holy_Renew") + end + + end + function pfUI.uf.raid:RefreshUnit(unit) if not unit.cache then unit.cache = {} end + unit.cache.hp = UnitHealth("raid"..unit.id) unit.cache.hpmax = UnitHealthMax("raid"..unit.id) unit.cache.power = UnitMana("raid" .. unit.id) @@ -21,6 +99,33 @@ pfUI:RegisterModule("raid", function () unit.hp.bar:SetMinMaxValues(0, unit.cache.hpmax) unit.power.bar:SetMinMaxValues(0, unit.cache.powermax) + pfUI.uf.raid:SetupBuffFilter() + if table.getn(pfUI.uf.raid.buffs) > 0 then + local active = {} + + for i=1,32 do + local texture = UnitBuff("raid" .. unit.id,i) + + -- match filter + for _, filter in pairs(pfUI.uf.raid.buffs) do + if filter == texture then + table.insert(active, texture) + break + end + end + + -- add icons for every found buff + for pos, icon in pairs(active) do + pfUI.uf.raid:AddIcon(this, pos, icon) + end + + -- hide unued icon slots + for pos=table.getn(active)+1, 6 do + pfUI.uf.raid:HideIcon(this, pos) + end + end + end + _, class = UnitClass("raid"..unit.id) local c = RAID_CLASS_COLORS[class] local cr, cg, cb = 0, 0, 0 @@ -215,6 +320,9 @@ pfUI:RegisterModule("raid", function () pfUI.uf.raid[i]:RegisterEvent("UNIT_MANA") pfUI.uf.raid[i]:RegisterEvent("UNIT_MANAMAX") pfUI.uf.raid[i]:RegisterEvent("RAID_ROSTER_UPDATE") + pfUI.uf.raid[i]:SetScript("OnShow", function () + pfUI.uf.raid:RefreshUnit(this) + end) pfUI.uf.raid[i]:SetScript("OnEvent", function () if arg1 == "raid" .. this.id or event == "RAID_ROSTER_UPDATE" then