changeset 71:6f8661094643

- obtains veneer objects through a common function and track them as a unified table.
author Nenue
date Tue, 23 Aug 2016 06:35:08 -0400
parents 1b0d7bcd252e
children d80db9a9b7e4
files Modules/BuffFrame.lua Modules/ObjectiveTracker.lua Modules/PaperDoll.lua Veneer.lua
diffstat 4 files changed, 208 insertions(+), 73 deletions(-) [+]
line wrap: on
line diff
--- a/Modules/BuffFrame.lua	Mon Aug 22 20:38:43 2016 -0400
+++ b/Modules/BuffFrame.lua	Tue Aug 23 06:35:08 2016 -0400
@@ -12,13 +12,15 @@
 --]]
 
 local BUFF_BUTTON_SIZE = 48
+local BUFF_BUTTON_SPACING_H = 4
+local BUFF_BUTTON_SPACING_V = 14
 local BUFF_PROGRESS_SIZE = 4
 local BUFF_PROGRESS_INSET = 1
 local BUFF_BUTTON_ZOOM = .15
-local BORDER_SIZE_L = 1
-local BORDER_SIZE_R = 1
+local BORDER_SIZE_L = 0
+local BORDER_SIZE_R = 0
 local BORDER_SIZE_U = 4
-local BORDER_SIZE_D = 1
+local BORDER_SIZE_D = 0
 
 
 local plugin = CreateFrame('Frame', 'VeneerBuffFrame', UIParent)
@@ -64,39 +66,14 @@
 local expirationCache = {}
 local visibility = {}
 
-local VeneerButton_OnHide = function(self)
-  self:SetScript('OnDragStart', self.StartMoving)
-  self:SetScript('OnDragStop', self.StopMovingOrSizing)
-  self:SetMovable(false)
-  self:EnableMouse(false)
-  self:RegisterForDrag('LeftButton')
-end
-local VeneerButton_OnShow = function(self)
-  self:SetScript('OnDragStart', self.StartMoving)
-  self:SetScript('OnDragStop', self.StopMovingOrSizing)
-  self:SetMovable(false)
-  self:EnableMouse(false)
-  self:RegisterForDrag('LeftButton')
-end
 
 
 local GetVeneer = function(frame)
   local name = frame:GetName()
   if not (_G[name..'Veneer']) then
     print('|cFF88FF00Creating', name,'Veneer')
-    local veneer = CreateFrame('Frame', name..'Veneer', UIParent)
+    local veneer = vn.GetVeneer(frame)
     local id = frame:GetID()
-    veneer:SetAllPoints(frame)
-    veneer:SetParent(frame)
-    veneer.bg = veneer:CreateTexture()
-    veneer.bg:SetColorTexture(1,1,1,0)
-    veneer.bg:SetAllPoints(veneer)
-    veneer.bg:Show()
-    veneer:Hide()
-    veneer:EnableMouse(false)
-
-    veneer:SetScript('OnShow', VeneerButton_OnShow)
-    veneer:SetScript('OnHide', VeneerButton_OnHide)
 
     local position = tonumber(name:match("%d"))
     if position == 1 then
@@ -105,8 +82,8 @@
 
     veneer.progress = CreateFrame('Frame', name .. 'VeneerProgress', veneer)
     veneer.progress:Hide()
-    veneer.progress:SetPoint('BOTTOMLEFT', veneer, 'BOTTOMLEFT', 3, -6)
-    veneer.progress:SetPoint('TOPRIGHT', veneer, 'BOTTOMRIGHT', -3, -1)
+    veneer.progress:SetPoint('BOTTOMLEFT', veneer, 'BOTTOMLEFT', 0, -6)
+    veneer.progress:SetPoint('TOPRIGHT', veneer, 'BOTTOMRIGHT', 0, -1)
     veneer.progress:SetHeight(BUFF_PROGRESS_SIZE + (BUFF_PROGRESS_INSET * 2))
 
     veneer.progress.bg = veneer.progress:CreateTexture(nil, 'BACKGROUND')
