forked from Dusk/ShaguTweaks-ClassicAPI
Release 3.8.6: module fixes and native timer optimizations
This commit is contained in:
@@ -121,7 +121,7 @@ local function SetupModernPowerBars()
|
||||
if not state then return end
|
||||
local unit = bar.unit or state.unit
|
||||
if not ShaguTweaks.ModernClassColors or not UnitExists(unit) then
|
||||
state.background:Hide()
|
||||
if state.background:IsShown() then state.background:Hide() end
|
||||
return
|
||||
end
|
||||
-- The druid's secondary bar stays mana while the primary bar is rage/energy.
|
||||
@@ -132,24 +132,37 @@ local function SetupModernPowerBars()
|
||||
local suffix = state.family
|
||||
if suffix == "Player" then
|
||||
suffix = ""
|
||||
local _, class = UnitClass(unit)
|
||||
-- Keep the retail energy variant for combo-point users.
|
||||
if powerType == 3 and (class == "ROGUE" or class == "DRUID") then
|
||||
suffix = "Class"
|
||||
if powerType == 3 then
|
||||
local _, class = UnitClass(unit)
|
||||
if class == "ROGUE" or class == "DRUID" then suffix = "Class" end
|
||||
end
|
||||
end
|
||||
-- Vanilla mana slots are rectangular. Retail target/small-frame fills
|
||||
-- have cut-out corners that leave a visible wedge inside those slots.
|
||||
-- Use the native rectangular mana artwork for every mana frame.
|
||||
if powerType == 0 then suffix = "Class" end
|
||||
bar:SetStatusBarTexture(texture .. suffix)
|
||||
state.background:Show()
|
||||
if state.styleTexture ~= texture or state.styleSuffix ~= suffix then
|
||||
state.styleTexture, state.styleSuffix = texture, suffix
|
||||
state.wantedTexture = texture .. suffix
|
||||
end
|
||||
local wanted = state.wantedTexture
|
||||
local current = bar:GetStatusBarTexture()
|
||||
if not current or current:GetTexture() ~= wanted then bar:SetStatusBarTexture(wanted) end
|
||||
if not state.background:IsShown() then state.background:Show() end
|
||||
-- Call the method captured before our hook to avoid recursive updates.
|
||||
state.setColor(bar, 1, 1, 1, 1)
|
||||
local r, g, b, a = bar:GetStatusBarColor()
|
||||
if not r or math.abs(r - 1) > .0001 or math.abs(g - 1) > .0001
|
||||
or math.abs(b - 1) > .0001 or not a or math.abs(a - 1) > .0001 then
|
||||
state.setColor(bar, 1, 1, 1, 1)
|
||||
end
|
||||
else
|
||||
-- Unknown/custom power types retain their original texture and tint.
|
||||
bar:SetStatusBarTexture(state.originalTexture)
|
||||
state.background:Hide()
|
||||
local current = bar:GetStatusBarTexture()
|
||||
if not current or current:GetTexture() ~= state.originalTexture then
|
||||
bar:SetStatusBarTexture(state.originalTexture)
|
||||
end
|
||||
if state.background:IsShown() then state.background:Hide() end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -190,7 +203,17 @@ local function SetupModernPowerBars()
|
||||
end
|
||||
-- Vanilla refreshes power type here. Appending preserves the normal frame
|
||||
-- updates, including shapeshifts and targets with a different power type.
|
||||
hooksecurefunc("UnitFrame_UpdateManaType", RefreshPowerBars)
|
||||
hooksecurefunc("UnitFrame_UpdateManaType", function(frame)
|
||||
-- Clients use either an explicit unit frame or the legacy `this` context.
|
||||
if type(frame) ~= "table" then frame = this end
|
||||
if not frame then return end
|
||||
if bars[frame] then ApplyPowerStyle(frame); return end
|
||||
if frame.manabar and bars[frame.manabar] then ApplyPowerStyle(frame.manabar); return end
|
||||
if not frame.unit then return end
|
||||
for bar, state in pairs(bars) do
|
||||
if (bar.unit or state.unit) == frame.unit then ApplyPowerStyle(bar) end
|
||||
end
|
||||
end)
|
||||
RefreshPowerBars()
|
||||
return RefreshPowerBars
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user