Harden module initialization order

This commit is contained in:
Dusk-92
2026-08-30 10:24:04 +02:00
parent 57614d7424
commit 48fa6cd025
7 changed files with 188 additions and 128 deletions
+36 -32
View File
@@ -11,47 +11,51 @@ local module = ShaguTweaks:register({
})
module.enable = function(self)
local raid = ShaguTweaksRaidFrame
if not raid then return end
if not ShaguTweaks.RaidFrame_OnReady then return end
local originals = {}
local hidden = false
for i = 1, MAX_PARTY_MEMBERS do
local frame = _G["PartyMemberFrame" .. i]
if frame then originals[frame] = frame.Show end
end
local function SetPartyFramesHidden(state)
if state == hidden then return end
hidden = state
ShaguTweaks.RaidFrame_OnReady(function(raid)
local originals = {}
local hidden = false
for i = 1, MAX_PARTY_MEMBERS do
local frame = _G["PartyMemberFrame" .. i]
if frame then
if state then
frame.Show = function() return end
frame:Hide()
else
frame.Show = originals[frame]
if GetPartyMember(i) then frame:Show() else frame:Hide() end
if frame then originals[frame] = frame.Show end
end
local function SetPartyFramesHidden(state)
if state == hidden then return end
hidden = state
for i = 1, MAX_PARTY_MEMBERS do
local frame = _G["PartyMemberFrame" .. i]
if frame then
if state then
frame.Show = function() return end
frame:Hide()
else
frame.Show = originals[frame]
if GetPartyMember(i) then frame:Show() else frame:Hide() end
end
end
end
end
end
local function UpdatePartyFrames()
SetPartyFramesHidden(raid:IsShown())
end
local function UpdatePartyFrames()
local active = raid:IsShown() and raid.cluster and raid.cluster:IsShown()
SetPartyFramesHidden(active and true or false)
end
ShaguTweaks.HookScript(raid, "OnShow", UpdatePartyFrames)
ShaguTweaks.HookScript(raid, "OnHide", UpdatePartyFrames)
ShaguTweaks.HookScript(raid, "OnShow", UpdatePartyFrames)
ShaguTweaks.HookScript(raid, "OnHide", UpdatePartyFrames)
ShaguTweaks.HookScript(raid.cluster, "OnShow", UpdatePartyFrames)
ShaguTweaks.HookScript(raid.cluster, "OnHide", UpdatePartyFrames)
local watcher = CreateFrame("Frame", nil, UIParent)
watcher:RegisterEvent("PLAYER_ENTERING_WORLD")
watcher:RegisterEvent("RAID_ROSTER_UPDATE")
watcher:RegisterEvent("PARTY_MEMBERS_CHANGED")
watcher:SetScript("OnEvent", UpdatePartyFrames)
local watcher = CreateFrame("Frame", nil, UIParent)
watcher:RegisterEvent("PLAYER_ENTERING_WORLD")
watcher:RegisterEvent("RAID_ROSTER_UPDATE")
watcher:RegisterEvent("PARTY_MEMBERS_CHANGED")
watcher:SetScript("OnEvent", UpdatePartyFrames)
UpdatePartyFrames()
UpdatePartyFrames()
end)
end