arkanes@0
|
1 local _, kbf = ...
|
arkanes@0
|
2
|
arkanes@0
|
3 KBF = kbf -- make global for debugging
|
arkanes@0
|
4
|
arkanes@0
|
5 local kbf = LibStub("AceAddon-3.0"):NewAddon(kbf, "KBF", "AceEvent-3.0", "AceConsole-3.0")
|
arkanes@0
|
6
|
arkanes@0
|
7
|
arkanes@0
|
8 function kbf:OnInitialize()
|
arkanes@10
|
9 self.debuffFrames = {}
|
arkanes@0
|
10 self.anchor = self:CreateAnchorFrame()
|
arkanes@0
|
11 self:RegisterEvent("UNIT_AURA")
|
arkanes@22
|
12 self:RegisterEvent("UNIT_ENTERING_VEHICLE")
|
arkanes@22
|
13 self:RegisterEvent("UNIT_EXITING_VEHICLE")
|
arkanes@4
|
14 -- set up the countdown timer
|
arkanes@4
|
15 -- TODO: Fancy enable/disable based on whether you have any timed buffs.
|
arkanes@4
|
16 -- Not a big deal, how often do you care about that
|
arkanes@8
|
17 -- also TODO: Maybe should bucket OnUpdates somehow
|
arkanes@18
|
18 -- AceTimer repeating events can only happen at 0.1 seconds, which is probably
|
arkanes@18
|
19 -- fast enough for updating, but makes the animation look jerky
|
arkanes@18
|
20 self.update = CreateFrame("FRAME")
|
arkanes@18
|
21 self.update:SetScript("OnUpdate", function() self:OnUpdate() end)
|
arkanes@7
|
22 self.dirty = true -- force an immediate scan on login
|
arkanes@14
|
23 self:HideBlizzardBuffFrames()
|
arkanes@18
|
24 self:RegisterChatCommand("kbf", "ToggleAnchor")
|
arkanes@0
|
25 end
|
arkanes@1
|
26 -- naming convention
|
arkanes@17
|
27 -- a "frame" is the top-level button (secure button from the header, or one I make myself)
|
arkanes@17
|
28 -- that will contain the UI information about the buff
|
arkanes@17
|
29 -- a "bar" is a frame that has the icon, status bar, ect associated with it
|
arkanes@0
|
30
|
arkanes@20
|
31 -- Secure aura header doesn't self-bind to vehicle,
|
arkanes@20
|
32 -- so this probably only works out of combat. But thats better than nothing...
|
arkanes@22
|
33 function kbf:UNIT_ENTERING_VEHICLE(event, unit)
|
arkanes@20
|
34 if unit ~= "player" then return end
|
arkanes@20
|
35 self.dirty = true
|
arkanes@20
|
36 -- hax until SAH supports vehicles - do the swap after we come out of combat
|
arkanes@20
|
37 if not InCombatLockdown() then
|
arkanes@20
|
38 self.secureFrame:SetAttribute("unit", "vehicle")
|
arkanes@20
|
39 else
|
arkanes@20
|
40 self.pollForUnitChange = true
|
arkanes@20
|
41 end
|
arkanes@20
|
42 end
|
arkanes@20
|
43
|
arkanes@22
|
44 function kbf:UNIT_EXITING_VEHICLE(event, unit)
|
arkanes@20
|
45 if unit ~= "player" then return end
|
arkanes@20
|
46 self.dirty = true
|
arkanes@20
|
47 -- hax until SAH supports vehicles - do the swap after we come out of combat
|
arkanes@20
|
48 if not InCombatLockdown() then
|
arkanes@20
|
49 self.secureFrame:SetAttribute("unit", "player")
|
arkanes@20
|
50 else
|
arkanes@20
|
51 self.pollForUnitChange = true
|
arkanes@20
|
52 end
|
arkanes@20
|
53 end
|
arkanes@20
|
54
|
arkanes@8
|
55 function kbf:HideBlizzardBuffFrames()
|
arkanes@8
|
56 local function HideBlizFrame(frame)
|
arkanes@8
|
57 if not frame then return end
|
arkanes@8
|
58 frame:UnregisterAllEvents()
|
arkanes@8
|
59 frame:SetScript("OnUpdate", nil)
|
arkanes@8
|
60 frame:Hide()
|
arkanes@8
|
61 frame.Show = function() end
|
arkanes@8
|
62 end
|
arkanes@8
|
63 HideBlizFrame(BuffFrame)
|
arkanes@8
|
64 HideBlizFrame(ConsolidatedBuffs)
|
arkanes@18
|
65 HideBlizFrame(TemporaryEnchantFrame)
|
arkanes@8
|
66
|
arkanes@8
|
67 end
|
arkanes@8
|
68
|
arkanes@4
|
69 function kbf:OnUpdate()
|
arkanes@20
|
70 if self.pollForUnitChange and not InCombatLockdown() then
|
arkanes@20
|
71 if UnitHasVehicleUI("player") then
|
arkanes@20
|
72 self.secureFrame:SetAttribute("unit", "vehicle")
|
arkanes@20
|
73 else
|
arkanes@20
|
74 self.secureFrame:SetAttribute("unit", "player")
|
arkanes@20
|
75 end
|
arkanes@20
|
76 self.pollForUnitChange = nil
|
arkanes@20
|
77 end
|
arkanes@10
|
78 local unit = self.secureFrame:GetAttribute("unit")
|
arkanes@10
|
79 local buffCount = 0
|
arkanes@4
|
80 for idx=1,99 do
|
arkanes@4
|
81 local frame = self.secureFrame:GetAttribute("child"..idx)
|
arkanes@10
|
82 if not (frame and frame:IsShown()) then break end
|
arkanes@10
|
83 buffCount = buffCount + 1
|
arkanes@6
|
84 if self.dirty then
|
arkanes@10
|
85 if self:BindBarToBuff(frame, unit) then break end
|
arkanes@9
|
86 end
|
arkanes@10
|
87 self:UpdateBarExpirationTime(frame)
|
arkanes@12
|
88 -- Don't forget to refresh shown tooltips
|
arkanes@12
|
89 if ( GameTooltip:IsOwned(frame) ) then
|
arkanes@15
|
90 self:OnEnter(frame)
|
arkanes@12
|
91 end
|
arkanes@10
|
92 end
|
arkanes@10
|
93 -- temporary enchants
|
arkanes@10
|
94 -- TODO: The blizz secure aura header binds both temp enchants
|
arkanes@10
|
95 -- to the main hand. No support for cancelling weapon enchants
|
arkanes@10
|
96 -- until this gets fixed up
|
arkanes@17
|
97 local tempEnchant = self.secureFrame:GetAttribute("tempEnchant1")
|
arkanes@17
|
98 if tempEnchant and tempEnchant:IsShown() then
|
arkanes@17
|
99 if self.dirty or true then
|
arkanes@17
|
100 self:BindBarToWeaponEnchant(tempEnchant, 16)
|
arkanes@17
|
101 end
|
arkanes@17
|
102 self:UpdateBarExpirationTime(tempEnchant)
|
arkanes@19
|
103 buffCount = buffCount + 1
|
arkanes@17
|
104 end
|
arkanes@17
|
105 tempEnchant = self.secureFrame:GetAttribute("tempEnchant2")
|
arkanes@17
|
106 if tempEnchant and tempEnchant:IsShown() then
|
arkanes@17
|
107 if self.dirty or true then
|
arkanes@17
|
108 self:BindBarToWeaponEnchant(tempEnchant, 17)
|
arkanes@17
|
109 end
|
arkanes@17
|
110 self:UpdateBarExpirationTime(tempEnchant)
|
arkanes@19
|
111 buffCount = buffCount + 1
|
arkanes@17
|
112 end
|
arkanes@24
|
113 -- there's also a third temp enchant for thrown weapons, which the
|
arkanes@24
|
114 -- current SAH doesn't support at all.
|
arkanes@24
|
115 -- Since I can't insert bars into the flow, can't support this
|
arkanes@24
|
116 -- until I either go to multiple secure headers & figure out how to position them
|
arkanes@24
|
117 -- or blizz fixes SAH
|
arkanes@10
|
118
|
arkanes@10
|
119 -- debuffs
|
arkanes@11
|
120 -- Since debuffs aren't cancellable, don't need to use the secure header
|
arkanes@11
|
121 -- for them. This could be rewritten to support useful features like
|
arkanes@11
|
122 -- sorting & scaling and stuff. Honestly, should at least be alphabetical.
|
arkanes@10
|
123 for idx=1,99 do
|
arkanes@10
|
124 local frame = self.debuffFrames[idx]
|
arkanes@10
|
125 if self.dirty then
|
arkanes@10
|
126 local name, rank, icon, stacks, debuffType, duration, expirationTime = UnitAura(unit, idx, "HARMFUL")
|
arkanes@10
|
127 if not name then
|
arkanes@10
|
128 -- out of debuffs, hide all the rest of them
|
arkanes@10
|
129 for jdx = idx, 99 do
|
arkanes@10
|
130 local bar = self.debuffFrames[jdx]
|
arkanes@10
|
131 if bar then bar:Hide() else break end
|
arkanes@10
|
132 end
|
arkanes@10
|
133 break
|
arkanes@10
|
134 end
|
arkanes@10
|
135 if not frame then
|
arkanes@10
|
136 frame = self:ConstructBar(nil, 1, 0, 0)
|
arkanes@10
|
137 self.debuffFrames[idx] = frame
|
arkanes@10
|
138 end
|
arkanes@10
|
139 self:SetBarAppearance(frame, name, icon, stacks, duration, expirationTime)
|
arkanes@10
|
140 frame:ClearAllPoints()
|
arkanes@10
|
141 -- position it under all the buffs, with a half-bar spacing
|
arkanes@19
|
142 frame:SetPoint("TOP", self.anchor, "BOTTOM", 0, (buffCount * -16))
|
arkanes@10
|
143 frame:Show()
|
arkanes@13
|
144 frame.filter = "HARMFUL"
|
arkanes@13
|
145 frame.unit = unit
|
arkanes@16
|
146 frame.index = idx
|
arkanes@13
|
147 frame:SetScript("OnEnter", function() kbf:OnEnter(frame) end)
|
arkanes@13
|
148 frame:SetScript("OnLeave", function() GameTooltip:Hide() end)
|
arkanes@23
|
149 frame:EnableMouse(true)
|
arkanes@10
|
150 buffCount = buffCount + 1
|
arkanes@10
|
151 else
|
arkanes@10
|
152 -- not dirty, so no frame means we're done
|
arkanes@10
|
153 if not frame then break end
|
arkanes@6
|
154 end
|
arkanes@10
|
155 self:UpdateBarExpirationTime(frame)
|
arkanes@13
|
156 if ( GameTooltip:IsOwned(frame) ) then
|
arkanes@15
|
157 self:OnEnter(frame)
|
arkanes@13
|
158 end
|
arkanes@4
|
159 end
|
arkanes@6
|
160 self.dirty = nil
|
arkanes@4
|
161 end
|
arkanes@4
|
162
|
arkanes@0
|
163 function kbf:UNIT_AURA(event, unit)
|
arkanes@2
|
164 if unit ~= self.secureFrame:GetAttribute("unit") then return end
|
arkanes@6
|
165 self.dirty = true
|
arkanes@0
|
166 end
|
arkanes@0
|
167
|
arkanes@10
|
168 function kbf:UpdateBarExpirationTime(frame)
|
arkanes@10
|
169 if frame.expirationTime then
|
arkanes@10
|
170 local remaining = frame.expirationTime - GetTime()
|
arkanes@10
|
171 remaining = math.max(0, remaining)
|
arkanes@10
|
172 local perc = remaining / frame.duration
|
arkanes@10
|
173 frame.timertext:SetText(self:FormatTimeText(remaining))
|
arkanes@10
|
174 frame.statusbar:SetValue(remaining)
|
arkanes@10
|
175 end
|
arkanes@10
|
176 end
|
arkanes@10
|
177
|
arkanes@17
|
178 function kbf:BindBarToWeaponEnchant(parentFrame, slotOverride)
|
arkanes@17
|
179 local index = parentFrame:GetAttribute("index")
|
arkanes@17
|
180 -- allow passing of explicit slot in order to work around aura header bug
|
arkanes@17
|
181 local slot = slotOverride or parentFrame:GetAttribute("target-slot")
|
arkanes@17
|
182 local itemIndex = slot - 15 -- 1MH, 2OF
|
arkanes@17
|
183 local RETURNS_PER_ITEM = 3
|
arkanes@17
|
184 local hasEnchant, remaining, enchantCharges = select(RETURNS_PER_ITEM * (itemIndex - 1) + 1, GetWeaponEnchantInfo())
|
arkanes@17
|
185 -- remaining time is in milliseconds
|
arkanes@17
|
186 if not hasEnchant then return end
|
arkanes@17
|
187 local remaining = remaining / 1000
|
arkanes@17
|
188 if not hasEnchant then return end -- this should never happen
|
arkanes@17
|
189 local icon = GetInventoryItemTexture("player", slot)
|
arkanes@17
|
190 -- this is terrible, but I hate myself and everyone else.
|
arkanes@17
|
191 -- We're going to assume that the duration of the temp enchant
|
arkanes@17
|
192 -- is either 60 minutes, or however long is left, because poisons are 1 hour
|
arkanes@17
|
193 local duration = max((60 * 60), remaining)
|
arkanes@17
|
194 local expirationTime = GetTime() + remaining
|
arkanes@17
|
195 -- TODO
|
arkanes@17
|
196 local name = GetItemInfo(GetInventoryItemID("player", slot))
|
arkanes@17
|
197 if not parentFrame.icon then
|
arkanes@17
|
198 self:ConstructBar(parentFrame, 1, 0, 1)
|
arkanes@17
|
199 end
|
arkanes@17
|
200 self:SetBarAppearance(parentFrame, name, icon, enchantCharges, duration, expirationTime)
|
arkanes@17
|
201 end
|
arkanes@17
|
202
|
arkanes@3
|
203 function kbf:BindBarToBuff(parentFrame, unit)
|
arkanes@3
|
204 local index = parentFrame:GetAttribute("index")
|
arkanes@3
|
205 local filter = parentFrame:GetAttribute("filter")
|
arkanes@10
|
206 local name, rank, icon, stacks, debuffType, duration, expirationTime,
|
arkanes@3
|
207 unitCaster, isStealable, shouldConsolidate, spellId = UnitAura(unit, index, filter)
|
arkanes@10
|
208 if not name then return end
|
arkanes@2
|
209 if not parentFrame.icon then
|
arkanes@2
|
210 self:ConstructBar(parentFrame)
|
arkanes@0
|
211 end
|
arkanes@10
|
212 self:SetBarAppearance(parentFrame, name, icon, stacks, duration, expirationTime)
|
arkanes@10
|
213 end
|
arkanes@10
|
214
|
arkanes@10
|
215 function kbf:SetBarAppearance(parentFrame, name, icon, stacks, duration, expirationTime)
|
arkanes@2
|
216 parentFrame.icon:SetNormalTexture(icon)
|
arkanes@0
|
217 if stacks and stacks > 0 then
|
arkanes@2
|
218 parentFrame.text:SetText(string.format("%s(%d)", name, stacks))
|
arkanes@0
|
219 else
|
arkanes@2
|
220 parentFrame.text:SetText(name)
|
arkanes@0
|
221 end
|
arkanes@4
|
222 parentFrame.timertext:SetText(self:FormatTimeText(duration))
|
arkanes@4
|
223 -- store duration information
|
arkanes@6
|
224 if duration and duration > 0 then
|
arkanes@4
|
225 parentFrame.expirationTime = expirationTime
|
arkanes@4
|
226 parentFrame.duration = duration
|
arkanes@4
|
227 parentFrame.statusbar:SetMinMaxValues(0, duration)
|
arkanes@4
|
228 else
|
arkanes@4
|
229 parentFrame.expirationTime = nil
|
arkanes@4
|
230 parentFrame.duration = 0
|
arkanes@4
|
231 parentFrame.statusbar:SetMinMaxValues(0,1)
|
arkanes@4
|
232 parentFrame.statusbar:SetValue(1)
|
arkanes@4
|
233 end
|
arkanes@4
|
234 end
|
arkanes@4
|
235
|
arkanes@17
|
236 -- expects time seconds
|
arkanes@4
|
237 function kbf:FormatTimeText(time)
|
arkanes@4
|
238 if not time or time == 0 then return "" end
|
arkanes@4
|
239 local timetext
|
arkanes@4
|
240 local h = floor(time/3600)
|
arkanes@4
|
241 local m = time - (h*3600)
|
arkanes@4
|
242 m = floor(m/60)
|
arkanes@4
|
243 local s = time - ((h*3600) + (m*60))
|
arkanes@4
|
244 if h > 0 then
|
arkanes@4
|
245 timetext = ("%d:%02d"):format(h, m)
|
arkanes@4
|
246 elseif m > 0 then
|
arkanes@4
|
247 timetext = string.format("%d:%02d", m, floor(s))
|
arkanes@4
|
248 elseif s < 10 then
|
arkanes@4
|
249 timetext = string.format("%1.1f", s)
|
arkanes@4
|
250 else
|
arkanes@4
|
251 timetext = string.format("%.0f", floor(s))
|
arkanes@4
|
252 end
|
arkanes@4
|
253 return timetext
|
arkanes@0
|
254 end
|
arkanes@0
|
255
|
arkanes@12
|
256 function KBF:OnEnter(button, motion)
|
arkanes@12
|
257 -- this is for the secure buttons, so use the attributes
|
arkanes@21
|
258 local unit = SecureButton_GetModifiedUnit(button) or button.unit-- will perform vehicle toggle
|
arkanes@21
|
259 local filter = button:GetAttribute("filter") or button.filter
|
arkanes@15
|
260 local index = button:GetAttribute("index") or button.index
|
arkanes@17
|
261 if unit and filter and index then
|
arkanes@21
|
262 -- I'd like a better place to position this but it's funky for right now, handle it later
|
arkanes@17
|
263 GameTooltip:SetOwner(button, "ANCHOR_BOTTOMLEFT");
|
arkanes@17
|
264 GameTooltip:SetFrameLevel(button:GetFrameLevel() + 2);
|
arkanes@17
|
265 GameTooltip:SetUnitAura(unit, index, filter);
|
arkanes@17
|
266 return
|
arkanes@17
|
267 end
|
arkanes@17
|
268 local slot = button:GetAttribute("target-slot") -- temp enchant
|
arkanes@12
|
269 GameTooltip:SetOwner(button, "ANCHOR_BOTTOMLEFT");
|
arkanes@13
|
270 GameTooltip:SetFrameLevel(button:GetFrameLevel() + 2);
|
arkanes@21
|
271 GameTooltip:SetInventoryItem(unit, slot)
|
arkanes@12
|
272 end
|
arkanes@12
|
273
|
arkanes@1
|
274 -- creates a icon + statusbar bar
|
arkanes@10
|
275 function kbf:ConstructBar(frame, r, g, b)
|
arkanes@0
|
276 local texture = "Interface\\TargetingFrame\\UI-StatusBar"
|
arkanes@1
|
277 -- Because of secureframe suckiness, these height & width numbers
|
arkanes@1
|
278 -- have to be consistent with the stuff in KBF.xml
|
arkanes@0
|
279 local height = 16
|
arkanes@1
|
280 local width = 200 -- this is the width *without* the icon
|
arkanes@22
|
281 local font, _, style = GameFontHighlight:GetFont()
|
arkanes@10
|
282 local r = r or 0
|
arkanes@10
|
283 local g = g or 1
|
arkanes@10
|
284 local b = b or 0
|
arkanes@10
|
285 local bgcolor = {r, g, b, 0.5}
|
arkanes@10
|
286 local color = {r, g, b, 1}
|
arkanes@0
|
287 local fontsize = 11
|
arkanes@0
|
288 local timertextwidth = fontsize * 3.6
|
arkanes@0
|
289 local textcolor = {1, 1, 1, 1}
|
arkanes@0
|
290 local timertextcolor = {1, 1, 1, 1}
|
arkanes@10
|
291 if not frame then
|
arkanes@10
|
292 frame = CreateFrame("Button", nil, UIParent) -- the "top level" frame that represents the bar as a whole
|
arkanes@10
|
293 frame:SetHeight(16)
|
arkanes@23
|
294 frame:SetWidth(200 + 16)
|
arkanes@10
|
295 end
|
arkanes@1
|
296 local bar = frame
|
arkanes@0
|
297 bar.icon = CreateFrame("Button", nil, bar) -- the icon
|
arkanes@0
|
298 bar.statusbarbg = CreateFrame("StatusBar", nil, bar) -- the bars background
|
arkanes@0
|
299 bar.statusbar = CreateFrame("StatusBar", nil, bar) -- and the bars foreground
|
arkanes@0
|
300 bar.text = bar.statusbar:CreateFontString(nil, "OVERLAY") -- the label text
|
arkanes@0
|
301 bar.timertext = bar.statusbar:CreateFontString(nil, "OVERLAY") -- and the timer text
|
arkanes@0
|
302
|
arkanes@0
|
303 -- the icon
|
arkanes@0
|
304 bar.icon:ClearAllPoints()
|
arkanes@0
|
305 bar.icon:SetPoint("LEFT", bar, "LEFT", 0, 0)
|
arkanes@0
|
306 -- icons are square
|
arkanes@0
|
307 bar.icon:SetWidth(height)
|
arkanes@0
|
308 bar.icon:SetHeight(height)
|
arkanes@2
|
309 --bar.icon:EnableMouse(false)
|
arkanes@0
|
310 -- the status bar background & foreground
|
arkanes@0
|
311 local function setupStatusBar(sb, color)
|
arkanes@0
|
312 sb:ClearAllPoints()
|
arkanes@0
|
313 sb:SetHeight(height)
|
arkanes@0
|
314 sb:SetWidth(width)
|
arkanes@0
|
315 -- offset the height of the frame on the x-axis for the icon.
|
arkanes@0
|
316 sb:SetPoint("TOPLEFT", bar, "TOPLEFT", height, 0)
|
arkanes@0
|
317 sb:SetStatusBarTexture(texture)
|
arkanes@0
|
318 sb:GetStatusBarTexture():SetVertTile(false)
|
arkanes@0
|
319 sb:GetStatusBarTexture():SetHorizTile(false)
|
arkanes@0
|
320 sb:SetStatusBarColor(unpack(color))
|
arkanes@0
|
321 sb:SetMinMaxValues(0,1)
|
arkanes@0
|
322 sb:SetValue(1)
|
arkanes@0
|
323 end
|
arkanes@0
|
324 setupStatusBar(bar.statusbarbg, bgcolor)
|
arkanes@0
|
325 setupStatusBar(bar.statusbar, color)
|
arkanes@0
|
326 bar.statusbarbg:SetFrameLevel(bar.statusbarbg:GetFrameLevel()-1) -- make sure the bg frame stays in the back
|
arkanes@0
|
327 -- timer text
|
arkanes@0
|
328 bar.timertext:SetFontObject(GameFontHighlight)
|
arkanes@0
|
329 bar.timertext:SetFont(GameFontHighlight:GetFont())
|
arkanes@0
|
330 bar.timertext:SetHeight(height)
|
arkanes@0
|
331 bar.timertext:SetWidth(timertextwidth)
|
arkanes@24
|
332 bar.timertext:SetPoint("LEFT", bar.statusbar, "LEFT", 2, 0)
|
arkanes@24
|
333 bar.timertext:SetJustifyH("LEFT")
|
arkanes@0
|
334 bar.timertext:SetText("time")
|
arkanes@0
|
335 bar.timertext:SetTextColor(timertextcolor[1], timertextcolor[2], timertextcolor[3], timertextcolor[4])
|
arkanes@0
|
336
|
arkanes@0
|
337 -- and the label text
|
arkanes@0
|
338 bar.text:SetFontObject(GameFontHighlight)
|
arkanes@0
|
339 bar.text:SetFont(GameFontHighlight:GetFont())
|
arkanes@0
|
340 bar.text:SetHeight(height)
|
arkanes@24
|
341 bar.text:SetPoint("LEFT", bar.timertext, "RIGHT", 0, 0)
|
arkanes@0
|
342 bar.text:SetPoint("RIGHT", bar.statusbar, "RIGHT", 0, 0)
|
arkanes@0
|
343 bar.text:SetJustifyH("LEFT")
|
arkanes@0
|
344 bar.text:SetText("text")
|
arkanes@0
|
345 bar.text:SetTextColor(textcolor[1], textcolor[2], textcolor[3], textcolor[4])
|
arkanes@0
|
346 return bar
|
arkanes@0
|
347 end
|
arkanes@0
|
348
|
arkanes@0
|
349 function kbf:CreateAnchorFrame()
|
arkanes@0
|
350 -- give it a name so it'll remember its position
|
arkanes@0
|
351 local anchor = CreateFrame("FRAME", "KBFAnchorFrame", UIParent)
|
arkanes@0
|
352 anchor:SetClampedToScreen(true)
|
arkanes@0
|
353 anchor:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background",
|
arkanes@0
|
354 edgeFile = "Interface/Tooltips/UI-Tooltip-Border",
|
arkanes@18
|
355 tile = true, tileSize = 16, edgeSize = 12,
|
arkanes@0
|
356 insets = { left = 4, right = 4, top = 4, bottom = 4 },
|
arkanes@0
|
357 })
|
arkanes@0
|
358 local text = anchor:CreateFontString(nil, "OVERLAY") -- the label text
|
arkanes@0
|
359 text:SetFontObject(GameFontHighlight)
|
arkanes@0
|
360 text:SetFont(GameFontHighlight:GetFont())
|
arkanes@0
|
361 text:SetPoint("TOPLEFT", anchor, "TOPLEFT", 0, 0)
|
arkanes@0
|
362 text:SetPoint("BOTTOMRIGHT", anchor, "BOTTOMRIGHT", 0, 0)
|
arkanes@0
|
363 text:SetText("KBF ANCHOR")
|
arkanes@18
|
364 anchor:SetWidth(200 +16)
|
arkanes@18
|
365 anchor:SetHeight(16)
|
arkanes@0
|
366 -- movability
|
arkanes@0
|
367 anchor:EnableMouse(true)
|
arkanes@0
|
368 anchor:SetMovable(true)
|
arkanes@0
|
369 anchor:RegisterForDrag("LeftButton")
|
arkanes@0
|
370 anchor:SetScript("OnDragStart", anchor.StartMoving)
|
arkanes@0
|
371 anchor:SetScript("OnDragStop", anchor.StopMovingOrSizing)
|
arkanes@0
|
372 anchor:ClearAllPoints()
|
arkanes@22
|
373 anchor:SetPoint("TOPRIGHT", UIParent, "TOPRIGHT", 0, 0)
|
arkanes@0
|
374 anchor:Hide()
|
arkanes@0
|
375
|
arkanes@18
|
376 local frame = CreateFrame("FRAME", "KBFBuffFrame", UIParent, "SecureAuraHeaderTemplate")
|
arkanes@0
|
377 --local frame = anchor
|
arkanes@0
|
378 frame:SetAttribute("filter", "HELPFUL")
|
arkanes@20
|
379 frame:SetAttribute("toggleForVehicle", true) -- this doesn't actually work right now, but maybe it eventually will
|
arkanes@0
|
380 frame:SetAttribute("template", "KBFSecureUnitAuraTemplate")
|
arkanes@3
|
381 frame:SetAttribute("point", "TOP")
|
arkanes@0
|
382 frame:SetAttribute("wrapAfter", 100) -- required due to bugs in secure header
|
arkanes@0
|
383 frame:SetAttribute("consolidateTo", nil)
|
arkanes@2
|
384 frame:SetAttribute("xOffset", 0)
|
arkanes@3
|
385 frame:SetAttribute("yOffset", -16)
|
arkanes@3
|
386 frame:SetAttribute("minWidth", 216)
|
arkanes@3
|
387 frame:SetAttribute("minHeight", 16)
|
arkanes@25
|
388 frame:SetAttribute("unit", "player")
|
arkanes@3
|
389 frame:SetAttribute("sortMethod", "NAME")
|
arkanes@3
|
390 frame:SetAttribute("sortOrder", "-")
|
arkanes@10
|
391 -- TODO: SecureAuraHeader doesn't correcltly implement the temp enchants
|
arkanes@17
|
392 frame:SetAttribute("weaponTemplate", "KBFSecureUnitAuraTemplate")
|
arkanes@17
|
393 frame:SetAttribute("includeWeapons", 1)
|
arkanes@18
|
394 frame:SetPoint("TOP", anchor, "TOP", 0, 0)
|
arkanes@5
|
395 frame:Show() -- has to be shown, otherwise the child frames don't show
|
arkanes@0
|
396 self.secureFrame = frame
|
arkanes@0
|
397 return anchor
|
arkanes@0
|
398 end
|
arkanes@18
|
399
|
arkanes@18
|
400 function kbf:ShowAnchor()
|
arkanes@18
|
401 self.secureFrame:ClearAllPoints()
|
arkanes@18
|
402 self.secureFrame:SetPoint("TOP", self.anchor, "BOTTOM", 0, 0)
|
arkanes@18
|
403 self.anchor:Show()
|
arkanes@18
|
404 end
|
arkanes@18
|
405
|
arkanes@18
|
406 function kbf:HideAnchor()
|
arkanes@18
|
407 self.secureFrame:ClearAllPoints()
|
arkanes@18
|
408 self.secureFrame:SetPoint("TOP", self.anchor, "TOP", 0, 0)
|
arkanes@18
|
409 self.anchor:Hide()
|
arkanes@18
|
410 end
|
arkanes@18
|
411
|
arkanes@18
|
412 function kbf:ToggleAnchor()
|
arkanes@18
|
413 if self.anchor:IsShown() then
|
arkanes@18
|
414 self:HideAnchor()
|
arkanes@18
|
415 else
|
arkanes@18
|
416 self:ShowAnchor()
|
arkanes@18
|
417 end
|
arkanes@18
|
418 end
|