Commit 8fba5c8c authored by Blazeflack's avatar Blazeflack
Browse files

CBS: Implement fail-safe in case ElvUI ActionBars are disabled

parent 59d33150
......@@ -235,6 +235,7 @@ function CBS:InsertOptions()
type = 'group',
name = L['Snap To Actionbars'],
guiInline = true,
disabled = function() return not E.private.actionbar.enable end,
args = {
enable = {
type = 'toggle',
......@@ -255,7 +256,7 @@ function CBS:InsertOptions()
order = 2,
name = L['Snap To'],
desc = L['Choose which actionbar you want the castbar to be attached to.'],
disabled = function() return not E.db.CBS.player.enable end,
disabled = function() return not E.private.actionbar.enable or not E.db.CBS.player.enable end,
get = function(info) return E.db.CBS.player.snapto end,
set = function(info, value)
E.db.CBS.player.snapto = value
......@@ -282,7 +283,7 @@ function CBS:InsertOptions()
local snapTo = E.db.CBS.player.snapto
CBS:PositionPlayerCastbar(snapTo)
end,
disabled = function() return not E.db.CBS.player.enable end,
disabled = function() return not E.private.actionbar.enable or not E.db.CBS.player.enable end,
min = -100, max = 100, step = 1,
},
},
......
......@@ -95,6 +95,9 @@ local CBSFrame = CreateFrame('Frame')
CBSFrame:RegisterEvent('PLAYER_ENTERING_WORLD')
CBSFrame:SetScript('OnEvent',function(self, event)
if event == 'PLAYER_ENTERING_WORLD' and E.db.CBS.player.enable == true then
--ElvUI ActionBars are not enabled, stop right here!
if E.private.actionbar.enable ~= true then return end
local snapTo = E.db.CBS.player.snapto
CBS:PlayerCastbarSetWidth(snapTo)
CBS:PositionPlayerCastbar(snapTo)
......@@ -103,6 +106,12 @@ CBSFrame:SetScript('OnEvent',function(self, event)
end)
function CBS:OnInitialize()
-- Register callback with LibElvUIPlugin
EP:RegisterPlugin(addon, CBS.InsertOptions)
--ElvUI ActionBars are not enabled, stop right here!
if E.private.actionbar.enable ~= true then return end
-- Hook UF:Update_PlayerFrame to set width and position on updates
hooksecurefunc(UF,'Update_PlayerFrame',function(self)
-- Safeguard against ElvUI_Enhanced and Shadow & Light.
......@@ -123,7 +132,4 @@ function CBS:OnInitialize()
CBS:PositionPlayerCastbar(bar)
end
end)
-- Register callback with LibElvUIPlugin
EP:RegisterPlugin(addon, CBS.InsertOptions)
end
\ No newline at end of file
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