Skip to content

Commit

Permalink
Update Timer bar templating, add to nameplate bars
Browse files Browse the repository at this point in the history
  • Loading branch information
Wutname1 committed Aug 17, 2024
1 parent 20cb8d3 commit 225472a
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 10 deletions.
52 changes: 42 additions & 10 deletions Core/Skins/Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,6 @@ function module.RemoveAllTextures(frame)
end
end

---comment
---@param frame FrameExpanded
---@param appearanceMode? AppearanceMode
function module.SetTemplate(frame, appearanceMode)
Expand All @@ -266,23 +265,27 @@ function module.SetTemplate(frame, appearanceMode)
local edgeSize = 1
if frame.appearanceMode == AppearanceMode.NoBackdrop then
frame:SetBackdrop(nil)
elseif frame.appearanceMode == AppearanceMode.NoBorder then
frame:SetBackdrop({
bgFile = Settings.edgeFile,
})
else
frame:SetBackdrop({
bgFile = Settings.edgeFile,
edgeFile = Settings.edgeFile,
edgeSize = edgeSize,
})
end

if frame.appearanceMode == AppearanceMode.Dark then
frame:SetBackdropColor(unpack(Settings.BackdropColorDark))
elseif frame.appearanceMode == AppearanceMode.Light then
frame:SetBackdropColor(unpack(Settings.BackdropColorLight))
else
frame:SetBackdropColor(unpack(Settings.BackdropColor))
end
if frame.appearanceMode == AppearanceMode.Dark then
frame:SetBackdropColor(unpack(Settings.BackdropColorDark))
elseif frame.appearanceMode == AppearanceMode.Light then
frame:SetBackdropColor(unpack(Settings.BackdropColorLight))
else
frame:SetBackdropColor(unpack(Settings.BackdropColor))
end

frame:SetBackdropBorderColor(unpack(Settings.MutedClassColor))
if frame.appearanceMode ~= AppearanceMode.NoBorder then frame:SetBackdropBorderColor(unpack(Settings.MutedClassColor)) end
end

module.Objects = {}
Expand Down Expand Up @@ -382,14 +385,42 @@ function module.Objects.StatusBar(statusBarFrame)
local bar = statusBarFrame.Bar
if not bar or bar.backdrop then return end

module.SetTemplate(bar)
-- Create a background frame
local bgFrame = CreateFrame('Frame', nil, bar)
bgFrame:SetFrameLevel(bar:GetFrameLevel() - 1) -- Set background frame level lower than the bar
bgFrame:SetAllPoints(bar)

-- Create a border frame
local borderFrame = CreateFrame('Frame', nil, bar)
borderFrame:SetFrameLevel(bar:GetFrameLevel() + 1) -- Set border frame level higher than the bar
borderFrame:SetAllPoints(bar)

-- Set up the background frame
module.SetTemplate(bgFrame, 'NoBackdrop')
bgFrame:SetBackdrop({
bgFile = Settings.edgeFile,
})
bgFrame:SetBackdropColor(unpack(Settings.BackdropColor))

-- Set up the border frame
module.SetTemplate(borderFrame, 'NoBorder')
borderFrame:SetBackdrop({
edgeFile = Settings.edgeFile,
edgeSize = 1,
})
borderFrame:SetBackdropBorderColor(unpack(Settings.MutedClassColor))

-- Hide default textures
if bar.BGLeft then bar.BGLeft:SetAlpha(0) end
if bar.BGRight then bar.BGRight:SetAlpha(0) end
if bar.BGCenter then bar.BGCenter:SetAlpha(0) end
if bar.BorderLeft then bar.BorderLeft:SetAlpha(0) end
if bar.BorderRight then bar.BorderRight:SetAlpha(0) end
if bar.BorderCenter then bar.BorderCenter:SetAlpha(0) end

-- Store references
bar.bgFrame = bgFrame
bar.borderFrame = borderFrame
end

---Skins a object
Expand Down Expand Up @@ -434,6 +465,7 @@ end
--Skins a frame and all its children
---@param widget Frame
function module.SkinWidgets(widget)
if not widget or not widget.widgetType then return end
---@diagnostic disable-next-line: undefined-field
local widgetFunc = module.Objects[GetWidgetVisualizationTypeKey(widget.widgetType)]
if widgetFunc then widgetFunc(widget) end
Expand Down
4 changes: 4 additions & 0 deletions Modules/Nameplates.lua
Original file line number Diff line number Diff line change
Expand Up @@ -469,6 +469,10 @@ local NameplateCallback = function(self, event, unit)
self.widgetContainer:SetParent(self)
self.widgetContainer:ClearAllPoints()
self.widgetContainer:SetPoint('TOP', self, 'BOTTOM')

for _, widget in pairs(self.widgetContainer.widgetFrames) do
if widget then SUI.Skins.SkinWidgets(widget) end
end
end
return
end
Expand Down

0 comments on commit 225472a

Please sign in to comment.