Editing and saving weights works
Kevin Lyles [10-13-09 - 09:39]
Editing and saving weights works
diff --git a/WeightsWatcher.xml b/WeightsWatcher.xml
index 663b8a5..e977d27 100644
--- a/WeightsWatcher.xml
+++ b/WeightsWatcher.xml
@@ -62,6 +62,37 @@
</FontString>
</Layer>
</Layers>
+ <Frames>
+ <EditBox letters="16" name="$parentStatValue" parentKey="statValue">
+ <Size>
+ <AbsDimension x="130" y="20"/>
+ </Size>
+ <Anchors>
+ <Anchor point="RIGHT"/>
+ </Anchors>
+ <Backdrop edgeFile="Interface\Tooltips\UI-Tooltip-Border" tile="true">
+ <EdgeSize>
+ <AbsValue val="10"/>
+ </EdgeSize>
+ <TileSize>
+ <AbsValue val="10"/>
+ </TileSize>
+ <BackgroundInsets>
+ <AbsInset left="0" right="0" top="5" bottom="5"/>
+ </BackgroundInsets>
+ </Backdrop>
+ <FontString inherits="GameFontNormal">
+ <Anchors>
+ <Anchor point="LEFT"/>
+ </Anchors>
+ </FontString>
+ <Scripts>
+ <OnLoad>
+ self:SetTextInsets(5, 5, 0, 0)
+ </OnLoad>
+ </Scripts>
+ </EditBox>
+ </Frames>
</Frame>
<!--virtual frame used to allow for script generated frames with stat information-->
<Frame name="ww_elementFrame" virtual="true">
@@ -208,6 +239,15 @@
</BackgroundInsets>
</Backdrop>
<Frames>
+ <!--Save button-->
+ <Button name="$parentSaveButton" parentKey="saveButton" inherits="UIPanelButtonTemplate" text="Save">
+ <Size>
+ <AbsDimension x="100" y="22"/>
+ </Size>
+ <Anchors>
+ <Anchor point="BOTTOMLEFT"/>
+ </Anchors>
+ </Button>
<!--used to hold a series of stat frames to maintain absolute position when scrolling-->
<Frame name="$parentScrollContainer" parentKey="scrollContainer">
<Anchors>
@@ -227,7 +267,7 @@
</Anchors>
<Scripts>
<OnShow>
- scrollBarUpdate(self, ww_config.rightPanel.scrollContainer, ww_statFrameTable, 20, -30, 26)
+ scrollBarUpdate(self, ww_config.rightPanel.scrollContainer, ww_statFrameTable, 20, -30, 25)
</OnShow>
<OnVerticalScroll>
FauxScrollFrame_OnVerticalScroll(self, offset, 20, self:GetScript("OnShow"))
diff --git a/config.lua b/config.lua
index fbab2c0..0b29fe8 100644
--- a/config.lua
+++ b/config.lua
@@ -50,12 +50,42 @@ function scrollBarUpdate(scrollFrame, scrolledFrame, buttonTable, buttonHeight,
end
end
+--opens a new config pane to edit stat weights
function configSelectWeight(weightFrame)
ww_config.rightPanel.statList = ww_vars.weightsList[weightFrame.category.class][weightFrame.name]
+
+ for _, frame in pairs(ww_statFrameTable) do
+ if frame.statName then
+ value = ww_config.rightPanel.statList[frame.statName]
+ if not value then
+ value = ""
+ end
+ 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)
+ for _, frame in pairs(ww_statFrameTable) do
+ if frame.statName then
+ value = frame.statValue:GetText()
+ if value == "" then
+ value = nil
+ else
+ value = tonumber(value)
+ end
+ ww_vars.weightsList[weight.category.class][weight.name][frame.statName] = value
+ end
+ end
+end
+
--loads the various class buttons onto the config frame
function loadClassButtons()
local classes, revClassLookup = {}, {}