mirror of
https://github.com/ppy/osu.git
synced 2025-01-31 12:52:53 +08:00
Add support for automatically downloading daily challenge during the intro display
This commit is contained in:
parent
e95d61d4c2
commit
5d66eda982
@ -563,7 +563,7 @@ namespace osu.Game.Beatmaps
|
||||
remove => workingBeatmapCache.OnInvalidated -= value;
|
||||
}
|
||||
|
||||
public override bool IsAvailableLocally(BeatmapSetInfo model) => Realm.Run(realm => realm.All<BeatmapSetInfo>().Any(s => s.OnlineID == model.OnlineID));
|
||||
public override bool IsAvailableLocally(BeatmapSetInfo model) => Realm.Run(realm => realm.All<BeatmapSetInfo>().Any(s => s.OnlineID == model.OnlineID && !s.DeletePending));
|
||||
|
||||
#endregion
|
||||
|
||||
|
@ -492,6 +492,9 @@ namespace osu.Game.Screens.OnlinePlay.DailyChallenge
|
||||
|
||||
public static void TrySetDailyChallengeBeatmap(OsuScreen screen, BeatmapManager beatmaps, RulesetStore rulesets, MusicController music, PlaylistItem item)
|
||||
{
|
||||
if (!screen.IsCurrentScreen())
|
||||
return;
|
||||
|
||||
var beatmap = beatmaps.QueryBeatmap(b => b.OnlineID == item.Beatmap.OnlineID);
|
||||
|
||||
screen.Beatmap.Value = beatmaps.GetWorkingBeatmap(beatmap); // this will gracefully fall back to dummy beatmap if missing locally.
|
||||
|
@ -12,6 +12,7 @@ using osu.Framework.Graphics.Shapes;
|
||||
using osu.Framework.Screens;
|
||||
using osu.Game.Beatmaps;
|
||||
using osu.Game.Beatmaps.Drawables;
|
||||
using osu.Game.Configuration;
|
||||
using osu.Game.Graphics;
|
||||
using osu.Game.Graphics.Sprites;
|
||||
using osu.Game.Online.Rooms;
|
||||
@ -72,7 +73,7 @@ namespace osu.Game.Screens.OnlinePlay.DailyChallenge
|
||||
protected override BackgroundScreen CreateBackground() => new DailyChallengeIntroBackgroundScreen(colourProvider);
|
||||
|
||||
[BackgroundDependencyLoader]
|
||||
private void load(BeatmapDifficultyCache difficultyCache)
|
||||
private void load(BeatmapDifficultyCache difficultyCache, BeatmapModelDownloader beatmapDownloader, OsuConfigManager config)
|
||||
{
|
||||
const float horizontal_info_size = 500f;
|
||||
|
||||
@ -309,11 +310,21 @@ namespace osu.Game.Screens.OnlinePlay.DailyChallenge
|
||||
beatmapBackgroundLoaded = true;
|
||||
updateAnimationState();
|
||||
});
|
||||
|
||||
if (config.Get<bool>(OsuSetting.AutomaticallyDownloadMissingBeatmaps))
|
||||
{
|
||||
if (!beatmapManager.IsAvailableLocally(new BeatmapSetInfo { OnlineID = item.Beatmap.BeatmapSet!.OnlineID }))
|
||||
beatmapDownloader.Download(item.Beatmap.BeatmapSet!, config.Get<bool>(OsuSetting.PreferNoVideo));
|
||||
}
|
||||
}
|
||||
|
||||
public override void OnEntering(ScreenTransitionEvent e)
|
||||
{
|
||||
base.OnEntering(e);
|
||||
|
||||
beatmapAvailabilityTracker.SelectedItem.Value = playlistItem;
|
||||
beatmapAvailabilityTracker.Availability.BindValueChanged(_ => TrySetDailyChallengeBeatmap(this, beatmapManager, rulesets, musicController, playlistItem), true);
|
||||
|
||||
this.FadeInFromZero(400, Easing.OutQuint);
|
||||
updateAnimationState();
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user