1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 09:27:29 +08:00

Fix nullref failure in tests

This commit is contained in:
Dean Herbert 2023-12-15 19:17:48 +09:00
parent eb5a8284f1
commit e8f3e52c9e
No known key found for this signature in database

View File

@ -109,22 +109,23 @@ namespace osu.Game.Rulesets.Mania.UI
if (!IsLoaded || !RuntimeInfo.IsMobile)
return;
// GridContainer+CellContainer containing this stage (gets split up for dual stages).
Vector2? containingCell = this.FindClosestParent<Stage>()?.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<Stage>().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)