Commit 6717e280 authored by Tukz's avatar Tukz

Pet Bar Update.

parent 0b31ae69
......@@ -17,15 +17,13 @@ function TukuiActionBars:CreatePetBar()
local Spacing = C.ActionBars.ButtonSpacing
local PetActionBarFrame = PetActionBarFrame
local PetActionBar_UpdateCooldowns = PetActionBar_UpdateCooldowns
PetActionBarFrame:RegisterEvent("PET_BAR_SHOWGRID")
PetActionBarFrame:RegisterEvent("PET_BAR_HIDEGRID")
for i = 1, NUM_PET_ACTION_SLOTS do
local Button = _G["PetActionButton"..i]
Button:ClearAllPoints()
Button:SetParent(Bar)
Button:Size(PetSize)
Button:SetNormalTexture("")
Button:Show()
if (i == 1) then
......@@ -40,6 +38,10 @@ function TukuiActionBars:CreatePetBar()
Bar:SetAttribute("addchild", Button)
Bar["Button"..i] = Button
end
PetActionBarFrame:EnableMouse(0)
PetActionBarFrame:ClearAllPoints()
PetActionBarFrame:SetParent(T.Panels.Hider)
hooksecurefunc("PetActionBar_Update", TukuiActionBars.UpdatePetBar)
......@@ -47,30 +49,5 @@ function TukuiActionBars:CreatePetBar()
RegisterStateDriver(Bar, "visibility", "[pet,nopetbattle,novehicleui,nooverridebar,nopossessbar,nobonusbar:5] show; hide")
Bar:RegisterEvent("PLAYER_CONTROL_LOST")
Bar:RegisterEvent("PLAYER_CONTROL_GAINED")
Bar:RegisterEvent("PLAYER_FARSIGHT_FOCUS_CHANGED")
Bar:RegisterEvent("PET_BAR_UPDATE")
Bar:RegisterEvent("PET_BAR_UPDATE_USABLE")
Bar:RegisterEvent("PET_BAR_UPDATE_COOLDOWN")
Bar:RegisterEvent("UNIT_PET")
Bar:RegisterEvent("UNIT_FLAGS")
Bar:RegisterEvent("UNIT_AURA")
Bar:SetScript("OnEvent", function(self, event, arg1)
if (event == "PET_BAR_UPDATE")
or (event == "UNIT_PET" and arg1 == "player")
or (event == "PLAYER_CONTROL_LOST")
or (event == "PLAYER_CONTROL_GAINED")
or (event == "PLAYER_FARSIGHT_FOCUS_CHANGED")
or (event == "UNIT_FLAGS")
or (arg1 == "pet" and (event == "UNIT_AURA")) then
TukuiActionBars:UpdatePetBar()
elseif event == "PET_BAR_UPDATE_COOLDOWN" then
PetActionBar_UpdateCooldowns()
else
TukuiActionBars:SkinPetButtons()
end
end)
Movers:RegisterFrame(Bar)
end
......@@ -16,7 +16,7 @@ local Panels = T["Panels"]
local Frames = {
MainMenuBar, MainMenuBarArtFrame, OverrideActionBar,
PossessBarFrame, PetActionBarFrame, ShapeshiftBarLeft, ShapeshiftBarMiddle, ShapeshiftBarRight,
PossessBarFrame, ShapeshiftBarLeft, ShapeshiftBarMiddle, ShapeshiftBarRight,
TalentMicroButtonAlert, CollectionsMicroButtonAlert, EJMicroButtonAlert, CharacterMicroButtonAlert
}
......@@ -235,79 +235,11 @@ function TukuiActionBars:AddPanels()
end
function TukuiActionBars:UpdatePetBar(...)
for i = 1, NUM_PET_ACTION_SLOTS, 1 do
for i=1, NUM_PET_ACTION_SLOTS, 1 do
local ButtonName = "PetActionButton" .. i
local PetActionButton = _G[ButtonName]
local PetActionIcon = _G[ButtonName.."Icon"]
local PetActionBackdrop = PetActionButton.Backdrop
local PetAutoCastableTexture = _G[ButtonName.."AutoCastable"]
local PetAutoCastShine = _G[ButtonName.."Shine"]
local Name, Texture, IsToken, IsActive, AutoCastAllowed, AutoCastEnabled = GetPetActionInfo(i)
PetActionButton:SetNormalTexture("")
if (not IsToken) then
PetActionIcon:SetTexture(Texture)
PetActionButton.tooltipName = Name
else
PetActionIcon:SetTexture(_G[Texture])
PetActionButton.tooltipName = _G[Name]
end
PetActionButton = _G[ButtonName]
PetActionButton.IsToken = IsToken
PetActionButton.tooltipSubtext = SubText
if (IsActive) then
PetActionButton:SetChecked(1)
if PetActionBackdrop then
PetActionBackdrop:SetBackdropBorderColor(0, 1, 0)
end
if IsPetAttackAction(i) then
PetActionButton_StartFlash(PetActionButton)
end
else
PetActionButton:SetChecked()
if PetActionBackdrop then
PetActionBackdrop:SetBackdropBorderColor(unpack(C.General.BorderColor))
end
if IsPetAttackAction(i) then
PetActionButton_StopFlash(PetActionButton)
end
end
if AutoCastAllowed then
PetAutoCastableTexture:Show()
else
PetAutoCastableTexture:Hide()
end
if AutoCastEnabled then
AutoCastShine_AutoCastStart(PetAutoCastShine)
else
AutoCastShine_AutoCastStop(PetAutoCastShine)
end
if Texture then
if (GetPetActionSlotUsable(i)) then
SetDesaturation(PetActionIcon, nil)
else
SetDesaturation(PetActionIcon, 1)
end
PetActionIcon:Show()
else
PetActionIcon:Hide()
end
if (not PetHasActionBar() and Texture and Name ~= "PET_ACTION_FOLLOW") then
PetActionButton_StopFlash(PetActionButton)
SetDesaturation(PetActionIcon, 1)
PetActionButton:SetChecked(0)
end
PetActionButton:SetNormalTexture("")
end
end
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment