mirror of
https://github.com/ppy/osu
synced 2025-03-22 19:06:58 +00:00
fix crash when restoring from any non-SongSelect-screen
removed unwanted refresh
This commit is contained in:
parent
12665fb8cf
commit
105d01d85b
@ -112,29 +112,26 @@ namespace osu.Game.Screens.Select
|
|||||||
Schedule(() => removeGroup(groups.Find(b => b.BeatmapSet.ID == beatmapSet.ID)));
|
Schedule(() => removeGroup(groups.Find(b => b.BeatmapSet.ID == beatmapSet.ID)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void UpdateBeatmap(BeatmapInfo beatmap)
|
public void UpdateBeatmapSet(BeatmapSetInfo beatmapSet)
|
||||||
{
|
{
|
||||||
// todo: this method should not run more than once for the same BeatmapSetInfo.
|
|
||||||
var set = manager.QueryBeatmapSet(s => s.ID == beatmap.BeatmapSetInfoID);
|
|
||||||
|
|
||||||
// todo: this method should be smarter as to not recreate panels that haven't changed, etc.
|
// todo: this method should be smarter as to not recreate panels that haven't changed, etc.
|
||||||
var group = groups.Find(b => b.BeatmapSet.ID == set.ID);
|
var oldGroup = groups.Find(b => b.BeatmapSet.ID == beatmapSet.ID);
|
||||||
|
|
||||||
int i = groups.IndexOf(group);
|
var newGroup = createGroup(beatmapSet);
|
||||||
if (i >= 0)
|
|
||||||
groups.RemoveAt(i);
|
|
||||||
|
|
||||||
var newGroup = createGroup(set);
|
int index = groups.IndexOf(oldGroup);
|
||||||
|
if (index >= 0)
|
||||||
|
groups.RemoveAt(index);
|
||||||
|
|
||||||
if (newGroup != null)
|
if (newGroup != null)
|
||||||
{
|
{
|
||||||
if (i >= 0)
|
if (index >= 0)
|
||||||
groups.Insert(i, newGroup);
|
groups.Insert(index, newGroup);
|
||||||
else
|
else
|
||||||
addGroup(newGroup);
|
addGroup(newGroup);
|
||||||
}
|
}
|
||||||
|
|
||||||
bool hadSelection = selectedGroup == group;
|
bool hadSelection = selectedGroup == oldGroup;
|
||||||
|
|
||||||
if (hadSelection && newGroup == null)
|
if (hadSelection && newGroup == null)
|
||||||
selectedGroup = null;
|
selectedGroup = null;
|
||||||
@ -147,8 +144,8 @@ namespace osu.Game.Screens.Select
|
|||||||
var newSelection =
|
var newSelection =
|
||||||
newGroup.BeatmapPanels.Find(p => p.Beatmap.ID == selectedPanel?.Beatmap.ID);
|
newGroup.BeatmapPanels.Find(p => p.Beatmap.ID == selectedPanel?.Beatmap.ID);
|
||||||
|
|
||||||
if(newSelection == null && group != null && selectedPanel != null)
|
if(newSelection == null && oldGroup != null && selectedPanel != null)
|
||||||
newSelection = newGroup.BeatmapPanels[Math.Min(newGroup.BeatmapPanels.Count - 1, group.BeatmapPanels.IndexOf(selectedPanel))];
|
newSelection = newGroup.BeatmapPanels[Math.Min(newGroup.BeatmapPanels.Count - 1, oldGroup.BeatmapPanels.IndexOf(selectedPanel))];
|
||||||
|
|
||||||
selectGroup(newGroup, newSelection);
|
selectGroup(newGroup, newSelection);
|
||||||
}
|
}
|
||||||
@ -306,8 +303,6 @@ namespace osu.Game.Screens.Select
|
|||||||
if (newCriteria != null)
|
if (newCriteria != null)
|
||||||
criteria = newCriteria;
|
criteria = newCriteria;
|
||||||
|
|
||||||
if (!IsLoaded) return;
|
|
||||||
|
|
||||||
Action perform = delegate
|
Action perform = delegate
|
||||||
{
|
{
|
||||||
filterTask = null;
|
filterTask = null;
|
||||||
@ -348,8 +343,6 @@ namespace osu.Game.Screens.Select
|
|||||||
|
|
||||||
private BeatmapGroup createGroup(BeatmapSetInfo beatmapSet)
|
private BeatmapGroup createGroup(BeatmapSetInfo beatmapSet)
|
||||||
{
|
{
|
||||||
beatmapSet = manager.Refresh(beatmapSet);
|
|
||||||
|
|
||||||
if (beatmapSet.Beatmaps.All(b => b.Hidden))
|
if (beatmapSet.Beatmaps.All(b => b.Hidden))
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
|
@ -203,8 +203,17 @@ namespace osu.Game.Screens.Select
|
|||||||
Push(new Editor());
|
Push(new Editor());
|
||||||
}
|
}
|
||||||
|
|
||||||
private void onBeatmapRestored(BeatmapInfo b) => Schedule(() => carousel.UpdateBeatmap(b));
|
private void onBeatmapRestored(BeatmapInfo beatmap)
|
||||||
private void onBeatmapHidden(BeatmapInfo b) => Schedule(() => carousel.UpdateBeatmap(b));
|
{
|
||||||
|
var beatmapSet = beatmaps.QueryBeatmapSet(s => s.ID == beatmap.BeatmapSetInfoID);
|
||||||
|
Schedule(() => carousel.UpdateBeatmapSet(beatmapSet));
|
||||||
|
}
|
||||||
|
|
||||||
|
private void onBeatmapHidden(BeatmapInfo beatmap)
|
||||||
|
{
|
||||||
|
var beatmapSet = beatmaps.QueryBeatmapSet(s => s.ID == beatmap.BeatmapSetInfoID);
|
||||||
|
Schedule(() => carousel.UpdateBeatmapSet(beatmapSet));
|
||||||
|
}
|
||||||
|
|
||||||
private void carouselBeatmapsLoaded()
|
private void carouselBeatmapsLoaded()
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user