1
0
mirror of https://github.com/ppy/osu.git synced 2024-11-11 15:47:26 +08:00

Fix beatmap carousel potentially missing beatmap imports

This commit is contained in:
Dean Herbert 2020-01-29 16:51:14 +09:00
parent 1db353558b
commit 77c06b1c6e
2 changed files with 30 additions and 24 deletions

View File

@ -68,6 +68,7 @@ namespace osu.Game.Screens.Select
private IEnumerable<CarouselBeatmapSet> beatmapSets => root.Children.OfType<CarouselBeatmapSet>();
// todo: only used for testing, maybe remove.
public IEnumerable<BeatmapSetInfo> BeatmapSets
{
get => beatmapSets.Select(g => g.BeatmapSet);
@ -133,8 +134,11 @@ namespace osu.Game.Screens.Select
};
}
[Resolved]
private BeatmapManager beatmaps { get; set; }
[BackgroundDependencyLoader(permitNulls: true)]
private void load(OsuConfigManager config, BeatmapManager beatmaps)
private void load(OsuConfigManager config)
{
config.BindWith(OsuSetting.RandomSelectAlgorithm, RandomAlgorithm);
config.BindWith(OsuSetting.SongSelectRightMouseScroll, RightClickScrollingEnabled);
@ -142,6 +146,11 @@ namespace osu.Game.Screens.Select
RightClickScrollingEnabled.ValueChanged += enabled => scroll.RightMouseScrollbar = enabled.NewValue;
RightClickScrollingEnabled.TriggerChange();
beatmaps.ItemAdded += beatmapAdded;
beatmaps.ItemRemoved += beatmapRemoved;
beatmaps.BeatmapHidden += beatmapHidden;
beatmaps.BeatmapRestored += beatmapRestored;
loadBeatmapSets(beatmaps.GetAllUsableBeatmapSetsEnumerable());
}
@ -535,11 +544,27 @@ namespace osu.Game.Screens.Select
{
base.Dispose(isDisposing);
if (beatmaps != null)
{
beatmaps.ItemAdded -= beatmapAdded;
beatmaps.ItemRemoved -= beatmapRemoved;
beatmaps.BeatmapHidden -= beatmapHidden;
beatmaps.BeatmapRestored -= beatmapRestored;
}
// aggressively dispose "off-screen" items to reduce GC pressure.
foreach (var i in Items)
i.Dispose();
}
private void beatmapRemoved(BeatmapSetInfo item) => RemoveBeatmapSet(item);
private void beatmapAdded(BeatmapSetInfo item) => UpdateBeatmapSet(item);
private void beatmapRestored(BeatmapInfo b) => UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
private void beatmapHidden(BeatmapInfo b) => UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
private CarouselBeatmapSet createCarouselSet(BeatmapSetInfo beatmapSet)
{
if (beatmapSet.Beatmaps.All(b => b.Hidden))

View File

@ -72,7 +72,9 @@ namespace osu.Game.Screens.Select
private BeatmapInfoWedge beatmapInfoWedge;
private DialogOverlay dialogOverlay;
private BeatmapManager beatmaps;
[Resolved]
private BeatmapManager beatmaps { get; set; }
protected ModSelectOverlay ModSelect { get; private set; }
@ -89,7 +91,7 @@ namespace osu.Game.Screens.Select
private MusicController music { get; set; }
[BackgroundDependencyLoader(true)]
private void load(BeatmapManager beatmaps, AudioManager audio, DialogOverlay dialog, OsuColour colours, SkinManager skins, ScoreManager scores)
private void load(AudioManager audio, DialogOverlay dialog, OsuColour colours, SkinManager skins, ScoreManager scores)
{
// initial value transfer is required for FilterControl (it uses our re-cached bindables in its async load for the initial filter).
transferRulesetValue();
@ -247,14 +249,6 @@ namespace osu.Game.Screens.Select
BeatmapOptions.AddButton(@"Delete", @"all difficulties", FontAwesome.Solid.Trash, colours.Pink, () => delete(Beatmap.Value.BeatmapSetInfo), Key.Number3);
}
if (this.beatmaps == null)
this.beatmaps = beatmaps;
this.beatmaps.ItemAdded += onBeatmapSetAdded;
this.beatmaps.ItemRemoved += onBeatmapSetRemoved;
this.beatmaps.BeatmapHidden += onBeatmapHidden;
this.beatmaps.BeatmapRestored += onBeatmapRestored;
dialogOverlay = dialog;
sampleChangeDifficulty = audio.Samples.Get(@"SongSelect/select-difficulty");
@ -563,14 +557,6 @@ namespace osu.Game.Screens.Select
base.Dispose(isDisposing);
decoupledRuleset.UnbindAll();
if (beatmaps != null)
{
beatmaps.ItemAdded -= onBeatmapSetAdded;
beatmaps.ItemRemoved -= onBeatmapSetRemoved;
beatmaps.BeatmapHidden -= onBeatmapHidden;
beatmaps.BeatmapRestored -= onBeatmapRestored;
}
}
/// <summary>
@ -617,11 +603,6 @@ namespace osu.Game.Screens.Select
lastTrack.SetTarget(track);
}
private void onBeatmapSetAdded(BeatmapSetInfo s) => Carousel.UpdateBeatmapSet(s);
private void onBeatmapSetRemoved(BeatmapSetInfo s) => Carousel.RemoveBeatmapSet(s);
private void onBeatmapRestored(BeatmapInfo b) => Carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
private void onBeatmapHidden(BeatmapInfo b) => Carousel.UpdateBeatmapSet(beatmaps.QueryBeatmapSet(s => s.ID == b.BeatmapSetInfoID));
private void carouselBeatmapsLoaded()
{
bindBindables();