/trunk
## Author: Grayal |
## DefaultState: enabled |
## SavedVariables: BisonDB |
## OptionalDeps: Ace3, LibDebugLog-1.0, ButtonFacade |
## OptionalDeps: Ace3, LibDebugLog-1.0 |
## X-Name: Bison |
## X-Embeds: Ace3, LibDebugLog-1.0, ButtonFacade |
## X-Embeds: Ace3, LibDebugLog-1.0 |
## X-Email: grayal@gmx.de |
## X-Category: Buffs |
## X-CompatibleLocales: enUS, enGB, deDE |
Localization.lua |
Bison.lua |
BuffBar.lua |
Facade.lua |
Options.lua |
b.icon:SetPoint( 'BOTTOMLEFT') |
b.count = b:CreateFontString( name..'Count', 'BACKGROUND', 'NumberFontNormal') |
b.count:SetPoint( 'BOTTOMRIGHT', b, 'BOTTOMRIGHT', -2, 2) |
b.left = b:CreateFontString( name..'Cooldown', 'ARTWORK', 'GameFontNormalSmall') |
b.left = b:CreateFontString( nil, 'ARTWORK', 'GameFontNormalSmall') |
b.left:SetPoint( 'TOP', b, 'BOTTOM') |
b.ghostlabel = b:CreateFontString( nil, 'OVERLAY', 'GameFontHighlight') |
b.ghostlabel:SetHeight( 10) |
--[[--------------------------------------------------------------------------------- |
BisonBar |
------------------------------------------------------------------------------------]] |
local LBF = LibStub('LibButtonFacade', true) |
local BisonBar = Bison:CreateClass( 'Frame') |
Bison.BisonBar = BisonBar |
function BisonBar:New( values) |
function BisonBar:New( values, barName) |
local f = self:Bind( CreateFrame( 'Frame', nil, UIParent)) |
f:SetToplevel( true) |
f:SetFrameStrata( 'LOW') |
f:SetWidth( 65) |
f:SetHeight( 40) |
-- f:AddHelpTexture() |
-- f:AddHelpTexture() -- only for test |
f.buttons = {} |
f.values = values |
f.values = values |
f.barName = barName |
return f |
end |
tex:SetPoint( 'BOTTOMLEFT') |
end |
function BisonBar:NewBuffBar( values) |
local f = self:New( values) |
function BisonBar:NewBuffBar( values, barName) |
local f = self:New( values, barName) |
f:RegisterEvent( 'UNIT_AURA') |
f:SetScript( 'OnEvent', BisonBar.OnEvent) |
f:SetScript( 'OnUpdate', BisonBar.OnUpdate) |
return f |
end |
function BisonBar:NewDebuffBar( values) |
local f = self:New( values) |
function BisonBar:NewDebuffBar( values, barName) |
local f = self:New( values, barName) |
f:RegisterEvent( 'UNIT_AURA') |
f:SetScript( 'OnEvent', BisonBar.OnEvent) |
f.name = 'debuff' |
return f |
end |
function BisonBar:NewWeaponBar( values) |
local f = self:New( values) |
function BisonBar:NewWeaponBar( values, barName) |
local f = self:New( values, barName) |
f:SetScript( 'OnUpdate', BisonBar.OnUpdateWeapon) |
f.name = 'weapon' |
f.buffFilter = nil |
end |
b:Update() |
table.insert( self.buttons, b) |
if LBF then |
LBF:Group( 'Bison', self.barName):AddButton( b) |
end |
end |
end |
self:SetPoint( 'BOTTOMLEFT', UIParent, 'BOTTOMLEFT', self.values.xPos, self.values.yPos) |
self:SetAnchors() |
self:UpdateLock( locked) |
if LBF then |
LBF:Group( 'Bison', self.barName):Skin( unpack( values.style)) |
end |
end |
function BisonBar:SetAnchors() |
local L = LibStub( 'AceLocale-3.0'):GetLocale( 'Bison') |
local DEFAULTS = { |
profile = { |
buff = { xPos = 400, yPos = 500, xPadding = 5, yPadding = 15, scale = 1.0, rows = 2, cols = 16, show = true, flashing = true, timer = true, horizontal = true, sort = 'dec', }, |
debuff = { xPos = 400, yPos = 250, xPadding = 5, yPadding = 15, scale = 1.0, rows = 1, cols = 16, show = true, flashing = true, timer = true, horizontal = true, sort = 'dec', }, |
weapon = { xPos = 400, yPos = 200, xPadding = 5, yPadding = 15, scale = 1.0, rows = 1, cols = 2, show = true, flashing = true, timer = true, horizontal = true, sort = 'none', }, |
buff = { xPos = 400, yPos = 500, xPadding = 5, yPadding = 15, scale = 1.0, rows = 2, cols = 16, show = true, flashing = true, timer = true, horizontal = true, sort = 'dec', style = { 'Blizzard', 0, nil }, }, |
debuff = { xPos = 400, yPos = 250, xPadding = 5, yPadding = 15, scale = 1.0, rows = 1, cols = 16, show = true, flashing = true, timer = true, horizontal = true, sort = 'dec', style = { 'Blizzard', 0, nil }, }, |
weapon = { xPos = 400, yPos = 200, xPadding = 5, yPadding = 15, scale = 1.0, rows = 1, cols = 2, show = true, flashing = true, timer = true, horizontal = true, sort = 'none', style = { 'Blizzard', 0, nil }, }, |
locked = true, |
enabled = true, |
} |
} |
local MAX_BUTTONS = { |
buff = 32, |
buff = 32, |
debuff = 16, |
weapon = 2, |
} |
local BAR_NAMES = { |
[L.BarBuff] = 'buff', |
[L.BarDebuff] = 'debuff', |
[L.BarWeapon] = 'weapon', |
} |
local SORT_TYPES = { |
['none'] = 1, |
['alpha'] = 2, |
Bison.version = format( L.Version, GetAddOnMetadata( 'Bison', 'Version') or 'unknown', RED_FONT_COLOR_CODE, 'WotLK', FONT_COLOR_CODE_CLOSE) |
function Bison:OnInitialize() |
self:ToggleDebugLog( false) |
self:ToggleDebugLog( true) |
self.db = LibStub( 'AceDB-3.0'):New( 'BisonDB', DEFAULTS, 'Default') |
self:InitConfig() |
end |
function Bison:OnEnable() |
self.buff = self.BisonBar:NewBuffBar( self.db.profile.buff) |
self.debuff = self.BisonBar:NewDebuffBar( self.db.profile.debuff) |
self.weapon = self.BisonBar:NewWeaponBar( self.db.profile.weapon) |
self.buff:CreateButtons( MAX_BUTTONS.buff, 0) |
self.buff = self.BisonBar:NewBuffBar( self.db.profile.buff, L.BarBuff) |
self.debuff = self.BisonBar:NewDebuffBar( self.db.profile.debuff, L.BarDebuff) |
self.weapon = self.BisonBar:NewWeaponBar( self.db.profile.weapon, L.BarWeapon) |
self.buff:CreateButtons( MAX_BUTTONS.buff, 0) |
self.debuff:CreateButtons( MAX_BUTTONS.debuff, 0) |
self.weapon:CreateButtons( MAX_BUTTONS.weapon, 15) |
self:Update() |
self.db.RegisterCallback( self, 'OnProfileCopied') |
self.db.RegisterCallback( self, 'OnProfileReset') |
self.db.RegisterCallback( self, 'OnProfileDeleted') |
local LBF = LibStub( 'LibButtonFacade', true) |
if LBF then |
LBF:RegisterSkinCallback( 'Bison', self.OnSkin, self) |
end |
self:Debug( 'Bison enabled') |
self:Print( self.version, 'loaded') |
end |
self:HideFrames() |
end |
function Bison:OnSkin( skin, gloss, backdrop, group, button, colors) |
if group and BAR_NAMES[group] then |
local bar = BAR_NAMES[group] |
local pro = self.db.profile[bar] |
if type(pro.style) ~= 'table' then pro.style = {} end |
pro.style[1] = skin |
pro.style[2] = gloss |
pro.style[3] = backdrop |
pro.style[4] = colors |
end |
end |
--[[--------------------------------------------------------------------------------- |
Main Methods |
------------------------------------------------------------------------------------]] |
end |
function Bison:AddButtons( biGrp, info) |
self:Debug(info) |
local bar = GetBar( info) |
self:Debug(bar) |
if self.db.profile[bar] then |
self[bar]:AddButtons( biGrp) |
end |