diff --git a/WeightsWatcher.xml b/WeightsWatcher.xml
index defe0f3..37b6cc8 100644
--- a/WeightsWatcher.xml
+++ b/WeightsWatcher.xml
@@ -18,6 +18,25 @@
</OnLoad>
</Scripts>
</Button>
+ <!--virtual frame used to allow for script generated frames with stat information-->
+ <Frame name="ww_statFrame" virtual="true">
+ <Size>
+ <AbsDimension x="400" y="20"/>
+ </Size>
+ <Layers>
+ <Layer level="OVERLAY">
+ <FontString name="$parentText" parentKey="text" inherits="GameFontNormal">
+ <Anchors>
+ <Anchor point="LEFT">
+ <Offset>
+ <AbsDimension x="20"/>
+ </Offset>
+ </Anchor>
+ </Anchors>
+ </FontString>
+ </Layer>
+ </Layers>
+ </Frame>
<!--weight edit frame-->
<Frame name="ww_editWeight" hidden="true" parent="UIParent" frameStrata="DIALOG">
<Size>
diff --git a/config.lua b/config.lua
index fd22561..a6fe2f0 100644
--- a/config.lua
+++ b/config.lua
@@ -3,7 +3,7 @@ if not WeightsWatcher then
end
ww_weightButtonTable = {}
-ww_statButtonTable = {}
+ww_statFrameTable = {}
function commandHandler(msg)
open_config()
@@ -30,29 +30,29 @@ function scrollBarUpdate()
--scroll bar position
local offset = FauxScrollFrame_GetOffset(ww_editWeight.scrollFrame)
--let the scroll bar position update
- FauxScrollFrame_Update(ww_editWeight.scrollFrame, #(ww_statButtonTable), numShown, 100)
+ FauxScrollFrame_Update(ww_editWeight.scrollFrame, #(ww_statFrameTable), numShown, 100)
offset = offset / 5
- if numShown > #(ww_statButtonTable) then
- numShown = #(ww_statButtonTable)
+ if numShown > #(ww_statFrameTable) then
+ numShown = #(ww_statFrameTable)
end
- if offset > #(ww_statButtonTable) - numShown then
- offset = #(ww_statButtonTable) - numShown
+ if offset > #(ww_statFrameTable) - numShown then
+ offset = #(ww_statFrameTable) - numShown
end
--change the position of the stats frame based on the offset
- ww_editWeight.scrollContainer:SetPoint("TOPLEFT", 0, -20 + 20 * offset)
+ ww_editWeight.scrollContainer:SetPoint("TOPLEFT", 0, 20 * offset)
- --hide the elements that appear before the first button shown
+ --hide the stats that appear before the first button shown
for i = 1, offset do
- ww_statButtonTable[i]:Hide()
+ ww_statFrameTable[i]:Hide()
end
--display those that fit in the window
for i = offset + 1, offset + numShown do
- ww_statButtonTable[i]:Show()
+ ww_statFrameTable[i]:Show()
end
- --hide the buttons after the window
- for i = offset + numShown + 1, #(ww_statButtonTable) do
- ww_statButtonTable[i]:Hide()
+ --hide the stats after the window
+ for i = offset + numShown + 1, #(ww_statFrameTable) do
+ ww_statFrameTable[i]:Hide()
end
end
@@ -108,29 +108,19 @@ end
--creates a list of fontStrings to display the stats
function createStatFontStrings()
- local xOffset, i, newCat = 5, 1
+ local i = 1
for category, stats in pairs(trackedStats) do
--for each category print the header and then the print the list of stats
- local newButton = CreateFrame("Button", category, ww_editWeight.scrollContainer, "ww_genericButton")
- if i == 1 then
- newButton:SetPoint("TOPLEFT", ww_editWeight.scrollContainer, "TOPLEFT", xOffset, 0)
- else
- newButton:SetPoint("TOPLEFT", ww_statButtonTable[i - 1], "BOTTOMLEFT", -2 * xOffset, 0)
- end
- newButton:SetText(category)
- table.insert(ww_statButtonTable, newButton)
+ local newFrame = CreateFrame("Frame", category, ww_editWeight.scrollContainer, "ww_statFrame")
+ newFrame.text:SetText(category)
+ newFrame:SetPoint("TOPLEFT", ww_editWeight.scrollContainer, "TOPLEFT", -15, -20 * i)
+ table.insert(ww_statFrameTable, newFrame)
i = i + 1
- newCat = true
for _ , stat in pairs(stats) do
- newButton = CreateFrame("Button", stat, ww_editWeight.scrollContainer, "ww_genericButton")
- if newCat then
- newButton:SetPoint("TOPLEFT", ww_statButtonTable[i - 1], "BOTTOMLEFT", 2 * xOffset, 0)
- newCat = false
- else
- newButton:SetPoint("TOPLEFT", ww_statButtonTable[i - 1], "BOTTOMLEFT", 0, 0)
- end
- newButton:SetText(stat)
- table.insert(ww_statButtonTable, newButton)
+ newFrame = CreateFrame("Frame", stat, ww_editWeight.scrollContainer, "ww_statFrame")
+ newFrame.text:SetText(stat)
+ newFrame:SetPoint("TOPLEFT", ww_editWeight.scrollContainer, "TOPLEFT", 0, -20 * i)
+ table.insert(ww_statFrameTable, newFrame)
i = i + 1
end
end