1
0
mirror of https://github.com/ppy/osu.git synced 2026-05-13 20:33:35 +08:00

Merge pull request #32567 from peppy/fix-christmas-music-oh-no

Fix christmas menu track potentially playing out of season
This commit is contained in:
Dan Balasescu
2025-03-26 14:41:31 +09:00
committed by GitHub
Unverified
+16 -13
View File
@@ -20,6 +20,7 @@ using osu.Game.Beatmaps;
using osu.Game.Configuration; using osu.Game.Configuration;
using osu.Game.Database; using osu.Game.Database;
using osu.Game.Rulesets.Mods; using osu.Game.Rulesets.Mods;
using osu.Game.Seasonal;
namespace osu.Game.Overlays namespace osu.Game.Overlays
{ {
@@ -256,8 +257,8 @@ namespace osu.Game.Overlays
playableSet = getNextRandom(-1, allowProtectedTracks); playableSet = getNextRandom(-1, allowProtectedTracks);
else else
{ {
playableSet = getBeatmapSets().TakeWhile(i => !i.Value.Equals(current?.BeatmapSetInfo)).LastOrDefault(s => !s.Value.Protected || allowProtectedTracks) playableSet = getBeatmapSets(allowProtectedTracks).TakeWhile(i => !i.Value.Equals(current?.BeatmapSetInfo)).LastOrDefault()
?? getBeatmapSets().LastOrDefault(s => !s.Value.Protected || allowProtectedTracks); ?? getBeatmapSets(allowProtectedTracks).LastOrDefault();
} }
if (playableSet != null) if (playableSet != null)
@@ -352,10 +353,8 @@ namespace osu.Game.Overlays
playableSet = getNextRandom(1, allowProtectedTracks); playableSet = getNextRandom(1, allowProtectedTracks);
else else
{ {
playableSet = getBeatmapSets().SkipWhile(i => !i.Value.Equals(current?.BeatmapSetInfo)) playableSet = getBeatmapSets(allowProtectedTracks).SkipWhile(i => !i.Value.Equals(current?.BeatmapSetInfo)).ElementAtOrDefault(1)
.Where(i => !i.Value.Protected || allowProtectedTracks) ?? getBeatmapSets(allowProtectedTracks).FirstOrDefault();
.ElementAtOrDefault(1)
?? getBeatmapSets().FirstOrDefault(i => !i.Value.Protected || allowProtectedTracks);
} }
var playableBeatmap = playableSet?.Value.Beatmaps.FirstOrDefault(); var playableBeatmap = playableSet?.Value.Beatmaps.FirstOrDefault();
@@ -376,12 +375,13 @@ namespace osu.Game.Overlays
{ {
Live<BeatmapSetInfo> result; Live<BeatmapSetInfo> result;
var possibleSets = getBeatmapSets().Where(s => !s.Value.Protected || allowProtectedTracks).ToList(); var possibleSets = getBeatmapSets(allowProtectedTracks).ToList();
if (possibleSets.Count == 0) if (possibleSets.Count == 0)
return null; return null;
// if there is only one possible set left, play it, even if it is the same as the current track. // if there is only
// one possible set left, play it, even if it is the same as the current track.
// looping is preferable over playing nothing. // looping is preferable over playing nothing.
if (possibleSets.Count == 1) if (possibleSets.Count == 1)
return possibleSets.Single(); return possibleSets.Single();
@@ -459,9 +459,12 @@ namespace osu.Game.Overlays
private TrackChangeDirection? queuedDirection; private TrackChangeDirection? queuedDirection;
private IEnumerable<Live<BeatmapSetInfo>> getBeatmapSets() => realm.Realm.All<BeatmapSetInfo>().Where(s => !s.DeletePending) private IEnumerable<Live<BeatmapSetInfo>> getBeatmapSets(bool allowProtectedTracks) =>
.AsEnumerable() realm.Realm.All<BeatmapSetInfo>().Where(s => !s.DeletePending)
.Select(s => new RealmLive<BeatmapSetInfo>(s, realm)); .AsEnumerable()
.Select(s => new RealmLive<BeatmapSetInfo>(s, realm))
.Where(i => (allowProtectedTracks || !i.Value.Protected)
&& (SeasonalUIConfig.ENABLED || i.Value.Hash != IntroChristmas.CHRISTMAS_BEATMAP_SET_HASH));
private void changeBeatmap(WorkingBeatmap newWorking) private void changeBeatmap(WorkingBeatmap newWorking)
{ {
@@ -488,8 +491,8 @@ namespace osu.Game.Overlays
else else
{ {
// figure out the best direction based on order in playlist. // figure out the best direction based on order in playlist.
int last = getBeatmapSets().TakeWhile(b => !b.Value.Equals(current.BeatmapSetInfo)).Count(); int last = getBeatmapSets(allowProtectedTracks: false).TakeWhile(b => !b.Value.Equals(current.BeatmapSetInfo)).Count();
int next = getBeatmapSets().TakeWhile(b => !b.Value.Equals(newWorking.BeatmapSetInfo)).Count(); int next = getBeatmapSets(allowProtectedTracks: false).TakeWhile(b => !b.Value.Equals(newWorking.BeatmapSetInfo)).Count();
direction = last > next ? TrackChangeDirection.Prev : TrackChangeDirection.Next; direction = last > next ? TrackChangeDirection.Prev : TrackChangeDirection.Next;
} }