mirror of
https://github.com/ppy/osu.git
synced 2025-01-28 06:42:54 +08:00
Fix event handling from outside carousel being scheduled at the wrong level
Was causing BeatmapSet's Set to run *after* newer events were received.
This commit is contained in:
parent
942054a30f
commit
30a15729ec
@ -110,42 +110,48 @@ namespace osu.Game.Screens.Select
|
||||
|
||||
public void RemoveBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
var existingSet = beatmapSets.FirstOrDefault(b => b.BeatmapSet.ID == beatmapSet.ID);
|
||||
Schedule(() =>
|
||||
{
|
||||
var existingSet = beatmapSets.FirstOrDefault(b => b.BeatmapSet.ID == beatmapSet.ID);
|
||||
|
||||
if (existingSet == null)
|
||||
return;
|
||||
if (existingSet == null)
|
||||
return;
|
||||
|
||||
root.RemoveChild(existingSet);
|
||||
itemsCache.Invalidate();
|
||||
root.RemoveChild(existingSet);
|
||||
itemsCache.Invalidate();
|
||||
});
|
||||
}
|
||||
|
||||
public void UpdateBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||
{
|
||||
CarouselBeatmapSet existingSet = beatmapSets.FirstOrDefault(b => b.BeatmapSet.ID == beatmapSet.ID);
|
||||
|
||||
bool hadSelection = existingSet?.State?.Value == CarouselItemState.Selected;
|
||||
|
||||
var newSet = createCarouselSet(beatmapSet);
|
||||
|
||||
if (existingSet != null)
|
||||
root.RemoveChild(existingSet);
|
||||
|
||||
if (newSet == null)
|
||||
Schedule(() =>
|
||||
{
|
||||
CarouselBeatmapSet existingSet = beatmapSets.FirstOrDefault(b => b.BeatmapSet.ID == beatmapSet.ID);
|
||||
|
||||
bool hadSelection = existingSet?.State?.Value == CarouselItemState.Selected;
|
||||
|
||||
var newSet = createCarouselSet(beatmapSet);
|
||||
|
||||
if (existingSet != null)
|
||||
root.RemoveChild(existingSet);
|
||||
|
||||
if (newSet == null)
|
||||
{
|
||||
itemsCache.Invalidate();
|
||||
SelectNext();
|
||||
return;
|
||||
}
|
||||
|
||||
root.AddChild(newSet);
|
||||
|
||||
applyActiveCriteria(false, false);
|
||||
|
||||
//check if we can/need to maintain our current selection.
|
||||
if (hadSelection)
|
||||
select((CarouselItem)newSet.Beatmaps.FirstOrDefault(b => b.Beatmap.ID == selectedBeatmap?.Beatmap.ID) ?? newSet);
|
||||
|
||||
itemsCache.Invalidate();
|
||||
SelectNext();
|
||||
return;
|
||||
}
|
||||
|
||||
root.AddChild(newSet);
|
||||
|
||||
applyActiveCriteria(false, false);
|
||||
|
||||
//check if we can/need to maintain our current selection.
|
||||
if (hadSelection)
|
||||
select((CarouselItem)newSet.Beatmaps.FirstOrDefault(b => b.Beatmap.ID == selectedBeatmap?.Beatmap.ID) ?? newSet);
|
||||
|
||||
itemsCache.Invalidate();
|
||||
});
|
||||
}
|
||||
|
||||
public void SelectBeatmap(BeatmapInfo beatmap)
|
||||
|
@ -417,32 +417,10 @@ namespace osu.Game.Screens.Select
|
||||
}
|
||||
}
|
||||
|
||||
private void onBeatmapSetAdded(BeatmapSetInfo s) => Schedule(() => carousel.UpdateBeatmapSet(s));
|
||||
|
||||
private void onBeatmapSetRemoved(BeatmapSetInfo s) => Schedule(() =>
|
||||
{
|
||||
carousel.RemoveBeatmapSet(s);
|
||||
if (carousel.SelectedBeatmap == null)
|
||||
Beatmap.SetDefault();
|
||||
});
|
||||
|
||||
private void onBeatmapRestored(BeatmapInfo beatmap)
|
||||
{
|
||||
Schedule(() =>
|
||||
{
|
||||
var beatmapSet = beatmaps.QueryBeatmapSet(s => s.ID == beatmap.BeatmapSetInfoID);
|
||||
carousel.UpdateBeatmapSet(beatmapSet);
|
||||
});
|
||||
}
|
||||
|
||||
private void onBeatmapHidden(BeatmapInfo beatmap)
|
||||
{
|
||||
Schedule(() =>
|
||||
{
|
||||
var beatmapSet = beatmaps.QueryBeatmapSet(s => s.ID == beatmap.BeatmapSetInfoID);
|
||||
carousel.UpdateBeatmapSet(beatmapSet);
|
||||
});
|
||||
}
|
||||
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()
|
||||
{
|
||||
|
Loading…
Reference in New Issue
Block a user