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
+51 -40
View File
@@ -11,61 +11,72 @@ local module = ShaguTweaks:register({
})
module.enable = function(self)
-- overwrite config
ShaguTweaksRaidCluster.config["raid.width"] = 64
ShaguTweaksRaidCluster.config["raid.height"] = 12
ShaguTweaksRaidCluster.config["raid.rows"] = 40
if not ShaguTweaks.RaidFrame_OnReady then return end
-- disable mana bars
ShaguTweaks.UnitFrame_NewComponent('compact layout', {
events = { },
create = function(frame)
frame.compact = true
ShaguTweaks.RaidFrame_OnReady(function(raid)
-- overwrite config before unit frames are created
raid.cluster.config["raid.width"] = 64
raid.cluster.config["raid.height"] = 12
raid.cluster.config["raid.rows"] = 40
-- hide mana bar
frame.mana:Hide()
-- disable mana bars
ShaguTweaks.UnitFrame_NewComponent('compact layout', {
events = { },
create = function(frame)
frame.compact = true
-- move player text to healthbar
frame.text:SetParent(frame.bar)
frame.icon:SetParent(frame.bar)
-- move raid icon
frame.icon:ClearAllPoints()
frame.icon:SetPoint("LEFT", frame.bar, "LEFT", 0, 0)
-- hide mana bar
frame.mana:Hide()
end,
update = function(frame, event)
-- compact mode is handled by the base text component
-- move player text to healthbar
frame.text:SetParent(frame.bar)
frame.icon:SetParent(frame.bar)
-- move raid icon
frame.icon:ClearAllPoints()
frame.icon:SetPoint("LEFT", frame.bar, "LEFT", 0, 0)
end,
update = function(frame, event)
-- compact mode is handled by the base text component
end
})
local headerTitle = T["Show Group Headers"]
local headerEnabled = ShaguTweaks_config and ShaguTweaks_config[headerTitle]
if headerEnabled == nil then
local headerModule = ShaguTweaks.mods and ShaguTweaks.mods[headerTitle]
headerEnabled = headerModule and headerModule.enabled and 1 or 0
end
})
-- wait for the game to be loaded
local delay = CreateFrame("Frame")
delay:SetScript("OnUpdate", function()
this.elapsed = (this.elapsed or 0) + arg1
-- No header module means there is nothing to wait for or reposition.
if headerEnabled ~= 1 then return end
local delay = CreateFrame("Frame")
delay:SetScript("OnUpdate", function()
this.elapsed = (this.elapsed or 0) + (arg1 or 0)
this.total = (this.total or 0) + (arg1 or 0)
if this.elapsed < .10 then return end
this.elapsed = 0
if ShaguTweaksRaidHeaders then
-- modify group headers
for i=1, 8 do
for i = 1, 8 do
if ShaguTweaksRaidHeaders[i] then
-- read raid anchor per group header
local _, anchor = ShaguTweaksRaidHeaders[i]:GetPoint()
-- remove background and move to the left
--ShaguTweaksRaidHeaders[i]:SetBackdrop(nil)
ShaguTweaksRaidHeaders[i]:ClearAllPoints()
ShaguTweaksRaidHeaders[i]:SetPoint("LEFT", anchor, "LEFT", -6, 6)
ShaguTweaksRaidHeaders[i]:SetWidth(16)
ShaguTweaksRaidHeaders[i]:SetHeight(16)
--ShaguTweaksRaidHeaders[i].text:SetTextColor(.5,.5,.5,1)
ShaguTweaksRaidHeaders[i].text:SetText(i)
ShaguTweaksRaidHeaders[i]:SetAlpha(.75)
if anchor then
ShaguTweaksRaidHeaders[i]:ClearAllPoints()
ShaguTweaksRaidHeaders[i]:SetPoint("LEFT", anchor, "LEFT", -6, 6)
ShaguTweaksRaidHeaders[i]:SetWidth(16)
ShaguTweaksRaidHeaders[i]:SetHeight(16)
ShaguTweaksRaidHeaders[i].text:SetText(i)
ShaguTweaksRaidHeaders[i]:SetAlpha(.75)
end
end
end
-- disable delay only after headers were actually available
this:Hide()
elseif this.total >= 10 then
-- Fail closed instead of polling forever if headers never materialize.
this:Hide()
end
end)
end)
end