Make BNP dark mode compatibility version-independent
This commit is contained in:
@@ -314,15 +314,61 @@ module.enable = function(self)
|
|||||||
DarkenFrame(_G["GameTooltipStatusBarBackdrop"])
|
DarkenFrame(_G["GameTooltipStatusBarBackdrop"])
|
||||||
end)
|
end)
|
||||||
|
|
||||||
-- BlizzNameplatesPlus v1.0.8 already re-applies ShaguTweaks dark mode
|
-- Prefer BlizzNameplatesPlus' own nameplate provider whenever available.
|
||||||
-- through its own nameplate library. In that exact known-compatible version,
|
-- This is capability-based instead of version-based, so BNP updates keep
|
||||||
-- do not register a second ShaguTweaks nameplate scanner callback.
|
-- working as long as its public libnameplate callback API remains available.
|
||||||
local bnpOwnsDarkNameplates = BNP
|
local bnpNameplates = BNP
|
||||||
and BNP.version == "1.0.8"
|
|
||||||
and BNP.libnameplate
|
and BNP.libnameplate
|
||||||
and BNP.shaguCompat
|
and BNP.libnameplate.OnInit
|
||||||
|
and BNP.libnameplate.OnShow
|
||||||
|
|
||||||
if not bnpOwnsDarkNameplates then
|
if bnpNameplates then
|
||||||
|
local pending = {}
|
||||||
|
local updater = CreateFrame("Frame")
|
||||||
|
|
||||||
|
local function StopUpdaterIfIdle()
|
||||||
|
if not next(pending) then
|
||||||
|
updater:SetScript("OnUpdate", nil)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
local function ReapplyBNPDarkMode(plate)
|
||||||
|
plate = plate or this
|
||||||
|
if not plate or not plate:IsShown() then return end
|
||||||
|
if plate.darkened then return end
|
||||||
|
|
||||||
|
plate.darkened = true
|
||||||
|
DarkenFrame(plate)
|
||||||
|
|
||||||
|
-- Blizzard can restore some nameplate textures immediately after OnShow.
|
||||||
|
-- Queue one delayed pass, then stop completely. If BNP's own Shagu
|
||||||
|
-- compatibility already darkened the plate first, the marker above makes
|
||||||
|
-- this path a no-op and avoids duplicate work.
|
||||||
|
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(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()
|
table.insert(ShaguTweaks.libnameplate.OnUpdate, function()
|
||||||
if not this.darkened then
|
if not this.darkened then
|
||||||
this.darkened = true
|
this.darkened = true
|
||||||
|
|||||||
Reference in New Issue
Block a user