Quantcast

* Added a playerframe to any frame tagged as "party"

James Whitehead II [04-25-07 - 22:07]
* Added a playerframe to any frame tagged as "party"
* When you have a frame tagged as "party" visible, then the default party frames will be hidden
* You can disable this by typing /script PerfectRaid.db.profile.hideparty = false
* I may eventually add a toggle, but I prefer the default behavior.
Filename
PerfectRaid.lua
diff --git a/PerfectRaid.lua b/PerfectRaid.lua
index 2aa6e7d..b0f61b3 100644
--- a/PerfectRaid.lua
+++ b/PerfectRaid.lua
@@ -40,6 +40,9 @@ local utils
 PerfectRaid = DongleStub("Dongle-1.0"):New("PerfectRaid")
 PerfectRaid.rev = tonumber(string.match("$Revision$", "(%d+)") or 1)

+-- This needs to be visible elsewhere
+local OnAttributeChanged
+
 function PerfectRaid:Initialize()
 	self.frames = frames
 	self.aggro = aggro
@@ -51,6 +54,7 @@ function PerfectRaid:Initialize()
 				},
 			},
 			positions = {},
+			hideparty = true,
 		},
 	}

@@ -117,11 +121,13 @@ function PerfectRaid:Enable()
 	self:RegisterEvent("CHAT_MSG_SYSTEM")

 	self:UpdateRaidFrames()
-end
+ end

 function PerfectRaid:UpdateRaidFrames()
 	local list = self.db.profile.headers

+	self.hasparty = nil
+
 	for idx=1,40 do
 		local name = "PRHeader"..idx
 		local frame = getglobal(name)
@@ -227,21 +233,45 @@ function PerfectRaid:CreateRaidFrame(idx)
 		}
 	end

-	if options.partyFrame then
-		-- Create the playerFrame here
-		-- frame.player = CreateFrame("Button", name.."Player", frame, "SecureUnitButtonTemplate")
-		-- frame.player:SetPoint("BOTTOMLEFT", frame, "TOPLEFT", 0, 0)
-		-- self.ConfigureButton(frame.player)
-		-- frame.player:SetAttribute("unit", "player")
-	end
+	frame.idx = idx
+	frame.title:SetText(options.title or "")

 	if options.disabled then
 		frame:Hide()
 		return
 	end

-	frame.idx = idx
-	frame.title:SetText(options.title or "")
+	if options.partyFrame then
+		frame.player = CreateFrame("Button", name.."Player", frame, "SecureUnitButtonTemplate")
+		frame.player:SetPoint("BOTTOMLEFT", frame, "TOPLEFT", 0, 0)
+		frame.player:SetAttribute("unit", "player")
+		self.ConfigureButton(frame.player)
+		OnAttributeChanged(frame.player, "unit", "player")
+		frame.player:Show()
+		frame.player:SetWidth(224)
+		frame.player:SetHeight(14)
+
+		self.hasparty = true
+	end
+
+	if self.db.profile.hideparty and self.hasparty then
+		-- Disable the party frames
+		self.hidingparty = true
+		for i=1,4 do
+			local f = getglobal("PartyMemberFrame"..i)
+			f:UnregisterEvent("RAID_ROSTER_UPDATE")
+			f:UnregisterEvent("PARTY_MEMBERS_CHANGED")
+		end
+		HidePartyFrame()
+	elseif self.hidingparty then
+		self.hidingparty = false
+		for i=1,4 do
+			local f = getglobal("PartyMemberFrame"..i)
+			f:RegisterEvent("RAID_ROSTER_UPDATE")
+			f:RegisterEvent("PARTY_MEMBERS_CHANGED")
+		end
+		ShowPartyFrame()
+	end

 	if options.hBackdrop then
 		frame:SetBackdrop(frame.backdrop)
@@ -445,7 +475,7 @@ local function OnHide(frame)
 	frames[unit][frame] = nil
 end

-local function OnAttributeChanged(frame, name, value)
+function OnAttributeChanged(frame, name, value)
 	if name ~= "unit" then return end

 	local self = PerfectRaid
@@ -655,4 +685,4 @@ function PerfectRaid:RAID_ROSTER_UPDATE()
 			end
 		end
 	end
-end
+ end