@@ -198,7 +175,7 @@
     hooksecurefunc(border, 'SetVertexColor', function(frame, r, g, b, a)
       frame:Hide()
       print('|cFF0088FFborder:SetVertexColor|r', r,g,b,a)
-      veneer.border:SetColorTexture(r,g,b,a)
+      veneer.progress.fg:SetColorTexture(r,g,b,a)
     end)
 
     local color = DebuffTypeColor["none"]
@@ -206,7 +183,7 @@
       color = DebuffTypeColor[aurasCache[frame][5]]
     end
 
-    veneer.border:SetColorTexture(color.r,color.g,color.b)
+    veneer.progress.fg:SetColorTexture(color.r,color.g,color.b)
   end
   if duration then
     duration:ClearAllPoints()
@@ -392,14 +369,15 @@
   for i = 1, BUFF_ACTUAL_DISPLAY do
     local buff = _G['BuffButton'..i]
     if buff then
-      if i == 1 then
-        buff:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', -120, -6)
-        topBuff = buff
-      elseif mod(i,12) == 1 then
-        buff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT', 0, -14)
+      if mod(i,12) == 1 then
+        if i == 1 then
+          buff:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', -120, -6)
+        else
+          buff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT', 0, -BUFF_BUTTON_SPACING_V)
+        end
         topBuff = buff
       else
-        buff:SetPoint('TOPRIGHT', lastBuff, 'TOPLEFT')
+        buff:SetPoint('TOPRIGHT', lastBuff, 'TOPLEFT', -BUFF_BUTTON_SPACING_H, 0)
       end
       lastBuff = buff
     end
@@ -410,16 +388,16 @@
     if debuff then
       if i == 1 then
         if topBuff then
-          debuff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT', 0, -14)
+          debuff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT',  0, -BUFF_BUTTON_SPACING_V)
         else
           debuff:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', -120, -6)
         end
         topBuff = debuff
       elseif mod(i, 12) == 1 then
-        debuff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT', 0, -14)
+        debuff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT',  0, -BUFF_BUTTON_SPACING_V)
         topBuff = debuff
       else
-        debuff:SetPoint('TOPRIGHT', lastBuff, 'TOPLEFT')
+        debuff:SetPoint('TOPRIGHT', lastBuff, 'TOPLEFT', -BUFF_BUTTON_SPACING_H, 0)
       end
       lastBuff = debuff
     end
--- a/Modules/ObjectiveTracker.lua	Mon Aug 22 20:38:43 2016 -0400
+++ b/Modules/ObjectiveTracker.lua	Tue Aug 23 06:35:08 2016 -0400
@@ -5,4 +5,50 @@
 -- Fixes objective tracker positioning in relation to buff frame alterations
 
 local plugin = CreateFrame('Frame', 'VeneerObjectives', UIParent)
-local vn, print = LibStub("LibKraken").register(VeneerController, plugin)
\ No newline at end of file
+local vn, print = LibStub("LibKraken").register(VeneerController, plugin)
+local ot
+local otvn
+
+local ResetObjectiveTrackerAnchor = function()
+
+  print('|cFFFF4400ObjectiveTracker_Initialize|r')
+  otvn = vn.GetVeneer(ot.BlocksFrame)
+  print(otvn:GetHeight())
+  vn:print(ot:GetHeight(), ot:GetWidth())
+
+
+  for i = 1, #ot.MODULES do
+    print(i, ot.MODULES[i])
+  end
+end
+
+local UpdateVeneer = function()
+  if not ot.initialized then
+    return
+  end
+
+  ot:ClearAllPoints()
+  ot:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', -5, -140)
+end
+
+local CreateVeneer = function()
+  ot = ObjectiveTrackerFrame
+  hooksecurefunc('ObjectiveTracker_Initialize', ResetObjectiveTrackerAnchor)
+  hooksecurefunc('ObjectiveTracker_Update', UpdateVeneer)
+end
+
+plugin.init = function()
+  if ObjectiveTrackerFrame then
+    print('tracker is already loaded')
+    CreateVeneer()
+  else
+    plugin:RegisterEvent('ADDON_LOADED')
+    plugin.ADDON_LOADED = function(self, addon)
+      if addon == 'Blizzard_ObjectiveTracker' then
+        print('responding to blizzard tracker loadin')
+        CreateVeneer()
+      end
+    end
+  end
+end
+
--- a/Modules/PaperDoll.lua	Mon Aug 22 20:38:43 2016 -0400
+++ b/Modules/PaperDoll.lua	Tue Aug 23 06:35:08 2016 -0400
@@ -54,27 +54,62 @@
 local pendingSlots = {}
 
 
