Quantcast

Collapse empty categories when selecting a weight

Kevin Lyles [10-27-09 - 20:28]
Collapse empty categories when selecting a weight
Filename
config.lua
diff --git a/config.lua b/config.lua
index 41c82b1..925c8d7 100644
--- a/config.lua
+++ b/config.lua
@@ -104,12 +104,29 @@ end

 --opens a new config pane to edit stat weights
 function configSelectWeight(weightFrame)
+	local empty
+
 	ww_config.rightPanel.weightFrame = weightFrame
 	ww_config.rightPanel.statList = ww_vars.weightsList[weightFrame.category.class][weightFrame.name]

 	-- Fills the right panel with the current weight's stats
 	configResetWeight()

+	for _, categoryFrame in ipairs(ww_config.rightPanel.scrollFrame.categories) do
+		empty = true
+		for _, statFrame in ipairs({categoryFrame:GetChildren()}) do
+			if statFrame.statName then
+				if statFrame.statValue:GetText() ~= "" then
+					empty = false
+					break
+				end
+			end
+		end
+		if (categoryFrame.collapsed and not empty) or (not categoryFrame.collapsed and empty) then
+			categoryFrame.text:Click()
+		end
+	end
+
 	ww_config.rightPanel.header:SetText(weightFrame.name)
 	ww_config.rightPanel:Show()
 end