I accounted for being in combat.
The error:
2x [ADDON_ACTION_BLOCKED] AddOn 'GalvinUnitBars' tried to call the protected function '<unnamed>:Hide()'.
!BugGrabber\BugGrabber.lua:573: in function <!BugGrabber\BugGrabber.lua:573>
[C]: in function `Hide'
GalvinUnitBars\Main.lua:917: in function <GalvinUnitBars\Main.lua:912>
[C]: in function `UIParent_ManageFramePositions'
FrameXML\BuffFrame.lua:332: in function `BuffFrame_UpdateAllBuffAnchors'
FrameXML\BuffFrame.lua:104: in function `BuffFrame_Update'
FrameXML\BuffFrame.lua:49: in function <FrameXML\BuffFrame.lua:45>
Locals:
InCombatSkipped
All the code can be found at:
https://repos.curseforge.com/wow/gal...bars/tags/6.30 release
Code:
-------------------------------------------------------------------------------
-- APBStopMoving
--
-- Stops moving the alternate power bars
-------------------------------------------------------------------------------
local function APBStopMoving(Frame)
if Frame == APBMover then
UnitBars.APBPos = { Frame:GetPoint() }
else
UnitBars.APBTimerPos = { Frame:GetPoint() }
end
Frame:StopMovingOrSizing()
end
-------------------------------------------------------------------------------
-- APBSetMover
--
-- Turns moving on or off for both Alternate Power Bars
--
-- Type : 'apb' and 'timer'. or nil for both
-------------------------------------------------------------------------------
function GUB.Main:APBSetMover(Type)
local Hide = false
if UnitBars.APBMoverOptionsDisabled then
Hide = true
end
if Type == nil or Type == 'apb' then
if not Hide and Main.APBMoverEnabled then
APBMover:Show()
else
APBMover:Hide()
end
end
if Type == nil or Type == 'timer' then
if not Hide and Main.APBBuffTimerMoverEnabled then
APBBuffTimerMover:Show()
else
APBBuffTimerMover:Hide()
end
end
end
-------------------------------------------------------------------------------
-- APBReset
--
-- Reset the alternate power bar movers to default position
-------------------------------------------------------------------------------
function GUB.Main:APBReset()
APBMover:ClearAllPoints()
APBMover:SetPoint('CENTER', 0, 0)
APBBuffTimerMover:ClearAllPoints()
APBBuffTimerMover:SetPoint('CENTER', 0, -75)
UnitBars.APBPos = {'CENTER', 0, 0}
UnitBars.APBTimerPos = {'CENTER', 0, -75}
Main:DoBlizzAltPowerBar()
end
-------------------------------------------------------------------------------
-- InitAltPowerBar
--
-- This sets up the blizzard alternate power bar for hiding/showing/moving
-------------------------------------------------------------------------------
local function InitAltPowerBar()
local APBPos = UnitBars.APBPos
local APBTimerPos = UnitBars.APBTimerPos
APBMover = CreateFrame('Frame', nil, UIParent)
APBMover:SetSize(75, 50)
APBMover:SetMovable(true)
APBMover:SetBackdrop(SelectFrameBorder)
APBMover:SetScript('OnMouseDown', APBMover.StartMoving)
APBMover:SetScript('OnMouseUp', APBStopMoving)
APBMover:SetFrameStrata('HIGH')
APBMover:SetClampedToScreen(true)
local FontString = APBMover:CreateFontString(nil)
FontString:SetAllPoints()
FontString:SetFont([[Fonts\FRIZQT__.TTF]], 13, 'THICKOUTLINE')
FontString:SetJustifyH('CENTER')
FontString:SetJustifyV('MIDDLE')
FontString:SetText('APB')
if next(APBPos) == nil then
APBMover:SetPoint('CENTER', 0, 0)
else
APBMover:SetPoint(unpack(APBPos))
end
APBBuffTimerMover = CreateFrame('Frame', nil, UIParent)
APBBuffTimerMover:SetPoint('CENTER')
APBBuffTimerMover:SetSize(250, 75)
APBBuffTimerMover:SetMovable(true)
APBBuffTimerMover:SetBackdrop(SelectFrameBorder)
APBBuffTimerMover:SetScript('OnMouseDown', APBBuffTimerMover.StartMoving)
APBBuffTimerMover:SetScript('OnMouseUp', APBStopMoving)
APBBuffTimerMover:SetFrameStrata('HIGH')
APBBuffTimerMover:SetClampedToScreen(true)
local FontString = APBBuffTimerMover:CreateFontString(nil)
FontString:SetAllPoints()
FontString:SetFont([[Fonts\FRIZQT__.TTF]], 13, 'THICKOUTLINE')
FontString:SetJustifyH('CENTER')
FontString:SetJustifyV('MIDDLE')
FontString:SetText('TIMER')
if next(APBTimerPos) == nil then
APBBuffTimerMover:SetPoint('CENTER', 0, -75)
else
APBBuffTimerMover:SetPoint(unpack(APBTimerPos))
end
-- Hook secure func for alt power bars
hooksecurefunc('PlayerBuffTimerManager_UpdateTimers', function()
if not UnitAffectingCombat('player') then
Main.DoBlizzAltPowerBar()
end
end)
-- This is used to make sure the power bar can be repositioned after reload UI
hooksecurefunc('UIParent_ManageFramePositions', function()
if not UnitAffectingCombat('player') then
local APBMoverOptionsDisabled = UnitBars.APBMoverOptionsDisabled
PlayerPowerBarAlt:SetMovable(true)
PlayerPowerBarAlt:SetUserPlaced(not APBMoverOptionsDisabled)
if not APBMoverOptionsDisabled then
PlayerPowerBarAlt:ClearAllPoints()
PlayerPowerBarAlt:SetPoint('CENTER', APBMover, 'CENTER')
end
end
end)
Main:APBSetMover()
end
-------------------------------------------------------------------------------
-- DoBlizzAltPowerBar
--
-- Hides and shows the blizzard alt power bar and BuffTimer frame
-- And positions them if moving is enable
--
-- Blizzard code will not modify the positon of the alt power bar when
-- SetUserPlaced is set to true
-- This also hides things like the darkmoon faire timers
--
-- NOTES: This function is also called when PlayerBuffTimerManager_UpdateTimers()
-- is called. This secure function call is done in InitAltPowerBar()
-------------------------------------------------------------------------------
function GUB.Main:DoBlizzAltPowerBar()
local BuffTimer = nil
local APBMoverOptionsDisabled = UnitBars.APBMoverOptionsDisabled
BlizzAltPowerVisible = UnitBars.APBDisabled or APBUseBlizz[AltPowerBarID] or false
-- Look for bufftimers for darkmoon faire or similar
for TimerIndex = 1, 10 do
BuffTimer = _G[format('BuffTimer%s', TimerIndex)]
if BuffTimer then
if BuffTimer:IsVisible() then
break
else
-- Clear points incase mover is disabled
BuffTimer:ClearAllPoints()
end
end
end
-- Need to do SetMovable otherwise SetUserPlaced causes an error
PlayerPowerBarAlt:SetMovable(true)
if not BlizzAltPowerVisible then -- hide
PlayerPowerBarAlt:SetUserPlaced(false)
PlayerPowerBarAlt:Hide()
if BuffTimer then
BuffTimer:Hide()
BuffTimer:ClearAllPoints()
end
else -- show
PlayerPowerBarAlt:SetUserPlaced(not APBMoverOptionsDisabled)
if not APBMoverOptionsDisabled then
PlayerPowerBarAlt:ClearAllPoints()
PlayerPowerBarAlt:SetPoint('CENTER', APBMover, 'CENTER')
if BuffTimer then
BuffTimer:ClearAllPoints()
BuffTimer:SetPoint('CENTER', APBBuffTimerMover, 'CENTER')
end
end
end
end
-------------------------------------------------------------------------------
-- EABReset
--
-- Reset the extra action button to default position
-------------------------------------------------------------------------------
function GUB.Main:EABReset()
EABMover:ClearAllPoints()
EABMover:SetPoint('CENTER', 0, -150)
UnitBars.EABPos = {'CENTER', 0, -150}
Main:DoBlizzAltPowerBar()
end
-------------------------------------------------------------------------------
-- InitExtraActionButton
--
-- This sets up the extra action button for hiding/showing/moving
-------------------------------------------------------------------------------
local function InitExtraActionButton()
local EABPos = UnitBars.EABPos
EABMover = CreateFrame('Frame', nil, UIParent)
EABMover:SetSize(ExtraActionButton1:GetSize())
EABMover:SetMovable(true)
EABMover:SetBackdrop(SelectFrameBorder)
EABMover:SetScript('OnMouseDown', EABMover.StartMoving)
EABMover:SetScript('OnMouseUp', function()
UnitBars.EABPos = { EABMover:GetPoint() }
EABMover:StopMovingOrSizing()
end)
EABMover:SetFrameStrata('HIGH')
EABMover:SetClampedToScreen(true)
local FontString = EABMover:CreateFontString(nil)
FontString:SetAllPoints()
FontString:SetFont([[Fonts\FRIZQT__.TTF]], 13, 'THICKOUTLINE')
FontString:SetJustifyH('CENTER')
FontString:SetJustifyV('MIDDLE')
FontString:SetText('EAB')
-- Hook secure func for extra action button
hooksecurefunc('UIParent_ManageFramePositions', function()
if not UnitAffectingCombat('player') then
Main.DoExtraActionButton()
end
end)
if next(EABPos) == nil then
EABMover:SetPoint(ExtraActionButton1:GetPoint())
else
EABMover:SetPoint(unpack(EABPos))
end
Main:DoExtraActionButton()
end
-------------------------------------------------------------------------------
-- DoExtraActionButton
--
-- Hides and shows the blizzard extra action button frame
-- And positions them if moving is enable
-------------------------------------------------------------------------------
function GUB.Main:DoExtraActionButton()
if not UnitBars.EABMoverOptionsDisabled then
if Main.EABMoverEnabled then
EABMover:Show()
else
EABMover:Hide()
end
ExtraActionButton1:ClearAllPoints()
ExtraActionButton1:SetPoint('CENTER', EABMover, 'CENTER')
else
EABMover:Hide()
end
end