From e8f3e52c9e0bccbe6f67f4904e4db0a45bd29f4b Mon Sep 17 00:00:00 2001 From: Dean Herbert Date: Fri, 15 Dec 2023 19:17:48 +0900 Subject: [PATCH] Fix nullref failure in tests --- osu.Game.Rulesets.Mania/UI/ColumnFlow.cs | 31 ++++++++++++------------ 1 file changed, 16 insertions(+), 15 deletions(-) diff --git a/osu.Game.Rulesets.Mania/UI/ColumnFlow.cs b/osu.Game.Rulesets.Mania/UI/ColumnFlow.cs index f28619fb64..3ecd14ce81 100644 --- a/osu.Game.Rulesets.Mania/UI/ColumnFlow.cs +++ b/osu.Game.Rulesets.Mania/UI/ColumnFlow.cs @@ -109,22 +109,23 @@ private void updateMobileSizing() if (!IsLoaded || !RuntimeInfo.IsMobile) return; + // GridContainer+CellContainer containing this stage (gets split up for dual stages). + Vector2? containingCell = this.FindClosestParent()?.Parent?.DrawSize; + + // Will be null in tests. + if (containingCell == null) + return; + + float aspectRatio = containingCell.Value.X / containingCell.Value.Y; + + // These numbers are based on mobile phones, aspect ~1.92. + float mobileAdjust = 2.83f * Math.Min(1, 7f / stageDefinition.Columns); + // We should scale it back for cases like tablets which aren't so extreme. + mobileAdjust *= aspectRatio / 1.92f; + + // Best effort until we have better mobile support. for (int i = 0; i < stageDefinition.Columns; i++) - { - // GridContainer+CellContainer containing this stage (gets split up for dual stages). - Vector2 containingCell = this.FindClosestParent().Parent!.DrawSize; - - // Best effort until we have better mobile support. - if (RuntimeInfo.IsMobile) - { - // These numbers are based on mobile phones, aspect ~1.92. - float mobileAdjust = 2.83f * Math.Min(1, 7f / stageDefinition.Columns); - // We should scale it back for cases like tablets which aren't so extreme. - mobileAdjust *= (containingCell.X / containingCell.Y) / 1.92f; - - columns[i].Width *= mobileAdjust; - } - } + columns[i].Width *= mobileAdjust; } protected override void Dispose(bool isDisposing)