diff KBF.lua @ 1:3d4128c79074

begin work on merging the timer bars into the actual secure buttons
author Chris Mellon <arkanes@gmai.com>
date Tue, 12 Oct 2010 16:36:58 -0500
parents 1516559044e3
children cf6e612a1c7e
line wrap: on
line diff
--- a/KBF.lua	Tue Oct 12 06:00:39 2010 -0500
+++ b/KBF.lua	Tue Oct 12 16:36:58 2010 -0500
@@ -12,33 +12,27 @@
     }
     self.anchor = self:CreateAnchorFrame()
     self.buffFrames = {}
--- for idx=1,40 do
---     self:ConstructBuffFrame(idx)
--- end
     self.anchor:Show()
     self:RegisterEvent("UNIT_AURA")
     self.unit = "player" -- TODO: Vehicle support
 end
+-- naming convention
+-- "frame" is the secure aura button created by the group handler
+-- "bar" is the set of icon + status bars that we create to show the buff time
 
 function kbf:UNIT_AURA(event, unit)
     if unit ~= self.unit then return end 
     for idx=1,9 do
-        local frame = self:BindFrameToBuff(idx)
-        if not frame then break end
-    end
-    
-    for idx=1,9 do
-        self:Print("SecureScanning", idx)
         local frame = self.secureFrame:GetAttribute("child"..idx)
         if not frame then break end
-        self:Print(frame:GetObjectType())
         local name, rank, icon, count, debuffType, duration, expirationTime, 
             unitCaster, isStealable, shouldConsolidate, spellId = UnitAura(self.unit, idx, "HELPFUL")
         frame:SetNormalTexture(icon)
+        self:BindFrameToBuff
     end
 end
 
-function kbf:BindFrameToBuff(idx)
+function kbf:BindBarToBuff(idx, parentFrame)
     local name, rank, icon, count, debuffType, duration, expirationTime, 
         unitCaster, isStealable, shouldConsolidate, spellId = UnitAura(self.unit, idx, "HELPFUL")
     if not name then
@@ -71,27 +65,28 @@
     return frame
 end
 
-function kbf:ConstructFrame()
+
+-- creates a icon + statusbar bar
+function kbf:ConstructBar(frame)
     local texture = "Interface\\TargetingFrame\\UI-StatusBar"
+    -- Because of secureframe suckiness, these height & width numbers
+    -- have to be consistent with the stuff in KBF.xml
     local height = 16
+    local width = 200 -- this is the width *without* the icon
     local font, _ style = GameFontHighlight:GetFont()
-    local width = 200 -- this is the width *without* the icon
     local bgcolor = {1, 0, 0, 0.5}
     local color = {0, 1, 0, 1}
     local fontsize = 11
     local timertextwidth = fontsize * 3.6
     local textcolor = {1, 1, 1, 1}
     local timertextcolor = {1, 1, 1, 1}
-    local bar = CreateFrame("Button", nil, UIParent, "SecureActionButtonTemplate") -- the "top level" frame that represents the bar as a whole
+    --local bar = CreateFrame("Button", nil, UIParent) -- the "top level" frame that represents the bar as a whole
+    local bar = frame
     bar.icon = CreateFrame("Button", nil, bar) -- the icon
     bar.statusbarbg = CreateFrame("StatusBar", nil, bar) -- the bars background
     bar.statusbar = CreateFrame("StatusBar", nil, bar) -- and the bars foreground
-    --bar.spark = bar.statusbar:CreateTexture(nil, "OVERLAY") -- the spark
     bar.text = bar.statusbar:CreateFontString(nil, "OVERLAY") -- the label text
     bar.timertext = bar.statusbar:CreateFontString(nil, "OVERLAY") -- and the timer text
-    -- the bar as a whole
-    bar:SetHeight(height)
-    bar:SetWidth(height + width)
 
     -- the icon
     bar.icon:ClearAllPoints()
@@ -136,14 +131,7 @@
     bar.text:SetJustifyH("LEFT")
     bar.text:SetText("text")
     bar.text:SetTextColor(textcolor[1], textcolor[2], textcolor[3], textcolor[4])
-    -- the status bar foreground
-    -- the spark
-    --bar.spark:SetTexture("Interface\\CastingBar\\UI-CastingBar-Spark")
-    --bar.spark:SetWidth(16)
-    --bar.spark:SetHeight(height + 25)
-    --bar.spark:SetBlendMode("ADD")
 
-    --bar:SetAlpha(0.7)
     bar:EnableMouse(true)
     return bar
 end