annotate KBF.lua @ 37:15b9e97ab2d2

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