changeset 3:3397aae1f44d

- use the correct key value when searching for action buttons - handle pre-built frames from XML
author Nenue
date Thu, 31 Mar 2016 07:32:05 -0400
parents a2396b03ce63
children 18eee961038e
files Core.xml Init.lua ObjectiveFrame.lua ObjectiveInfo.lua ObjectiveTracker.lua ObjectiveTracker.xml ObjectiveUI.lua ObjectiveWidgets.xml
diffstat 8 files changed, 235 insertions(+), 35 deletions(-) [+]
line wrap: on
line diff
--- a/Core.xml	Thu Mar 31 01:38:47 2016 -0400
+++ b/Core.xml	Thu Mar 31 07:32:05 2016 -0400
@@ -393,7 +393,7 @@
   </Button>
 
 
-  <Frame name="Veneer" hidden="true" enableMouse="true" movable="true" parent="UIParent">
+  <Frame name="Veneer" hidden="true" enableMouse="true" movable="true" parent="UIParent" frameStrata="DIALOG">
     <Size x="400" y="400" />
     <Anchors>
       <Anchor point="CENTER" relativePoint="CENTER" x="0" y="0" />
--- a/Init.lua	Thu Mar 31 01:38:47 2016 -0400
+++ b/Init.lua	Thu Mar 31 07:32:05 2016 -0400
@@ -6,7 +6,7 @@
 local ADDON, A = ...
 Veneer = Veneer or CreateFrame('Frame', 'Veneer', UIParent)
 local B = Veneer
-local wipe, min, max, random, tinsert = table.wipe, math.min, math.max, math.random, table.insert
+local wipe, min, max, random, tinsert, tremove = table.wipe, math.min, math.max, math.random, table.insert, table.remove
 local pairs, ipairs, select, unpack, _G = pairs, ipairs, select, unpack, _G
 local type, tostring, format = type, tostring, string.format
 A.frame = B
@@ -15,6 +15,7 @@
 local initOnced
 local modules = {}
 local queuedModules = {}
+local checkForConfig = {}
 local moduleStack = {
 }
 
@@ -247,6 +248,16 @@
       --@end-non-debug@]===]
     end
   end
+
+
+  if #checkForConfig >= 1 then
+    local queuedFrame = tremove(checkForConfig)
+    while queuedFrame do
+      B.SetConfigLayers(queuedFrame)
+      B.InitXMLFrame(queuedFrame)
+      queuedFrame = tremove(checkForConfig)
+    end
+  end
   -- remove from existing
 end
 
@@ -296,6 +307,7 @@
     module = CreateFrame('Frame', 'Veneer' .. tostring(name) .. 'Handler', B, 'VeneerHandlerTemplate')
   end
   modules[name] = module
+  B[name] = module
   if select('#', ...) >= 1 then
     local numDeps = select('#', ...)
     print('  '..numDeps..' deps detected')
@@ -331,6 +343,7 @@
 end
 
 B.RemoveConfigLayers = function(frame)
+
   local print = B.fprint()
   print('|cFFFF0000RemoveConfigLayers', frame:GetName())
   for i, subframe in pairs(layers) do
