Quantcast

* Added textures and logic for mouseover highlighting, as well as debuff highlighting

James Whitehead II [05-07-07 - 22:56]
* Added textures and logic for mouseover highlighting, as well as debuff highlighting
* These settings will default based on your class and as always can be overwritten
* Removed the script to convert savedvariables.
* If you are using an OLDER version of PerfectRaid (i.e. haven't updated since Feb) then you will need to reset your settings.
* Fixed the backdrop offsets, better graphics
* Changed the offset on titles
* The deficit text is now on top of the mana bar, as expected
* Debuffs with the same name as their type (a Poison called Poison) will no longer show up as a double stack
* Added a "Highlight" tab to configure the new highlighting options
Filename
Localization.enUS.lua
PerfectRaid.lua
PerfectRaid_Buffs.lua
diff --git a/Localization.enUS.lua b/Localization.enUS.lua
index 11397d3..a58a2de 100644
--- a/Localization.enUS.lua
+++ b/Localization.enUS.lua
@@ -56,6 +56,11 @@ PerfectRaidLocals = {
 	["Group frames by:"] = "Group frames by:",
 	["Healing Touch"] = "Healing Touch",
 	["Healing Wave"] = "Healing Wave",
+	["Highlight on mouseover"] = "Highlight on mouseover",
+	["Highlight when cursed"] = "Highlight when cursed",
+	["Highlight when diseased"] = "Highlight when diseased",
+	["Highlight when magic debuffed"] = "Highlight when magic debuffed",
+	["Highlight when poisoned"] = "Highlight when poisoned",
 	["Holy Light"] = "Holy Light",
 	["Hunter"] = "Hunter",
 	["If you choose any of the column options, all of them become required fields.  Please choose the number of columns, max units, column spacing and column anchor."] = "If you choose any of the column options, all of them become required fields.  Please choose the number of columns, max units, column spacing and column anchor.",
diff --git a/PerfectRaid.lua b/PerfectRaid.lua
index a7812cf..5b54fca 100644
--- a/PerfectRaid.lua
+++ b/PerfectRaid.lua
@@ -46,6 +46,9 @@ local OnAttributeChanged
 function PerfectRaid:Initialize()
 	self.frames = frames
 	self.aggro = aggro
+
+	local class = select(2, UnitClass("player"))
+
 	self.defaults = {
 		profile = {
 			headers = {
@@ -56,6 +59,13 @@ function PerfectRaid:Initialize()
 			positions = {},
 			hideparty = true,
 			showmanaonly = true,
+			highlight = {
+				mouseover = true,
+				curse = (class == "DRUID" or class == "MAGE"),
+				disease = (class == "PRIEST" or class == "PALADIN" or class == "SHAMAN"),
+				magic = (class == "PRIEST" or class == "PALADIN"),
+				poison = (class == "DRUID" or class == "PALADIN" or class == "SHAMAN"),
+			},
 		},
 	}

@@ -65,48 +75,23 @@ function PerfectRaid:Initialize()

 	utils = self.utils

-	-- This is a small procedure to update the saved variables
-	PerfectRaidDB = PerfectRaidDB or {}
-	local sv = PerfectRaidDB
-
-	if not sv.global then sv.global = {} end
-
-	if sv and not sv.global.sv_converted then
-		if sv.char then
-			local converted = {}
-			for key,entry in pairs(sv.char) do
-				local char,server = key:match("^(.+) of (.+)$")
-				if char then
-					local new_key = ("%s - %s"):format(char, server)
-					converted[new_key] = entry
-				else
-					converted[key] = entry
-				end
-			end
-			sv.char = converted
-		end
-
-		if sv.profileKeys then
-			local converted = {}
-			for ukey,pkey in pairs(sv.profileKeys) do
-				-- Update each user key
-				local char,server = ukey:match("^(.+) of (.+)$")
-				if char then
-					local new_key = ("%s - %s"):format(char, server)
-					converted[new_key] = pkey
-				else
-					converted[key] = entry
-				end
+	if PerfectRaidDB then
+		if PerfectRaidDB.global then
+			if PerfectRaidDB.global.sv_converted then
+				PerfectRaidDB.global.sv_converted = nil
+				PerfectRaidDB.global.sv_version = self.rev
+			elseif PerfectRaidDB.global.sv_version < 693 then
+				self:Print("You're upgrading from an old version of PerfectRaid")
+				PerfectRaidDB = {}
+				self:Print("All settings have been set to default")
 			end
-			sv.profileKeys = converted
 		end
-
-		sv.global.sv_converted = true
 	end
 end

 function PerfectRaid:Enable()
 	self.db = self:InitializeDB("PerfectRaidDB", self.defaults)
+	self.db.global.sv_version = self.rev

 	self:RegisterEvent("RAID_ROSTER_UPDATE")
 	self:RegisterEvent("PARTY_MEMBERS_CHANGED")
@@ -230,15 +215,23 @@ function PerfectRaid:CreateRaidFrame(idx)
 		frame.title = frame:CreateFontString(nil, "ARTWORK", "GameFontNormalSmall")
 		local offset = options.partyFrame and 17 or 3

-		local bgtopoffset = 5
-		bgtopoffset = bgtopoffset + (options.partyFrame and 21 or 0)
-		bgtopoffset = bgtopoffset + (options.title and 20 or 0)
-
+		frame.title:SetPoint("BOTTOM", frame, "TOP", 0, offset)
 		frame.bg = bg
-		bg:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, bgtopoffset)
-		bg:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", 0, -5)

-		frame.title:SetPoint("BOTTOM", frame, "TOP", 0, offset)
+		frame.backdrop = {
+			bgFile = "Interface\\AddOns\\PerfectRaid\\images\\bgFile",
+			tile = true, tileSize = 32,
+			edgeFile = "Interface\\AddOns\\PerfectRaid\\images\\edgeFile",
+			edgeSize = 16,
+			insets = {
+				left = 6,
+				right = 5,
+				top = 6,
+				bottom = 5
+			},
+		}
+
+--[[
 		frame.backdrop = {
 			bgFile = "Interface\\Tooltips\\UI-Tooltip-Background",
 			edgeFile = "Interface\\AddOns\\PerfectRaid\\images\\backdrop",
@@ -247,8 +240,17 @@ function PerfectRaid:CreateRaidFrame(idx)
 			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)
+	bgtopoffset = bgtopoffset + (options.title and 20 or 0)
+
+	frame.bg:SetPoint("TOPLEFT", frame, "TOPLEFT", 0, bgtopoffset)
+	frame.bg:SetPoint("BOTTOMRIGHT", frame, "BOTTOMRIGHT", 0, -5)
+
 	frame.idx = idx
 	frame.title:SetText(options.title or "")

@@ -301,6 +303,7 @@ function PerfectRaid:CreateRaidFrame(idx)
 	if options.hBackdrop then
 		frame.bg:SetBackdrop(frame.backdrop)
 		frame.bg:SetBackdropColor(0,0,0,.7)
+		frame.bg:SetBackdropBorderColor(0,0,0,.7)
 	else
 		frame.bg:SetBackdrop(nil)
 	end
@@ -330,7 +333,7 @@ function PerfectRaid:CreateRaidFrame(idx)
 	frame.initialConfigFunction = PerfectRaid.ConfigureButton
 	frame:SetMovable(true)
 	frame:SetClampedToScreen(true)
-	frame:SetScale(options.scale)
+	frame.bg:SetScale(options.scale)
 	frame:Show()
 	frame.bg:Show()
 	self:RestorePosition(name)
@@ -634,15 +637,19 @@ function PerfectRaid.ConfigureButton(button)
 	local bar = CreateFrame("StatusBar", nil, button)
 	button.healthbar = bar

+	local raise = CreateFrame("Frame", nil, button.healthbar)
+	raise:SetAllPoints()
+	--raise:Show()
+
+	local font = raise:CreateFontString(nil, "OVERLAY", "GameFontHighlightSmall")
+	button.status = font
+
 	local bar = CreateFrame("StatusBar", nil, button.healthbar)
 	button.manabar = bar

 	local font = button.healthbar:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
 	button.name = font

-	local font = button.healthbar:CreateFontString(nil, "ARTWORK", "GameFontHighlightSmall")
-	button.status = font
-
 	button:SetClampedToScreen(true)
 	button:RegisterForDrag("LeftButton")

diff --git a/PerfectRaid_Buffs.lua b/PerfectRaid_Buffs.lua
index 756b13d..42cd290 100644
--- a/PerfectRaid_Buffs.lua
+++ b/PerfectRaid_Buffs.lua
@@ -93,6 +93,43 @@ function Buffs:ConfigureButton(button)
 	button.aura = font
 end

+local backdrop = {
+	bgFile = "Interface\\AddOns\\PerfectRaid\\images\\bgFile",
+	tile = true, tileSize = 32,
+--	edgeFile = "Interface\\AddOns\\PerfectRaid\\images\\edgeFile",
+--	edgeSize = 16,
+	insets = {
+		left = 6,
+		right = 6,
+--		top = 1,
+--		bottom = 1
+	},
+}
+
+local r,g,b,a
+local function OnEnter(frame)
+	if not PerfectRaid.db.profile.highlight.mouseover then return end
+
+	if frame.backdropset then
+		r,g,b,a = frame:GetBackdropColor()
+	end
+
+--	frame:SetBackdropColor(1, 0.84, 0, 0.3)
+	frame:SetBackdropColor(0.9, 0.9, 0.9, 0.3)
+	frame.backdropset = true
+end
+
+local function OnLeave(frame)
+	if r then
+		frame:SetBackdropColor(r,g,b,a)
+	else
+		frame:SetBackdropColor(0,0,0,0)
+	end
+
+	frame.backdropset = false
+	r,g,b,a = nil,nil,nil,nil
+end
+
 function Buffs:UpdateButtonLayout(button, options)
 	button.aura:ClearAllPoints()

@@ -101,6 +138,12 @@ function Buffs:UpdateButtonLayout(button, options)
 	else
 		button.aura:SetPoint("LEFT", button.rightbox, "LEFT", 2, 0)
 	end
+
+	button:SetBackdrop(backdrop)
+	button:SetBackdropColor(0,0,0,0)
+
+	button:SetScript("OnEnter", OnEnter)
+	button:SetScript("OnLeave", OnLeave)
 end

 function Buffs:ShowButton(button)
@@ -110,6 +153,7 @@ end

 local buffs = {}
 local buffcache = {}
+
 local work = {}
 function Buffs:UNIT_AURA(event, unit)
 	if not frames[unit] then return end
@@ -122,12 +166,14 @@ function Buffs:UNIT_AURA(event, unit)
 		buffcache[name] = (buffcache[name] or 0) + 1
 	end

+	local debuffType
 	for i=1,40 do
 		local name,rank,texture,count,type = UnitDebuff(unit, i)
 		if not name and not type then break end
 		buffcache[name] = (buffcache[name] or 0) + 1
-		if type then
+		if type and name ~= type then
 			buffcache[type] = (buffcache[type] or 0) + 1
+			debuffType = type
 		end
 	end

@@ -162,13 +208,36 @@ function Buffs:UNIT_AURA(event, unit)
 		end
 	end

+	-- Check to see if we need to change the backdrop
+	local opt = PerfectRaid.db.profile.highlight
+	local r,g,b,a
+	if buffcache.Curse and opt.curse then
+		r,g,b,a = 0.6,0,1,0.7
+	elseif buffcache.Poison and opt.poison then
+		r,g,b,a = 0,0.6,0,0.7
+	elseif buffcache.Disease and opt.disease then
+		r,g,b,a = 0.6,0.4,0,0.7
+	elseif buffcache.Magic and opt.magic then
+		r,g,b,a = 0.2,0.6,1,0.7
+	end
+
 	local status = strjoin(" ", unpack(work))
 	for frame in pairs(frames[unit]) do
 		frame.aura:SetText(status)
+		if r then
+			frame:SetBackdropColor(r,g,b,a)
+			frame.backdropset = true
+		elseif frame.backdropset then
+			frame:SetBackdropColor(0,0,0,0)
+		end
 	end
 end

 function Buffs:CreateOptions(opt)
+
+	-- Call the highlight options frame creation script
+	self:CreateOptions_Highlight(opt)
+
 	self.options = opt
 	local options = CreateFrame("Frame", "PROptions_Buffs", PROptions)
 	opt:AddOptionsTab(L["Buffs/Debuffs"], options)
@@ -690,7 +759,93 @@ function Buffs:AddDefaultBuff(profile, entry)
 	tbl.disabled = nil
 	table.insert(profile, tbl)
 end
+
+local options
+function Buffs:CreateOptions_Highlight(opt)
+	options = CreateFrame("Frame", "PROptions_Highlight", PROptions)
+
+	opt:AddOptionsTab("Highlight", options)
+
+	options.widgets = {}
+
+	local check = CreateFrame("CheckButton", "PRHighlight_Mouseover", options, "PRCheckTemplate")
+	check.Label:SetText(L["Highlight on mouseover"])
+	table.insert(options.widgets, check)
+
+	local check = CreateFrame("CheckButton", "PRHighlight_Disease", options, "PRCheckTemplate")
+	check.Label:SetText(L["Highlight when diseased"])
+	table.insert(options.widgets, check)
+
+	local check = CreateFrame("CheckButton", "PRHighlight_Curse", options, "PRCheckTemplate")
+	check.Label:SetText(L["Highlight when cursed"])
+	table.insert(options.widgets, check)
+
+	local check = CreateFrame("CheckButton", "PRHighlight_Magic", options, "PRCheckTemplate")
+	check.Label:SetText(L["Highlight when magic debuffed"])
+	table.insert(options.widgets, check)
+
+	local check = CreateFrame("CheckButton", "PRHighlight_Poison", options, "PRCheckTemplate")
+	check.Label:SetText(L["Highlight when poisoned"])
+	table.insert(options.widgets, check)
+
+	local cancel = CreateFrame("Button", "PRHighlight_Cancel", options, "PRButtonTemplate")
+	cancel:SetText(L["Cancel"])
+	cancel:SetPoint("BOTTOMRIGHT", 0, 5)
+	cancel:SetScript("OnClick", function() options:CancelOptions() end)
+	cancel:Show()

+	local save = CreateFrame("Button", "PRHighlight_Save", options, "PRButtonTemplate")
+	save:SetText(L["Save"])
+	save:SetPoint("BOTTOMRIGHT", cancel, "BOTTOMLEFT", -10, 0)
+	save:SetScript("OnClick", function() options:SaveOptions() end)
+	save:Show()
+
+	function options:SaveOptions()
+		local mouseover = PRHighlight_Mouseover:GetChecked()
+		local disease = PRHighlight_Disease:GetChecked()
+		local curse = PRHighlight_Curse:GetChecked()
+		local magic = PRHighlight_Magic:GetChecked()
+		local poison = PRHighlight_Poison:GetChecked()
+
+		PerfectRaid.db.profile.highlight.mouseover = mouseover
+		PerfectRaid.db.profile.highlight.disease = disease
+		PerfectRaid.db.profile.highlight.curse = curse
+		PerfectRaid.db.profile.highlight.magic = magic
+		PerfectRaid.db.profile.highlight.poison = poison
+		-- Trigger update here
+		for unit in pairs(frames) do
+			Buffs:UNIT_AURA(nil, unit)
+		end
+	end
+
+	function options:CancelOptions()
+		local opt = PerfectRaid.db.profile.highlight
+
+		PRHighlight_Mouseover:SetChecked(opt.mouseover)
+		PRHighlight_Disease:SetChecked(opt.disease)
+		PRHighlight_Curse:SetChecked(opt.curse)
+		PRHighlight_Magic:SetChecked(opt.magic)
+		PRHighlight_Poison:SetChecked(opt.poison)
+
+		-- Trigger update here
+		for unit in pairs(frames) do
+			Buffs:UNIT_AURA(nil, unit)
+		end
+	end
+
+	-- Force an update when tab is clicked
+	options:SetScript("OnShow", options.CancelOptions)
+
+	for idx,widget in ipairs(options.widgets) do
+		widget:Show()
+		if idx == 1 then
+			widget:SetPoint("TOPLEFT", 0, 0)
+		else
+			widget:SetPoint("TOPLEFT", options.widgets[idx - 1], "BOTTOMLEFT", 0, -15)
+		end
+	end
+end
+
 local class = select(2, UnitClass("player"))
 local race = select(2, UnitRace("player"))