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

Pass bindable to BeatmapMetadataDisplay

It was reported that mods selected in song select would show up during
loading of replays which were recorded under a different set of mods.
This was caused by BeatmapMetadataDisplay accepting a plain read-only
value of the Mods bindable in PlayerLoader.load(), therefore making the
mod value assignment in ReplayPlayerLoader.OnEntering() have no effect
on that component.

To resolve this issue, make BeatmapMetadataDisplay accept the
higher-level bindable, bind to it locally and pass it down the hierarchy
to ModDisplay.
This commit is contained in:
Bartłomiej Dach 2020-01-08 20:10:43 +01:00
parent a3f7d3c445
commit f0fe3bc804
2 changed files with 8 additions and 6 deletions

View File

@ -233,7 +233,7 @@ namespace osu.Game.Tests.Visual.Gameplay
public new Task DisposalTask => base.DisposalTask;
public IReadOnlyList<Mod> DisplayedMods => MetadataInfo.Mods;
public IReadOnlyList<Mod> DisplayedMods => MetadataInfo.Mods.Value;
public TestPlayerLoader(Func<Player> createPlayer)
: base(createPlayer)

View File

@ -96,7 +96,7 @@ namespace osu.Game.Screens.Play
RelativeSizeAxes = Axes.Both,
}).WithChildren(new Drawable[]
{
MetadataInfo = new BeatmapMetadataDisplay(Beatmap.Value, Mods.Value, content.LogoFacade)
MetadataInfo = new BeatmapMetadataDisplay(Beatmap.Value, Mods, content.LogoFacade)
{
Alpha = 0,
Anchor = Anchor.Centre,
@ -379,11 +379,12 @@ namespace osu.Game.Screens.Play
}
private readonly WorkingBeatmap beatmap;
private readonly Bindable<IReadOnlyList<Mod>> mods;
private readonly Drawable facade;
private LoadingAnimation loading;
private Sprite backgroundSprite;
public IReadOnlyList<Mod> Mods { get; }
public IBindable<IReadOnlyList<Mod>> Mods => mods;
public bool Loading
{
@ -402,12 +403,13 @@ namespace osu.Game.Screens.Play
}
}
public BeatmapMetadataDisplay(WorkingBeatmap beatmap, IReadOnlyList<Mod> mods, Drawable facade)
public BeatmapMetadataDisplay(WorkingBeatmap beatmap, Bindable<IReadOnlyList<Mod>> mods, Drawable facade)
{
this.beatmap = beatmap;
this.facade = facade;
Mods = mods;
this.mods = new Bindable<IReadOnlyList<Mod>>();
this.mods.BindTo(mods);
}
[BackgroundDependencyLoader]
@ -494,7 +496,7 @@ namespace osu.Game.Screens.Play
Origin = Anchor.TopCentre,
AutoSizeAxes = Axes.Both,
Margin = new MarginPadding { Top = 20 },
Current = { Value = Mods }
Current = mods
}
},
}