1
0
mirror of https://github.com/ppy/osu.git synced 2024-12-14 17:32:54 +08:00

fix crash when restoring from any non-SongSelect-screen

removed unwanted refresh
This commit is contained in:
Aergwyn 2017-12-07 22:02:53 +01:00
parent 12665fb8cf
commit 105d01d85b
2 changed files with 22 additions and 20 deletions

View File

@ -112,29 +112,26 @@ namespace osu.Game.Screens.Select
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.
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);
if (i >= 0)
groups.RemoveAt(i);
var newGroup = createGroup(beatmapSet);
var newGroup = createGroup(set);
int index = groups.IndexOf(oldGroup);
if (index >= 0)
groups.RemoveAt(index);
if (newGroup != null)
{
if (i >= 0)
groups.Insert(i, newGroup);
if (index >= 0)
groups.Insert(index, newGroup);
else
addGroup(newGroup);
}
bool hadSelection = selectedGroup == group;
bool hadSelection = selectedGroup == oldGroup;
if (hadSelection && newGroup == null)
selectedGroup = null;
@ -147,8 +144,8 @@ namespace osu.Game.Screens.Select
var newSelection =
newGroup.BeatmapPanels.Find(p => p.Beatmap.ID == selectedPanel?.Beatmap.ID);
if(newSelection == null && group != null && selectedPanel != null)
newSelection = newGroup.BeatmapPanels[Math.Min(newGroup.BeatmapPanels.Count - 1, group.BeatmapPanels.IndexOf(selectedPanel))];
if(newSelection == null && oldGroup != null && selectedPanel != null)
newSelection = newGroup.BeatmapPanels[Math.Min(newGroup.BeatmapPanels.Count - 1, oldGroup.BeatmapPanels.IndexOf(selectedPanel))];
selectGroup(newGroup, newSelection);
}
@ -306,8 +303,6 @@ namespace osu.Game.Screens.Select
if (newCriteria != null)
criteria = newCriteria;
if (!IsLoaded) return;
Action perform = delegate
{
filterTask = null;
@ -348,8 +343,6 @@ namespace osu.Game.Screens.Select
private BeatmapGroup createGroup(BeatmapSetInfo beatmapSet)
{
beatmapSet = manager.Refresh(beatmapSet);
if (beatmapSet.Beatmaps.All(b => b.Hidden))
return null;

View File

@ -203,8 +203,17 @@ namespace osu.Game.Screens.Select
Push(new Editor());
}
private void onBeatmapRestored(BeatmapInfo b) => Schedule(() => carousel.UpdateBeatmap(b));
private void onBeatmapHidden(BeatmapInfo b) => Schedule(() => carousel.UpdateBeatmap(b));
private void onBeatmapRestored(BeatmapInfo beatmap)
{
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()
{