1
0
mirror of https://github.com/ppy/osu.git synced 2024-09-22 20:47:25 +08:00

Merge pull request #1391 from peppy/fix-ef-hiding

Fix issues related to hiding beatmaps
This commit is contained in:
Dan Balasescu 2017-10-20 20:12:02 +09:00 committed by GitHub
commit da5e7766fb
2 changed files with 18 additions and 6 deletions

View File

@ -104,6 +104,7 @@ namespace osu.Game.Beatmaps
if (beatmap.Hidden) return false; if (beatmap.Hidden) return false;
beatmap.Hidden = true; beatmap.Hidden = true;
context.Update(beatmap);
context.SaveChanges(); context.SaveChanges();
BeatmapHidden?.Invoke(beatmap); BeatmapHidden?.Invoke(beatmap);
@ -122,6 +123,7 @@ namespace osu.Game.Beatmaps
if (!beatmap.Hidden) return false; if (!beatmap.Hidden) return false;
beatmap.Hidden = false; beatmap.Hidden = false;
context.Update(beatmap);
context.SaveChanges(); context.SaveChanges();
BeatmapRestored?.Invoke(beatmap); BeatmapRestored?.Invoke(beatmap);

View File

@ -52,7 +52,7 @@ namespace osu.Game.Screens.Select
Schedule(() => Schedule(() =>
{ {
foreach (var g in newGroups) foreach (var g in newGroups)
addGroup(g); if (g != null) addGroup(g);
computeYPositions(); computeYPositions();
BeatmapsChanged?.Invoke(); BeatmapsChanged?.Invoke();
@ -101,6 +101,9 @@ namespace osu.Game.Screens.Select
{ {
var group = createGroup(beatmapSet); var group = createGroup(beatmapSet);
if (group == null)
return;
addGroup(group); addGroup(group);
computeYPositions(); computeYPositions();
if (selectedGroup == null) if (selectedGroup == null)
@ -124,19 +127,23 @@ namespace osu.Game.Screens.Select
if (group == null) if (group == null)
return; return;
var newGroup = createGroup(set);
int i = groups.IndexOf(group); int i = groups.IndexOf(group);
groups.RemoveAt(i); groups.RemoveAt(i);
groups.Insert(i, newGroup);
if (selectedGroup == group && newGroup.BeatmapPanels.Count == 0) var newGroup = createGroup(set);
if (newGroup != null)
groups.Insert(i, newGroup);
bool hadSelection = selectedGroup == group;
if (hadSelection && newGroup == null)
selectedGroup = null; selectedGroup = null;
Filter(null, false); Filter(null, false);
//check if we can/need to maintain our current selection. //check if we can/need to maintain our current selection.
if (selectedGroup == group && newGroup.BeatmapPanels.Count > 0) if (hadSelection && newGroup != null)
{ {
var newSelection = var newSelection =
newGroup.BeatmapPanels.Find(p => p.Beatmap.ID == selectedPanel?.Beatmap.ID) ?? newGroup.BeatmapPanels.Find(p => p.Beatmap.ID == selectedPanel?.Beatmap.ID) ??
@ -335,6 +342,9 @@ namespace osu.Game.Screens.Select
private BeatmapGroup createGroup(BeatmapSetInfo beatmapSet) private BeatmapGroup createGroup(BeatmapSetInfo beatmapSet)
{ {
if (beatmapSet.Beatmaps.All(b => b.Hidden))
return null;
foreach (var b in beatmapSet.Beatmaps) foreach (var b in beatmapSet.Beatmaps)
{ {
if (b.Metadata == null) if (b.Metadata == null)