Mercurial > wow > kbf
comparison KBF.lua @ 54:c4324144d380
start adding configuration - options to toggle consolidated buff support. pkgmeta and embeds updates for the extra libs
author | Chris Mellon <arkanes@gmail.com> |
---|---|
date | Wed, 13 Jul 2011 21:30:32 -0500 |
parents | 7d961c698b71 |
children | 4d359ee4649c |
comparison
equal
deleted
inserted
replaced
53:c67355a1ec40 | 54:c4324144d380 |
---|---|
4 | 4 |
5 local kbf = LibStub("AceAddon-3.0"):NewAddon(kbf, "KBF", "AceEvent-3.0", "AceConsole-3.0") | 5 local kbf = LibStub("AceAddon-3.0"):NewAddon(kbf, "KBF", "AceEvent-3.0", "AceConsole-3.0") |
6 | 6 |
7 | 7 |
8 function kbf:OnInitialize() | 8 function kbf:OnInitialize() |
9 -- config settings - account wide shared profile by default | |
10 self.db = LibStub("AceDB-3.0"):New("KBFSavedVars", self.defaultConfig, true) | |
9 -- create frames here so that they will be correctly stored in location cache by | 11 -- create frames here so that they will be correctly stored in location cache by |
10 -- the UI. | 12 -- the UI. |
11 self.anchor, self.secureHeader, self.consolidateHeader, self.consolidateProxy = self:CreateCoreFrames() | 13 self.anchor, self.secureHeader, self.consolidateHeader, self.consolidateProxy = self:CreateCoreFrames() |
12 self.debuffFrames = {} | 14 self.debuffFrames = {} |
13 local defaultSettings = { | |
14 -- global bar settings | |
15 -- overrides for buffs | |
16 -- overrides for debuffs | |
17 } | |
18 self:RegisterEvent("UNIT_AURA") | 15 self:RegisterEvent("UNIT_AURA") |
19 self:RegisterEvent("UNIT_ENTERING_VEHICLE", "PollForVehicleChange") | 16 self:RegisterEvent("UNIT_ENTERING_VEHICLE", "PollForVehicleChange") |
20 self:RegisterEvent("UNIT_EXITING_VEHICLE", "PollForVehicleChange") | 17 self:RegisterEvent("UNIT_EXITING_VEHICLE", "PollForVehicleChange") |
21 self:RegisterChatCommand("kbf", "ToggleAnchor") | 18 self:RegisterChatCommand("kbf", "ToggleAnchor") |
22 | 19 |
389 -- creates a icon + statusbar bar | 386 -- creates a icon + statusbar bar |
390 function kbf:ConstructBar(frame, r, g, b) | 387 function kbf:ConstructBar(frame, r, g, b) |
391 local texture = "Interface\\TargetingFrame\\UI-StatusBar" | 388 local texture = "Interface\\TargetingFrame\\UI-StatusBar" |
392 -- Because of secureframe suckiness, these height & width numbers | 389 -- Because of secureframe suckiness, these height & width numbers |
393 -- have to be consistent with the stuff in KBF.xml | 390 -- have to be consistent with the stuff in KBF.xml |
394 local height = 16 | 391 local height = self.staticConfig.BAR_HEIGHT |
395 local width = 200 -- this is the width *without* the icon | 392 local width = self.staticConfig.BAR_WIDTH -- this is the width *without* the icon |
396 local font, _, style = GameFontHighlight:GetFont() | 393 local font, _, style = GameFontHighlight:GetFont() |
397 local r = r or 0 | 394 local r = r or 0 |
398 local g = g or 1 | 395 local g = g or 1 |
399 local b = b or 0 | 396 local b = b or 0 |
400 local bgcolor = {r, g, b, 0.5} | 397 local bgcolor = {r, g, b, 0.5} |
403 local timertextwidth = fontsize * 3.6 | 400 local timertextwidth = fontsize * 3.6 |
404 local textcolor = {1, 1, 1, 1} | 401 local textcolor = {1, 1, 1, 1} |
405 local timertextcolor = {1, 1, 1, 1} | 402 local timertextcolor = {1, 1, 1, 1} |
406 if not frame then | 403 if not frame then |
407 frame = CreateFrame("Button", nil, UIParent) -- the "top level" frame that represents the bar as a whole | 404 frame = CreateFrame("Button", nil, UIParent) -- the "top level" frame that represents the bar as a whole |
408 frame:SetHeight(16) | 405 frame:SetHeight(height) |
409 frame:SetWidth(200 + 16) | 406 frame:SetWidth(width + height) |
410 end | 407 end |
411 local bar = frame | 408 local bar = frame |
412 bar.icon = CreateFrame("Button", nil, bar) -- the icon | 409 bar.icon = CreateFrame("Button", nil, bar) -- the icon |
413 bar.statusbarbg = CreateFrame("StatusBar", nil, bar) -- the bars background | 410 bar.statusbarbg = CreateFrame("StatusBar", nil, bar) -- the bars background |
414 bar.statusbar = CreateFrame("StatusBar", nil, bar) -- and the bars foreground | 411 bar.statusbar = CreateFrame("StatusBar", nil, bar) -- and the bars foreground |
462 end | 459 end |
463 | 460 |
464 function kbf:CreateCoreFrames() | 461 function kbf:CreateCoreFrames() |
465 -- this is the visible anchor frame that the user interacts with | 462 -- this is the visible anchor frame that the user interacts with |
466 -- to move the buffs around | 463 -- to move the buffs around |
464 local height = self.staticConfig.BAR_HEIGHT | |
465 local width = self.staticConfig.BAR_WIDTH -- this is the width *without* the icon | |
467 local anchor = CreateFrame("FRAME", "KBFAnchorFrame", UIParent) | 466 local anchor = CreateFrame("FRAME", "KBFAnchorFrame", UIParent) |
468 anchor:SetClampedToScreen(true) | 467 anchor:SetClampedToScreen(true) |
469 anchor:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", | 468 anchor:SetBackdrop({bgFile = "Interface/Tooltips/UI-Tooltip-Background", |
470 edgeFile = "Interface/Tooltips/UI-Tooltip-Border", | 469 edgeFile = "Interface/Tooltips/UI-Tooltip-Border", |
471 tile = true, tileSize = 16, edgeSize = 12, | 470 tile = true, tileSize = height, edgeSize = 12, |
472 insets = { left = 4, right = 4, top = 4, bottom = 4 }, | 471 insets = { left = 4, right = 4, top = 4, bottom = 4 }, |
473 }) | 472 }) |
474 local text = anchor:CreateFontString(nil, "OVERLAY") -- the label text | 473 local text = anchor:CreateFontString(nil, "OVERLAY") -- the label text |
475 text:SetFontObject(GameFontHighlight) | 474 text:SetFontObject(GameFontHighlight) |
476 text:SetFont(GameFontHighlight:GetFont()) | 475 text:SetFont(GameFontHighlight:GetFont()) |
477 text:SetPoint("TOPLEFT", anchor, "TOPLEFT", 0, 0) | 476 text:SetPoint("TOPLEFT", anchor, "TOPLEFT", 0, 0) |
478 text:SetPoint("BOTTOMRIGHT", anchor, "BOTTOMRIGHT", 0, 0) | 477 text:SetPoint("BOTTOMRIGHT", anchor, "BOTTOMRIGHT", 0, 0) |
479 text:SetText("KBF ANCHOR") | 478 text:SetText("KBF ANCHOR") |
480 anchor:SetWidth(200 +16) | 479 anchor:SetWidth(height + width) |
481 anchor:SetHeight(16) | 480 anchor:SetHeight(height) |
482 -- movability | 481 -- movability |
483 anchor:EnableMouse(true) | 482 anchor:EnableMouse(true) |
484 anchor:SetMovable(true) | 483 anchor:SetMovable(true) |
485 anchor:RegisterForDrag("LeftButton") | 484 anchor:RegisterForDrag("LeftButton") |
486 anchor:SetScript("OnDragStart", anchor.StartMoving) | 485 anchor:SetScript("OnDragStart", anchor.StartMoving) |
490 anchor:Hide() | 489 anchor:Hide() |
491 -- this is the parent & host for the secure aura buttons. | 490 -- this is the parent & host for the secure aura buttons. |
492 | 491 |
493 local secureHeader = CreateFrame("FRAME", "KBFBuffFrame", UIParent, "SecureAuraHeaderTemplate") | 492 local secureHeader = CreateFrame("FRAME", "KBFBuffFrame", UIParent, "SecureAuraHeaderTemplate") |
494 self:SetCommonSecureHeaderAttributes(secureHeader) | 493 self:SetCommonSecureHeaderAttributes(secureHeader) |
495 secureHeader:SetAttribute("consolidateTo", 99) | 494 if self.db.profile.consolidateBuffs then |
495 secureHeader:SetAttribute("consolidateTo", 99) | |
496 end | |
496 secureHeader:SetPoint("TOP", anchor, "TOP", 0, 0) | 497 secureHeader:SetPoint("TOP", anchor, "TOP", 0, 0) |
497 | 498 |
498 -- this is the "button" in the aura flow that represents the consolidated buffs. | 499 -- this is the "button" in the aura flow that represents the consolidated buffs. |
499 -- pre-creating it here in order to perform customization | 500 -- pre-creating it here in order to perform customization |
500 local consolidateProxy = CreateFrame("BUTTON", nil, UIParent, "SecureHandlerClickTemplate") | 501 local consolidateProxy = CreateFrame("BUTTON", nil, UIParent, "SecureHandlerClickTemplate") |
520 consolidateProxy:EnableMouse(true) | 521 consolidateProxy:EnableMouse(true) |
521 consolidateProxy:RegisterForClicks("AnyUp") | 522 consolidateProxy:RegisterForClicks("AnyUp") |
522 | 523 |
523 -- position it relative to the proxy, so it can appear where we want it | 524 -- position it relative to the proxy, so it can appear where we want it |
524 consolidateHeader:SetPoint("TOPRIGHT", anchor, "TOPLEFT", 0, 0) | 525 consolidateHeader:SetPoint("TOPRIGHT", anchor, "TOPLEFT", 0, 0) |
525 consolidateHeader:SetWidth(200 +16) | 526 consolidateHeader:SetWidth(height + width) |
526 consolidateHeader:SetHeight(16) | 527 consolidateHeader:SetHeight(height) |
527 consolidateHeader:Show() | 528 consolidateHeader:Show() |
528 | 529 |
529 return anchor, secureHeader, consolidateHeader, consolidateProxy | 530 return anchor, secureHeader, consolidateHeader, consolidateProxy |
530 end | 531 end |
531 | 532 |