Quantcast

* Added frame options for "Show in Party", "Show in Raid", "Show Player", "Show Solo", these are just analogous to the template options

James Whitehead II [01-25-08 - 08:14]
* Added frame options for "Show in Party", "Show in Raid", "Show Player", "Show Solo", these are just analogous to the template options
* Removed lots of hacky "player" code, since the templates support it natively now
Filename
Localization.enUS.lua
PerfectRaid.lua
PerfectRaid_Frames.lua
diff --git a/Localization.enUS.lua b/Localization.enUS.lua
index 26fa223..a33b7e6 100644
--- a/Localization.enUS.lua
+++ b/Localization.enUS.lua
@@ -79,7 +79,6 @@ PerfectRaidLocals = {
 	["Only show if this buff is missing"] = "Only show if this buff is missing",
 	["Out-of-Range Alpha"] = "Out-of-Range Alpha",
 	["Paladin"] = "Paladin",
-	["Party"] = "Party",
 	["PerfectRaid Options"] = "PerfectRaid Options",
 	["Perform aggro checking"] = "Perform aggro checking",
 	["Perform range checking"] = "Perform range checking",
@@ -133,8 +132,12 @@ PerfectRaidLocals = {
 	["Shadow Protection"] = "Shadow Protection",
 	["Shaman"] = "Shaman",
 	["Show HP deficit"] = "Show HP deficit",
+	["Show frame in raid"] = "Show frame in raid",
+	["Show frame when solo"] = "Show frame when solo",
+	["Show frame while in party"] = "Show frame while in party",
 	["Show group number"] = "Show group number",
 	["Show options GUI"] = "Show options GUI",
+	["Show player in frame"] = "Show player in frame",
 	["Show unit tooltip on mouseover"] = "Show unit tooltip on mouseover",
 	["Sort Frames By:"] = "Sort Frames By:",
 	["Soulstone Resurrection"] = "Soulstone Resurrection",
diff --git a/PerfectRaid.lua b/PerfectRaid.lua
index 073d1ec..76306c3 100644
--- a/PerfectRaid.lua
+++ b/PerfectRaid.lua
@@ -54,6 +54,7 @@ function PerfectRaid:Initialize()
 			headers = {
 				["*"] = {
 					manaheight = 0,
+					showRaid = true,
 				},
 			},
 			positions = {},
@@ -206,11 +207,7 @@ end
 function PerfectRaid:CreateRaidFrame(idx)
 	local options = self.db.profile.headers[idx]
 	local name = "PRHeader"..idx
-	local template = "SecureRaidGroupHeaderTemplate"
-	if options.partyFrame then
-		name = name .. "Party"
-		template = "SecurePartyHeaderTemplate"
-	end
+	local template = "SecureGroupHeaderTemplate"

 	local frame = getglobal(name)

@@ -219,9 +216,8 @@ function PerfectRaid:CreateRaidFrame(idx)

 		frame = CreateFrame("Frame", name, bg, template)
 		frame.title = frame:CreateFontString(nil, "ARTWORK", "GameFontNormalSmall")
-		local offset = options.partyFrame and 17 or 3

-		frame.title:SetPoint("BOTTOM", frame, "TOP", 0, offset)
+		frame.title:SetPoint("BOTTOM", frame, "TOP", 0, 3)
 		frame.bg = bg

 		frame.backdrop = {
@@ -237,21 +233,10 @@ function PerfectRaid:CreateRaidFrame(idx)
 			},
 		}

---[[
-		frame.backdrop = {
-			bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
-			edgeFile = "Interface\\AddOns\\PerfectRaid\\images\\backdrop",
-			tile = true,
-			tileSize = 16,
-			edgeSize = 4,
-			insets = {left = 4, right = 4, top = 4, bottom = 4},
-		}
-		--]]
 	end

 	-- Position backdrop
-	local bgtopoffset = 5
-	bgtopoffset = bgtopoffset + (options.partyFrame and 15 or 1)
+	local bgtopoffset = 6
 	bgtopoffset = bgtopoffset + (options.title and 20 or 0)

 	frame.bg:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, bgtopoffset)
@@ -266,46 +251,6 @@ function PerfectRaid:CreateRaidFrame(idx)
 		return
 	end

