Skip to content

Commit

Permalink
Add DailyChallengeIntroPlayed session static
Browse files Browse the repository at this point in the history
  • Loading branch information
frenzibyte committed Aug 20, 2024
1 parent f4b8fc6 commit 637c9ae
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 1 deletion.
6 changes: 6 additions & 0 deletions osu.Game/Configuration/SessionStatics.cs
Original file line number Diff line number Diff line change
Expand Up @@ -80,5 +80,11 @@ public enum Static
/// Stores the local user's last score (can be completed or aborted).
/// </summary>
LastLocalUserScore,

/// <summary>
/// Whether the intro animation for the daily challenge screen has been played once.
/// This is reset when a new challenge is up.
/// </summary>
DailyChallengeIntroPlayed,
}
}
7 changes: 7 additions & 0 deletions osu.Game/Screens/Menu/DailyChallengeButton.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using osu.Framework.Threading;
using osu.Framework.Utils;
using osu.Game.Beatmaps.Drawables;
using osu.Game.Configuration;
using osu.Game.Graphics;
using osu.Game.Graphics.Sprites;
using osu.Game.Localisation;
Expand Down Expand Up @@ -46,6 +47,9 @@ public partial class DailyChallengeButton : MainMenuButton
[Resolved]
private INotificationOverlay? notificationOverlay { get; set; }

[Resolved]
private SessionStatics statics { get; set; } = null!;

public DailyChallengeButton(string sampleName, Color4 colour, Action<MainMenuButton>? clickAction = null, params Key[] triggerKeys)
: base(ButtonSystemStrings.DailyChallenge, sampleName, OsuIcon.DailyChallenge, colour, clickAction, triggerKeys)
{
Expand Down Expand Up @@ -148,6 +152,9 @@ private void dailyChallengeChanged(ValueChangedEvent<DailyChallengeInfo?> _)

roomRequest.Success += room =>
{
// force showing intro on the first time when a new daily challenge is up.
statics.SetValue(Static.DailyChallengeIntroPlayed, false);
Room = room;
cover.OnlineInfo = TooltipContent = room.Playlist.FirstOrDefault()?.Beatmap.BeatmapSet as APIBeatmapSet;
Expand Down
5 changes: 4 additions & 1 deletion osu.Game/Screens/Menu/MainMenu.cs
Original file line number Diff line number Diff line change
Expand Up @@ -150,7 +150,10 @@ private void load(BeatmapListingOverlay beatmapListing, SettingsOverlay settings
OnPlaylists = () => this.Push(new Playlists()),
OnDailyChallenge = room =>
{
this.Push(new DailyChallengeIntro(room));
if (statics.Get<bool>(Static.DailyChallengeIntroPlayed))
this.Push(new DailyChallenge(room));
else
this.Push(new DailyChallengeIntro(room));
},
OnExit = () =>
{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,9 @@ public partial class DailyChallengeIntro : OsuScreen
[Resolved]
private MusicController musicController { get; set; } = null!;

[Resolved]
private SessionStatics statics { get; set; } = null!;

private Sample? dateWindupSample;
private Sample? dateImpactSample;
private Sample? beatmapWindupSample;
Expand Down Expand Up @@ -461,6 +464,8 @@ private void beginAnimation()
{
Schedule(() =>
{
statics.SetValue(Static.DailyChallengeIntroPlayed, true);
if (this.IsCurrentScreen())
this.Push(new DailyChallenge(room));
});
Expand Down

0 comments on commit 637c9ae

Please sign in to comment.