Skip to content

Commit 3e7e5ed

Browse files
committed
fix dungeons with more bosses than the corresponding m+ key has
1 parent 2ad6032 commit 3e7e5ed

File tree

1 file changed

+21
-12
lines changed

1 file changed

+21
-12
lines changed

Display.lua

Lines changed: 21 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@ function MPT:Init(preview)
2121
self.level = level
2222
self.opened = false
2323
self.done = false
24-
self.IsPreview = preview
24+
self.IsPreview = preview
25+
self.PreviousMaxBossFrame = 0
2526
self:CreateStates(preview)
2627
if not preview then self:UpdateAllStates() end
2728
self:ShowFrame(true)
@@ -139,7 +140,7 @@ function MPT:UpdateMainFrame(BackgroundOnly)
139140
local F = self.Frame
140141
-- Main Frame
141142
if BackgroundOnly then
142-
local bosscount = #self.BossNames
143+
local bosscount = self.MaxBossFrame
143144
local spacing = self.Spacing*(bosscount-1)
144145
if self.KeyInfo.AnchoredTo ~= "MainFrame" then spacing = spacing+self.Spacing end
145146
if self.TimerBar.AnchoredTo ~= "MainFrame" then spacing = spacing+self.Spacing end
@@ -217,7 +218,7 @@ function MPT:UpdateKeyInfo(Full, Deaths, preview)
217218
end
218219
end
219220
end
220-
local parent = (self.KeyInfo.AnchoredTo == "MainFrame" and F) or (self.KeyInfo.AnchoredTo == "Bosses" and F["Bosses"..#self.BossNames]) or F[self.KeyInfo.AnchoredTo]
221+
local parent = (self.KeyInfo.AnchoredTo == "MainFrame" and F) or (self.KeyInfo.AnchoredTo == "Bosses" and F["Bosses"..self.MaxBossFrame]) or F[self.KeyInfo.AnchoredTo]
221222
local spacing = parent == F and 0 or self.Spacing
222223
self:SetPoint(F.KeyInfo, self.KeyInfo.Anchor, parent, self.KeyInfo.RelativeTo, self.KeyInfo.xOffset, -spacing+self.KeyInfo.yOffset)
223224
F.KeyInfo:SetSize(self.KeyInfo.Width, self.KeyInfo.Height)
@@ -273,7 +274,7 @@ function MPT:UpdateTimerBar(Start, Completion, preview)
273274
if (self.cmap and self.cmap ~= 0) or preview then
274275
self.timelimit = preview and 2280 or select(3, C_ChallengeMode.GetMapUIInfo(self.cmap))
275276
local timeremain = self.timelimit-self.timer
276-
local parent = (self.TimerBar.AnchoredTo == "MainFrame" and F) or (self.TimerBar.AnchoredTo == "Bosses" and F["Bosses"..#self.BossNames]) or F[self.TimerBar.AnchoredTo]
277+
local parent = (self.TimerBar.AnchoredTo == "MainFrame" and F) or (self.TimerBar.AnchoredTo == "Bosses" and F["Bosses"..self.MaxBossFrame]) or F[self.TimerBar.AnchoredTo]
277278
local spacing = parent == F and 0 or self.Spacing
278279
self:SetPoint(F.TimerBar, self.TimerBar.Anchor, parent, self.TimerBar.RelativeTo, self.TimerBar.xOffset, -spacing+self.TimerBar.yOffset)
279280
F.TimerBar:SetSize(self.TimerBar.Width, self.TimerBar.Height)
@@ -458,6 +459,7 @@ function MPT:UpdateBosses(Start, count, preview)
458459
if C_ScenarioInfo.GetCriteriaInfo(max) and C_ScenarioInfo.GetCriteriaInfo(max).isWeightedProgress then max = max-1 end
459460
local pb = self.BossSplit.enabled and self:GetPB(self.cmap, self.level, self.seasonID, self.LowerKey)
460461
local pb2 = self.BossTimer.enabled and self:GetPB(self.cmap, self.level, self.seasonID, self.LowerKey)
462+
self.MaxBossFrame = 0
461463
for i=1, max do
462464
local num = (self.cmap == 370 and i+4) or (self.cmap == 392 and i+5) or (self.cmap == 227 and i+2) or (self.cmap == 234 and i+6) or (self.cmap == 464 and i+4) or i
463465
local name = self.BossNames[num]
@@ -470,7 +472,8 @@ function MPT:UpdateBosses(Start, count, preview)
470472
end
471473
if self.cmap == 227 and num == 3 then name = "Opera Hall" end
472474
if name and name ~= "" then
473-
name = self:Utf8Sub(name, 1, self.BossName.MaxLength)
475+
name = self:Utf8Sub(name, 1, self.BossName.MaxLength)
476+
self.MaxBossFrame = i
474477
local completed = criteria.completed
475478
local defeated = criteria.elapsed
476479
local frame = F["Bosses"..i]
@@ -502,6 +505,17 @@ function MPT:UpdateBosses(Start, count, preview)
502505
frame:Show()
503506
end
504507
end
508+
if self.MaxBossFrame > self.PreviousMaxBossFrame then -- re-anchor other elements if they are anchored to Bosses
509+
if self.KeyInfo.AnchoredTo == "Bosses" then self:UpdateKeyInfo(true, true) end
510+
if self.TimerBar.AnchoredTo == "Bosses" then self:UpdateTimerBar(true) end
511+
if self.ForcesBar.AnchoredTo == "Bosses" then self:UpdateEnemyForces(true) end
512+
end
513+
self.PreviousMaxBossFrame = self.MaxBossFrame
514+
if self.MaxBossFrame == 0 then
515+
local frame = F["Bosses"..1] -- if somehow we don't have any boss frame, we force show one to prevent errors
516+
frame:Show()
517+
self.MaxBossFrame = 1
518+
end
505519
end
506520
elseif not self.IsPreview then
507521
self.BossTimes = self.BossTimes or {}
@@ -533,15 +547,10 @@ function MPT:UpdateBosses(Start, count, preview)
533547
end
534548
end
535549
end
536-
return true
537550
end
538-
539551
end
540552

541553
function MPT:UpdateEnemyForces(Start, preview, completion)
542-
-- Current Pull Overlay is only shown in Preview as no API for it is available in midnight
543-
-- If an API is provided I have to add stuff to the else statement below
544-
-- Mostly copy paste from the preview
545554
local F = self.Frame
546555
local steps = preview and 5 or select(3, C_Scenario.GetStepInfo())
547556
if not steps or steps <= 0 then
@@ -558,7 +567,7 @@ function MPT:UpdateEnemyForces(Start, preview, completion)
558567
end
559568
if Start or preview then
560569
local bosscount = preview and 5 or #self.BossNames
561-
local parent = (self.ForcesBar.AnchoredTo == "MainFrame" and F) or (self.ForcesBar.AnchoredTo == "Bosses" and F["Bosses"..#self.BossNames]) or F[self.ForcesBar.AnchoredTo]
570+
local parent = (self.ForcesBar.AnchoredTo == "MainFrame" and F) or (self.ForcesBar.AnchoredTo == "Bosses" and F["Bosses"..self.MaxBossFrame]) or F[self.ForcesBar.AnchoredTo]
562571
local spacing = parent == F and 0 or self.Spacing
563572
self:SetPoint(F.ForcesBar, self.ForcesBar.Anchor, parent, self.ForcesBar.RelativeTo, self.ForcesBar.xOffset, -spacing+self.ForcesBar.yOffset)
564573
F.ForcesBar:SetSize(self.ForcesBar.Width, self.ForcesBar.Height)
@@ -681,7 +690,7 @@ function MPT:UpdatePBInfo(preview)
681690
local finishtime = preview and math.random(1500000, 2000000) or pb.finish
682691
local date = self:GetDateFormat(preview and {11, 10, 2025, 17, 30} or pb.date)
683692
text = string.format("PB: +%s %s %s", level, self:FormatTime(finishtime/1000), date)
684-
local parent = (self.PBInfo.AnchoredTo == "MainFrame" and F) or (self.PBInfo.AnchoredTo == "Bosses" and F["Bosses"..#self.BossNames]) or F[self.PBInfo.AnchoredTo]
693+
local parent = (self.PBInfo.AnchoredTo == "MainFrame" and F) or (self.PBInfo.AnchoredTo == "Bosses" and F["Bosses"..self.MaxBossFrame]) or F[self.PBInfo.AnchoredTo]
685694
self:ApplyTextSettings(F.ForcesBar.PBInfo, self.PBInfo, text, false, parent)
686695
end
687696
end

0 commit comments

Comments
 (0)