Quantcast

Copying weights works

Kevin Lyles [11-27-09 - 07:58]
Copying weights works
Filename
WeightsWatcher.xml
config.lua
diff --git a/WeightsWatcher.xml b/WeightsWatcher.xml
index a01044a..a8db2fd 100644
--- a/WeightsWatcher.xml
+++ b/WeightsWatcher.xml
@@ -263,6 +263,19 @@
 							<Anchor point="BOTTOMLEFT"/>
 						</Anchors>
 					</Button>
+					<!--Copy button-->
+					<Button name="$parentCopyButton" parentKey="copyButton" inherits="UIPanelButtonTemplate" text="Copy">
+						<Size>
+							<AbsDimension x="100" y="22"/>
+						</Size>
+						<Anchors>
+							<Anchor point="LEFT" relativePoint="RIGHT" relativeTo="$parentSaveButton">
+								<Offset>
+									<AbsDimension x="3"/>
+								</Offset>
+							</Anchor>
+						</Anchors>
+					</Button>
 					<!--Reset button-->
 					<Button name="$parentResetButton" parentKey="resetButton" inherits="UIPanelButtonTemplate" text="Reset">
 						<Size>
@@ -278,7 +291,11 @@
 							<AbsDimension x="100" y="22"/>
 						</Size>
 						<Anchors>
-							<Anchor point="BOTTOM"/>
+							<Anchor point="RIGHT" relativePoint="LEFT" relativeTo="$parentResetButton">
+								<Offset>
+									<AbsDimension x="-3"/>
+								</Offset>
+							</Anchor>
 						</Anchors>
 					</Button>
 					<!--used to hold a series of stat frames to maintain absolute position when scrolling-->
@@ -479,7 +496,14 @@
 						if ww_vars.weightsList[class][name] then
 							local error = StaticPopup_Show("WW_WEIGHT_EXISTS", classNames[class], name)
 						else
-							setWeight(class, name, {})
+							setWeight(class, name, self:GetParent().statList)
+							for _, classFrame in ipairs(ww_classFrameTable) do
+								if classFrame.class == class then
+									local children = {classFrame:GetChildren()}
+									configSelectWeight(children[classFrame:GetNumChildren()])
+									break
+								end
+							end
 							self:GetParent():Hide()
 						end
 					</OnClick>
diff --git a/config.lua b/config.lua
index 8e7aa4c..08e4ae2 100644
--- a/config.lua
+++ b/config.lua
@@ -120,6 +120,10 @@ function configSelectWeight(weightFrame)
 		function()
 			configSaveWeight(weightFrame)
 		end)
+	ww_config.rightPanel.copyButton:SetScript("OnClick",
+		function()
+			configNewWeight(weightFrame.category.class, "Copy of " .. weightFrame.name, ww_config.rightPanel.statList)
+		end)
 	ww_config.rightPanel.deleteButton:SetScript("OnClick",
 		function()
 			configDeleteWeight(weightFrame)
@@ -198,7 +202,9 @@ function deleteWeight(weight)
 	ww_config.leftPanel.scrollFrame:GetScript("OnShow")(ww_config.leftPanel.scrollFrame)
 end

-function configNewWeight(class, weight)
+function configNewWeight(class, weight, statList)
+	-- Need to call show first to re-initialize the dropdown
+	ww_newWeight:Show()
 	if class then
 		UIDropDownMenu_SetSelectedValue(ww_newWeight.dropdown, class, false)
 	end
@@ -206,7 +212,10 @@ function configNewWeight(class, weight)
 	if weight then
 		ww_newWeight.editBox:SetText(weight)
 	end
-	ww_newWeight:Show()
+	if not statList then
+		statList = {}
+	end
+	ww_newWeight.statList = statList
 end

 function setWeight(class, weight, statList)