Quantcast

* Made the "show only my buffs" more robust, no longer a filter

James Whitehead II [02-13-08 - 15:36]
* Made the "show only my buffs" more robust, no longer a filter
* Added a way to reorder the buffs listed, this changes the order in which they are displayed
Filename
Localization.enUS.lua
PerfectRaid_Buffs.lua
diff --git a/Localization.enUS.lua b/Localization.enUS.lua
index 81a28c8..3436bb7 100644
--- a/Localization.enUS.lua
+++ b/Localization.enUS.lua
@@ -32,6 +32,7 @@ PerfectRaidLocals = {
 	["Display a header backdrop"] = "Display a header backdrop",
 	["Divine Spirit"] = "Divine Spirit",
 	["Do not check this buff (Disable)"] = "Do not check this buff (Disable)",
+	["Down"] = "Down",
 	["Druid"] = "Druid",
 	["Edit"] = "Edit",
 	["Enable"] = "Enable",
@@ -61,6 +62,7 @@ PerfectRaidLocals = {
 	["Healing Touch"] = "Healing Touch",
 	["Healing Wave"] = "Healing Wave",
 	["Hide Blizzard Party Frames"] = "Hide Blizzard Party Frames",
+	["Highlight my target"] = "Highlight my target",
 	["Highlight on mouseover"] = "Highlight on mouseover",
 	["Highlight when cursed"] = "Highlight when cursed",
 	["Highlight when diseased"] = "Highlight when diseased",
@@ -84,6 +86,7 @@ PerfectRaidLocals = {
 	["Offline"] = "Offline",
 	["Only show if this buff is missing"] = "Only show if this buff is missing",
 	["Only show mana bar for mana users"] = "Only show mana bar for mana users",
+	["Only show my buffs"] = "Only show my buffs",
 	["Out-of-Range Alpha"] = "Out-of-Range Alpha",
 	["Paladin"] = "Paladin",
 	["PerfectRaid Options"] = "PerfectRaid Options",
@@ -151,6 +154,7 @@ PerfectRaidLocals = {
 	["Spacing between columns:"] = "Spacing between columns:",
 	["Thorns"] = "Thorns",
 	["Title:"] = "Title:",
+	["Up"] = "Up",
 	["Update delay"] = "Update delay",
 	["Warlock"] = "Warlock",
 	["Warrior"] = "Warrior",
diff --git a/PerfectRaid_Buffs.lua b/PerfectRaid_Buffs.lua
index 0341b31..a9a98fb 100644
--- a/PerfectRaid_Buffs.lua
+++ b/PerfectRaid_Buffs.lua
@@ -148,9 +148,6 @@ function Buffs:UNIT_AURA(event, unit)
 	for i=1,40 do
 		local name,rank,texture,count,type,durating,timeleft = UnitDebuff(unit, i)
 		if not name and not type then break end
-		if timeleft then
-			mybuffs[name] = true
-		end

 		buffcache[name] = (buffcache[name] or 0) + 1

@@ -203,6 +200,8 @@ function Buffs:UNIT_AURA(event, unit)

 	for i,entry in ipairs(buffs) do
 		local checkcond = false
+
+		-- Determine which spell name we matched
 		local buffname
 		if buffcache[entry.buffname] then
 			buffname = entry.buffname
@@ -210,7 +209,12 @@ function Buffs:UNIT_AURA(event, unit)
 			buffname = entry.groupname
 		end

+		-- How many stacks are there?
 		local num = buffcache[buffname]
+		local class = select(2, UnitClass(unit))
+		local conds = self.conditions
+		local group = raidLookup[unit]
+		local mine = mybuffs[buffname]

 		if entry.missing then
 			if not buffname then
@@ -218,14 +222,11 @@ function Buffs:UNIT_AURA(event, unit)
 			end
 		else
 			if buffname then
-				checkcond = true
+				if (entry.mine and mine) or not entry.mine then
+					checkcond = true
+				end
 			end
 		end
-
-		local class = select(2, UnitClass(unit))
-		local conds = self.conditions
-		local group = raidLookup[unit]
-		local mine = mybuffs[buffname]

 		-- Handle the condition checking for the buff, taking strictness into account
 		if checkcond then
@@ -248,7 +249,7 @@ function Buffs:UNIT_AURA(event, unit)

 						table.insert(work, entry.colortext .. "(" .. num .. ")")
 					else
-						if mymask[buffname] and not mine then
+						if (entry.onlymine and not mine) or (not entry.onlymine and mymask[buffname]) then
 							-- Do nothing
 						else
 							table.insert(work, entry.colortext)
@@ -269,12 +270,8 @@ function Buffs:UNIT_AURA(event, unit)

 							table.insert(work, entry.colortext .. "(" .. num .. ")")
 						else
-							-- If this is a single buff, check to see if its masked
-							if mymask[buffname] then
-								-- If this buff is mine, and this entry shows mine
-								if mine and entry.showmine then
-									table.insert(work, entry.colortext)
-								end
+						if (entry.onlymine and not mine) or (not entry.onlymine and mymask[buffname]) then
+								-- Don't show
 							else
 								table.insert(work, entry.colortext)
 							end
@@ -390,6 +387,20 @@ function Buffs:CreateOptions(opt)
 	disable:SetScript("OnClick", function() self:DisableEntry() end)
 	disable:Show()

+	local up = CreateFrame("Button", "PRBuffs_Up", options, "PRButtonTemplate")
+	up:SetWidth(70)
+	up:SetText(L["Up"])
+	up:SetPoint("BOTTOMRIGHT", disable, "BOTTOMLEFT", -10, 0)
+	up:SetScript("OnClick", function() self:MoveEntry("UP") end)
+	up:Show()
+
+	local down = CreateFrame("Button", "PRBuffs_Down", options, "PRButtonTemplate")
+	down:SetWidth(70)
+	down:SetText(L["Down"])
+	down:SetPoint("BOTTOMRIGHT", up, "BOTTOMLEFT", -10, 0)
+	down:SetScript("OnClick", function() self:MoveEntry("DOWN") end)
+	down:Show()
+
 	self:CreateEditFrame(options)
 end

@@ -563,7 +574,7 @@ function Buffs:CreateEditFrame(parent)
 	checks[19]:SetPoint("TOPLEFT", checks[13], "BOTTOMLEFT", 0, -10)
 	checks[19]:Show()

-	for i=20,22 do
+	for i=20,21 do
 		checks[i] = makeCheck(self.conditions[i])
 		checks[i]:SetPoint("TOPLEFT", checks[i-1], "TOPRIGHT", 60, 0)
 		checks[i]:Show()
@@ -599,6 +610,12 @@ function Buffs:CreateEditFrame(parent)
 	strict:Show()
 	frame.strict = strict

+	local onlymine = CreateFrame("CheckButton", "PRBuffs_OnlyMine", PROptions_Buffs_Edit, "PRCheckTemplate")
+	onlymine.Label:SetText(L["Only show my buffs"])
+	onlymine:SetPoint("TOPLEFT", strict, "BOTTOMLEFT", 0, -10)
+	onlymine:Show()
+	frame.onlymine = onlymine
+
 	local dropdown = CreateFrame("Frame", "PRBuffs_Dropdown", PROptions_Buffs_Edit, "UIDropDownMenuTemplate")
 	dropdown:SetID(1)
 	dropdown:SetPoint("BOTTOMRIGHT", -115, 30)
@@ -631,6 +648,7 @@ function Buffs:FillEntry(entry)
 	options.missing:SetChecked(entry.missing)
 	options.disabled:SetChecked(entry.disabled)
 	options.strict:SetChecked(entry.strict)
+	options.onlymine:SetChecked(entry.onlymine)
 end

 function Buffs:EditEntry()
@@ -646,13 +664,33 @@ function Buffs:EditEntry()
 	self:FillEntry(entry)
 end

+function Buffs:MoveEntry(direction)
+	local selected = PROptions_Buffs.selected
+	local destination
+
+	if direction == "UP" then
+		destination = selected - 1
+	else
+		destination = selected + 1
+	end
+
+	local tmp = PerfectRaid.db.profile.buffs[destination]
+	PerfectRaid.db.profile.buffs[destination] = PerfectRaid.db.profile.buffs[selected]
+	PerfectRaid.db.profile.buffs[selected] = tmp
+
+	PROptions_Buffs.selected = destination
+	PROptions_BuffsScrollFrame.update()
+	self:EnableButtons()
+	self:UpdateBuffTable()
+end
+
 function Buffs:DisableEntry()
 	local scrollframe = PROptions_BuffsScrollFrame
 	local offset = FauxScrollFrame_GetOffset(scrollframe)
 	local selected = PROptions_Buffs.selected
-	local idx = offset + selected
-	local entry = PerfectRaid.db.profile.buffs[idx]
+	local entry = PerfectRaid.db.profile.buffs[selected]
 	entry.disabled = not entry.disabled
+
 	scrollframe.update()
 	self:EnableButtons()
 	self:UpdateBuffTable()
@@ -674,6 +712,7 @@ function Buffs:AddEntry()
 	options.missing:SetChecked(false)
 	options.disabled:SetChecked(false)
 	options.strict:SetChecked(false)
+	options.onlymine:SetChecked(false)
 	options.buffname:SetFocus()
 end

@@ -681,9 +720,10 @@ function Buffs:DeleteEntry()
 	local scrollframe = PROptions_BuffsScrollFrame
 	local offset = FauxScrollFrame_GetOffset(scrollframe)
 	local selected = PROptions_Buffs.selected
-	local idx = offset + selected
-	table.remove(PerfectRaid.db.profile.buffs, idx)
+
+	table.remove(PerfectRaid.db.profile.buffs, selected)
 	PROptions_Buffs.selected = nil
+
 	scrollframe.update()
 	self:EnableButtons()
 	self:UpdateBuffTable()
@@ -702,8 +742,9 @@ function Buffs:UpdateBuffTable()
 			tbl.missing = entry.missing
 			tbl.strict = entry.strict
 			tbl.cond = {string.split(",", entry.conds)}
-			if entry.conds:match("MySpell") then
-				tbl.showmine = true
+			tbl.onlymine = entry.onlymine
+
+			if tbl.onlymine then
 				mymask[tbl.buffname] = true
 				if entry.groupname then
 					mymask[tbl.groupname] = true
@@ -762,6 +803,7 @@ function Buffs:SaveEntry()
 	entry.missing = frame.missing:GetChecked()
 	entry.disabled = frame.disabled:GetChecked()
 	entry.strict = frame.strict:GetChecked()
+	entry.onlymine = frame.onlymine:GetChecked()

 	local color = utils.RGBPercToHex(frame.disptext:GetTextColor())
 	entry.color = color
@@ -789,13 +831,23 @@ function Buffs:EnableButtons()
 		PRBuffs_Edit:Enable()
 		PRBuffs_Delete:Enable()
 		PRBuffs_Disable:Enable()
+		PRBuffs_Up:Enable()
+		PRBuffs_Down:Enable()

 		-- Change enable/disable
 		local scrollframe = PROptions_BuffsScrollFrame
 		local offset = FauxScrollFrame_GetOffset(scrollframe)
 		local selected = PROptions_Buffs.selected
-		local idx = offset + selected
-		local entry = PerfectRaid.db.profile.buffs[idx]
+		local entry = PerfectRaid.db.profile.buffs[selected]
+
+		if selected == 1 then
+			PRBuffs_Up:Disable()
+		end
+
+		if selected == #PerfectRaid.db.profile.buffs then
+			PRBuffs_Down:Disable()
+		end
+
 		if entry.disabled then
 			PRBuffs_Disable:SetText(L["Enable"])
 		else
@@ -805,6 +857,8 @@ function Buffs:EnableButtons()
 		PRBuffs_Edit:Disable()
 		PRBuffs_Delete:Disable()
 		PRBuffs_Disable:Disable()
+		PRBuffs_Up:Disable()
+		PRBuffs_Down:Disable()
 	end
 end

@@ -830,7 +884,6 @@ Buffs.conditions = {
 	["Group 7"] = function(u,c,g) return g == 7 end,
 	["Group 8"] = function(u,c,g) return g == 8 end,
 	["MyGroup"] = function(u,c,g) return g == raidLookup.player end,
-	["MySpell"] = function(u,c,g,m) return m end,
 }

 local work = {}