-
+local jewel = {}
 local UpdateVeneer = function(itemslot, frame)
   local slot = itemslot:GetID()
   if itemslot.hasItem then
     frame.link = GetInventoryItemLink('player', slot)
-    --print(frame.link)
+
     local name, link, something, ilevel = GetItemInfo(frame.link)
     frame.label:SetText(ilevel)
     -- todo: test GetExtendedItemInfo()
 
-    GameTooltip:SetOwner(plugin)
-    GameTooltip:SetInventoryItem('player', slot)
-    GameTooltip:Hide()
+    local item = {strsplit(":", link)}
+    local _, itemId, enchantId, jewelId1, jewelId2, jewelId3, jewelId4, suffixId,
+    uniqueId, linkLevel, specializationID, instanceDifficultyId, numBonusIds, bonusId1, bonusId2, upgradeValue
 
-    for i = 1, 3 do
-      local gname = 'gem'..i
-      if frame[gname] then
-        frame.gemslot[i] = frame.gemslot[i] or frame:CreateTexture(nil, 'ARTWORK')
-        print(frame[gname])
+    specializationID, instanceDifficultyId, numBonusIds = item[11], item[12], item[13]
+    jewel[1], jewel[2], jewel[3], jewel[4] = item[4], item[5], item[6], item[7]
+    --vn:print(jewelId1, jewelId2, jewelId3, jewelId4)
+    for i = 1, 4 do
+      local gemslot = frame.gemslot[i]
+      if tonumber(jewel[i]) ~= nil then
+        if not gemslot then
+          gemslot = frame:CreateTexture(itemslot:GetName()..'Gem'..i, 'ARTWORK')
+          gemslot:SetSize(16,16)
+          local posx = 3 + (i-1)*16
+          if slot_anchors[slot]:match('RIGHT') then
+            posx = posx * -1
+          end
+          gemslot:SetPoint(slot_anchors[slot], frame.label, slot_relative[slot], posx, 0)
+          frame.gemslot[i] = gemslot
+        end
+        gemslot:SetTexture(GetItemIcon(jewel[i]))
+        gemslot:Show()
+      else
+        if gemslot then
+          gemslot:Hide()
+        end
+
       end
     end
+--[[
+    print(link)
+    local difftag = '?'
+    if tonumber(numBonusIds) ~= nil then
+      local name, groupType, isHeroic, isChallengeMode, displayHeroic, displayMythic, toggleDifficultyID = GetDifficultyInfo(numBonusIds)
+      difftag = (name or '??') .. (isHeroic and ' (Heroic)' or '')
+    end
+
+    print(instanceDifficultyId, '|cFF00FFFF',  difftag, numBonusIds)
+    --if tonumber(numBonusIds) ~= nil then
+      for i = 8, #item do
+        print(i..'-', item[i])
+      end
+    --end
+
+--]]
+
     frame:Show()
   else
     frame:Hide()
@@ -105,6 +140,7 @@
 
 end
 
+
 -- PaperDollFrame is separate from InspectUI handlers
 local PaperDollItemSlotButton_Update = function(self)
   local name = self:GetName()
@@ -132,7 +168,7 @@
       y = 4
     end
 
-
+    frame.gemslot = {}
     frame:SetPoint(anchor, self, relative, x, y)
     frame:SetSize(200,24)
     frame.label:ClearAllPoints()
@@ -175,21 +211,3 @@
 
 
 hooksecurefunc("PaperDollItemSlotButton_Update", PaperDollItemSlotButton_Update)
