Quantcast

* Added a button to disable raid frames on the raid frame tab.

James Whitehead II [04-20-07 - 03:17]
* Added a button to disable raid frames on the raid frame tab.
* You can hide and show the frames from this screen, and only the events for shown frames should be processed
* There is a slider to change the manabar height on the raid frame editor.
* Mana bars default to 0, which is hidden.
Filename
Dongle.lua
Localization.enUS.lua
PerfectRaid.lua
PerfectRaid_Frames.lua
diff --git a/Dongle.lua b/Dongle.lua
index ce96b4d..1a76e32 100644
--- a/Dongle.lua
+++ b/Dongle.lua
@@ -29,7 +29,7 @@
   OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
 ---------------------------------------------------------------------------]]
 local major = "DongleStub"
-local minor = tonumber(string.match("$Revision: 291 $", "(%d+)") or 1)
+local minor = tonumber(string.match("$Revision: 313 $", "(%d+)") or 1)

 local g = getfenv(0)

@@ -118,6 +118,7 @@ if not g.DongleStub or g.DongleStub:IsNewerVersion(major, minor) then

 		-- Deactivate the old libary if necessary
 		if type(oldDeactivate) == "function" then
+			local major, minor = oldInstance:GetVersion()
 			table.insert(self.log, string.format("Deactivate: %s, %s", major, minor))
 			oldDeactivate(oldInstance, newInstance)
 		end
@@ -154,7 +155,7 @@ end
 ---------------------------------------------------------------------------]]

 local major = "Dongle-1.0"
-local minor = tonumber(string.match("$Revision: 303 $", "(%d+)") or 1)
+local minor = tonumber(string.match("$Revision: 317 $", "(%d+)") or 1)

 assert(DongleStub, string.format("Dongle requires DongleStub.", major))

@@ -225,8 +226,9 @@ local function assert(level,condition,message)
 end

 local function argcheck(value, num, ...)
-	assert(1, type(num) == "number",
-		string.format(L["BAD_ARGUMENT"], 2, "argcheck", "number", type(level)))
+	if type(num) ~= "number" then
+		error(L["BAD_ARGUMENT"]:format(2, "argcheck", "number", type(num)), 1)
+	end

 	for i=1,select("#", ...) do
 		if type(value) == select(i, ...) then return end
@@ -234,7 +236,7 @@ local function argcheck(value, num, ...)

 	local types = strjoin(", ", ...)
 	local name = string.match(debugstack(2,2,0), ": in function [`<](.-)['>]")
-	error(string.format(L["BAD_ARGUMENT"], num, name, types, type(value)), 3)
+	error(L["BAD_ARGUMENT"]:format(num, name, types, type(value)), 3)
 end

 local function safecall(func,...)
@@ -621,6 +623,10 @@ local function copyDefaults(dest, src, force)
 							tbl = copyTable(v)
 							rawset(cache, k, tbl)
 							local mt = getmetatable(tbl)
+							if not mt then
+								mt = {}
+								setmetatable(tbl, mt)
+							end
 							local newindex = function(t,k,v)
 								rawset(parent, parentkey, t)
 								rawset(t, k, v)
@@ -631,6 +637,10 @@ local function copyDefaults(dest, src, force)
 					end,
 				}
 				setmetatable(dest, mt)
+				-- Now need to set the metatable on any child tables
+				for dkey,dval in pairs(dest) do
+					copyDefaults(dval, v)
+				end
 			else
 				-- Values are not tables, so this is just a simple return
 				local mt = {__index = function() return v end}
@@ -662,6 +672,10 @@ local function removeDefaults(db, defaults)
 					rawset(db, cacheKey, cacheValue)
 				end
 			end
+			-- Now loop through all the actual k,v pairs and remove
+			for key,value in pairs(db) do
+				removeDefaults(value, v)
+			end
 		elseif type(v) == "table" and db[k] then
 			removeDefaults(db[k], v)
 			if not next(db[k]) then
@@ -708,6 +722,10 @@ local dbmt = {
 				if new then
 					Dongle:TriggerMessage("DONGLE_PROFILE_CREATED", t, rawget(t, "parent"), rawget(t, "sv_name"), key)
 				end
+			elseif section == "profiles" then
+				local sv = rawget(t, "sv")
+				if not sv.profiles then sv.profiles = {} end
+				rawset(t, "profiles", sv.profiles)
 			elseif section == "global" then
 				local sv = rawget(t, "sv")
 				if not sv.global then sv.global = {} end
@@ -761,6 +779,7 @@ local function initdb(parent, name, defaults, defaultProfile, olddb)
 		["factionrealm"] = factionrealm,
 		["global"] = true,
 		["profile"] = profileKey,
+		["profiles"] = true, -- Don't create until we need
 	}

 	-- If we've been passed an old database, clear it out
@@ -829,7 +848,13 @@ function Dongle:ClearDBDefaults()
 			for section,key in pairs(db.keys) do
 				local tbl = rawget(db, section)
 				if tbl and not next(tbl) then