@@ -368,4 +381,45 @@
   end
 
   print('['..func..'] updated', #layers, 'regions,', numAnchors, 'frames')
+end
+
+--- Generic handlers for keeping track of XML-defined frames
+B.OnLoad = function(self)
+  tinsert(checkForConfig, self)
+end
+
+B.InitXMLFrame = function(self)
+  print('|cFF00FF00hello from '..self:GetName())
+
+  self:RegisterForDrag('LeftButton')
+  if not B.Conf.FramePosition then
+    B.Conf.FramePosition = {}
+  end
+  if B.Conf.FramePosition[self:GetName()] then
+    print('restoring frame position', unpack(B.Conf.FramePosition[self:GetName()]))
+    self:ClearAllPoints()
+    local anchorTo, relativePoint, x, y = unpack(B.Conf.FramePosition[self:GetName()])
+    self:SetPoint(anchorTo, UIParent, relativePoint, x, y)
+  end
+end
+
+B.OnDragStart = function(self)
+  self.xA = self:GetLeft()
+  self.yA = self:GetBottom()
+  self.anchorTo, self.relativeTo, self.relativePoint, self.x, self.y = self:GetPoint(1)
+  print('acquire anchor', self:GetPoint(1))
+  print(self:GetName(), 'start moving ('..self.x..', '..self.y..')')
+  self:StartMoving()
+end
+
+B.OnDragStop = function(self)
+  print(self:GetName(), 'stop moving ('..self:GetLeft()..', '..self:GetBottom()..')')
+  local xB = self:GetLeft() - self.xA
+  local yB = self:GetBottom() - self.yA
+  print('storing anchor point', self.anchorTo, self.relativePoint, self.x + xB, self.y + yB)
+
+  self:StopMovingOrSizing()
+  B.Conf.FramePosition[self:GetName()] = {self.anchorTo, self.relativePoint, self.x + xB, self.y + yB}
+  B.InitXMLFrame(self)
+
 end
\ No newline at end of file
--- a/ObjectiveFrame.lua	Thu Mar 31 01:38:47 2016 -0400
+++ b/ObjectiveFrame.lua	Thu Mar 31 07:32:05 2016 -0400
@@ -54,7 +54,7 @@
   },
   ObjectiveHeaderStyle = {
     Normal = {
-      Gradient = {MinColor = {0,0,0,0.5}, MaxColor = {0,0,0,1}},
+      Gradient = {MinColor = {0,0,0,0.5}, MaxColor = {0,0,0,.25}},
       Font = {headerFont, headerSize, headerOutline}, Spacing = headerSpacing,
     }
   },
@@ -109,6 +109,13 @@
   }
 }
 
+local FontBank = {
+  ['Normal'] = VeneerCriteriaFontNormal,
+  ['Progress'] = VeneerCriteriaFontProgress,
+  ['Complete'] = VeneerCriteriaFontComplete,
+  ['Failed'] = VeneerCriteriaFontFailed,
+}
+
 local Scroller_OnShow = function()
   Wrapper.watchMoneyReasons = 0;
   mod.UpdateWrapper()
@@ -227,16 +234,17 @@
   if rest then
     XPBar.rested:ClearAllPoints()
     if xp == 0 then
-      XPBar.rested:SetPoint('LEFT', XPBar, 'LEFT', 0, 0)
+      XPBar.rested:SetPoint('TOPLEFT', XPBar, 'TOPLEFT', 0, 0)
     else
-      XPBar.rested:SetPoint('LEFT', XPBar.fg, 'RIGHT', 0, 0)
+      XPBar.rested:SetPoint('TOPLEFT', XPBar.fg, 'TOPRIGHT', 0, 0)
     end
 
     if (xp + rest) > xpmax then
-      XPBar.rested:SetPoint('RIGHT', XPBar, 'RIGHT', 0, 0)
+      XPBar.rested:SetPoint('BOTTOMRIGHT', XPBar, 'BOTTOMRIGHT', 0, 0)
     else
-      XPBar.rested:SetWidth((xp/xpmax) * XPBar:GetWidth())
+      XPBar.rested:SetWidth((rest/xpmax) * XPBar:GetWidth())
     end
+    XPBar.rested:SetPoint('BOTTOM', XPBar, 'BOTTOM')
     XPBar.rested:Show()
   else
     XPBar.rested:Hide()
@@ -367,19 +375,56 @@
   elseif info.numObjectives >= 1 then
     t.objectives:Show()
     print('  - objective lines:', info.numObjectives, 'can wrap:', t.objectives:CanWordWrap())
+
     local text = ''
+    if info.description then
+      print('  -- has description text:', select('#', info.description), info.description)
+      text = info.description
+    end
+
+    --- todo: implement objective displays
+     -- in an accumulator loop, call upon handler for the appropriate display frame, each defining:
+      -- * height of whatever display widget is involved in conveying the task
+      -- * number of non-wrapped text lines to account for line space; may be discarded depending on things
+      -- * boolean that determines listening for money events or not
+    t.attachmentHeight = 0
     for o, obj in ipairs(t.info.objectives) do
