Skip to content

Commit

Permalink
Added StatusBar and Widget Skinning
Browse files Browse the repository at this point in the history
Enhanced the skinning module with two new functions: one for status bars and another for widgets. The status bar function applies a template to the bar, setting alpha values of various elements to 0. The widget function identifies the type of widget and applies appropriate skinning. Also added event handlers in BlizzMovers.lua to update UI widgets when entering the world or on UI updates.
  • Loading branch information
Wutname1 committed Aug 11, 2024
1 parent 8227124 commit 66bf5a5
Show file tree
Hide file tree
Showing 2 changed files with 50 additions and 0 deletions.
30 changes: 30 additions & 0 deletions Core/Skins/Core.lua
Original file line number Diff line number Diff line change
Expand Up @@ -326,6 +326,7 @@ function module.Objects.Tab(widget, mode, NormalTex, regionsToFade)

if widget.text then widget:SetNormalFontObject(GameFontHighlightSmall) end
end

function module.Objects.CheckBox(button, mode, NormalTex, regionsToFade)
-- local check = button.check
-- local checkbg = button.checkbg
Expand Down Expand Up @@ -372,6 +373,20 @@ function module.Objects.Button(button, mode, NormalTex, regionsToFade)
button.isSkinned = true
end

function module.Objects.StatusBar(statusBarFrame)
local bar = statusBarFrame.Bar
if not bar or bar.backdrop then return end

module.SetTemplate(bar)

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
end

---Skins a object
---@param ObjType string
---@param object FrameExpanded
Expand Down Expand Up @@ -404,6 +419,21 @@ function module.SkinObj(ObjType, object, mode, component)
object.isSkinned = true
end

local function GetWidgetVisualizationTypeKey(value)
for k, v in pairs(Enum.UIWidgetVisualizationType) do
if v == value then return k end
end
return nil -- Return nil if no matching key is found
end

--Skins a frame and all its children
---@param widget Frame
function module.SkinWidgets(widget)
---@diagnostic disable-next-line: undefined-field
local widgetFunc = module.Objects[GetWidgetVisualizationTypeKey(widget.widgetType)]
if widgetFunc then widgetFunc(widget) end
end

module.Registry = {}

local function functionAddToOptions(name, settings)
Expand Down
20 changes: 20 additions & 0 deletions Modules/Artwork/BlizzMovers.lua
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,26 @@ local function TopCenterContainer()
AttachToHolder(_G['UIWidgetTopCenterContainerFrame'], holder)
hooksecurefunc(_G['UIWidgetTopCenterContainerFrame'], 'SetPoint', ResetPosition)
MoveIt:CreateMover(holder, 'TopCenterContainer', 'Top center container', nil, 'Blizzard UI')
for _, widget in pairs(_G['UIWidgetTopCenterContainerFrame'].widgetFrames) do
SUI.Skins.SkinWidgets(widget)
end
module:RegisterEvent('PLAYER_ENTERING_WORLD')
module:RegisterEvent('UPDATE_ALL_UI_WIDGETS')
module:RegisterEvent('UPDATE_UI_WIDGET')
end

function module:UPDATE_UI_WIDGET()
module:UPDATE_ALL_UI_WIDGETS()
end
function module:UPDATE_ALL_UI_WIDGETS()
for _, widget in pairs(_G['UIWidgetTopCenterContainerFrame'].widgetFrames) do
SUI.Skins.SkinWidgets(widget)
end
end

function module:PLAYER_ENTERING_WORLD()
print('PLAYER_ENTERING_WORLD')
module:UPDATE_ALL_UI_WIDGETS()
end

-- This is the main inpoint
Expand Down

0 comments on commit 66bf5a5

Please sign in to comment.