Quantcast

Fix an issue where if you didn't have all your factions expanded, it wouldn't figure out what reps you had. Feel free to use the code for curesprofiler ckk

ackis [01-03-09 - 05:48]
Fix an issue where if you didn't have all your factions expanded, it wouldn't figure out what reps you had.  Feel free to use the code for curesprofiler ckk
Filename
AckisRecipeList.lua
diff --git a/AckisRecipeList.lua b/AckisRecipeList.lua
index e852e72..b63a109 100644
--- a/AckisRecipeList.lua
+++ b/AckisRecipeList.lua
@@ -82,6 +82,10 @@ local GetTradeSkillLine = GetTradeSkillLine
 local GetTradeSkillInfo = GetTradeSkillInfo
 local GetTradeSkillRecipeLink = GetTradeSkillRecipeLink
 local ExpandTradeSkillSubClass = ExpandTradeSkillSubClass
+local GetNumFactions = GetNumFactions
+local GetFactionInfo = GetFactionInfo
+local CollapseFactionHeader = CollapseFactionHeader
+local ExpandFactionHeader = ExpandFactionHeader

 local select = select
 local format = format
@@ -415,23 +419,45 @@ function addon:GetFactionLevels(RepTable)

 -- Bug here when I reload UI
 	if (not RepTable) then
-
 		return
+	end
+
+	local t = {}

+	-- Number of factions before we expand
+	local numfactions = GetNumFactions()
+
+	-- Lets expand all the headers
+	for i=numfactions,1,-1 do
+		local name, _, _, _, _, _, _, _, _, isCollapsed = GetFactionInfo(i)
+
+		if (isCollapsed) then
+			ExpandFactionHeader(i)
+			t[name] = true
+		end
 	end

-	for i=1,GetNumFactions(),1 do
+	-- Number of factions with everything expanded
+	numfactions = GetNumFactions()

+	-- Get the rep levels
+	for i=1,numfactions,1 do
 		local name,_,replevel = GetFactionInfo(i)

 		-- If the rep is greater than neutral
 		if (replevel > 4) then
-
 			-- We use levels of 0, 1, 2, 3, 4 internally for reputation levels, make it corrospond here
 			RepTable[name] = replevel - 4
-
 		end
+	end

+	-- Collapse the headers again
+	for i=numfactions,1,-1 do
+		local name = GetFactionInfo(i)
+
+		if (t[name]) then
+			CollapseFactionHeader(i)
+		end
 	end

 end