-      local line = obj.text
-      if obj.type == 'monster' then
-        line = '|cFFFFFF00' .. line .. '|r'
-      elseif obj.type == 'item' then
-        line = '|cFF44BBFF' .. line .. '|r'
-      elseif obj.type == 'object' then
-        line = '|cFFFFFFFF' .. line .. '|r'
+      --- achievement criteria
+      if obj.flags then
+
+        if bit.band(obj.flags, 0x00000001) > 0 then
+          obj.type = 'ProgressBar'
+          obj.widget = mod.SetWidget(obj, info)
+        elseif bit.band(obj.flags, 0x00000002) then
+          obj.type = 'Hidden'
+          obj.widget = nil
+        else
+          obj.type = 'Text'
+          obj.widget = nil
+          text = text .. ((text == '') and "" or "\n") .. obj.text
+        end
+
+        print(obj.type, obj.text, obj.quantityString)
+      --- none of the above (most quests)
+      else
+        local line = obj.text
+        if obj.type == 'monster' then
+          line = '|cFFFFFF00' .. line .. '|r'
+        elseif obj.type == 'item' then
+          line = '|cFF44BBFF' .. line .. '|r'
+        elseif obj.type == 'object' then
+          line = '|cFFFFFFFF' .. line .. '|r'
+        end
+        text = text .. ((text == '') and "" or "\n") .. line
       end
-      text = text .. ((text == '') and "" or "\n") .. line
+
+      if obj.widget then
+        t.attachmentHeight = t.attachmentHeight + obj.widget.height
+      end
+
     end
     t.objectives:SetText(text)
+    t.objectives:SetWordWrap(true)
 
 
     -- todo: set up a SecureActionButton template
@@ -402,12 +447,11 @@
     style = 'Super'
   end
 
+  --- metrics are calculated in SetStyle
   t:SetStyle(style)
+  t:Show()
 
-
-  local fullheight = t:GetHeight()
-  t:Show()
-  print('  |cFF00FFFF)|r -> ', t, t:GetHeight(), fullheight)
+  print('  |cFF00FFFF)|r -> ', t, t:GetHeight())
   return t
 end
 
@@ -558,8 +602,8 @@
   local previousItem
   for questID, itemButton in pairs(usedButtons) do
     local questIndex = mod.Quest.Info[questID].questLogIndex
-    print('|cFF00FFFF', questIndex, itemButton:GetName())
-    local block = mod.Quest.LogBlock[questIndex]
+    print('|cFF00FFFF', questID, itemButton:GetName())
+    local block = mod.Quest.LogBlock[questID]
     print(block:GetTop())
     if block then
       if IsQuestWatched(questIndex) then
--- a/ObjectiveInfo.lua	Thu Mar 31 01:38:47 2016 -0400
+++ b/ObjectiveInfo.lua	Thu Mar 31 07:32:05 2016 -0400
@@ -128,7 +128,6 @@
   local cheevID = Cheevs.trackedCheevs[index]
   local id, name, points, completed, month, day, year, description, flags, icon, rewardText, isGuildAch, wasEarnedByMe, earnedBy = GetAchievementInfo(cheevID)
 
-  print('|cFF00FF00', GetAchievementNumCriteria(cheevID))
   self.Info[cheevID] = {}
   local c = self.Info[cheevID]
   c.type = 'Cheevs'
@@ -154,6 +153,7 @@
       criteriaID = criteriaID,
     }
   end
+  print('Cheevs.|cFF0088FFGetInfo|r('..index..')', 'obj:', GetAchievementNumCriteria(cheevID), name, description)
 
   self.WatchInfo[index] = c
   return self.Info[cheevID]
--- a/ObjectiveTracker.lua	Thu Mar 31 01:38:47 2016 -0400
+++ b/ObjectiveTracker.lua	Thu Mar 31 07:32:05 2016 -0400
@@ -202,11 +202,6 @@
   if not isHandled then
     print('|cFFFF4400'..event..'|r', ...)
   end
-  --@debug@
-  if Devian and Devian.InWorkspace() then
-    frame_guide_init(Scroller)
-    frame_guide(Scroller, Scroller)
-  end
 end
 
 mod.SetEvents = function()
@@ -223,7 +218,7 @@
 
 function mod:OnInitialize()
   self.InitializeTrackers()
-
+  self.InitializeXPTracker()
   mod.SetEvents()
   ObjectiveTrackerFrame:UnregisterAllEvents()
   ObjectiveTrackerFrame:Hide()