-
-hooksecurefunc(GameTooltip, "SetInventoryItem", function(self, unit, slot)
-  if self:GetOwner() == plugin then
-  if unit == 'player' and vnslot[slot] then
-
-    local text
-    for i = 1, 3 do
-      text = _G['GameTooltipTextLeft'..i]:GetText()
-      text = text:match('Item Level (%d+)')
-      if text then
-        break
-      end
-    end
-    vnslot[slot].label:SetText(text or '???')
-  end
-  end
-end)
-
--- a/Veneer.lua	Mon Aug 22 20:38:43 2016 -0400
+++ b/Veneer.lua	Tue Aug 23 06:35:08 2016 -0400
@@ -1,9 +1,5 @@
 -- Veneer
--- Customization tool for the small bits and pieces
-
--- BuffFrame
--- Provides mechanisms for positioning and alter buff button parameters.
--- Mostly re-configures the blizzard UI frames due to limitations of SecureTemplate.
+-- Base framework for making things draggable.
 
 local vn, print = LibStub("LibKraken").register(VeneerController)
 
@@ -18,11 +14,104 @@
     height = 48,
   }
 }
+local configMode
+local veneers = {}
+
+do
+  local anonID = 0
+  local AnonymousName = function()
+    anonID = anonID + 1
+    return 'VN' .. anonID
+  end
+end
+
+
+local VeneerButton_Update = function(self)
+  if configMode then
+    self:SetScript('OnDragStart', self.StartMoving)
+    self:SetScript('OnDragStop', self.StopMovingOrSizing)
+    self:SetMovable(false)
+    self:EnableMouse(false)
+    self:RegisterForDrag('LeftButton')
+
+    self.bg:SetColorTexture(0,1,0,0.5)
+  else
+
+    self:SetScript('OnDragStart', self.StartMoving)
+    self:SetScript('OnDragStop', self.StopMovingOrSizing)
+    self:SetMovable(false)
+    self:EnableMouse(false)
+
+    self.bg:SetColorTexture(0,1,0,0)
+  end
+end
+
+local ToggleVeneerConfig = function()
+  if configMode then
+    configMode = false
+    vn:print('Config mode off.')
+  else
+    configMode = true
+    vn:print('Config mode on.')
+  end
+
+  for frame, veneer in pairs(veneers) do
+    VeneerButton_Update(veneer)
+  end
+end
+
+local VeneerButton_OnShow = function(self)
+  VeneerButton_Update(self)
+end
+
+vn.GetVeneer = function(frame)
+  if not frame then
+    print('|cFFFF4400Unable to acquire frame...|r')
+    return
+  end
+
+
+  if veneers[frame] then
+    return veneers[frame]
+  end
+
+  local veneer = CreateFrame('Frame', (frame:GetName() or AnonymousName())..'Veneer', UIParent)
+
+  veneer:SetAllPoints(frame)
+  veneer:SetParent(frame)
+  veneer.bg = veneer:CreateTexture()
+  veneer.bg:SetColorTexture(1,1,1,0)
+  veneer.bg:SetAllPoints(veneer)
+  veneer.bg:Show()
+  veneer:Hide()
+  veneer:EnableMouse(false)
+
+  veneer:SetScript('OnShow', VeneerButton_OnShow)
+
+  -- find current X/Y
+  veneer.currentLeft = frame:GetLeft()
+  veneer.currentTop = frame:GetTop()
+
+  veneers[frame] = veneer
+  return veneers[frame]
+end
 
 vn.init = function()
   if (not VeneerData) or (not VeneerData.version) then
     VeneerData = defaults
   end
   vn.db = VeneerData
+end
 
+
+vn.wrap = function(module)
+  vn.modules = vn.modules or {}
+  tinsert(vn.modules, module)
+end
+
+SLASH_VENEER1 = "/veneer"
+SLASH_VENEER2 = "/vn"
+
+SlashCmdList.VENEER = function()
+  ToggleVeneerConfig()
 end
\ No newline at end of file