idActionBar = {}
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:addBar(name, first, last)
local Button
local totalWidth
local totalHeight
Button = getglobal(name..first)
Button:ClearAllPoints()
Button:SetPoint('CENTER', UIParent, 'CENTER')
for i=first+1, last do
Button = getglobal(name..i)
Button:ClearAllPoints()
Button:SetPoint('LEFT', getglobal(name..i-1), 'RIGHT')
end
totalWidth = ((last-first)+1)*getglobal(name..first):GetWidth()
totalHeight = getglobal(name..first):GetHeight()
return totalWidth, totalHeight
end
function idActionBar:alterButtonLooks(Button)
bg = getglobal(Button:GetName()..'NormalTexture2') or getglobal(Button:GetName()..'NormalTexture')
ic = getglobal(Button:GetName()..'Icon')
bg:SetAlpha(0)
ic:SetTexCoord(0.07, 0.93, 0.07, 0.93)
end
function idActionBar:giveStandardBackground(Frame)
Frame:SetBackdrop({
bgFile = 'Interface\\Tooltips\\UI-Tooltip-Background',
edgeFile = '',
tile = true,
tileSize = 16,
edgeSize = 0,
insets = {
left = 0,
right = 0,
top = 0,
bottom = 0
}
})
Frame:SetBackdropColor(0,0,0,0.4)
end
function idActionBar:setupMainbar()
local Mainbar = CreateFrame('frame', 'idActionBarMainbar', UIParent)
w,h = self:addBar('idActionButton', 1, 12)
self:addBar('idActionButton', 13, 24)
self:addBar('idActionButton', 25, 36)
Mainbar:SetWidth(w)
Mainbar:SetHeight(h*3)
for i=1,36 do
getglobal('idActionButton'..i):SetParent(Mainbar)
self:alterButtonLooks(getglobal('idActionButton'..i))
end
idActionButton1:ClearAllPoints()
idActionButton1:SetPoint('BOTTOMLEFT', Mainbar, 'BOTTOMLEFT')
idActionButton13:ClearAllPoints()
idActionButton13:SetPoint('BOTTOM', idActionButton1, 'TOP')
idActionButton25:ClearAllPoints()
idActionButton25:SetPoint('BOTTOM', idActionButton13, 'TOP')
self:giveStandardBackground(Mainbar)
Mainbar:ClearAllPoints()
Mainbar:SetPoint('BOTTOM', UIParent, 'BOTTOM')
Mainbar:Show()
self.Mainbar = Mainbar
end
function idActionBar:setupPetbar()
local PetClasses = {Priest=1,Warlock=1,Hunter=1,}
if not PetClasses[UnitClass('player')] then return end
local Petbar = CreateFrame('frame', 'idActionBarPetbar', UIParent)
w,h = self:addBar('PetActionButton', 1, 10)
Petbar:SetWidth(w)
Petbar:SetHeight(h)
for i=1,36 do
Button = getglobal('PetActionButton'..i)
if Button then
Button:SetParent(Petbar)
self:alterButtonLooks(Button)
end
end
PetActionButton1:ClearAllPoints()
PetActionButton1:SetPoint('BOTTOMLEFT', Petbar, 'BOTTOMLEFT')
Petbar:SetScript("OnEvent", function()
if event == 'PET_BAR_SHOWGRID' then
Petbar:Show()
elseif event == 'PET_BAR_HIDEGRID' then
Petbar:Hide()
end
end)
self:giveStandardBackground(Petbar)
Petbar:ClearAllPoints()
Petbar:SetPoint('BOTTOMLEFT', self.Mainbar, 'TOPLEFT')
self.Petbar = Petbar
end
function idActionBar:Enable()
local oldActionButton_HideGrid
local Petbar
oldActionButton_HideGrid = ActionButton_HideGrid
ActionButton_HideGrid = function(Button)
Button = Button or this
if string.find(Button:GetName(), 'idActionButton') then
idActionBar:alterButtonLooks(Button)
end
oldActionButton_HideGrid(Button)
end
MainMenuBar:Hide()
self:setupMainbar()
self:setupPetbar()
end
idActionBar:Enable()