Quantcast

Resetting individual weights works

Kevin Lyles [10-13-09 - 09:39]
Resetting individual weights works
Filename
WeightsWatcher.xml
config.lua
diff --git a/WeightsWatcher.xml b/WeightsWatcher.xml
index e977d27..27752f5 100644
--- a/WeightsWatcher.xml
+++ b/WeightsWatcher.xml
@@ -248,6 +248,15 @@
 							<Anchor point="BOTTOMLEFT"/>
 						</Anchors>
 					</Button>
+					<!--Reset button-->
+					<Button name="$parentResetButton" parentKey="resetButton" inherits="UIPanelButtonTemplate" text="Reset">
+						<Size>
+							<AbsDimension x="100" y="22"/>
+						</Size>
+						<Anchors>
+							<Anchor point="BOTTOMRIGHT"/>
+						</Anchors>
+					</Button>
 					<!--used to hold a series of stat frames to maintain absolute position when scrolling-->
 					<Frame name="$parentScrollContainer" parentKey="scrollContainer">
 						<Anchors>
diff --git a/config.lua b/config.lua
index 0b29fe8..5211306 100644
--- a/config.lua
+++ b/config.lua
@@ -54,6 +54,24 @@ end
 function configSelectWeight(weightFrame)
 	ww_config.rightPanel.statList = ww_vars.weightsList[weightFrame.category.class][weightFrame.name]

+	-- Fills the right panel with the current weight's stats
+	configResetWeight(weightFrame)
+
+	ww_config.rightPanel.header:SetText(weightFrame.name)
+	ww_config.rightPanel.saveButton:SetScript("OnClick",
+		function()
+			configSaveWeight(weightFrame)
+		end)
+	ww_config.rightPanel.resetButton:SetScript("OnClick",
+		function()
+			configResetWeight(weightFrame)
+		end)
+	ww_config.rightPanel:Show()
+end
+
+function configResetWeight(weight)
+	local value
+
 	for _, frame in pairs(ww_statFrameTable) do
 		if frame.statName then
 			value = ww_config.rightPanel.statList[frame.statName]
@@ -63,13 +81,6 @@ function configSelectWeight(weightFrame)
 			frame.statValue:SetText(value)
 		end
 	end
-
-	ww_config.rightPanel.header:SetText(weightFrame.name)
-	ww_config.rightPanel.saveButton:SetScript("OnClick",
-		function()
-			configSaveWeight(weightFrame)
-		end)
-	ww_config.rightPanel:Show()
 end

 function configSaveWeight(weight)