Quantcast

Added an auto-fill for default buffs which are included, so you can add them without having to fill them out

James Whitehead II [01-07-07 - 00:04]
Added an auto-fill for default buffs which are included, so you can add them without having to fill them out
Fixed some of the list entry code so things properly select/edit
Altered OnShow and OAC to prevent excessive lag during raid changes
Filename
Localization.enUS.lua
PerfectRaid.lua
PerfectRaid_Buffs.lua
PerfectRaid_Options.lua
diff --git a/Localization.enUS.lua b/Localization.enUS.lua
index ae56c61..3fa407a 100644
--- a/Localization.enUS.lua
+++ b/Localization.enUS.lua
@@ -6,13 +6,13 @@ PerfectRaidLocals = {
 	["Aggro"] = "Aggro",
 	["Arcane Brilliance"] = "Arcane Brilliance",
 	["Arcane Intellect"] = "Arcane Intellect",
+	["Auto-fill Default"] = "Auto-fill Default",
 	["Blessing of Kings"] = "Blessing of Kings",
 	["Blessing of Light"] = "Blessing of Light",
 	["Blessing of Might"] = "Blessing of Might",
 	["Blessing of Salvation"] = "Blessing of Salvation",
 	["Blessing of Sanctuary"] = "Blessing of Sanctuary",
 	["Blessing of Wisdom"] = "Blessing of Wisdom",
-	["Buff Name"] = "Buff Name",
 	["Buff Name:"] = "Buff Name:",
 	["Buffs/Debuffs"] = "Buffs/Debuffs",
 	["Cancel"] = "Cancel",
@@ -53,6 +53,7 @@ PerfectRaidLocals = {
 	["Prayer of Shadow Protection"] = "Prayer of Shadow Protection",
 	["Prayer of Spirit"] = "Prayer of Spirit",
 	["Put a backdrop behind PerfectRaid"] = "Put a backdrop behind PerfectRaid",
+	["Raid Frames"] = "Raid Frames",
 	["Regrowth"] = "Regrowth",
 	["Rejuvenation"] = "Rejuvenation",
 	["Renew"] = "Renew",
diff --git a/PerfectRaid.lua b/PerfectRaid.lua
index c80f958..63c51f3 100644
--- a/PerfectRaid.lua
+++ b/PerfectRaid.lua
@@ -299,6 +299,15 @@ end
 local function OnShow(frame)
 	local self = PerfectRaid
 	local unit = frame:GetAttribute("unit")
+	local name = UnitName(unit)
+	if not frame.name then
+		frame.name = name
+	else
+		if frame.name == name then
+			return
+		end
+	end
+
 	frame.name:SetText(self:GetColoredName(unit))
 --	frame.name:SetText(UnitName(unit))

@@ -346,6 +355,13 @@ end

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

 	for unit,tbl in pairs(frames) do
 		if tbl[frame] and frame:GetAttribute("unit") ~= unit then
diff --git a/PerfectRaid_Buffs.lua b/PerfectRaid_Buffs.lua
index 85553aa..1785fcb 100644
--- a/PerfectRaid_Buffs.lua
+++ b/PerfectRaid_Buffs.lua
@@ -187,7 +187,7 @@ function Buffs:CreateOptions(opt)
 				display = display .. " (|cFF"..entry.color..entry.disptext.."|r)"
 				button.line1:SetText(display)
 				button:Show()
-				if scrollframe.selected == idx then
+				if options.selected == idx then
 					button:SetChecked(true)
 				else
 					button:SetChecked(false)
@@ -438,19 +438,18 @@ function Buffs:CreateEditFrame(parent)
 	disabled:SetPoint("BOTTOMLEFT", missing, "TOPLEFT", 0, 10)
 	disabled:Show()
 	frame.disabled = disabled
-end

-function Buffs:EditEntry()
-	local scrollframe = PROptions_BuffsScrollFrame
-	local offset = FauxScrollFrame_GetOffset(scrollframe)
-	local selected = PROptions_Buffs.selected
-	local entry = PerfectRaid.db.profile.buffs[selected]
+	local dropdown = CreateFrame("Frame", "PRBuffs_Dropdown", PROptions_Buffs_Edit, "UIDropDownMenuTemplate")
+	dropdown:SetID(1)
+	dropdown:SetPoint("BOTTOMRIGHT", -115, 30)
+	dropdown:SetScript("OnShow", function() self:DropDown_OnShow() end)

-	local options = PROptions_Buffs_Edit
-	options.editEntry = entry
+	PRBuffs_DropdownButton:SetScript("OnClick", function() ToggleDropDownMenu(nil, nil, PRBuffs_Dropdown, "cursor") end)
+	UIDropDownMenu_SetText(L["Auto-fill Default"], dropdown)
+end

-	self.options:FadeOut(PROptions_Buffs)
-	self.options:FadeIn(options)
+function Buffs:FillEntry(entry)
+	local options = PROptions_Buffs_Edit
 	options.buffname:SetText(entry.buffname)
 	options.groupname:SetText(entry.groupname or "")
 	options.disptext:SetText(entry.disptext)
@@ -473,6 +472,19 @@ function Buffs:EditEntry()
 	options.disabled:SetChecked(entry.disabled)
 end

+function Buffs:EditEntry()
+	local scrollframe = PROptions_BuffsScrollFrame
+	local offset = FauxScrollFrame_GetOffset(scrollframe)
+	local selected = PROptions_Buffs.selected
+	local entry = PerfectRaid.db.profile.buffs[selected]
+
+	local options = PROptions_Buffs_Edit
+	options.editEntry = entry
+	self.options:FadeOut(PROptions_Buffs)
+	self.options:FadeIn(options)
+	self:FillEntry(entry)
+end
+
 function Buffs:AddEntry()
 	local options = PROptions_Buffs_Edit
 	self.options:FadeOut(PROptions_Buffs)
@@ -543,6 +555,10 @@ function Buffs:SaveEntry()
 		return
 	end

+	if groupname == "" then
+		groupname = nil
+	end
+
 	local options = PROptions_Buffs_Edit
 	local entry = options.editEntry or {}

@@ -636,6 +652,31 @@ StaticPopupDialogs["PR_BUFF_SAVE_ERROR"] = {
 	hideOnEscape = 1
 }

+local click_func = function() Buffs:DropDown_OnClick() end
+local init_func = function() Buffs:DropDown_Initialize() end
+
+function Buffs:DropDown_Initialize()
+    local info = {}
+
+    for k,v in pairs(self.defaults) do
+        info = {}
+        info.text = string.format("%s (|cFF%s%s|r)", v.buffname, v.color, v.disptext)
+        info.value = v
+        info.func = click_func
+        UIDropDownMenu_AddButton(info)
+	end
+end
+
+function Buffs:DropDown_OnClick()
+	local entry = this.value
+	self:FillEntry(entry)
+end
+
+function Buffs:DropDown_OnShow(this)
+	table.sort(self.defaults, function(a,b) return a.buffname < b.buffname end)
+	UIDropDownMenu_Initialize(PRBuffs_Dropdown, init_func);
+end
+
 function Buffs:AddDefaultBuff(profile, entry)
 	local tbl = {}
 	for k,v in pairs(entry) do tbl[k] = v end
diff --git a/PerfectRaid_Options.lua b/PerfectRaid_Options.lua
index 0355e90..9dc9817 100644
--- a/PerfectRaid_Options.lua
+++ b/PerfectRaid_Options.lua
@@ -153,9 +153,15 @@ function Options:CreateListFrame(parent, num)
 		local offset = FauxScrollFrame_GetOffset(scrollframe)
 		local idx = offset + self.idx

-		if parent.selected then
-			parent.entries[parent.selected - offset]:SetChecked(nil)
+		if parent.selected and parent.selected - offset == self.idx then
+			parent.entries[parent.selected - offset]:SetChecked(true)
+		elseif parent.selected then
+			local idx = parent.selected - offset
+			if idx <= num then
+				parent.entries[parent.selected - offset]:SetChecked(false)
+			end
 		end
+
 		parent.selected = idx
 	end