Verified Commit f0b3a00b authored by Repooc's avatar Repooc
Browse files

Enhanced Shadows - Unitframe Shadows Rewritten

Options regarding unitframe shadows have been reset due to the reworking of the code
parent 8a21c770
......@@ -60,30 +60,7 @@ V["sle"] = {
["points"] = {},
},
["shadows"] = {
["arena"] = false,
["arenaLegacy"] = false,
["boss"] = false,
["bossLegacy"] = false,
["focus"] = false,
["focusLegacy"] = false,
["focustarget"] = false,
["focustargetLegacy"] = false,
["party"] = false,
["partyLegacy"] = false,
["pet"] = false,
["petLegacy"] = false,
["pettarget"] = false,
["pettargetLegacy"] = false,
["player"] = false,
["playerLegacy"] = false,
["raid"] = false,
["raidLegacy"] = false,
["raid40"] = false,
["raid40Legacy"] = false,
["target"] = false,
["targetLegacy"] = false,
["targettarget"] = false,
["targettargetLegacy"] = false,
enable = true, -- TODO: Still need to implement this
["vehicle"] = false,
["actionbars"] = {
["bar1"] = false,
......
......@@ -795,8 +795,76 @@ P["sle"] = {
},
--Shadows
['shadows'] = {
['shadowcolor'] = { ['r'] = 0, ['g'] = 0, ['b'] = 0 },
['size'] = 3,
shadowcolor = { ['r'] = 0, ['g'] = 0, ['b'] = 0 },
size = 3,
unitframes = {
player = {
legacy = false,
health = false,
power = false,
classbar = false,
},
target = {
legacy = false,
health = false,
power = false,
},
targettarget = {
legacy = false,
health = false,
power = false,
},
targettargettarget = {
legacy = false,
health = false,
power = false,
},
focus = {
legacy = false,
health = false,
power = false,
},
focustarget = {
legacy = false,
health = false,
power = false,
},
pet = {
legacy = false,
health = false,
power = false,
},
pettarget = {
legacy = false,
health = false,
power = false,
},
boss = {
legacy = false,
health = false,
power = false,
},
arena = {
legacy = false,
health = false,
power = false,
},
party = {
legacy = false,
health = false,
power = false,
},
raid = {
legacy = false,
health = false,
power = false,
},
raid40 = {
legacy = false,
health = false,
power = false,
},
},
},
--Skins
["skins"] = {
......
local SLE, T, E, L, V, P, G = unpack(select(2, ...))
if SLE._Compatibility["ElvUI_NihilistUI"] then return end
local ES = SLE:NewModule('EnhancedShadows', 'AceEvent-3.0')
local UF, MM = SLE:GetElvModules('UnitFrames', 'Minimap')
local MM = E:GetModule('Minimap')
local Border, LastSize
local Abars = 10
--GLOBALS: hooksecurefunc
local _G = _G
local UnitAffectingCombat = UnitAffectingCombat
local SIDE_BUTTON = E.db.chat.hideChatToggles and 0 or 19
local Border
local Abars = 10
--Registered shadows table
ES.CreatedShadows = {}
......@@ -16,21 +16,6 @@ ES.DummyPanels = {}
--The table for frames groupped based on similariy
ES.FramesToShadow = {
["UFrames"] = {
--unit, FrameName var
{"player", "Player"},
{"target", "Target"},
{"targettarget", "TargetTarget"},
{"focus", "Focus"},
{"focustarget", "FocusTarget"},
{"pet", "Pet"},
{"pettarget", "PetTarget"},
},
["UGroups"] = {
--unit, FrameName var, number of frames
{"boss", "Boss", 5},
{"arena", "Arena", 5},
},
["Datapanels"] = {
["leftchat"] = "LeftChatDataPanel",
["rightchat"] = "RightChatDataPanel",
......@@ -75,139 +60,32 @@ function ES:RegisterShadow(shadow)
shadow.isRegistered = true
end
--Update shadows for UF, hooked to UF's own update function
function ES:UpdateFrame(frame, db)
if not frame then return end
local size = E.db.sle.shadows.size
if frame.Health and frame.Health.EnhShadow then
frame.Health.EnhShadow:SetOutside(frame.Health, size, size)
end
if frame.Power and frame.Power.EnhShadow then
frame.Power.EnhShadow:SetOutside(frame.Power, size, size)
end
if frame.EnhShadow then
frame.EnhShadow:SetOutside(frame, size, size)
end
end
--Creating shadows for provided frame
function ES:CreateFrameShadow(frame, parent, legacy)
function ES:CreateFrameShadow(frame, parent)
if not frame then return end
if not legacy then --If using new style with health and power having separated shadows
--UF Health
if frame.Health then
frame.Health:CreateShadow()
frame.Health.EnhShadow = frame.Health.shadow
frame.Health.shadow = nil
ES:RegisterShadow(frame.Health.EnhShadow)
frame.Health.EnhShadow:SetParent(frame.Health)
end
--UF Power
if frame.Power then
frame.Power:CreateShadow()
frame.Power.EnhShadow = frame.Power.shadow
frame.Power.shadow = nil
ES:RegisterShadow(frame.Power.EnhShadow)
frame.Power.EnhShadow:SetParent(frame.Power)
end
end
--if it is not UF at all or old way is enabled
if legacy or (not frame.Health and not frame.Power) then
frame:CreateShadow()
frame.EnhShadow = frame.shadow
frame.shadow = nil
ES:RegisterShadow(frame.EnhShadow)
if parent and parent ~= "none" then
frame.EnhShadow:SetParent(parent)
elseif not parent then
frame.EnhShadow:SetParent(frame)
end
frame:CreateShadow()
frame.EnhShadow = frame.shadow
frame.shadow = nil
ES:RegisterShadow(frame.EnhShadow)
if parent and parent ~= "none" then
frame.EnhShadow:SetParent(parent)
elseif not parent then
frame.EnhShadow:SetParent(frame)
end
end
function ES:CreateShadows()
--Unitframes--
do
for i = 1, #ES.FramesToShadow.UFrames do
local unit, name = unpack(ES.FramesToShadow.UFrames[i])
if E.private.sle.module.shadows[unit] then
ES:CreateFrameShadow(_G["ElvUF_"..name],_G["ElvUF_"..name], E.private.sle.module.shadows[unit.."Legacy"])
hooksecurefunc(UF, "Update_"..name.."Frame", ES.UpdateFrame)
end
end
for i = 1, #ES.FramesToShadow.UGroups do
local unit, name, num = unpack(ES.FramesToShadow.UGroups[i])
if E.private.sle.module.shadows[unit] then
for j = 1, num do
ES:CreateFrameShadow(_G["ElvUF_"..name..j], _G["ElvUF_"..name..j], E.private.sle.module.shadows[unit.."Legacy"])
hooksecurefunc(UF, "Update_"..name.."Frames", ES.UpdateFrame)
end
end
end
end
-- Party Shadows
if E.private.sle.module.shadows.party then
do
local header = _G['ElvUF_Party']
for i = 1, header:GetNumChildren() do
local group = select(i, header:GetChildren())
for j = 1, group:GetNumChildren() do
local unitbutton = select(j, group:GetChildren())
if unitbutton then
ES:CreateFrameShadow(unitbutton, "none", E.private.sle.module.shadows.partyLegacy)
-- hooksecurefunc(UF, "Update_PartyFrames", ES.UpdateFrame)
end
end
end
end
end
-- Raid Shadows
if E.private.sle.module.shadows.raid then
do
local header = _G['ElvUF_Raid']
for i = 1, header:GetNumChildren() do
local group = select(i, header:GetChildren())
for j = 1, group:GetNumChildren() do
local unitbutton = select(j, group:GetChildren())
if unitbutton then
ES:CreateFrameShadow(unitbutton, "none", E.private.sle.module.shadows.raidLegacy)
-- hooksecurefunc(UF, "Update_PartyFrames", ES.UpdateFrame)
end
end
end
end
end
-- Raid-40 Shadows
if E.private.sle.module.shadows.raid40 then
do
local header = _G['ElvUF_Raid40']
for i = 1, header:GetNumChildren() do
local group = select(i, header:GetChildren())
for j = 1, group:GetNumChildren() do
local unitbutton = select(j, group:GetChildren())
if unitbutton then
ES:CreateFrameShadow(unitbutton, "none", E.private.sle.module.shadows.raid40Legacy)
-- hooksecurefunc(UF, "Update_PartyFrames", ES.UpdateFrame)
end
end
end
end
end
--Actionbars--
do
for i=1, Abars do
if E.private.sle.module.shadows.actionbars["bar"..i] then ES:CreateFrameShadow( _G["ElvUI_Bar"..i], _G["ElvUI_Bar"..i].backdrop) end
if E.private.sle.module.shadows.actionbars["bar"..i] then
ES:CreateFrameShadow( _G["ElvUI_Bar"..i], _G["ElvUI_Bar"..i].backdrop)
end
if E.private.sle.module.shadows.actionbars["bar"..i.."buttons"] then
for j = 1, 12 do ES:CreateFrameShadow(_G["ElvUI_Bar"..i.."Button"..j], _G["ElvUI_Bar"..i.."Button"..j].backdrop) end
for j = 1, 12 do
ES:CreateFrameShadow(_G["ElvUI_Bar"..i.."Button"..j], _G["ElvUI_Bar"..i.."Button"..j].backdrop)
end
end
end
if E.private.sle.module.shadows.actionbars.stancebar then ES:CreateFrameShadow(_G["ElvUI_StanceBar"], _G["ElvUI_StanceBar"].backdrop) end
......@@ -232,8 +110,9 @@ function ES:CreateShadows()
end
end
end
--Datatexts--
for panel,enabled in pairs(E.private.sle.module.shadows.datatexts) do
for panel, enabled in pairs(E.private.sle.module.shadows.datatexts) do
if enabled then
if panel == "leftchat" then
ES.DummyPanels.LeftChat = CreateFrame("Frame", nil, _G[ES.FramesToShadow.Datapanels[panel]])
......
local SLE, T, E, L, V, P, G = unpack(select(2, ...))
local SUF = SLE:GetModule('UnitFrames');
local UF = E:GetModule('UnitFrames');
function SUF:Configure_ClassBar(frame)
local db = E.db.sle.shadows
local bars = frame[frame.ClassBar]
if not bars then return end
local r, g, b = db.shadowcolor.r, db.shadowcolor.g, db.shadowcolor.b
local offset = (E.PixelMode and db.size) or (db.size + 1)
if frame.SLCLASSBAR_ENHSHADOW then
if not bars.backdrop.enhshadow then
bars.backdrop.enhshadow = bars.backdrop:CreateShadow(4, true)
end
bars.backdrop.enhshadow:SetFrameLevel(bars.backdrop:GetFrameLevel())
if frame.SLLEGACY_ENHSHADOW then
bars.backdrop.enhshadow:SetFrameStrata('BACKGROUND')
else
bars.backdrop.enhshadow:SetFrameStrata(bars.backdrop:GetFrameStrata())
end
bars.backdrop.enhshadow:SetOutside(bars.backdrop.enhshadow:GetParent(), offset, offset, nil, true)
bars.backdrop.enhshadow:SetBackdrop({
edgeFile = E.LSM:Fetch('border', 'ElvUI GlowBorder'), edgeSize = db.size > 3 and db.size or 3,
-- insets = {left = E:Scale(5), right = E:Scale(5), top = E:Scale(5), bottom = E:Scale(5)}, --! Don't see a need for this
})
bars.backdrop.enhshadow:SetBackdropColor(r, g, b, 0)
bars.backdrop.enhshadow:SetBackdropBorderColor(r, g, b, 0.9)
bars.backdrop.enhshadow:Hide()
else
if bars.backdrop.enhshadow then
bars.backdrop.enhshadow:Kill()
bars.backdrop.enhshadow = nil
end
end
if bars.backdrop.enhshadow then
if frame.USE_MINI_CLASSBAR and not frame.CLASSBAR_DETACHED then
if frame.db.classbar.fill == 'spaced' then
bars.backdrop.enhshadow:Show()
else
bars.backdrop.enhshadow:Hide()
end
elseif not frame.CLASSBAR_DETACHED then
bars.backdrop.enhshadow:Hide()
else
bars.backdrop.enhshadow:Show()
end
end
if frame.ClassBar == 'ClassPower' or frame.ClassBar == 'Runes' then
local maxBars = max(UF['classMaxResourceBar'][E.myclass] or 0, _G.MAX_COMBO_POINTS)
for i = 1, maxBars do
if frame.SLCLASSBAR_ENHSHADOW and frame.USE_MINI_CLASSBAR then
if not bars[i].backdrop.enhshadow then
bars[i].backdrop.enhshadow = bars[i].backdrop:CreateShadow(4, true)
end
bars[i].backdrop.enhshadow:SetFrameLevel(bars[i].backdrop:GetFrameLevel())
if frame.SLLEGACY_ENHSHADOW then
bars[i].backdrop.enhshadow:SetFrameStrata('BACKGROUND')
else
bars[i].backdrop.enhshadow:SetFrameStrata(bars[i].backdrop:GetFrameStrata())
end
bars[i].backdrop.enhshadow:SetOutside(bars[i].backdrop.enhshadow:GetParent(), offset, offset, nil, true)
bars[i].backdrop.enhshadow:SetBackdrop({
edgeFile = E.LSM:Fetch('border', 'ElvUI GlowBorder'), edgeSize = db.size > 3 and db.size or 3,
-- insets = {left = E:Scale(5), right = E:Scale(5), top = E:Scale(5), bottom = E:Scale(5)}, --! Don't see a need for this
})
bars[i].backdrop.enhshadow:SetBackdropColor(r, g, b, 0)
bars[i].backdrop.enhshadow:SetBackdropBorderColor(r, g, b, 0.9)
bars[i].backdrop.enhshadow:Hide()
if frame.USE_MINI_CLASSBAR then
bars[i].backdrop.enhshadow:Show()
end
else
if bars[i].backdrop.enhshadow then
bars[i].backdrop.enhshadow:Kill()
bars[i].backdrop.enhshadow = nil
end
end
end
end
end
local SLE, T, E, L, V, P, G = unpack(select(2, ...))
local SUF = SLE:GetModule('UnitFrames');
function SUF:Configure_Health(frame)
local health = frame.Health
local db = E.db.sle.shadows
local r, g, b = db.shadowcolor.r, db.shadowcolor.g, db.shadowcolor.b
local offset = (E.PixelMode and db.size) or (db.size + 1)
if frame.SLHEALTH_ENHSHADOW then
if not health.backdrop.enhshadow then
health.backdrop.enhshadow = frame:CreateShadow(4, true)
end
health.backdrop.enhshadow:SetFrameLevel(health.backdrop:GetFrameLevel())
if frame.SLLEGACY_ENHSHADOW then
health.backdrop.enhshadow:SetFrameStrata('BACKGROUND')
else
health.backdrop.enhshadow:SetFrameStrata(health.backdrop:GetFrameStrata())
end
health.backdrop.enhshadow:SetOutside(frame.TargetGlow, offset-E.Border-3, offset-E.Border-3, nil, true)
health.backdrop.enhshadow:SetBackdrop({
edgeFile = E.LSM:Fetch('border', 'ElvUI GlowBorder'), edgeSize = db.size > 2 and db.size or 2,
-- insets = {left = E:Scale(5), right = E:Scale(5), top = E:Scale(5), bottom = E:Scale(5)}, --! Don't see a need for this
})
health.backdrop.enhshadow:SetBackdropColor(r, g, b, 0)
health.backdrop.enhshadow:SetBackdropBorderColor(r, g, b, 0.9)
health.backdrop.enhshadow:Hide()
elseif not frame.SLHEALTH_ENHSHADOW then
if health.backdrop.enhshadow then
health.backdrop.enhshadow:Kill()
health.backdrop.enhshadow = nil
end
end
if frame.SLHEALTH_ENHSHADOW then
health.backdrop.enhshadow:Show()
end
end
<Ui xmlns="http://www.blizzard.com/wow/ui/">
<Script file='health.lua'/>
<Script file='power.lua'/>
<Script file='classbars.lua'/>
</Ui>
\ No newline at end of file
local SLE, T, E, L, V, P, G = unpack(select(2, ...))
local SUF = SLE:GetModule('UnitFrames');
function SUF:Configure_Power(frame)
local power = frame.Power
local db = E.db.sle.shadows
local r, g, b = db.shadowcolor.r, db.shadowcolor.g, db.shadowcolor.b
local offset = (E.PixelMode and db.size) or (db.size + 1)
if frame.SLPOWER_ENHSHADOW then
if not power.backdrop.enhshadow then
power.backdrop.enhshadow = power.backdrop:CreateShadow(4, true)
end
power.backdrop.enhshadow:SetFrameLevel(power.backdrop:GetFrameLevel())
if frame.SLLEGACY_ENHSHADOW then
power.backdrop.enhshadow:SetFrameStrata('BACKGROUND')
else
power.backdrop.enhshadow:SetFrameStrata(power.backdrop:GetFrameStrata())
end
power.backdrop.enhshadow:SetOutside(power.backdrop.enhshadow:GetParent(), offset, offset, nil, true)
power.backdrop.enhshadow:SetBackdrop({
edgeFile = E.LSM:Fetch('border', 'ElvUI GlowBorder'), edgeSize = db.size > 3 and db.size or 3,
-- insets = {left = E:Scale(5), right = E:Scale(5), top = E:Scale(5), bottom = E:Scale(5)}, --! Don't see a need for this
})
power.backdrop.enhshadow:SetBackdropColor(r, g, b, 0)
power.backdrop.enhshadow:SetBackdropBorderColor(r, g, b, 0.9)
power.backdrop.enhshadow:Hide()
elseif not frame.SLPOWER_ENHSHADOW then
if power.backdrop.enhshadow then
power.backdrop.enhshadow:Kill()
power.backdrop.enhshadow = nil
end
end
if frame.USE_POWERBAR and frame.SLPOWER_ENHSHADOW then
if frame.POWERBAR_DETACHED then
power.backdrop.enhshadow:Show()
else
if frame.db.power.width ~= 'fill' then
power.backdrop.enhshadow:Show()
elseif not frame.SLHEALTH_ENHSHADOW then
power.backdrop.enhshadow:Show()
else
power.backdrop.enhshadow:Hide()
end
end
end
end
local SLE, T, E, L, V, P, G = unpack(select(2, ...))
local SUF = SLE:GetModule("UnitFrames")
local UF = E:GetModule('UnitFrames');
--GLOBALS: hooksecurefunc
local _G = _G
function SUF:Construct_ArenaFrame()
if not E.db.unitframe.units.arena.enable then return end
SUF:ArrangeArena()
end
function SUF:ArrangeArena()
local enableState = E.db.unitframe.units.arena.enable
for i = 1, 5 do
local frame = _G["ElvUF_Arena"..i]
local db = E.db.sle.shadows.unitframes[frame.unitframeType]
do
frame.SLHEALTH_ENHSHADOW = enableState and db.health or enableState
frame.SLPOWER_ENHSHADOW = enableState and db.power or enableState
frame.SLLEGACY_ENHSHADOW = enableState and db.legacy or enableState
end
-- Health
SUF:Configure_Health(frame)
-- Power
SUF:Configure_Power(frame)
frame:UpdateAllElements("SLE_UpdateAllElements")
end
end
function SUF:InitArena()
SUF:Construct_ArenaFrame()
hooksecurefunc(UF, "Update_ArenaFrames", function(_, frame)
if frame.unitframeType == 'arena' then SUF:ArrangeArena() end
end)
end
local SLE, T, E, L, V, P, G = unpack(select(2, ...))
local SUF = SLE:GetModule("UnitFrames")
local UF = E:GetModule('UnitFrames');
--GLOBALS: hooksecurefunc
local _G = _G
function SUF:Construct_BossFrame()
if not E.db.unitframe.units.boss.enable then return end
SUF:ArrangeBoss()
end
function SUF:ArrangeBoss()
local enableState = E.db.unitframe.units.boss.enable
for i = 1, 5 do
local frame = _G["ElvUF_Boss"..i]
local db = E.db.sle.shadows.unitframes[frame.unitframeType]
do
frame.SLHEALTH_ENHSHADOW = enableState and db.health or enableState
frame.SLPOWER_ENHSHADOW = enableState and db.power or enableState
frame.SLLEGACY_ENHSHADOW = enableState and db.legacy or enableState
end
-- Health