1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-05 16:02:56 +08:00

Merge pull request #13915 from bdach/fix-tourney-seeding-crash

Fix seeding screen crashing on seedings with null mod
This commit is contained in:
Dean Herbert 2021-07-18 17:47:29 +09:00 committed by GitHub
commit 353ff5c6ce
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 69 additions and 36 deletions

View File

@ -1,9 +1,13 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence. // Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text. // See the LICENCE file in the repository root for full licence text.
using System.Linq;
using NUnit.Framework;
using osu.Framework.Allocation; using osu.Framework.Allocation;
using osu.Framework.Graphics; using osu.Framework.Graphics;
using osu.Framework.Testing;
using osu.Game.Tournament.Models; using osu.Game.Tournament.Models;
using osu.Game.Tournament.Screens.Ladder.Components;
using osu.Game.Tournament.Screens.TeamIntro; using osu.Game.Tournament.Screens.TeamIntro;
namespace osu.Game.Tournament.Tests.Screens namespace osu.Game.Tournament.Tests.Screens
@ -11,16 +15,41 @@ namespace osu.Game.Tournament.Tests.Screens
public class TestSceneSeedingScreen : TournamentTestScene public class TestSceneSeedingScreen : TournamentTestScene
{ {
[Cached] [Cached]
private readonly LadderInfo ladder = new LadderInfo(); private readonly LadderInfo ladder = new LadderInfo
[BackgroundDependencyLoader]
private void load()
{ {
Add(new SeedingScreen Teams =
{
new TournamentTeam
{
FullName = { Value = @"Japan" },
Acronym = { Value = "JPN" },
SeedingResults =
{
new SeedingResult
{
// Mod intentionally left blank.
Seed = { Value = 4 }
},
new SeedingResult
{
Mod = { Value = "DT" },
Seed = { Value = 8 }
}
}
}
}
};
[Test]
public void TestBasic()
{
AddStep("create seeding screen", () => Add(new SeedingScreen
{ {
FillMode = FillMode.Fit, FillMode = FillMode.Fit,
FillAspectRatio = 16 / 9f FillAspectRatio = 16 / 9f
}); }));
AddStep("set team to Japan", () => this.ChildrenOfType<SettingsTeamDropdown>().Single().Current.Value = ladder.Teams.Single());
} }
} }
} }

View File

@ -181,21 +181,28 @@ namespace osu.Game.Tournament.Screens.TeamIntro
[BackgroundDependencyLoader] [BackgroundDependencyLoader]
private void load(TextureStore textures) private void load(TextureStore textures)
{ {
FillFlowContainer row;
InternalChildren = new Drawable[] InternalChildren = new Drawable[]
{ {
new FillFlowContainer row = new FillFlowContainer
{ {
AutoSizeAxes = Axes.Both, AutoSizeAxes = Axes.Both,
Direction = FillDirection.Horizontal, Direction = FillDirection.Horizontal,
Spacing = new Vector2(5), Spacing = new Vector2(5),
Children = new Drawable[] },
};
if (!string.IsNullOrEmpty(mods))
{ {
new Sprite row.Add(new Sprite
{ {
Texture = textures.Get($"mods/{mods.ToLower()}"), Texture = textures.Get($"mods/{mods.ToLower()}"),
Scale = new Vector2(0.5f) Scale = new Vector2(0.5f)
}, });
new Container }
row.Add(new Container
{ {
Size = new Vector2(50, 16), Size = new Vector2(50, 16),
CornerRadius = 10, CornerRadius = 10,
@ -215,10 +222,7 @@ namespace osu.Game.Tournament.Screens.TeamIntro
Colour = TournamentGame.ELEMENT_FOREGROUND_COLOUR Colour = TournamentGame.ELEMENT_FOREGROUND_COLOUR
}, },
} }
}, });
}
},
};
} }
} }
} }