From 2ae973cd7242b582e7622956851dbe2c0dd64df7 Mon Sep 17 00:00:00 2001 From: shagu Date: Fri, 21 Apr 2017 21:32:33 +0200 Subject: [PATCH] group: unify code, hide group in raid --- api/unitframes.lua | 57 +++++++++++++++++++++++++++++++--------------- modules/group.lua | 34 +-------------------------- 2 files changed, 40 insertions(+), 51 deletions(-) diff --git a/api/unitframes.lua b/api/unitframes.lua index 374a0d26..a11de539 100644 --- a/api/unitframes.lua +++ b/api/unitframes.lua @@ -154,7 +154,13 @@ function pfUI.uf:CreateUnitFrame(unit, id, config, tick) pfUI.uf:RefreshUnit(this, "all") elseif ( this.label == "party" or this.label == "player" ) and event == "PARTY_MEMBERS_CHANGED" then pfUI.uf:RefreshUnit(this, "all") - elseif this.label == "raid" and event == "RAID_ROSTER_UPDATE" then + elseif this.label == "party" and event == "PARTY_MEMBER_ENABLE" then + pfUI.uf:RefreshUnit(this, "all") + elseif this.label == "party" and event == "PARTY_MEMBER_DISABLE" then + pfUI.uf:RefreshUnit(this, "all") + elseif this.label == "party" and event == "GROUP_ROSTER_UPDATE" then + pfUI.uf:RefreshUnit(this, "all") + elseif ( this.label == "raid" or this.label == "party" ) and event == "RAID_ROSTER_UPDATE" then pfUI.uf:RefreshUnit(this, "all") elseif this.label == "player" and event == "PLAYER_AURAS_CHANGED" then pfUI.uf:RefreshUnit(this, "aura") @@ -209,26 +215,26 @@ function pfUI.uf:CreateUnitFrame(unit, id, config, tick) pfUI.uf:RefreshUnit(this, "all") end - if this.config.faderange == "1" then - if pfUI.api.UnitInRange(this.label .. this.id, 4) or not UnitName(this.label .. this.id) then - if this:GetAlpha() ~= 1 then - this:SetAlpha(1) - if this.config.portrait == "bar" then - this.portrait:SetAlpha(pfUI_config.unitframes.portraitalpha) + if UnitIsConnected(this.label .. this.id) or ( pfUI.gitter and pfUI.gitter:IsShown()) then + if not this.cache then return end + + if this.config.faderange == "1" then + if pfUI.api.UnitInRange(this.label .. this.id, 4) or (pfUI.gitter and pfUI.gitter:IsShown()) then + if this:GetAlpha() ~= 1 then + this:SetAlpha(1) + if this.config.portrait == "bar" then + this.portrait:SetAlpha(pfUI_config.unitframes.portraitalpha) + end end - end - else - if this:GetAlpha() ~= .5 then - this:SetAlpha(.5) - if this.config.portrait == "bar" then - this.portrait:SetAlpha(pfUI_config.unitframes.portraitalpha) + else + if this:GetAlpha() ~= .5 then + this:SetAlpha(.5) + if this.config.portrait == "bar" then + this.portrait:SetAlpha(pfUI_config.unitframes.portraitalpha) + end end end end - end - - if UnitIsConnected(this.label .. this.id) then - if not this.cache then return end local hpDisplay = this.hp.bar:GetValue() local hpReal = this.cache.hp @@ -272,6 +278,13 @@ function pfUI.uf:CreateUnitFrame(unit, id, config, tick) this.power.bar:SetMinMaxValues(0, 100) this.hp.bar:SetValue(0) this.power.bar:SetValue(0) + + if ( this.label == "party" or this.label == "raid" ) and this:GetAlpha() ~= .25 then + this:SetAlpha(.25) + if this.config.portrait == "bar" then + this.portrait:SetAlpha(pfUI_config.unitframes.portraitalpha) + end + end end end) f:SetScript("OnEnter", function() @@ -543,7 +556,15 @@ function pfUI.uf:RefreshUnit(unit, component) end if UnitName(unit.label .. unit.id) or (pfUI.gitter and pfUI.gitter:IsShown()) or unit.unitname then - unit:Show() else unit:Hide() + if pfUI_config["unitframes"]["group"]["hide_in_raid"] == "1" and strsub(unit.label,0,5) == "party" and UnitInRaid("player") then + unit:Hide() + elseif strsub(unit.label,0,8) == "partypet" and not UnitIsVisible(unit.label .. unit.id) then + unit:Hide() + else + unit:Show() + end + else + unit:Hide() end if not unit.cache then unit.cache = {} end diff --git a/modules/group.lua b/modules/group.lua index 2485ca31..e92147b1 100644 --- a/modules/group.lua +++ b/modules/group.lua @@ -17,39 +17,7 @@ pfUI:RegisterModule("group", function () end end - pfUI.uf.group = CreateFrame("Button","pfGroup",UIParent) - pfUI.uf.group:Hide() - - pfUI.uf.group:RegisterEvent("PLAYER_ENTERING_WORLD") - pfUI.uf.group:RegisterEvent("PARTY_MEMBERS_CHANGED") - pfUI.uf.group:RegisterEvent("PARTY_MEMBER_ENABLE") - pfUI.uf.group:RegisterEvent("PARTY_MEMBER_DISABLE") - pfUI.uf.group:RegisterEvent("RAID_ROSTER_UPDATE") - pfUI.uf.group:RegisterEvent("GROUP_ROSTER_UPDATE") - - pfUI.uf.group:SetScript("OnEvent", function() - PartyMemberBackground:Hide() - - for i=1, 4 do - if C.unitframes.group.hide_in_raid == "1" and UnitInRaid("player") then - pfUI.uf.group[i]:Hide() - else - if GetNumPartyMembers() >= i then - pfUI.uf.group[i]:Show() - if UnitIsConnected("party"..i) or not UnitName("party"..i) then - pfUI.uf.group[i]:SetAlpha(1) - else - pfUI.uf.group[i]:SetAlpha(.25) - end - else - if pfUI.uf.group[i] then - pfUI.uf.group[i]:Hide() - end - end - end - end - end) - + pfUI.uf.group = {} for i=1, 4 do pfUI.uf.group[i] = pfUI.uf:CreateUnitFrame("Party", i, C.unitframes.group)