--- a/ObjectiveTracker.xml	Thu Mar 31 01:38:47 2016 -0400
+++ b/ObjectiveTracker.xml	Thu Mar 31 07:32:05 2016 -0400
@@ -5,19 +5,35 @@
     <Color r="1" g="1" b="0" a="1" />
   </Texture>
 
+  <Font name="VeneerCriteriaFontNormal" virtual="true" font="Fonts\FRIZQT__.TTF" outline="NORMAL" height="16">
+    <Color r="1" g="1" b="1" a="1" />
+  </Font>
+  <Font name="VeneerCriteriaFontComplete" virtual="true" font="Fonts\FRIZQT__.TTF" outline="NORMAL" height="16">
+    <Color r="0" g="1" b="0" a=".75" />
+  </Font>
+  <Font name="VeneerCriteriaFontProgressed" virtual="true" font="Fonts\FRIZQT__.TTF" outline="NORMAL" height="16">
+    <Color r="1" g="1" b="0" a="1" />
+  </Font>
+
+  <Font name="VeneerCriteriaFontFailed" virtual="true" font="Fonts\FRIZQT__.TTF" outline="NORMAL" height="16">
+    <Color r="1" g=".4" b="0" a=".75" />
+  </Font>
+
   <Frame name="VeneerObjectiveWrapper" parent="UIParent" movable="true" enableMouse="true">
     <Scripts>
       <OnLoad>
         self.toggle = true
-        self:RegisterForDrag('LeftButton')
+        self.drag = true
+        Veneer.OnLoad(self)
       </OnLoad>
       <OnShow>
       </OnShow>
       <OnDragStart>
-        self:StartMoving()
+        Veneer.OnDragStart(self)
       </OnDragStart>
       <OnDragStop>
-        self:StopMovingOrSizing()
+        Veneer.OnDragStop(self)
+        Veneer.ObjectiveTracker.UpdateActionButtons()
       </OnDragStop>
       <!--@debug@-->
       <!--@end-debug@-->
@@ -28,7 +44,6 @@
     <Layers>
 
       <Layer level="ARTWORK">
-        <Texture parentKey="HeaderBounds" />
         <Texture parentKey="BackgroundLeft" parentArray="header" hidden="false" alpha="1" atlas="Objective-Header" useAtlasSize="false">
           <Size x="100" y="84" />
           <TexCoords up="0" down="1" left="0" right="0.3" />
@@ -40,7 +55,7 @@
           <Size x="70" y="84" />
           <TexCoords up="0" down="1" left="0.6" right="1" />
           <Anchors>
-            <Anchor point="TOPRIGHT"  x="24" y="12" />
+            <Anchor point="TOPRIGHT"  x="30" y="12" />
           </Anchors>
         </Texture>
         <Texture parentKey="BackgroundTile" parentArray="header" hidden="false" alpha="1" atlas="Objective-Header" useAtlasSize="false" tile="true">
@@ -51,6 +66,20 @@
             <Anchor point="TOPRIGHT" relativePoint="TOPLEFT" relativeKey="$parent.BackgroundRight" />
           </Anchors>
         </Texture>
+        <Texture parentKey="HeaderBounds" parentArray="config" alphaMode="ADD" hidden="true">
+          <Color r="0" g="0" b="1" a="0.5" />
+          <Anchors>
+            <Anchor point="TOPLEFT" relativeKey="$parent.BackgroundLeft" />
+            <Anchor point="BOTTOMRIGHT" relativeKey="$parent.BackgroundRight" />
+          </Anchors>
+        </Texture>
+        <Texture parentKey="FrameBounds" parentArray="config" alphaMode="ADD" hidden="true">
+          <Color r="1" g="0" b="1" a="0.25" />
+          <Anchors>
+            <Anchor point="TOPLEFT" />
+            <Anchor point="BOTTOMRIGHT"  />
+          </Anchors>
+        </Texture>
         <!--<Texture desatuated="true" parentKey="LineGlow" hidden="false" alpha="0" alphaMode="ADD" atlas="OBJFX_LineGlow" useAtlasSize="true">
           <Anchors>
             <Anchor point="LEFT" relativeKey="$parent.Background" x="-21" y="18"/>
@@ -79,7 +108,7 @@
     </Layers>
     <Frames>
 
