comparison KBF.lua @ 2:cf6e612a1c7e

finish mergeing the bars with the secure buttons. Almost done! Just minor housekeeping to take care of at this point
author Chris Mellon <arkanes@gmai.com>
date Tue, 12 Oct 2010 16:52:47 -0500
parents 3d4128c79074
children bb1143608eb4
comparison
equal deleted inserted replaced
1:3d4128c79074 2:cf6e612a1c7e
9 self.options = { 9 self.options = {
10 barWidth = 200 + 16 + 8, 10 barWidth = 200 + 16 + 8,
11 barHeight = 16 + 8 11 barHeight = 16 + 8
12 } 12 }
13 self.anchor = self:CreateAnchorFrame() 13 self.anchor = self:CreateAnchorFrame()
14 self.buffFrames = {} 14 self.buffBars = {}
15 self.anchor:Show() 15 self.anchor:Show()
16 self:RegisterEvent("UNIT_AURA") 16 self:RegisterEvent("UNIT_AURA")
17 self.unit = "player" -- TODO: Vehicle support
18 end 17 end
19 -- naming convention 18 -- naming convention
20 -- "frame" is the secure aura button created by the group handler 19 -- "frame" is the secure aura button created by the group handler
21 -- "bar" is the set of icon + status bars that we create to show the buff time 20 -- "bar" is the set of icon + status bars that we create to show the buff time
22 21
23 function kbf:UNIT_AURA(event, unit) 22 function kbf:UNIT_AURA(event, unit)
24 if unit ~= self.unit then return end 23 if unit ~= self.secureFrame:GetAttribute("unit") then return end
25 for idx=1,9 do 24 for idx=1,99 do
26 local frame = self.secureFrame:GetAttribute("child"..idx) 25 local frame = self.secureFrame:GetAttribute("child"..idx)
27 if not frame then break end 26 if not frame then break end
28 local name, rank, icon, count, debuffType, duration, expirationTime, 27 self:BindBarToBuff(idx, frame, unit, "HELPFUL")
29 unitCaster, isStealable, shouldConsolidate, spellId = UnitAura(self.unit, idx, "HELPFUL")
30 frame:SetNormalTexture(icon)
31 self:BindFrameToBuff
32 end 28 end
33 end 29 end
34 30
35 function kbf:BindBarToBuff(idx, parentFrame) 31 function kbf:BindBarToBuff(idx, parentFrame, unit, filter)
36 local name, rank, icon, count, debuffType, duration, expirationTime, 32 local name, rank, icon, count, debuffType, duration, expirationTime,
37 unitCaster, isStealable, shouldConsolidate, spellId = UnitAura(self.unit, idx, "HELPFUL") 33 unitCaster, isStealable, shouldConsolidate, spellId = UnitAura(unit, idx, "HELPFUL")
38 if not name then 34 -- This shouldn't be neccesary as the bar is parented to the frame, which is
39 if self.buffFrames[idx] then 35 -- hidden by the group handler
40 self.buffFrames[idx]:Hide() 36 if not parentFrame.icon then
41 end 37 self:ConstructBar(parentFrame)
42 return nil
43 end 38 end
44 local frame = self.buffFrames[idx] or self:ConstructBuffFrame(idx) 39 parentFrame.icon:SetNormalTexture(icon)
45 frame.icon:SetNormalTexture(icon)
46 if stacks and stacks > 0 then 40 if stacks and stacks > 0 then
47 frame.text:SetText(string.format("%s(%d)", name, stacks)) 41 parentFrame.text:SetText(string.format("%s(%d)", name, stacks))
48 else 42 else
49 frame.text:SetText(name) 43 parentFrame.text:SetText(name)
50 end 44 end
51 frame:Show()
52 return frame
53 end 45 end
54
55 function kbf:ConstructBuffFrame(idx)
56 local frame = self:ConstructFrame()
57 frame:RegisterForClicks("RightButtonUp")
58 frame:SetAttribute("type*", "cancelaura" )
59 frame:SetAttribute("unit", "player")
60 frame:SetAttribute("index", idx)
61 -- position
62 local parent = self.buffFrames[idx-1] or self.anchor
63 frame:SetPoint("TOP", parent, "BOTTOM", 0, 0)
64 self.buffFrames[idx] = frame
65 return frame
66 end
67
68 46
69 -- creates a icon + statusbar bar 47 -- creates a icon + statusbar bar
70 function kbf:ConstructBar(frame) 48 function kbf:ConstructBar(frame)
71 local texture = "Interface\\TargetingFrame\\UI-StatusBar" 49 local texture = "Interface\\TargetingFrame\\UI-StatusBar"
72 -- Because of secureframe suckiness, these height & width numbers 50 -- Because of secureframe suckiness, these height & width numbers
92 bar.icon:ClearAllPoints() 70 bar.icon:ClearAllPoints()
93 bar.icon:SetPoint("LEFT", bar, "LEFT", 0, 0) 71 bar.icon:SetPoint("LEFT", bar, "LEFT", 0, 0)
94 -- icons are square 72 -- icons are square
95 bar.icon:SetWidth(height) 73 bar.icon:SetWidth(height)
96 bar.icon:SetHeight(height) 74 bar.icon:SetHeight(height)
97 bar.icon:EnableMouse(false) 75 --bar.icon:EnableMouse(false)
98 -- the status bar background & foreground 76 -- the status bar background & foreground
99 local function setupStatusBar(sb, color) 77 local function setupStatusBar(sb, color)
100 sb:ClearAllPoints() 78 sb:ClearAllPoints()
101 sb:SetHeight(height) 79 sb:SetHeight(height)
102 sb:SetWidth(width) 80 sb:SetWidth(width)
170 frame:SetAttribute("point", "CENTER") 148 frame:SetAttribute("point", "CENTER")
171 frame:SetAttribute("wrapAfter", 100) -- required due to bugs in secure header 149 frame:SetAttribute("wrapAfter", 100) -- required due to bugs in secure header
172 frame:SetAttribute("consolidateTo", nil) 150 frame:SetAttribute("consolidateTo", nil)
173 --frame:SetAttribute("wrapXOffset", 0) 151 --frame:SetAttribute("wrapXOffset", 0)
174 --frame:SetAttribute("wrapYOffset", -34) 152 --frame:SetAttribute("wrapYOffset", -34)
175 frame:SetAttribute("xOffset", 32) 153 frame:SetAttribute("xOffset", 0)
176 frame:SetAttribute("yOffset", 0) 154 frame:SetAttribute("yOffset", 16)
177 frame:SetAttribute("minWidth", 32) 155 frame:SetAttribute("minWidth", 32)
178 frame:SetAttribute("minHeight", 32) 156 frame:SetAttribute("minHeight", 32)
179 frame:SetAttribute("unit", "player") 157 frame:SetAttribute("unit", "player") -- TODO: figure out the vehicle swapping stuff
180 frame:SetPoint("BOTTOM", anchor, "TOP", 0, 0) 158 frame:SetPoint("BOTTOM", anchor, "TOP", 0, 0)
181 frame:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", 159 frame:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background",
182 edgeFile = "Interface/Tooltips/UI-Tooltip-Border", 160 edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
183 tile = true, tileSize = 16, edgeSize = 16, 161 tile = true, tileSize = 16, edgeSize = 16,
184 insets = { left = 4, right = 4, top = 4, bottom = 4 }, 162 insets = { left = 4, right = 4, top = 4, bottom = 4 },