diff --git a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs index a1eb416043..ad5950d9fc 100644 --- a/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs +++ b/osu.Game.Tests/Visual/Gameplay/TestScenePlayerLoader.cs @@ -146,6 +146,18 @@ public void TestModReinstantiation() AddAssert("player mods applied", () => playerMod2.Applied); } + [Test] + public void TestModDisplayChanges() + { + var testMod = new TestMod(); + + AddStep("load player", () => ResetPlayer(true)); + + AddUntilStep("wait for loader to become current", () => loader.IsCurrentScreen()); + AddStep("set test mod in loader", () => loader.Mods.Value = new[] { testMod }); + AddAssert("test mod is displayed", () => (TestMod)loader.DisplayedMods.Single() == testMod); + } + [Test] public void TestMutedNotificationMasterVolume() => addVolumeSteps("master volume", () => audioManager.Volume.Value = 0, null, () => audioManager.Volume.IsDefault); @@ -221,6 +233,8 @@ private class TestPlayerLoader : PlayerLoader public new Task DisposalTask => base.DisposalTask; + public IReadOnlyList DisplayedMods => MetadataInfo.Mods.Value; + public TestPlayerLoader(Func createPlayer) : base(createPlayer) { diff --git a/osu.Game/Screens/Play/PlayerLoader.cs b/osu.Game/Screens/Play/PlayerLoader.cs index 64fcc48004..f37faac988 100644 --- a/osu.Game/Screens/Play/PlayerLoader.cs +++ b/osu.Game/Screens/Play/PlayerLoader.cs @@ -44,7 +44,7 @@ public class PlayerLoader : ScreenWithBeatmapBackground private LogoTrackingContainer content; - private BeatmapMetadataDisplay info; + protected BeatmapMetadataDisplay MetadataInfo; private bool hideOverlays; public override bool HideOverlaysOnEnter => hideOverlays; @@ -96,7 +96,7 @@ private void load(SessionStatics sessionStatics) RelativeSizeAxes = Axes.Both, }).WithChildren(new Drawable[] { - info = new BeatmapMetadataDisplay(Beatmap.Value, Mods.Value, content.LogoFacade) + MetadataInfo = new BeatmapMetadataDisplay(Beatmap.Value, Mods, content.LogoFacade) { Alpha = 0, Anchor = Anchor.Centre, @@ -138,7 +138,7 @@ public override void OnEntering(IScreen last) contentIn(); - info.Delay(750).FadeIn(500); + MetadataInfo.Delay(750).FadeIn(500); this.Delay(1800).Schedule(pushWhenLoaded); if (!muteWarningShownOnce.Value) @@ -158,7 +158,7 @@ public override void OnResuming(IScreen last) contentIn(); - info.Loading = true; + MetadataInfo.Loading = true; //we will only be resumed if the player has requested a re-run (see ValidForResume setting above) loadNewPlayer(); @@ -174,7 +174,7 @@ private void loadNewPlayer() player.RestartCount = restartCount; player.RestartRequested = restartRequested; - LoadTask = LoadComponentAsync(player, _ => info.Loading = false); + LoadTask = LoadComponentAsync(player, _ => MetadataInfo.Loading = false); } private void contentIn() @@ -350,7 +350,7 @@ protected override void Update() } } - private class BeatmapMetadataDisplay : Container + protected class BeatmapMetadataDisplay : Container { private class MetadataLine : Container { @@ -379,11 +379,13 @@ public MetadataLine(string left, string right) } private readonly WorkingBeatmap beatmap; - private readonly IReadOnlyList mods; + private readonly Bindable> mods; private readonly Drawable facade; private LoadingAnimation loading; private Sprite backgroundSprite; + public IBindable> Mods => mods; + public bool Loading { set @@ -401,11 +403,13 @@ public bool Loading } } - public BeatmapMetadataDisplay(WorkingBeatmap beatmap, IReadOnlyList mods, Drawable facade) + public BeatmapMetadataDisplay(WorkingBeatmap beatmap, Bindable> mods, Drawable facade) { this.beatmap = beatmap; - this.mods = mods; this.facade = facade; + + this.mods = new Bindable>(); + this.mods.BindTo(mods); } [BackgroundDependencyLoader] @@ -492,7 +496,7 @@ private void load() Origin = Anchor.TopCentre, AutoSizeAxes = Axes.Both, Margin = new MarginPadding { Top = 20 }, - Current = { Value = mods } + Current = mods } }, }