/trunk
local LBF = LibStub( 'LibButtonFacade', true) |
if not LBF then return end |
local BF = LibStub( 'AceAddon-3.0'):GetAddon( 'ButtonFacade') |
if not BF then return end |
local BFBI = BF:NewModule( 'Bison') |
local Bison = LibStub( 'AceAddon-3.0'):GetAddon( 'Bison') |
local defaults = { |
profile = { |
['*'] = { |
Skin = 'Blizzard', |
Gloss = 0, |
Backdrop = false, |
Colors = {}, |
}, |
}, |
} |
--[[--------------------------------------------------------------------------------- |
Class Setup |
------------------------------------------------------------------------------------]] |
function BFBI:OnInitialize() |
self.db = self:RegisterNamespace( 'Bison', defaults) |
end |
function BFBI:OnEnable() |
self:Load() |
end |
function BFBI:OnDisable() |
end |
--[[--------------------------------------------------------------------------------- |
Main Methods |
------------------------------------------------------------------------------------]] |
function BFBI:Load() |
self:SetupGroup( 'buff') |
self:SetupGroup( 'debuff') |
self:SetupGroup( 'weapon') |
LBF:RegisterSkinCallback( 'Bison', self.SkinCallback, self) |
end |
function BFBI:SetupGroup( group) |
local biGrp = LBF:Group( 'Bison', group) |
Bison:AddButtons( biGrp, group) |
local ns = self.db.profile[group] |
biGrp:Skin( ns.Skin, ns.Gloss, ns].Backdrop, ns.Colors) |
end |
function BFBI:SkinCallback( skin, gloss, backdrop, group, button, colors) |
if group then |
local ns = self.db.profile[group] |
ns.Skin = skin |
ns.Gloss = gloss |
ns.Backdrop = backdrop |
ns.Colors = colors |
end |
end |
------------------------------------------------------------------------------------]] |
local BisonButton = Bison:CreateClass( 'Button') |
function BisonButton:New( bar, id) |
local b = self:Bind( CreateFrame( 'Button', nil, bar)) |
function BisonButton:New( bar, id, name) |
local b = self:Bind( CreateFrame( 'Button', name, bar)) |
b.bar = bar |
b.timeLeft = nil |
b:SetID( id) |
b:SetWidth( 30) |
b:SetHeight( 30) |
b.icon = b:CreateTexture( nil, 'BACKGROUND') |
b.icon = b:CreateTexture( name..'Icon', 'BACKGROUND') |
b.icon:SetPoint( 'TOPRIGHT') |
b.icon:SetPoint( 'BOTTOMLEFT') |
b.count = b:CreateFontString( nil, 'BACKGROUND', 'NumberFontNormal') |
b.count = b:CreateFontString( name..'Count', 'BACKGROUND', 'NumberFontNormal') |
b.count:SetPoint( 'BOTTOMRIGHT', b, 'BOTTOMRIGHT', -2, 2) |
b.left = b:CreateFontString( nil, 'ARTWORK', 'GameFontNormalSmall') |
b.left = b:CreateFontString( name..'Cooldown', 'ARTWORK', 'GameFontNormalSmall') |
b.left:SetPoint( 'TOP', b, 'BOTTOM') |
b.ghostlabel = b:CreateFontString( nil, 'OVERLAY', 'GameFontHighlight') |
b.ghostlabel:SetHeight( 10) |
return b |
end |
function BisonButton:NewBuff( bar, id) |
local b = self:New( bar, id) |
function BisonButton:NewBuff( bar, id, name) |
local b = self:New( bar, id, name) |
b:RegisterForClicks( 'RightButtonUp') |
b:SetScript( 'OnEnter', BisonButton.OnEnter) |
b:SetScript( 'OnShow', BisonButton.Update) |
return b |
end |
function BisonButton:NewDebuff( bar, id) |
local b = self:New( bar, id) |
function BisonButton:NewDebuff( bar, id, name) |
local b = self:New( bar, id, name) |
b:SetScript( 'OnEnter', BisonButton.OnEnter) |
b:SetScript( 'OnShow', BisonButton.Update) |
b:SetScript( 'OnUpdate', BisonButton.OnUpdate) |
return b |
end |
function BisonButton:NewWeapon( bar, id) |
local b = self:New( bar, id) |
function BisonButton:NewWeapon( bar, id, name) |
local b = self:New( bar, id, name) |
b:RegisterForClicks( 'RightButtonUp') |
b:SetScript( 'OnEnter', BisonButton.OnEnterWeapon) |
b:SetScript( 'OnClick', BisonButton.OnClickWeapon) |
for i = 1, size do |
local b |
if self.name == 'buff' then |
b = BisonButton:NewBuff( self, i + offset) |
b = BisonButton:NewBuff( self, i + offset, 'BisonBuff'..i) |
b:SetGhost( tostring( b:GetID()), 0.2, 0.8, 0.2) |
elseif self.name == 'debuff' then |
b = BisonButton:NewDebuff( self, i + offset) |
b = BisonButton:NewDebuff( self, i + offset, 'BisonDebuff'..i) |
b:AddBorder() |
b:SetGhost( tostring( b:GetID()), 0.8, 0.2, 0.2) |
elseif self.name == 'weapon' then |
b = BisonButton:NewWeapon( self, i + offset) |
b = BisonButton:NewWeapon( self, i + offset, 'BisonWeapon'..i) |
b:SetGhost( (b:GetID() == 17) and 'MH' or 'OH', 0.2, 0.2, 0.2) |
end |
b:Update() |
self:SetAnchors() |
end |
function BisonBar:Sort() |
table.sort( self.buttons, SORT[self.values.sort]) |
end |
function BisonBar:OnUpdate( elapsed) |
if updateTimeBuff < 0 then |
updateTimeBuff = updateTimeBuff + UPDATE_TIME_BUFF |
btnOff:Alpha( alphaValue) |
end |
function BisonBar:AddButtons( biGrp) |
for i,b in pairs( self.buttons) do |
biGrp:AddButton( b) |
end |
end |
function BisonBar:Sort() |
table.sort( self.buttons, SORT[self.values.sort]) |
end |
function BisonBar:RestoreSettings( locked, values) |
self.values = values |
self:ClearAllPoints() |
local last, lastFirst |
local row = 1 |
local col = 1 |
for i, b in pairs( self.buttons) do |
for i,b in pairs( self.buttons) do |
b:ClearAllPoints() |
if last and lastFirst then |
if self.values.horizontal then |
self:Print( self.version) |
end |
local function GetBar( info) |
return (type(info) == 'table') and info.arg or tostring(info) |
end |
function Bison:AddButtons( biGrp, info) |
local bar = GetBar( info) |
if self.db.profile[bar] then |
self[bar]:AddButtons( biGrp) |
end |
end |
--[[--------------------------------------------------------------------------------- |
Set/Get Methods |
------------------------------------------------------------------------------------]] |
self:SetEnabled( not self:IsEnabled()) |
end |
local function GetBar( info) |
return (type(info) == 'table') and info.arg or tostring(info) |
end |
function Bison:IsVisible( info) |
local bar = GetBar( info) |
return self.db.profile[bar] and self.db.profile[bar].show |
Bison.lua |
BuffBar.lua |
Options.lua |
Facade.lua |