-      <Frame name="$parentXP" parentKey="xpBar" hidden="true">
+      <Frame name="$parentXP" parentKey="XPBar" hidden="true">
         <Size x="250" y="24" />
         <Anchors>
           <Anchor point="TOPLEFT" />
@@ -268,6 +297,8 @@
   </Frame>
 
   <Include file="ObjectiveSecure.xml" />
+  <Include file="ObjectiveWidgets.xml" />
+
   <Script file="ObjectiveTracker.lua" />
   <Script file="ObjectiveInfo.lua" />
   <Script file="ObjectiveUI.lua" />
--- a/ObjectiveUI.lua	Thu Mar 31 01:38:47 2016 -0400
+++ b/ObjectiveUI.lua	Thu Mar 31 07:32:05 2016 -0400
@@ -9,7 +9,7 @@
 local Tracker, AutoQuest, Quest, Cheevs = mod.Tracker, mod.AutoQuest, mod.Quest, mod.Cheevs
 
 --------------------------------------------------------------------
---- Tracker-specific widget functions
+--- Tracker-specific widgets and their handlers
 --------------------------------------------------------------------
 
 Tracker.Select = function(self) end
@@ -71,6 +71,13 @@
 end
 
 Cheevs.Open = function(self)
+  if ( not AchievementFrame ) then
+    AchievementFrame_LoadUI();
+  end
+  if ( not AchievementFrame:IsShown() ) then
+    AchievementFrame_ToggleAchievementFrame();
+  end
+  AchievementFrame_SelectAchievement(self.info.cheevID);
 end
 
 ----------------------------------------------------------------------------------------
@@ -192,4 +199,36 @@
       SetItemButtonTextureVertexColor(itemButton, 1, 1, 1)
     end
   end
+end
+
+-----------------------------------------
+-- Progress slider for achievements, and area objecitves
+-- Stored by criteria ID to account for multiple bars in one cheev
+Tracker.SetProgress = function(criteria, info)
+end
+
+mod.WidgetRegistry = {}
+local wr = mod.WidgetRegistry
+mod.SetWidget = function(criteria, info)
+  local widget
+  if not wr[criteria.type] then
+    print('|cFFFF4400[[WidgetTemplate]]|r', criteria.type)
+    wr[criteria.type] = { free = {}, used = {}, }
+  end
+  if #wr[criteria.type].free == 0 then
+
+    local frameID = #wr[criteria.type].free + #wr[criteria.type].used
+    widget = CreateFrame('Frame', 'VeneerCriteria' .. criteria.type .. frameID, VeneerObjectiveWrapper, 'VeneerObjectiveCriteria' .. criteria.type)
+  end
+end
+mod.RegisterWidget = function(frame)
+  tinsert(wr[frame.widgetType].free, frame)
+end
+mod.InitializeWidget = function(frame)
+
+end
+mod.ReleaseWidget = function(frame)
+
+  if tContains(wr[frame.widgetType], frame) then
+  end
 end
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ObjectiveWidgets.xml	Thu Mar 31 07:32:05 2016 -0400
@@ -0,0 +1,37 @@
+<Ui>
+  <!-- houses objective widget templates -->
+
+  <Frame name="VeneerObjectiveCriteriaProgressBar" virtual="true">
+    <Size x="250" y="30" />
+    <Scripts>
+      <OnLoad>
+        self.widgetType = 'ProgressBar'
+        Veneer.ObjectiveTracker.RegisterWidget(self)
+      </OnLoad>
+      <OnShow>
+        Veneer.ObjectiveTracker.InitializeWidget(self)
+      </OnShow>
+      <OnHide>
+        Veneer.ObjectiveTracker.ReleaseWidget(self)
+      </OnHide>
+      <OnEvent>
+
+      </OnEvent>
+    </Scripts>
+    <Layers>
+      <Layer level="BACKGROUND">
+        <Texture SetAllPoints="true" name="$parentBackground" parentKey="bg" setAllPoints="true">
+          <Color r="0" g="0" b="0" a="0.25" />
+        </Texture>
+      </Layer>
+      <Layer level="ARTWORK">
+
+      </Layer>
+      <Layer level="OVERLAY">
+        <FontString name="$parentQuantityString" parentKey="quantityString" inherits="VeneerCriteriaFont">
+
+        </FontString>
+      </Layer>
+    </Layers>
+  </Frame>
+</Ui>
\ No newline at end of file