Skip to content

Commit

Permalink
Update Toolkit.lua
Browse files Browse the repository at this point in the history
  • Loading branch information
noname08662 authored Aug 28, 2024
1 parent a9cbaf0 commit 7c831ba
Showing 1 changed file with 16 additions and 15 deletions.
31 changes: 16 additions & 15 deletions Optionals/Toolkit.lua
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,7 @@ local unpack, type, select, getmetatable = unpack, type, select, getmetatable
--WoW API / Variables
local CreateFrame = CreateFrame

local globalShadow = false
local globalShadowSize, globalShadowR, globalShadowG, globalShadowB, globalShadowA = 1, 1, 1, 1, 1
E.pendingShadowUpdate = {}

local backdropr, backdropg, backdropb, backdropa, borderr, borderg, borderb = 0, 0, 0, 1, 0, 0, 0
local function GetTemplate(template, isUnitFrameElement)
Expand Down Expand Up @@ -80,17 +79,23 @@ local function SetInside(obj, anchor, xOffset, yOffset, anchor2)
obj:Point("BOTTOMRIGHT", anchor2 or anchor, "BOTTOMRIGHT", -xOffset, yOffset)
end

function E:CreateGlobalShadow(frame)
if frame.globalShadow then return end
function E:CreateGlobalShadow(db, frame)
if frame.globalShadow or not db.enabled then return end

local size = db.size
local r, g, b, a = unpack(db.color or {0,0,0,0.8})

local shadow = CreateFrame("Frame", nil, frame)
local strata = frame:GetFrameStrata()

if strata ~= 'UNKNOWN' then shadow:SetFrameStrata(strata) end

shadow:SetFrameLevel(1)
shadow:SetOutside(frame, globalShadowSize or 1, globalShadowSize or 1)
shadow:SetBackdrop({edgeFile = LSM:Fetch("border", "ElvUI GlowBorder"), edgeSize = E:Scale(globalShadowSize or 2)})
shadow:SetOutside(frame, size, size)
shadow:SetBackdrop({edgeFile = LSM:Fetch("border", "ElvUI GlowBorder"), edgeSize = E:Scale(size)})
shadow:SetBackdropColor(0, 0, 0, 0)
shadow:SetBackdropBorderColor(globalShadowR or 0, globalShadowG or 0, globalShadowB or 0, globalShadowA or 0.8)
shadow:SetBackdropBorderColor(r, g, b, a)

frame.globalShadow = shadow
end

Expand Down Expand Up @@ -155,16 +160,12 @@ local function SetTemplate(frame, template, glossTex, ignoreUpdates, forcePixelM
end

--GLOBAL SHADOW--
local db = E.db.Extras and E.db.Extras.general["GeneralMisc."].GlobalShadow
local db = E.globalShadow

if db then
globalShadowSize = db.size
globalShadowR, globalShadowG, globalShadowB, globalShadowA = unpack(db.color or {0,0,0,0.8})
globalShadow = db.enabled
end

if globalShadow then
E:CreateGlobalShadow(frame)
E:CreateGlobalShadow(db, frame)
elseif E.pendingShadowUpdate then
E.pendingShadowUpdate[frame] = true
end
--GLOBAL SHADOW--
end
Expand Down

0 comments on commit 7c831ba

Please sign in to comment.