* Fixed mana bars to properly change when a unit switches power types
James Whitehead II [04-25-07 - 23:43]
* Fixed mana bars to properly change when a unit switches power types
* Playerframe will now properly hide when you aren't in a party
diff --git a/PerfectRaid.lua b/PerfectRaid.lua
index d142fc1..b0f47f2 100644
--- a/PerfectRaid.lua
+++ b/PerfectRaid.lua
@@ -109,6 +109,8 @@ function PerfectRaid:Enable()
self.db = self:InitializeDB("PerfectRaidDB", self.defaults)
self:RegisterEvent("RAID_ROSTER_UPDATE")
+ self:RegisterEvent("PARTY_MEMBERS_CHANGED")
+ self:RegisterEvent("UNIT_DISPLAYPOWER")
self:RegisterEvent("UNIT_HEALTH")
self:RegisterEvent("UNIT_MAXHEALTH")
self:RegisterEvent("UNIT_MANA", "UNIT_MANA")
@@ -122,7 +124,8 @@ function PerfectRaid:Enable()
self:RegisterEvent("CHAT_MSG_SYSTEM")
self:UpdateRaidFrames()
- end
+ self:PARTY_MEMBERS_CHANGED()
+end
function PerfectRaid:UpdateRaidFrames()
local list = self.db.profile.headers
@@ -242,7 +245,7 @@ function PerfectRaid:CreateRaidFrame(idx)
return
end
- if options.partyFrame then
+ if options.partyFrame and not frame.player then
frame.player = CreateFrame("Button", name.."Player", frame, "SecureUnitButtonTemplate")
frame.player:SetPoint("BOTTOMLEFT", frame, "TOPLEFT", 0, 0)
frame.player:SetAttribute("unit", "player")
@@ -253,6 +256,14 @@ function PerfectRaid:CreateRaidFrame(idx)
frame.player:SetHeight(14)
self.hasparty = true
+ end
+
+ if options.partyFrame then
+ if self.inparty then
+ frame.player:Show()
+ else
+ frame.player:Hide()
+ end
end
if self.db.profile.hideparty and self.hasparty then
@@ -272,7 +283,7 @@ function PerfectRaid:CreateRaidFrame(idx)
f:RegisterEvent("PARTY_MEMBERS_CHANGED")
end
ShowPartyFrame()
- end
+ end
if options.hBackdrop then
frame:SetBackdrop(frame.backdrop)
@@ -694,3 +705,31 @@ function PerfectRaid:RAID_ROSTER_UPDATE()
end
end
end
+
+function PerfectRaid:PARTY_MEMBERS_CHANGED()
+ self.inparty = GetNumPartyMembers() > 0
+ self:UpdateRaidFrames()
+end
+
+function PerfectRaid:UNIT_DISPLAYPOWER(event, unit)
+ if not frames[unit] then return end
+ local color = ManaBarColor[UnitPowerType(unit)]
+ local show = UnitPowerType(unit) == 0
+ local max = UnitManaMax(unit)
+ local mana = UnitMana(unit)
+ local manaonly = self.db.profile.showmanaonly
+
+ for frame in pairs(frames[unit]) do
+ frame.manacolor = color
+ local bar = frame.manabar
+ bar:SetStatusBarColor(color.r, color.g, color.b)
+ bar:SetMinMaxValues(0, max)
+ bar:SetValue(mana)
+
+ if show and frame.options.manaheight > 0 then
+ bar:Show()
+ elseif manaonly then
+ bar:Hide()
+ end
+ end
+end