-	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")
-		self.ConfigureButton(frame.player)
-		OnAttributeChanged(frame.player, "unit", "player")
-		frame.player:Show()
-		frame.player:SetWidth(224)
-		frame.player:SetHeight(14)
-		frame.player.dragparent = frame
-	 end
-
-	if options.partyFrame then
-		self.hasparty = true
-		if self.inparty then
-			frame.player:Show()
-		else
-			frame.player:Hide()
-		end
-	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.bg:SetBackdrop(frame.backdrop)
 		frame.bg:SetBackdropColor(0,0,0,.7)
@@ -335,6 +280,11 @@ function PerfectRaid:CreateRaidFrame(idx)
 	frame:SetAttribute("unitsPerColumn", options.maxUnits)
 	frame:SetAttribute("columnSpacing", options.colSpacing)
 	frame:SetAttribute("columnAnchorPoint", options.colAnchor)
+	frame:SetAttribute("showParty", options.showParty)
+	frame:SetAttribute("showRaid", options.showRaid)
+	frame:SetAttribute("showPlayer", options.showPlayer)
+	frame:SetAttribute("showSolo", options.showSolo)
+
 	frame.dragparent = dragparent or frame
 	frame.initialConfigFunction = PerfectRaid.ConfigureButton
 	frame:SetMovable(true)
diff --git a/PerfectRaid_Frames.lua b/PerfectRaid_Frames.lua
index c6b214c..b9ad65e 100644
--- a/PerfectRaid_Frames.lua
+++ b/PerfectRaid_Frames.lua
@@ -236,13 +236,12 @@ function Frames:CreateEditFrame(parent)
 	makeCheck(L["Group 6"], "6")
 	makeCheck(L["Group 7"], "7")
 	makeCheck(L["Group 8"], "8")
-	makeCheck(L["Party"], "Party")

 	for idx,button in ipairs(self.filters) do
 		if idx == 1 then
 			button:SetPoint("TOPLEFT", title, "BOTTOMLEFT", 0, -15)
 		elseif math.fmod(idx - 1, 6) == 0 then
-			button:SetPoint("TOPLEFT", self.filters[idx-6], "BOTTOMLEFT", 0, -15)
+			button:SetPoint("TOPLEFT", self.filters[idx-6], "BOTTOMLEFT", 0, -5)
 		else
 			button:SetPoint("LEFT", self.filters[idx-1], "RIGHT", 60, 0)
 		end
@@ -300,7 +299,7 @@ function Frames:CreateEditFrame(parent)

 	local hbackdrop = CreateFrame("CheckButton", "PRFrame_HeaderBackdrop", PROptions_Frames_Edit, "PRCheckTemplate")
 	hbackdrop.Label:SetText(L["Display a header backdrop"])
-	hbackdrop:SetPoint("BOTTOMLEFT", 0, 140)
+	hbackdrop:SetPoint("BOTTOMLEFT", 0, 175)
 	hbackdrop:Show()

 	local strict = CreateFrame("CheckButton", "PRFrame_Strict", PROptions_Frames_Edit, "PRCheckTemplate")
@@ -338,6 +337,37 @@ function Frames:CreateEditFrame(parent)
 	alignBottom:SetPoint("TOPLEFT", alignRight, "BOTTOMLEFT", 0, 0)
 	alignBottom:Show()

