mirror of
https://github.com/ppy/osu
synced 2025-03-24 20:08:50 +00: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)
|
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)
|
if (existingSet == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
root.RemoveChild(existingSet);
|
root.RemoveChild(existingSet);
|
||||||
itemsCache.Invalidate();
|
itemsCache.Invalidate();
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateBeatmapSet(BeatmapSetInfo beatmapSet)
|
public void UpdateBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||||
{
|
{
|
||||||
CarouselBeatmapSet existingSet = beatmapSets.FirstOrDefault(b => b.BeatmapSet.ID == beatmapSet.ID);
|
Schedule(() =>
|
||||||
|
|
||||||
bool hadSelection = existingSet?.State?.Value == CarouselItemState.Selected;
|
|
||||||
|
|
||||||
var newSet = createCarouselSet(beatmapSet);
|
|
||||||
|
|
||||||
if (existingSet != null)
|
|
||||||
root.RemoveChild(existingSet);
|
|
||||||
|
|
||||||
if (newSet == null)
|
|
||||||
{
|
{
|
||||||
|
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();
|
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)
|
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 onBeatmapSetAdded(BeatmapSetInfo s) => carousel.UpdateBeatmapSet(s);
|
||||||
|
private void onBeatmapSetRemoved(BeatmapSetInfo s) => carousel.RemoveBeatmapSet(s);
|
||||||
private void onBeatmapSetRemoved(BeatmapSetInfo s) => Schedule(() =>
|
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));
|
||||||
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 carouselBeatmapsLoaded()
|
private void carouselBeatmapsLoaded()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user