idActionBar = {}
idActionBar.hook = {}
idActionBar.boolDebug = false
function idActionBar:debug(var)
if self.boolDebug
then DEFAULT_CHAT_FRAME:AddMessage(var)
end
end
function idActionBar:ActionButtonDown(b)
b = getglobal('idActionButton'..b)
if b:GetButtonState() == 'NORMAL' then
b:SetButtonState('PUSHED')
end
end
function idActionBar:ActionButtonUp(b)
b = getglobal('idActionButton'..b)
if b:GetButtonState() == 'PUSHED' then
b:SetButtonState('NORMAL')
UseAction(ActionButton_GetPagedID(b), 0, onSelf)
if IsCurrentAction(ActionButton_GetPagedID(b)) then
b:SetChecked(1)
else
b:SetChecked(0)
end
end
end
function idActionBar:newBar(parent, frame, first, rows, cols, spacing)
local Button, ButtonUnder, ButtonLeft
Button=getglobal(frame..first) -- the first button
self:alterButtonLooks(Button)
parent:SetFrameStrata('BACKGROUND')
parent:SetHeight(rows * Button:GetHeight() + (rows * spacing) - spacing)
parent:SetWidth(cols * Button:GetWidth() + (cols * spacing) - spacing)
Button:SetParent(parent)
Button:SetPoint('BOTTOMLEFT', parent, 'BOTTOMLEFT')
Button:Show()
for i=first+1, rows*cols do
Button = getglobal(frame..i)
if math.mod(i-1, cols) == 0 then
ButtonUnder = getglobal(frame..i-cols)
Button:ClearAllPoints()
Button:SetPoint('BOTTOM', ButtonUnder, 'TOP', 0, spacing)
else
ButtonLeft = getglobal(frame..i-1)
Button:ClearAllPoints()
Button:SetPoint('LEFT', ButtonLeft, 'RIGHT', spacing, 0)
end
self:alterButtonLooks(Button)
Button:SetParent(parent)
Button:Show()
end
end
idActionBar.main = {}
function idActionBar.main:Enable()
self.wrap = CreateFrame('frame', nil, UIParent)
idActionBar:newBar(self.wrap, 'idActionButton', 1, 3, 12, 0)
self.wrap:ClearAllPoints()
self.wrap:SetPoint('BOTTOM', UIParent, 'BOTTOM')
MainMenuBar:Hide()
self.wrap:Show()
end
idActionBar.pet = {}
function idActionBar.pet:Enable()
self.wrap = CreateFrame('frame', nil, UIParent)
idActionBar:newBar(self.wrap, 'PetActionButton', 1, 1, 10, 0)
self.wrap:ClearAllPoints()
if self.showmain then
self.wrap:SetPoint('BOTTOMLEFT', self.wrap, 'TOPLEFT', 0, 0)
else
self.wrap:SetPoint('BOTTOM', UIParent, 'BOTTOM')
end
self.wrap:Show()
end
-- Thanks DimUI
function idActionBar:alterButtonLooks(Button)
background = getglobal(Button:GetName()..'NormalTexture') or getglobal(Button:GetName()..'NormalTexture2')
icon = getglobal(Button:GetName()..'Icon')
background:SetAlpha(0)
icon:SetTexCoord( 0.07, 0.93, 0.07, 0.93 )
end
function idActionBar:ActionButton_HideGrid(Button)
Button = Button or this
if string.find(Button:GetName(), 'idActionButton') then
self:alterButtonLooks(Button)
end
self.hook.ActionButton_HideGrid(Button)
end
function idActionBar:Enable()
local petclasses = {Warlock=1, Hunter=1}
self.showmain = true
self.showpet = true
self.hook.ActionButton_HideGrid = ActionButton_HideGrid
ActionButton_HideGrid = self.ActionButton_HideGrid
if self.showmain then
self.main:Enable()
end
if self.showpet and petclasses[UnitClass('player')] then
self.pet:Enable()
end
end
idActionBar:Enable()