Release 3.8.6: module fixes and native timer optimizations

This commit is contained in:
2026-11-06 17:20:18 -04:00
parent b9912256bf
commit e43d93a524
48 changed files with 1966 additions and 2731 deletions
+28 -14
View File
@@ -13,6 +13,8 @@ for _, name in pairs(tocs) do
end
end
local CLASS_PORTRAIT_TEXTURE = (addonpath or "Interface\\AddOns\\ShaguTweaks") .. "\\img\\UI-Classes-Circles"
local CLASS_ICON_TCOORDS = {
["WARRIOR"] = { 0, 0.25, 0, 0.25 },
["MAGE"] = { 0.25, 0.49609375, 0, 0.25 },
@@ -46,33 +48,45 @@ local function UpdatePortraits(frame)
if class then
local iconCoords = CLASS_ICON_TCOORDS[class]
if iconCoords then
frame.portrait:SetTexture(addonpath .. "\\img\\UI-Classes-Circles")
frame.portrait:SetTexCoord(unpack(iconCoords))
local wanted = CLASS_PORTRAIT_TEXTURE
if frame.portrait:GetTexture() ~= wanted then frame.portrait:SetTexture(wanted) end
local l, t, l2, b, r, t2, r2, b2 = frame.portrait:GetTexCoord()
if l ~= iconCoords[1] or t ~= iconCoords[3] or l2 ~= iconCoords[1]
or b ~= iconCoords[4] or r ~= iconCoords[2] or t2 ~= iconCoords[3]
or r2 ~= iconCoords[2] or b2 ~= iconCoords[4] then
frame.portrait:SetTexCoord(unpack(iconCoords))
end
end
else
frame.portrait:SetTexCoord(0, 1, 0, 1)
local l, t, l2, b, r, t2, r2, b2 = frame.portrait:GetTexCoord()
if l ~= 0 or t ~= 0 or l2 ~= 0 or b ~= 1 or r ~= 1 or t2 ~= 0 or r2 ~= 1 or b2 ~= 1 then
frame.portrait:SetTexCoord(0, 1, 0, 1)
end
end
end
module.enable = function(self)
-- overwrite portraits set by the game
local original = UnitFrame_Update
UnitFrame_Update = function(arg1, arg2, arg3)
original(arg1, arg2, arg3)
UpdatePortraits(this)
end
ShaguTweaks.hooksecurefunc("UnitFrame_Update", function(frame)
UpdatePortraits(type(frame) == "table" and frame.unit and frame or this)
end)
-- handle portrait update events
local events = CreateFrame("Frame")
events:RegisterEvent("PLAYER_ENTERING_WORLD")
events:RegisterEvent("UNIT_PORTRAIT_UPDATE")
local function RefreshFrame(frame)
if not frame or not frame.unit then return end
if event == "PLAYER_ENTERING_WORLD" or frame.unit == arg1
or (arg1 and UnitIsUnit(frame.unit, arg1)) then UpdatePortraits(frame) end
end
events:SetScript("OnEvent", function()
UpdatePortraits(PlayerFrame)
UpdatePortraits(TargetFrame)
UpdatePortraits(PartyMemberFrame1)
UpdatePortraits(PartyMemberFrame2)
UpdatePortraits(PartyMemberFrame3)
UpdatePortraits(PartyMemberFrame4)
RefreshFrame(PlayerFrame)
RefreshFrame(TargetFrame)
RefreshFrame(PartyMemberFrame1)
RefreshFrame(PartyMemberFrame2)
RefreshFrame(PartyMemberFrame3)
RefreshFrame(PartyMemberFrame4)
end)
-- Turtle/Vanilla already runs TargetofTarget_OnUpdate for the target-of-target