Make raid first-frame state deterministic
This commit is contained in:
+36
-19
@@ -23,38 +23,33 @@ module.enable = function(self)
|
||||
events = { },
|
||||
|
||||
create = function(frame)
|
||||
-- skip if already initialized
|
||||
if init then return else init = true end
|
||||
if init then return end
|
||||
init = true
|
||||
|
||||
-- create shortcut to raid.cluster
|
||||
local cluster = frame:GetParent()
|
||||
|
||||
-- initialize header frame on cluster
|
||||
local header = CreateFrame("Frame", "ShaguTweaksRaidHeaders", cluster)
|
||||
header:SetFrameLevel(128)
|
||||
header:SetScale(.9)
|
||||
header:SetAllPoints(cluster)
|
||||
header:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
header:RegisterEvent("RAID_ROSTER_UPDATE")
|
||||
header:SetScript("OnEvent", function()
|
||||
for i = 1, 40 do
|
||||
if math.mod(i, 5) == 1 then
|
||||
local group = math.ceil(i/5)
|
||||
|
||||
-- create header base frame
|
||||
local function UpdateHeaders()
|
||||
if not cluster.frames then return end
|
||||
|
||||
for group = 1, 8 do
|
||||
local index = (group - 1) * 5 + 1
|
||||
local anchorFrame = cluster.frames[index]
|
||||
|
||||
if anchorFrame then
|
||||
if not header[group] then
|
||||
header[group] = header[group] or CreateFrame("Frame", "ShaguTweaksRaidGroupHeader" .. group, header)
|
||||
header[group]:SetPoint("TOP", cluster.frames[i], "TOP", 0, 6)
|
||||
header[group] = CreateFrame("Frame", "ShaguTweaksRaidGroupHeader" .. group, header)
|
||||
header[group]:SetPoint("TOP", anchorFrame, "TOP", 0, 6)
|
||||
header[group]:SetWidth(42)
|
||||
header[group]:SetHeight(16)
|
||||
header[group]:SetBackdrop(backdrop)
|
||||
header[group]:SetBackdropBorderColor(.8, .8, .8, 1)
|
||||
header[group]:SetBackdropColor(.4, .4, .4, 1)
|
||||
ShaguTweaks.DarkenFrame(header[group])
|
||||
end
|
||||
|
||||
-- create header text
|
||||
if not header[group].text then
|
||||
header[group].text = header[group]:CreateFontString(nil, "HIGH", "GameFontWhite")
|
||||
header[group].text:SetFont(STANDARD_TEXT_FONT, 7, "THINOUTLINE")
|
||||
header[group].text:SetAllPoints(header[group])
|
||||
@@ -63,14 +58,36 @@ module.enable = function(self)
|
||||
header[group].text:SetText("Group " .. group)
|
||||
end
|
||||
|
||||
-- toggle visibility if needed
|
||||
if RAID_SUBGROUP_LISTS and RAID_SUBGROUP_LISTS[group] and table.getn(RAID_SUBGROUP_LISTS[group]) > 0 then
|
||||
local inRaid = RAID_SUBGROUP_LISTS
|
||||
and RAID_SUBGROUP_LISTS[group]
|
||||
and table.getn(RAID_SUBGROUP_LISTS[group]) > 0
|
||||
local inParty = group == 1
|
||||
and not UnitInRaid("player")
|
||||
and GetNumPartyMembers() > 0
|
||||
|
||||
if inRaid or inParty then
|
||||
header[group]:Show()
|
||||
else
|
||||
header[group]:Hide()
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
header.Update = UpdateHeaders
|
||||
header:RegisterEvent("PLAYER_ENTERING_WORLD")
|
||||
header:RegisterEvent("RAID_ROSTER_UPDATE")
|
||||
header:RegisterEvent("PARTY_MEMBERS_CHANGED")
|
||||
header:SetScript("OnEvent", UpdateHeaders)
|
||||
|
||||
-- The header container is created while the first raid unit frame is
|
||||
-- still being built. Wait until all 40 anchors exist, then initialize
|
||||
-- once even if the PLAYER_ENTERING_WORLD event that created us was missed.
|
||||
header:SetScript("OnUpdate", function()
|
||||
if cluster.frames and cluster.frames[40] then
|
||||
UpdateHeaders()
|
||||
this:SetScript("OnUpdate", nil)
|
||||
end
|
||||
end)
|
||||
end,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user