Skip to content

Commit

Permalink
Allow notification of new strings
Browse files Browse the repository at this point in the history
  • Loading branch information
peppy committed Jul 30, 2024
1 parent bdc465e commit e77489f
Show file tree
Hide file tree
Showing 3 changed files with 33 additions and 6 deletions.
29 changes: 29 additions & 0 deletions osu.Game/Localisation/DailyChallengeStrings.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
// Copyright (c) ppy Pty Ltd <contact@ppy.sh>. Licensed under the MIT Licence.
// See the LICENCE file in the repository root for full licence text.

using osu.Framework.Localisation;

namespace osu.Game.Localisation
{
public static class DailyChallengeStrings
{
private const string prefix = @"osu.Game.Resources.Localisation.DailyChallenge";

/// <summary>
/// "Today&#39;s daily challenge has concluded – thanks for playing!
///
/// Tomorrow&#39;s challenge is now being prepared and will appear soon."
/// </summary>
public static LocalisableString ChallengeEndedNotification => new TranslatableString(getKey(@"todays_daily_challenge_has_concluded"),
@"Today's daily challenge has concluded – thanks for playing!
Tomorrow's challenge is now being prepared and will appear soon.");

/// <summary>
/// "Today&#39;s daily challenge is now live! Click here to play."
/// </summary>
public static LocalisableString ChallengeLiveNotification => new TranslatableString(getKey(@"todays_daily_challenge_is_now"), @"Today's daily challenge is now live! Click here to play.");

private static string getKey(string key) => $@"{prefix}:{key}";
}
}
7 changes: 2 additions & 5 deletions osu.Game/Screens/OnlinePlay/DailyChallenge/DailyChallenge.cs
Original file line number Diff line number Diff line change
Expand Up @@ -417,16 +417,13 @@ private void dailyChallengeChanged(ValueChangedEvent<DailyChallengeInfo?> change
{
if (change.OldValue?.RoomID == room.RoomID.Value && change.NewValue == null)
{
notificationOverlay?.Post(new SimpleNotification
{
Text = "Today's daily challenge has concluded – thanks for playing!\n\nTomorrow's challenge is now being prepared and will appear soon."
});
notificationOverlay?.Post(new SimpleNotification { Text = DailyChallengeStrings.ChallengeEndedNotification });
}
}

private void forcefullyExit()
{
Logger.Log($"{this} forcefully exiting due to loss of API connection");
Logger.Log(@$"{this} forcefully exiting due to loss of API connection");

// This is temporary since we don't currently have a way to force screens to be exited
// See also: `OnlinePlayScreen.forcefullyExit()`
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@
using osu.Game.Online.Rooms;
using osu.Game.Overlays.Notifications;
using osu.Game.Screens.Menu;
using osu.Game.Localisation;

namespace osu.Game.Screens.OnlinePlay.DailyChallenge
{
Expand All @@ -26,7 +27,7 @@ public NewDailyChallengeNotification(Room room)
[BackgroundDependencyLoader]
private void load(OsuGame? game)
{
Text = "Today's daily challenge is now live! Click here to play.";
Text = DailyChallengeStrings.ChallengeLiveNotification;
Content.Add(card = new BeatmapCardNano((APIBeatmapSet)room.Playlist.Single().Beatmap.BeatmapSet!));
Activated = () =>
{
Expand Down

0 comments on commit e77489f

Please sign in to comment.