Commit 67690cee authored by Darth Predator's avatar Darth Predator

Rewrite. Now hooking to AB config instead of frame config

parent 16c978e3
...@@ -13,12 +13,15 @@ P['abm'] = { ...@@ -13,12 +13,15 @@ P['abm'] = {
['player'] = false, ['player'] = false,
['target'] = false, ['target'] = false,
['focus'] = false, ['focus'] = false,
['pet'] = false,
['playerw'] = E.db.unitframe.units.player.width, ['playerw'] = E.db.unitframe.units.player.width,
['targetw'] = E.db.unitframe.units.target.width, ['targetw'] = E.db.unitframe.units.target.width,
['focusw'] = E.db.unitframe.units.focus.width, ['focusw'] = E.db.unitframe.units.focus.width,
['petw'] = E.db.unitframe.units.pet.width,
['playerSpace'] = 0, ['playerSpace'] = 0,
['targetSpace'] = 0, ['targetSpace'] = 0,
['focusSpace'] = 0, ['focusSpace'] = 0,
['petSpace'] = 0,
} }
function ABM:PlayerABmove() function ABM:PlayerABmove()
...@@ -57,143 +60,43 @@ function ABM:FocusABmove() ...@@ -57,143 +60,43 @@ function ABM:FocusABmove()
UF:CreateAndUpdateUF('focus') UF:CreateAndUpdateUF('focus')
end end
function ABM:UpdatePlayer(frame, db) function ABM:PetABmove()
frame.db = db local auraBar = _G["ElvUF_Pet"].AuraBars
local POWERBAR_OFFSET = db.power.offset --Create Holder frame for our AuraBar Mover
if not db.aurabar.enable then return end local holder = CreateFrame('Frame', nil, auraBar)
holder:Point("BOTTOM", _G["ElvUF_Pet"], "TOP", 0, 0)
local auraBars = frame.AuraBars auraBar:SetPoint("BOTTOM", holder, "TOP", 0, 0)
auraBar.Holder = holder
if frame and auraBars and auraBars.spacing then
auraBars.spacing = (E.PixelMode and -1 or 1) + E.db.abm.playerSpace
end
local anchorPoint, anchorTo = 'BOTTOM', 'TOP'
if db.aurabar.anchorPoint == 'BELOW' then
anchorPoint, anchorTo = 'TOP', 'BOTTOM'
end
--Set size of mover
auraBars.Holder:Width(E.db.abm.playerw)
auraBars.Holder:Height(20)
auraBars.Holder:GetScript('OnSizeChanged')(auraBars.Holder)
auraBars:ClearAllPoints()
if not E.db.abm.player then
local attachTo
if db.aurabar.attachTo == 'BUFFS' then
attachTo = frame.Buffs
elseif db.aurabar.attachTo == 'DEBUFFS' then
attachTo = frame.Debuffs
end
local yOffset = 0;
if E.PixelMode then
if db.aurabar.anchorPoint == 'BELOW' then
yOffset = 1;
else
yOffset = -1;
end
end
local BarWidth = E.db.abm.playerw - db.width
local xCoord = attachTo == frame and POWERBAR_OFFSET * (anchorTo == 'BOTTOM' and 0 or -1) or 0
xCoord = xCoord + BarWidth
auraBars:SetPoint(anchorPoint..'LEFT', attachTo, anchorTo..'LEFT', (attachTo == frame and anchorTo == 'BOTTOM') and POWERBAR_OFFSET or 0, E.PixelMode and anchorPoint == -1 or yOffset)
auraBars:SetPoint(anchorPoint..'RIGHT', attachTo, anchorTo..'RIGHT', xCoord, E.PixelMode and -1 or yOffset)
else
auraBars:SetPoint(anchorPoint..'LEFT', auraBars.Holder, anchorTo..'LEFT')
auraBars:SetPoint(anchorPoint..'RIGHT', auraBars.Holder, anchorTo..'RIGHT', -POWERBAR_OFFSET, 0)
end
auraBars:SetAnchors()
frame:UpdateAllElements("AurabarsMovers_UpdateAllElements") E:CreateMover(auraBar.Holder, 'ElvUF_PetAuraMover', "Pet Aura Bars", nil, nil, nil, 'ALL,SOLO')
if auraBars.bars[1] and auraBars.bars[1]:GetWidth() ~= E.db.abm.playerw then auraBars.bars[1]:SetWidth(E.db.abm.playerw - auraBars.bars[1].statusBar.icon:GetWidth()) end UF:CreateAndUpdateUF('pet')
end end
function ABM:UpdateTarget(frame, db) function ABM:Configure_AuraBars(frame)
frame.db = db local unit = frame.unit
local POWERBAR_OFFSET = db.power.offset local db = frame.db
if not db.aurabar.enable then return end if not db.aurabar.enable then return end
if E.db.abm[unit] == nil then return end
local auraBars = frame.AuraBars
if frame and auraBars and auraBars.spacing then
auraBars.spacing = (E.PixelMode and -1 or 1) + E.db.abm.targetSpace
end
local anchorPoint, anchorTo = 'BOTTOM', 'TOP'
if db.aurabar.anchorPoint == 'BELOW' then
anchorPoint, anchorTo = 'TOP', 'BOTTOM'
end
--Set size of mover
auraBars.Holder:Width(E.db.abm.targetw)
auraBars.Holder:Height(20)
auraBars.Holder:GetScript('OnSizeChanged')(auraBars.Holder)
auraBars:ClearAllPoints()
if not E.db.abm.target then
local attachTo = frame
if db.aurabar.attachTo == 'BUFFS' then
attachTo = frame.Buffs
elseif db.aurabar.attachTo == 'DEBUFFS' then
attachTo = frame.Debuffs
elseif db.aurabar.attachTo == "PLAYER_AURABARS" and ElvUF_Player then
attachTo = ElvUF_Player.AuraBars
end
local yOffset = 0;
if E.PixelMode then
if db.aurabar.anchorPoint == 'BELOW' then
yOffset = 1;
else
yOffset = -1;
end
end
local BarWidth = E.db.abm.targetw - db.width
local xCoord = attachTo == frame and POWERBAR_OFFSET * (anchorTo == 'BOTTOM' and 0 or -1) or 0
xCoord = xCoord + BarWidth
auraBars:SetPoint(anchorPoint..'LEFT', attachTo, anchorTo..'LEFT', (attachTo == frame and anchorTo == 'BOTTOM') and POWERBAR_OFFSET or 0, E.PixelMode and anchorPoint == -1 or yOffset)
auraBars:SetPoint(anchorPoint..'RIGHT', attachTo, anchorTo..'RIGHT', xCoord, E.PixelMode and -1 or yOffset)
else
auraBars:SetPoint(anchorPoint..'LEFT', auraBars.Holder, anchorTo..'LEFT')
auraBars:SetPoint(anchorPoint..'RIGHT', auraBars.Holder, anchorTo..'RIGHT', -POWERBAR_OFFSET, 0)
end
auraBars:SetAnchors()
frame:UpdateAllElements("AurabarsMovers_UpdateAllElements")
end
function ABM:UpdateFocus(frame, db)
frame.db = db
local POWERBAR_OFFSET = db.power.offset local POWERBAR_OFFSET = db.power.offset
if not db.aurabar.enable then return end
local auraBars = frame.AuraBars local auraBars = frame.AuraBars
if frame and auraBars and auraBars.spacing then if frame and auraBars and auraBars.spacing then
auraBars.spacing = (E.PixelMode and -1 or 1) + E.db.abm.focusSpace auraBars.spacing = (E.PixelMode and -1 or 1) + E.db.abm[unit.."Space"]
end end
local anchorPoint, anchorTo = 'BOTTOM', 'TOP' local anchorPoint, anchorTo = 'BOTTOM', 'TOP'
if db.aurabar.anchorPoint == 'BELOW' then if db.aurabar.anchorPoint == 'BELOW' then
anchorPoint, anchorTo = 'TOP', 'BOTTOM' anchorPoint, anchorTo = 'TOP', 'BOTTOM'
end end
--Set size of mover --Set size of mover
auraBars.Holder:Width(E.db.abm.focusw) auraBars.Holder:Width(E.db.abm[unit.."w"])
auraBars.Holder:Height(20) auraBars.Holder:Height(20)
auraBars.Holder:GetScript('OnSizeChanged')(auraBars.Holder) auraBars.Holder:GetScript('OnSizeChanged')(auraBars.Holder)
auraBars:ClearAllPoints() auraBars:ClearAllPoints()
if not E.db.abm.focus then if not E.db.abm[unit] then
local attachTo local attachTo
if db.aurabar.attachTo == 'BUFFS' then if db.aurabar.attachTo == 'BUFFS' then
attachTo = frame.Buffs attachTo = frame.Buffs
...@@ -210,7 +113,7 @@ function ABM:UpdateFocus(frame, db) ...@@ -210,7 +113,7 @@ function ABM:UpdateFocus(frame, db)
end end
end end
local BarWidth = E.db.abm.focusw - db.width local BarWidth = E.db.abm[unit.."w"] - db.width
local xCoord = attachTo == frame and POWERBAR_OFFSET * (anchorTo == 'BOTTOM' and 0 or -1) or 0 local xCoord = attachTo == frame and POWERBAR_OFFSET * (anchorTo == 'BOTTOM' and 0 or -1) or 0
xCoord = xCoord + BarWidth xCoord = xCoord + BarWidth
...@@ -246,6 +149,11 @@ function ABM:MoverToggle() ...@@ -246,6 +149,11 @@ function ABM:MoverToggle()
else else
E:DisableMover("ElvUF_FocusAuraMover") E:DisableMover("ElvUF_FocusAuraMover")
end end
if E.db.abm.pet then
E:EnableMover("ElvUF_PetAuraMover")
else
E:DisableMover("ElvUF_PetAuraMover")
end
end end
function ABM:Initialize() function ABM:Initialize()
...@@ -253,10 +161,9 @@ function ABM:Initialize() ...@@ -253,10 +161,9 @@ function ABM:Initialize()
ABM:PlayerABmove() ABM:PlayerABmove()
ABM:TargetABmove() ABM:TargetABmove()
ABM:FocusABmove() ABM:FocusABmove()
ABM:PetABmove()
hooksecurefunc(UF, "Update_PlayerFrame", ABM.UpdatePlayer) hooksecurefunc(UF, "Configure_AuraBars", ABM.Configure_AuraBars)
hooksecurefunc(UF, "Update_TargetFrame", ABM.UpdateTarget)
hooksecurefunc(UF, "Update_FocusFrame", ABM.UpdateFocus)
self:RegisterEvent("PLAYER_TARGET_CHANGED", "ChangeTarget") self:RegisterEvent("PLAYER_TARGET_CHANGED", "ChangeTarget")
ABM:MoverToggle() ABM:MoverToggle()
......
...@@ -80,4 +80,30 @@ E.Options.args.unitframe.args.focus.args.aurabar.args.space = { ...@@ -80,4 +80,30 @@ E.Options.args.unitframe.args.focus.args.aurabar.args.space = {
get = function(info) return E.db.abm.focusSpace end, get = function(info) return E.db.abm.focusSpace end,
set = function(info, value) E.db.abm.focusSpace = value; UF:CreateAndUpdateUF('focus') end, set = function(info, value) E.db.abm.focusSpace = value; UF:CreateAndUpdateUF('focus') end,
} }
E.Options.args.unitframe.args.pet.args.aurabar.args.detach = {
order = 25,
type = "toggle",
name = '|cff30ee30'..L['Detach From Frame']..'|r',
get = function(info) return E.db.abm.pet end,
set = function(info, value) E.db.abm.pet = value; UF:CreateAndUpdateUF('pet'); ABM:MoverToggle() end,
}
E.Options.args.unitframe.args.pet.args.aurabar.args.width = {
order = 26,
type = "range",
name = '|cff30ee30'..L['Width']..'|r',
min = 50, max = 500, step = 1,
get = function(info) return E.db.abm.petw end,
set = function(info, value) E.db.abm.petw = value; UF:CreateAndUpdateUF('pet') end,
}
E.Options.args.unitframe.args.pet.args.aurabar.args.space = {
order = 27,
type = "range",
name = '|cff30ee30'..L["Vertical Spacing"]..'|r',
min = -10, max = 20, step = 1,
get = function(info) return E.db.abm.petSpace end,
set = function(info, value) E.db.abm.petSpace = value; UF:CreateAndUpdateUF('pet') end,
}
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