diff Modules/BuffFrame.lua @ 75:d9d16e67725c

- refactor objectives plugin
author Nenue
date Sat, 27 Aug 2016 07:09:54 -0400
parents cd6e78091b04
children 08951972041a
line wrap: on
line diff
--- a/Modules/BuffFrame.lua	Tue Aug 23 19:50:10 2016 -0400
+++ b/Modules/BuffFrame.lua	Sat Aug 27 07:09:54 2016 -0400
@@ -11,6 +11,7 @@
   - BuffButtons can only be hidden/shown by blizzcode, so functions doing that have to be accounted for
 --]]
 
+local BUFFS_PER_ROW = 12
 local BUFF_BUTTON_SIZE = 48
 local BUFF_BUTTON_SPACING_H = 4
 local BUFF_BUTTON_SPACING_V = 14
@@ -21,10 +22,12 @@
 local BORDER_SIZE_R = 0
 local BORDER_SIZE_U = 4
 local BORDER_SIZE_D = 0
+local BUFF_FRAMES_X = -230
+local BUFF_FRAMES_Y = -4
 
 
 local plugin = CreateFrame('Frame', 'VeneerBuffFrame', UIParent)
-local vn, print = LibStub("LibKraken").register(VeneerController, plugin)
+local vn, print = LibStub("LibKraken").register(Veneer, plugin)
 local tprint = DEVIAN_WORKSPACE and function(...) _G.print('Timer', ...) end or function() end
 
 local _G, UIParent = _G, UIParent
@@ -33,44 +36,42 @@
 local UnitAura, GetTime, CreateFrame =  UnitAura, GetTime, CreateFrame
 local hooksecurefunc = hooksecurefunc
 
-local buttons = {}
-local buffTypes = {
+local aurasCache = {}
+local skinnedFrames = {}
+local pendingFrames = {}
+local veneers = {}
+local expirationCache = {}
+local visibility = {}
+local isHooked = {}
+
+plugin.options = {
+  nameString = 'Buff Frames',
   {
-    name = 'buff',
-    pattern = 'BuffButton(%d)',
-    filters = 'HELPFUL',
+    name = 'BuffButtonZoom',
+    type = 'slider',
+    min = 0,
+    max = 100,
+    fullwidth = true,
   },
   {
-    name = 'debuff',
-    pattern = 'DebuffButton(%d)',
-    filters = 'HARMFUL',
+    name = 'BuffBorderLeft',
+    type = 'slider',
+    min = 0,
+    max = 16,
   },
   {
-    name = 'tempenchant',
-    pattern = 'TempEnchant(%d)',
-    filters = 'TEMPENCHANT'
+    name = 'BuffBorderLeft',
+    type = 'slider',
+    min = 0,
+    max = 16,
   }
 }
 
-local textureMapping = {
-  [1] = 16,	--Main hand
-  [2] = 17,	--Off-hand
-  [3] = 18,	--Ranged
-}
-
-local tickCounter = {}
-local aurasCache = {}
-local skinnedFrames = {}
-local pendingFrames = {}
-local anchors = {}
-local expirationCache = {}
-local visibility = {}
-
-
 
 local GetVeneer = function(frame)
-  local name = frame:GetName()
-  if not (_G[name..'Veneer']) then
+
+  if not (veneers[frame]) then
+    local name = frame:GetName()
     print('|cFF88FF00Creating', name,'Veneer')
     local veneer = vn.GetVeneer(frame, 'VeneerBuffTemplate')
     local id = frame:GetID()
@@ -80,7 +81,10 @@
     veneer.progress:SetPoint('TOPRIGHT', veneer, 'BOTTOMRIGHT', 0, -1)
     veneer.progress:SetHeight(BUFF_PROGRESS_SIZE + (BUFF_PROGRESS_INSET * 2))
 
-    veneer.progress.fg:SetColorTexture(0,1,0,1)
+    veneer.progress.bg:SetColorTexture(0,0,0,1)
+
+    veneer.progress.fg:SetColorTexture(1,1,1,1)
+    veneer.progress.fg:ClearAllPoints()
     veneer.progress.fg:SetPoint('BOTTOMLEFT', BUFF_PROGRESS_INSET,BUFF_PROGRESS_INSET)
     veneer.progress.fg:SetPoint('TOP', 0, -BUFF_PROGRESS_INSET)
 
@@ -100,10 +104,11 @@
     veneer.border:Show()
 
 
+    veneers[frame] = veneer
   end
 
 
-  return _G[name..'Veneer']
+  return veneers[frame]
 end
 
 
@@ -141,7 +146,7 @@
     end
 
     veneer.progress.fg:SetColorTexture(color.r,color.g,color.b)
-    veneer.border:SetColorTexture(color.r,color.g,color.b)
+    veneer.border:SetColorTexture(0,0,0,1)
   end
   if duration then
     duration:ClearAllPoints()
@@ -205,12 +210,8 @@
     veneer.underlay:Show()
   end)
 
-  anchors[frame] = veneer
 end
 
-local Aura_SetBorderColor = function(self, r,g,b,a) end
-local Aura_OnShow = function(self) end
-local Aura_OnHide = function(self) end
 
 --- Set widgets to reflect the passed parameters
 local UpdateVeneer = function (frame, duration, expires)
@@ -294,7 +295,6 @@
   local bName = name..index
   local frame = _G[bName]
   if frame and frame:IsVisible() then
-    tickCounter[frame] = (tickCounter[frame] or 0) + 1
     local cacheDiff = CacheCheck(frame, UnitAura(frame.unit, frame:GetID(), frame.filter))
     -- if the name or expirationTime changed
     if (cacheDiff >= 1) then
@@ -338,9 +338,9 @@
     if buff then
       numBuffs = numBuffs + 1
       buff:ClearAllPoints()
-      if mod(numBuffs,12) == 1 then
+      if mod(numBuffs,BUFFS_PER_ROW) == 1 then
         if numBuffs == 1 then
-          buff:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', -120, -6)
+          buff:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', BUFF_FRAMES_X, BUFF_FRAMES_Y)
           plugin.currentTop = buff:GetTop()
         else
           buff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT', 0, -BUFF_BUTTON_SPACING_V)
@@ -365,7 +365,7 @@
           debuff:SetPoint('TOPRIGHT', UIParent, 'TOPRIGHT', -120, -6)
         end
         topBuff = debuff
-      elseif mod(numBuffs, 12) == 1 then
+      elseif mod(numBuffs, BUFFS_PER_ROW) == 1 then
         debuff:SetPoint('TOPRIGHT', topBuff, 'BOTTOMRIGHT',  0, -BUFF_BUTTON_SPACING_V)
         topBuff = debuff
       else
@@ -398,7 +398,7 @@
     if not veneer.duration.getHuge then
       veneer.duration.getHuge = true
       veneer.duration:SetFontObject(VeneerNumberFontLarge)
-      veneer.duration:SetTextColor(1,0,0,1)
+      veneer.duration:SetTextColor(1,1,0,1)
     end
   else
     if veneer.duration.getHuge then