Skip to content

Commit

Permalink
Teach ElvUI skinning about parentKeys instead of just frame names (#958)
Browse files Browse the repository at this point in the history
* Teach ElvUI skinning about parentKeys instead of just frame names

This fixes the skinning issues presented with the TWW UI rework (#937) which removed `TRP3_TargetFrameCaptionPanel` but instead use the parentKey of `Header` from `TRP3_TargetFrame`.
To use these for skinning, you use "FrameName.ParentKeyName" within `SKINNABLE_FRAMES` for ElvUI.

There's also some minor additions of semi-colons where they were missing.

* Apply suggestions from code review

Meorawr, the one who floats like a butterfly and stings like a bee.

Co-authored-by: Daniel Yates <[email protected]>

---------

Co-authored-by: Daniel Yates <[email protected]>
  • Loading branch information
Raenore and Meorawr authored Jul 5, 2024
1 parent 37fdd24 commit 5078efe
Showing 1 changed file with 16 additions and 9 deletions.
25 changes: 16 additions & 9 deletions totalRP3/Modules/TooltipSkins/ElvUI.lua
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ TRP3_API.module.registerModule({

local SKINNABLE_FRAMES = {
"TRP3_TargetFrame",
"TRP3_TargetFrameCaptionPanel",
"TRP3_TargetFrame.Header",
"TRP3_GlanceBar",
"TRP3_GlanceBarSlot1",
"TRP3_GlanceBarSlot2",
Expand Down Expand Up @@ -84,14 +84,14 @@ TRP3_API.module.registerModule({
-- Register configuration handlers to apply the changes
TRP3_API.configuration.registerHandler(CONFIG.SKIN_TOOLTIPS, function()
if TRP3_API.configuration.getValue(CONFIG.SKIN_TOOLTIPS) then
skinTooltips()
skinTooltips();
else
TRP3_API.popup.showConfirmPopup(loc.CO_UI_RELOAD_WARNING, ReloadUI);
end
end);
TRP3_API.configuration.registerHandler(CONFIG.SKIN_TARGET_FRAME, function()
if TRP3_API.configuration.getValue(CONFIG.SKIN_TARGET_FRAME) then
skinTargetFrame()
skinTargetFrame();
else
TRP3_API.popup.showConfirmPopup(loc.CO_UI_RELOAD_WARNING, ReloadUI);
end
Expand All @@ -108,24 +108,31 @@ TRP3_API.module.registerModule({
for _, tooltip in pairs(TOOLTIPS) do
if _G[tooltip] then
-- We check that the tooltip exists and then add it to ElvUI
TT:SecureHookScript(_G[tooltip], 'OnShow', 'SetStyle')
TT:SecureHookScript(_G[tooltip], 'OnShow', 'SetStyle');
end
end
end

-- 9.2 changed Tooltips to use NineSlice but TargetFrame doesn't use it, therefore we need to use the old styling function
local function SetStyleForTargetFrame(tt)
if not tt or (tt == _G["ElvUI"][1].ScanTooltip or tt.IsEmbedded or not tt.SetTemplate or not tt.SetBackdrop) or tt:IsForbidden() then return end
tt.customBackdropAlpha = TT.db.colorAlpha
tt:SetTemplate('Transparent')
if not tt or (tt == _G["ElvUI"][1].ScanTooltip or tt.IsEmbedded or not tt.SetTemplate or not tt.SetBackdrop) or tt:IsForbidden() then return; end
tt.customBackdropAlpha = TT.db.colorAlpha;
tt:SetTemplate('Transparent');
end

function skinTargetFrame()
-- Go through each skinnable frames from our table
for _, frame in pairs(SKINNABLE_FRAMES) do
local parentKey;
frame, parentKey = string.split(".", frame, 2);

if _G[frame] then
-- We check that the frame exists and then add it to ElvUI
TT:SecureHookScript(_G[frame], 'OnShow', SetStyleForTargetFrame)
-- If parentKey is not nil, check if a frame exists with said parentKey within this frame
if parentKey ~= nil and _G[frame][parentKey] then
TT:SecureHookScript(_G[frame][parentKey], 'OnShow', SetStyleForTargetFrame);
elseif parentKey == nil then
TT:SecureHookScript(_G[frame], 'OnShow', SetStyleForTargetFrame);
end
end
end
end
Expand Down

0 comments on commit 5078efe

Please sign in to comment.