-					sv[section][key] = nil
+					if sv[section] then
+						if type(key) == "string" then
+							sv[section][key] = nil
+						else
+							sv[section] = nil
+						end
+					end
 				end
 			end
 		end
diff --git a/Localization.enUS.lua b/Localization.enUS.lua
index 1ce4466..6cbdfb6 100644
--- a/Localization.enUS.lua
+++ b/Localization.enUS.lua
@@ -23,12 +23,15 @@ PerfectRaidLocals = {
 	["Column Anchor Point:"] = "Column Anchor Point:",
 	["Dead"] = "Dead",
 	["Delete"] = "Delete",
+	["Disable"] = "Disable",
+	["Disabled: "] = "Disabled: ",
 	["Display Text:"] = "Display Text:",
 	["Display a header backdrop"] = "Display a header backdrop",
 	["Divine Spirit"] = "Divine Spirit",
 	["Do not check this buff (Disable)"] = "Do not check this buff (Disable)",
 	["Druid"] = "Druid",
 	["Edit"] = "Edit",
+	["Enable"] = "Enable",
 	["Fear Ward"] = "Fear Ward",
 	["Frame Scale:"] = "Frame Scale:",
 	["Frames have been locked"] = "Frames have been locked",
@@ -60,6 +63,7 @@ PerfectRaidLocals = {
 	["Lesser Heal"] = "Lesser Heal",
 	["Mage"] = "Mage",
 	["Make filters strict"] = "Make filters strict",
+	["Mana Bar Height:"] = "Mana Bar Height:",
 	["Mark of the Wild"] = "Mark of the Wild",
 	["Max Units per Column:"] = "Max Units per Column:",
 	["Mortal Strike"] = "Mortal Strike",
@@ -68,8 +72,8 @@ PerfectRaidLocals = {
 	["Offline"] = "Offline",
 	["Only show if this buff is missing"] = "Only show if this buff is missing",
 	["Out-of-Range Alpha"] = "Out-of-Range Alpha",
-	["Party"] = "Party",
 	["Paladin"] = "Paladin",
+	["Party"] = "Party",
 	["PerfectRaid Options"] = "PerfectRaid Options",
 	["Perform aggro checking"] = "Perform aggro checking",
 	["Perform range checking"] = "Perform range checking",
diff --git a/PerfectRaid.lua b/PerfectRaid.lua
index 10de551..551e438 100644
--- a/PerfectRaid.lua
+++ b/PerfectRaid.lua
@@ -45,7 +45,11 @@ function PerfectRaid:Initialize()
 	self.aggro = aggro
 	self.defaults = {
 		profile = {
-			headers = {},
+			headers = {
+				["*"] = {
+					manaheight = 0,
+				},
+			},
 			positions = {},
 		},
 	}
@@ -212,6 +216,11 @@ function PerfectRaid:CreateRaidFrame(idx)
 		}
 	end

+	if options.disabled then
+		frame:Hide()
+		return
+	end
+
 	frame.idx = idx
 	frame.title:SetText(options.title or "")

@@ -574,9 +583,14 @@ function PerfectRaid:UpdateButtonLayout(button)
 	button.manabar:ClearAllPoints()
 	button.manabar:SetPoint("BOTTOMLEFT", 0, 0)
 	button.manabar:SetPoint("BOTTOMRIGHT", 0, 0)
-	button.manabar:SetHeight(2)
+	if options.manaheight == 0 then
+		button.manabar:Hide()
+	else
+		button.manabar:Show()
+		button.manabar:SetHeight(options.manaheight)
+	end
+
 	button.manabar:SetStatusBarTexture("Interface\\AddOns\\PerfectRaid\\images\\smooth")
-	button.manabar:Hide()

 	button.status:ClearAllPoints()
 	button.status:SetPoint("RIGHT", -2, 0)
diff --git a/PerfectRaid_Frames.lua b/PerfectRaid_Frames.lua
index ffd99a8..52f0f2f 100644
--- a/PerfectRaid_Frames.lua
+++ b/PerfectRaid_Frames.lua
@@ -94,13 +94,13 @@ function Frames:CreateOptions(opt)
 				local entry = list[idx]
 				local display
 				if entry.title then
-					display = string.format("%s: %s", entry.title, entry.filter or L["No filters selected"])
+					display = string.format("%s%s: %s", entry.disabled and L["Disabled: "] or "", entry.title, entry.filter or L["No filters selected"])
 				else
-					display = string.format("%s", entry.filter or L["No filters selected"])
+					display = string.format("%s%s", entry.disabled and L["Disabled: "] or "", entry.filter or L["No filters selected"])
 				end
 				button.line1:SetText(display)
 				button:Show()
-				if scrollframe.selected == idx then
+				if PROptions_Frames.selected == idx then
 					button:SetChecked(true)
 				else
 					button:SetChecked(false)
@@ -151,6 +151,12 @@ function Frames:CreateOptions(opt)
 	add:SetScript("OnClick", function() self:AddEntry() end)
 	add:Show()

+	local disable = CreateFrame("Button", "PRFrames_Disable", options, "PRButtonTemplate")
+	disable:SetText(L["Disable"])
+	disable:SetPoint("BOTTOMRIGHT", add, "BOTTOMLEFT", -10, 0)
+	disable:SetScript("OnClick", function() self:DisableEntry() end)
+	disable:Show()
+
 	self:CreateEditFrame(options)
 end

@@ -342,12 +348,24 @@ function Frames:CreateEditFrame(parent)
 	slider.Text:SetText(L["Frame Scale:"])
 	slider.High:SetText("2.0")
 	slider.Low:SetText("0.1")
+	slider:SetWidth(125)
 	slider:SetMinMaxValues(0.1,2.0)
 	slider:SetValueStep(0.05)
 	slider:SetPoint("BOTTOMLEFT", 10, 15)
 	slider:SetValue(1.0)
 	slider:Show()

+	local slider = CreateFrame("Slider", "PRFrame_ManaHeight", PROptions_Frames_Edit, "PRSliderTemplate")
+	slider.Text:SetText(L["Mana Bar Height:"])
+	slider.High:SetText("10")
+	slider.Low:SetText("0")
+	slider:SetWidth(125)
+	slider:SetMinMaxValues(0,10)
+	slider:SetValueStep(1)
+	slider:SetPoint("LEFT", PRFrame_Scale, "RIGHT", 50, 0)
+	slider:SetValue(2.0)
+	slider:Show()
+
 	local cancel = CreateFrame("Button", "PRFrames_Cancel", PROptions_Frames_Edit, "PRButtonTemplate")
 	cancel:SetText(L["Cancel"])
 	cancel:SetPoint("BOTTOMRIGHT", 0, 5)
@@ -384,6 +402,16 @@ function Frames:CreateEditFrame(parent)
 	PROptions_Frames_EditColSpacing:SetScript("OnTabPressed", onTabPressed)
 end

+function Frames:DisableEntry()
+	local idx = PROptions_Frames.selected
+	local list = PerfectRaid.db.profile.headers
+	local entry = list[idx]
+
+	entry.disabled = not entry.disabled
+	self.scrollframe.update()
+	PerfectRaid:UpdateRaidFrames()
+end
+
 function Frames:EditEntry()
 	local idx = PROptions_Frames.selected
 	local list = PerfectRaid.db.profile.headers
@@ -417,6 +445,7 @@ function Frames:EditEntry()
 	UIDropDownMenu_SetSelectedValue(PRFrames_ColAnchorDropDown, entry.colAnchor)
 	PRFrame_HeaderBackdrop:SetChecked(entry.hBackdrop)
 	PRFrame_Scale:SetValue(entry.scale)
+	PRFrame_ManaHeight:SetValue(entry.manaheight or 0)
 	PRFrame_Strict:SetChecked(entry.strict)

 	PRFrame_ColorClass:SetChecked(entry.colorclass)
@@ -448,9 +477,18 @@ function Frames:EnableButtons()
 	if PROptions_Frames.selected then
 		PRFrames_Edit:Enable()
 		PRFrames_Delete:Enable()
+		PRFrames_Disable:Enable()
+		local list = PerfectRaid.db.profile.headers
+		local entry = list[PROptions_Frames.selected]
+		if entry.disabled then
+			PRFrames_Disable:SetText(L["Enable"])
+		else
+			PRFrames_Disable:SetText(L["Disable"])
+		end
 	else
 		PRFrames_Edit:Disable()
 		PRFrames_Delete:Disable()
+		PRFrames_Disable:Disable()
 	end
 end

@@ -476,6 +514,7 @@ function Frames:SaveEntry()
 	local colAnchor = UIDropDownMenu_GetSelectedValue(PRFrames_ColAnchorDropDown)
 	local hBackdrop = PRFrame_HeaderBackdrop:GetChecked()
 	local scale = PRFrame_Scale:GetValue()
+	local manaheight = PRFrame_ManaHeight:GetValue()
 	local strict = PRFrame_Strict:GetChecked()
 	local colorclass = PRFrame_ColorClass:GetChecked()
 	local reverse = PRFrame_ReverseBar:GetChecked()
@@ -519,6 +558,7 @@ function Frames:SaveEntry()
 	entry.colAnchor = colAnchor
 	entry.hBackdrop = hBackdrop
 	entry.scale = scale
+	entry.manaheight = manaheight
 	entry.strict = strict
 	entry.colorclass = colorclass
 	entry.reverse = reverse
@@ -560,6 +600,7 @@ function Frames:CancelEntry()
 	PROptions_Frames_EditColSpacing:SetText("")
 	PRFrame_HeaderBackdrop:SetChecked(false)
 	PRFrame_Scale:SetValue(1.0)
+	PRFrame_ManaHeight:SetValue(0)
 	PRFrame_Strict:SetChecked(false)
 	PRFrame_ColorClass:SetChecked(false)
 	PRFrame_ReverseBar:SetChecked(false)