+	-- showRaid = [BOOLEAN] -- true if the header should be shown while in a raid
+	-- showParty = [BOOLEAN] -- true if the header should be shown while in a party and not in a raid
+	-- showPlayer = [BOOLEAN] -- true if the header should show the player when not in a raid
+	-- showSolo = [BOOLEAN] -- true if the header should be shown while not in a group (implies showPlayer)
+
+	local showRaid = CreateFrame("CheckButton", "PRFrame_ShowRaid", PROptions_Frames_Edit, "PRCheckTemplate")
+	showRaid.Label:SetText(L["Show frame in raid"])
+	showRaid:SetPoint("TOPLEFT", showGroupNum, "BOTTOMLEFT", 0, 0)
+	showRaid:Show()
+
+	local showParty = CreateFrame("CheckButton", "PRFrame_ShowParty", PROptions_Frames_Edit, "PRCheckTemplate")
+	showParty.Label:SetText(L["Show frame while in party"])
+	showParty:SetPoint("TOPLEFT", showRaid, "BOTTOMLEFT", 0, 0)
+	showParty:Show()
+
+	local showPlayer = CreateFrame("CheckButton", "PRFrame_ShowPlayer", PROptions_Frames_Edit, "PRCheckTemplate")
+	showPlayer.Label:SetText(L["Show player in frame"])
+	showPlayer:SetPoint("TOPLEFT", alignBottom, "BOTTOMLEFT", 0, 0)
+	showPlayer:Show()
+
+	local showSolo = CreateFrame("CheckButton", "PRFrame_ShowSolo", PROptions_Frames_Edit, "PRCheckTemplate")
+	showSolo.Label:SetText(L["Show frame when solo"])
+	showSolo:SetPoint("TOPLEFT", showPlayer, "BOTTOMLEFT", 0, 0)
+	showSolo:Show()
+
+	showSolo:SetScript("PostClick", function(self)
+										if self:GetChecked() then
+											showPlayer:SetChecked(true)
+										end
+									end)
+
 --[[
 	local hborderswatch = self:CreateSwatch("PRFrame_HBorder_Color", PROptions_Frames_Edit)
 	local fborderswatch = self:CreateSwatch("PRFrame_FBorder_Color", PROptions_Frames_Edit)
@@ -459,6 +489,11 @@ function Frames:EditEntry()
 	PRFrame_Deficit:SetChecked(entry.deficit)
 	PRFrame_AlignRight:SetChecked(entry.alignright)
 	PRFrame_AlignBottom:SetChecked(entry.alignbottom)
+
+	PRFrame_ShowParty:SetChecked(entry.showParty)
+	PRFrame_ShowRaid:SetChecked(entry.showRaid)
+	PRFrame_ShowPlayer:SetChecked(entry.showPlayer)
+	PRFrame_ShowSolo:SetChecked(entry.showSolo)
 end

 function Frames:AddEntry()
@@ -528,6 +563,10 @@ function Frames:SaveEntry()
 	local deficit = PRFrame_Deficit:GetChecked()
 	local alignright = PRFrame_AlignRight:GetChecked()
 	local alignbottom = PRFrame_AlignBottom:GetChecked()
+	local showParty = PRFrame_ShowParty:GetChecked()
+	local showRaid = PRFrame_ShowRaid:GetChecked()
+	local showPlayer = PRFrame_ShowPlayer:GetChecked()
+	local showSolo = PRFrame_ShowSolo:GetChecked()

 	if title == "" then title = nil end
 	if filter == "" then filter = nil end
@@ -574,6 +613,11 @@ function Frames:SaveEntry()
 	entry.alignright = alignright
 	entry.alignbottom = alignbottom

+	entry.showParty = showParty
+	entry.showRaid = showRaid
+	entry.showPlayer = showPlayer
+	entry.showSolo = showSolo
+
 	if not self.editEntry then
 		table.insert(PerfectRaid.db.profile.headers, entry)
 	end
@@ -585,16 +629,10 @@ function Frames:SaveEntry()
 	local idx = PROptions_Frames.selected
 	if idx then
 		local name = "PRHeader"..idx
-		if partyFrame then
-			name = name .. "Party"
-		end

 		local header = getglobal(name)
 		for i=1,header:GetNumChildren() do
 			local button = header:GetAttribute("child"..i)
-			if not button then
-				button = header.player
-			end
 			PerfectRaid:UpdateButtonLayout(button)
 		end
 		for unit in pairs(frames) do
@@ -623,6 +661,10 @@ function Frames:CancelEntry()
 	PRFrame_Deficit:SetChecked(false)
 	PRFrame_AlignRight:SetChecked(false)
 	PRFrame_AlignBottom:SetChecked(false)
+	PRFrame_ShowParty:SetChecked(false)
+	PRFrame_ShowRaid:SetChecked(false)
+	PRFrame_ShowPlayer:SetChecked(false)
+	PRFrame_ShowSolo:SetChecked(false)

 	self.options:FadeOut(PROptions_Frames_Edit)
 	self.options:FadeIn(PROptions_Frames)