Harden module initialization order
This commit is contained in:
+36
-32
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user