From cee87b24330844041ff38c2aba72c7c1444866e8 Mon Sep 17 00:00:00 2001 From: Dusk-92 Date: Thu, 3 Sep 2026 11:17:16 +0200 Subject: [PATCH] Remove permanent dark nameplate callback --- mods/dark-ui-elements.lua | 50 +++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 7 deletions(-) diff --git a/mods/dark-ui-elements.lua b/mods/dark-ui-elements.lua index 3b86e2d..ee31f3c 100644 --- a/mods/dark-ui-elements.lua +++ b/mods/dark-ui-elements.lua @@ -367,13 +367,49 @@ module.enable = function(self) table.insert(BNP.libnameplate.OnInit, ReapplyBNPDarkMode) table.insert(BNP.libnameplate.OnShow, ReapplyBNPDarkMode) else - -- Plain ShaguTweaks / no compatible BNP provider: preserve the original - -- libnameplate behavior and let the lazy library activate automatically. - table.insert(ShaguTweaks.libnameplate.OnUpdate, function() - if not this.darkened then - this.darkened = true - DarkenFrame(this) + -- Native ShaguTweaks nameplates only need darkening when a plate is first + -- discovered or shown. Avoid keeping a per-frame libnameplate callback + -- alive just to test the permanent "darkened" marker. + local pending = {} + local updater = CreateFrame("Frame") + + local function StopUpdaterIfIdle() + if not next(pending) then + updater:SetScript("OnUpdate", nil) end - end) + end + + local function ReapplyShaguDarkMode(plate) + plate = plate or this + if not plate or not plate:IsShown() then return end + + plate.darkened = nil + DarkenFrame(plate) + plate.darkened = true + + -- Some clients restore nameplate textures immediately after OnShow. + -- Re-apply once after that short window, then stop completely. + pending[plate] = GetTime() + 0.08 + if not updater:GetScript("OnUpdate") then + updater:SetScript("OnUpdate", function() + local now = GetTime() + local current, due + for current, due in pairs(pending) do + if now >= due then + pending[current] = nil + if current and current:IsShown() then + current.darkened = nil + DarkenFrame(current) + current.darkened = true + end + end + end + StopUpdaterIfIdle() + end) + end + end + + table.insert(ShaguTweaks.libnameplate.OnInit, ReapplyShaguDarkMode) + table.insert(ShaguTweaks.libnameplate.OnShow, ReapplyShaguDarkMode) end end