Mercurial > wow > kbf
comparison 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 |
comparison
equal
deleted
inserted
replaced
0:1516559044e3 | 1:3d4128c79074 |
---|---|
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.buffFrames = {} |
15 -- for idx=1,40 do | |
16 -- self:ConstructBuffFrame(idx) | |
17 -- end | |
18 self.anchor:Show() | 15 self.anchor:Show() |
19 self:RegisterEvent("UNIT_AURA") | 16 self:RegisterEvent("UNIT_AURA") |
20 self.unit = "player" -- TODO: Vehicle support | 17 self.unit = "player" -- TODO: Vehicle support |
21 end | 18 end |
19 -- naming convention | |
20 -- "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 | |
22 | 22 |
23 function kbf:UNIT_AURA(event, unit) | 23 function kbf:UNIT_AURA(event, unit) |
24 if unit ~= self.unit then return end | 24 if unit ~= self.unit then return end |
25 for idx=1,9 do | 25 for idx=1,9 do |
26 local frame = self:BindFrameToBuff(idx) | |
27 if not frame then break end | |
28 end | |
29 | |
30 for idx=1,9 do | |
31 self:Print("SecureScanning", idx) | |
32 local frame = self.secureFrame:GetAttribute("child"..idx) | 26 local frame = self.secureFrame:GetAttribute("child"..idx) |
33 if not frame then break end | 27 if not frame then break end |
34 self:Print(frame:GetObjectType()) | |
35 local name, rank, icon, count, debuffType, duration, expirationTime, | 28 local name, rank, icon, count, debuffType, duration, expirationTime, |
36 unitCaster, isStealable, shouldConsolidate, spellId = UnitAura(self.unit, idx, "HELPFUL") | 29 unitCaster, isStealable, shouldConsolidate, spellId = UnitAura(self.unit, idx, "HELPFUL") |
37 frame:SetNormalTexture(icon) | 30 frame:SetNormalTexture(icon) |
31 self:BindFrameToBuff | |
38 end | 32 end |
39 end | 33 end |
40 | 34 |
41 function kbf:BindFrameToBuff(idx) | 35 function kbf:BindBarToBuff(idx, parentFrame) |
42 local name, rank, icon, count, debuffType, duration, expirationTime, | 36 local name, rank, icon, count, debuffType, duration, expirationTime, |
43 unitCaster, isStealable, shouldConsolidate, spellId = UnitAura(self.unit, idx, "HELPFUL") | 37 unitCaster, isStealable, shouldConsolidate, spellId = UnitAura(self.unit, idx, "HELPFUL") |
44 if not name then | 38 if not name then |
45 if self.buffFrames[idx] then | 39 if self.buffFrames[idx] then |
46 self.buffFrames[idx]:Hide() | 40 self.buffFrames[idx]:Hide() |
69 frame:SetPoint("TOP", parent, "BOTTOM", 0, 0) | 63 frame:SetPoint("TOP", parent, "BOTTOM", 0, 0) |
70 self.buffFrames[idx] = frame | 64 self.buffFrames[idx] = frame |
71 return frame | 65 return frame |
72 end | 66 end |
73 | 67 |
74 function kbf:ConstructFrame() | 68 |
69 -- creates a icon + statusbar bar | |
70 function kbf:ConstructBar(frame) | |
75 local texture = "Interface\\TargetingFrame\\UI-StatusBar" | 71 local texture = "Interface\\TargetingFrame\\UI-StatusBar" |
72 -- Because of secureframe suckiness, these height & width numbers | |
73 -- have to be consistent with the stuff in KBF.xml | |
76 local height = 16 | 74 local height = 16 |
75 local width = 200 -- this is the width *without* the icon | |
77 local font, _ style = GameFontHighlight:GetFont() | 76 local font, _ style = GameFontHighlight:GetFont() |
78 local width = 200 -- this is the width *without* the icon | |
79 local bgcolor = {1, 0, 0, 0.5} | 77 local bgcolor = {1, 0, 0, 0.5} |
80 local color = {0, 1, 0, 1} | 78 local color = {0, 1, 0, 1} |
81 local fontsize = 11 | 79 local fontsize = 11 |
82 local timertextwidth = fontsize * 3.6 | 80 local timertextwidth = fontsize * 3.6 |
83 local textcolor = {1, 1, 1, 1} | 81 local textcolor = {1, 1, 1, 1} |
84 local timertextcolor = {1, 1, 1, 1} | 82 local timertextcolor = {1, 1, 1, 1} |
85 local bar = CreateFrame("Button", nil, UIParent, "SecureActionButtonTemplate") -- the "top level" frame that represents the bar as a whole | 83 --local bar = CreateFrame("Button", nil, UIParent) -- the "top level" frame that represents the bar as a whole |
84 local bar = frame | |
86 bar.icon = CreateFrame("Button", nil, bar) -- the icon | 85 bar.icon = CreateFrame("Button", nil, bar) -- the icon |
87 bar.statusbarbg = CreateFrame("StatusBar", nil, bar) -- the bars background | 86 bar.statusbarbg = CreateFrame("StatusBar", nil, bar) -- the bars background |
88 bar.statusbar = CreateFrame("StatusBar", nil, bar) -- and the bars foreground | 87 bar.statusbar = CreateFrame("StatusBar", nil, bar) -- and the bars foreground |
89 --bar.spark = bar.statusbar:CreateTexture(nil, "OVERLAY") -- the spark | |
90 bar.text = bar.statusbar:CreateFontString(nil, "OVERLAY") -- the label text | 88 bar.text = bar.statusbar:CreateFontString(nil, "OVERLAY") -- the label text |
91 bar.timertext = bar.statusbar:CreateFontString(nil, "OVERLAY") -- and the timer text | 89 bar.timertext = bar.statusbar:CreateFontString(nil, "OVERLAY") -- and the timer text |
92 -- the bar as a whole | |
93 bar:SetHeight(height) | |
94 bar:SetWidth(height + width) | |
95 | 90 |
96 -- the icon | 91 -- the icon |
97 bar.icon:ClearAllPoints() | 92 bar.icon:ClearAllPoints() |
98 bar.icon:SetPoint("LEFT", bar, "LEFT", 0, 0) | 93 bar.icon:SetPoint("LEFT", bar, "LEFT", 0, 0) |
99 -- icons are square | 94 -- icons are square |
134 bar.text:SetWidth((width - timertextwidth) *.9) | 129 bar.text:SetWidth((width - timertextwidth) *.9) |
135 bar.text:SetPoint("RIGHT", bar.statusbar, "RIGHT", 0, 0) | 130 bar.text:SetPoint("RIGHT", bar.statusbar, "RIGHT", 0, 0) |
136 bar.text:SetJustifyH("LEFT") | 131 bar.text:SetJustifyH("LEFT") |
137 bar.text:SetText("text") | 132 bar.text:SetText("text") |
138 bar.text:SetTextColor(textcolor[1], textcolor[2], textcolor[3], textcolor[4]) | 133 bar.text:SetTextColor(textcolor[1], textcolor[2], textcolor[3], textcolor[4]) |
139 -- the status bar foreground | |
140 -- the spark | |
141 --bar.spark:SetTexture("Interface\\CastingBar\\UI-CastingBar-Spark") | |
142 --bar.spark:SetWidth(16) | |
143 --bar.spark:SetHeight(height + 25) | |
144 --bar.spark:SetBlendMode("ADD") | |
145 | 134 |
146 --bar:SetAlpha(0.7) | |
147 bar:EnableMouse(true) | 135 bar:EnableMouse(true) |
148 return bar | 136 return bar |
149 end | 137 end |
150 | 138 |
151 function kbf:CreateAnchorFrame() | 139 function kbf:CreateAnchorFrame() |