diff ObjectiveTracker/Widgets.lua @ 33:64f2a9bbea79

- implementing structural revisions in bonus objectives - prevent instances of nil arithmetic - decide on where to keep style values - start widgets with dummy values for operability
author Nenue
date Fri, 15 Apr 2016 17:01:06 -0400
parents c33c17dd97e7
children 9856ebc63fa4
line wrap: on
line diff
--- a/ObjectiveTracker/Widgets.lua	Fri Apr 15 07:01:40 2016 -0400
+++ b/ObjectiveTracker/Widgets.lua	Fri Apr 15 17:01:06 2016 -0400
@@ -308,13 +308,17 @@
     wr[widgetType].lastn = wr[widgetType].lastn + 1
   end
 end
-
 --- WidgetTemplate 'OnShow'
+local wrapperWidth, textIndent
 T.InitializeWidget = setmetatable({}, {
   __call = function(t, frame)
     -- todo: config pull
+    if not wrapperWidth then
+      wrapperWidth = T.Conf.Wrapper.Width
+      textIndent = T.Conf.Wrapper.TextIndent
+    end
 
-    frame:SetWidth(T.Conf.Wrapper.Width - T.Conf.Style.Format.status.Indent * 2)
+    frame:SetWidth(wrapperWidth - textIndent * 2)
     frame:SetScript('OnEvent', T.UpdateWidget[frame.widgetType])
     frame:RegisterEvent('TRACKED_ACHIEVEMENT_UPDATE')
     frame:RegisterEvent('TRACKED_ACHIEVEMENT_LIST_CHANGED')
@@ -394,6 +398,8 @@
   self.height = progressHeight + c.TextSpacing
   self.width = c.Width - c.TextSpacing
   self.indent = progressIndent
+  self.value = 1
+  self.maxValue = 1
 
   self:SetHeight(progressHeight)
   self.bg:SetHeight(progressHeight)
@@ -406,7 +412,7 @@
 end
 
 T.UpdateWidget.ProgressBar = function (self)
-  local quantity, requiredQuantity = self.objective.value, self.objective.maxValue
+  local quantity, requiredQuantity = self.value, self.maxValue
   print('update vals:')
   for k,v in pairs(self.line) do
     print(k, v)