mirror of
https://github.com/ppy/osu
synced 2025-01-10 16:19:47 +00:00
Merge pull request #17042 from peppy/ruleset-leaderboard-unavailable
Improve leaderboard messaging when using a custom ruleset (and add localisation support)
This commit is contained in:
commit
1d7d6a1b65
@ -10,6 +10,7 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Logging;
|
using osu.Framework.Logging;
|
||||||
using osu.Game.Configuration;
|
using osu.Game.Configuration;
|
||||||
|
using osu.Game.Extensions;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
@ -108,10 +109,7 @@ namespace osu.Desktop
|
|||||||
presence.Assets.LargeImageText = $"{user.Value.Username}" + (user.Value.Statistics?.GlobalRank > 0 ? $" (rank #{user.Value.Statistics.GlobalRank:N0})" : string.Empty);
|
presence.Assets.LargeImageText = $"{user.Value.Username}" + (user.Value.Statistics?.GlobalRank > 0 ? $" (rank #{user.Value.Statistics.GlobalRank:N0})" : string.Empty);
|
||||||
|
|
||||||
// update ruleset
|
// update ruleset
|
||||||
int onlineID = ruleset.Value.OnlineID;
|
presence.Assets.SmallImageKey = ruleset.Value.IsLegacyRuleset() ? $"mode_{ruleset.Value.OnlineID}" : "mode_custom";
|
||||||
bool isLegacyRuleset = onlineID >= 0 && onlineID <= ILegacyRuleset.MAX_LEGACY_RULESET_ID;
|
|
||||||
|
|
||||||
presence.Assets.SmallImageKey = isLegacyRuleset ? $"mode_{onlineID}" : "mode_custom";
|
|
||||||
presence.Assets.SmallImageText = ruleset.Value.Name;
|
presence.Assets.SmallImageText = ruleset.Value.Name;
|
||||||
|
|
||||||
client.SetPresence(presence);
|
client.SetPresence(presence);
|
||||||
|
@ -119,7 +119,8 @@ namespace osu.Game.Tests.Visual.SongSelect
|
|||||||
AddStep(@"Network failure", () => leaderboard.SetErrorState(LeaderboardState.NetworkFailure));
|
AddStep(@"Network failure", () => leaderboard.SetErrorState(LeaderboardState.NetworkFailure));
|
||||||
AddStep(@"No supporter", () => leaderboard.SetErrorState(LeaderboardState.NotSupporter));
|
AddStep(@"No supporter", () => leaderboard.SetErrorState(LeaderboardState.NotSupporter));
|
||||||
AddStep(@"Not logged in", () => leaderboard.SetErrorState(LeaderboardState.NotLoggedIn));
|
AddStep(@"Not logged in", () => leaderboard.SetErrorState(LeaderboardState.NotLoggedIn));
|
||||||
AddStep(@"Unavailable", () => leaderboard.SetErrorState(LeaderboardState.Unavailable));
|
AddStep(@"Ruleset unavailable", () => leaderboard.SetErrorState(LeaderboardState.RulesetUnavailable));
|
||||||
|
AddStep(@"Beatmap unavailable", () => leaderboard.SetErrorState(LeaderboardState.BeatmapUnavailable));
|
||||||
AddStep(@"None selected", () => leaderboard.SetErrorState(LeaderboardState.NoneSelected));
|
AddStep(@"None selected", () => leaderboard.SetErrorState(LeaderboardState.NoneSelected));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -9,6 +9,7 @@ using osu.Framework.Allocation;
|
|||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
using osu.Framework.Extensions.IEnumerableExtensions;
|
using osu.Framework.Extensions.IEnumerableExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
|
using osu.Game.Extensions;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Rulesets;
|
using osu.Game.Rulesets;
|
||||||
@ -83,7 +84,7 @@ namespace osu.Game.Beatmaps
|
|||||||
requestedUserId = api.LocalUser.Value.Id;
|
requestedUserId = api.LocalUser.Value.Id;
|
||||||
|
|
||||||
// only query API for built-in rulesets
|
// only query API for built-in rulesets
|
||||||
rulesets.AvailableRulesets.Where(ruleset => ruleset.OnlineID >= 0 && ruleset.OnlineID <= ILegacyRuleset.MAX_LEGACY_RULESET_ID).ForEach(rulesetInfo =>
|
rulesets.AvailableRulesets.Where(ruleset => ruleset.IsLegacyRuleset()).ForEach(rulesetInfo =>
|
||||||
{
|
{
|
||||||
var req = new GetUserRequest(api.LocalUser.Value.Id, rulesetInfo);
|
var req = new GetUserRequest(api.LocalUser.Value.Id, rulesetInfo);
|
||||||
|
|
||||||
|
@ -72,6 +72,11 @@ namespace osu.Game.Extensions
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Check whether this <see cref="IRulesetInfo"/>'s online ID is within the range that defines it as a legacy ruleset (ie. either osu!, osu!taiko, osu!catch or osu!mania).
|
||||||
|
/// </summary>
|
||||||
|
public static bool IsLegacyRuleset(this IRulesetInfo ruleset) => ruleset.OnlineID >= 0 && ruleset.OnlineID <= ILegacyRuleset.MAX_LEGACY_RULESET_ID;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Check whether the online ID of two <see cref="IBeatmapSetInfo"/>s match.
|
/// Check whether the online ID of two <see cref="IBeatmapSetInfo"/>s match.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
49
osu.Game/Localisation/LeaderboardStrings.cs
Normal file
49
osu.Game/Localisation/LeaderboardStrings.cs
Normal file
@ -0,0 +1,49 @@
|
|||||||
|
// 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 LeaderboardStrings
|
||||||
|
{
|
||||||
|
private const string prefix = @"osu.Game.Resources.Localisation.Leaderboard";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Couldn't fetch scores!"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString CouldntFetchScores => new TranslatableString(getKey(@"couldnt_fetch_scores"), @"Couldn't fetch scores!");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Please select a beatmap!"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString PleaseSelectABeatmap => new TranslatableString(getKey(@"please_select_a_beatmap"), @"Please select a beatmap!");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Leaderboards are not available for this ruleset!"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString LeaderboardsAreNotAvailableForThisRuleset => new TranslatableString(getKey(@"leaderboards_are_not_available_for_this_ruleset"), @"Leaderboards are not available for this ruleset!");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Leaderboards are not available for this beatmap!"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString LeaderboardsAreNotAvailableForThisBeatmap => new TranslatableString(getKey(@"leaderboards_are_not_available_for_this_beatmap"), @"Leaderboards are not available for this beatmap!");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "No records yet!"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString NoRecordsYet => new TranslatableString(getKey(@"no_records_yet"), @"No records yet!");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Please sign in to view online leaderboards!"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString PleaseSignInToViewOnlineLeaderboards => new TranslatableString(getKey(@"please_sign_in_to_view_online_leaderboards"), @"Please sign in to view online leaderboards!");
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// "Please invest in an osu!supporter tag to view this leaderboard!"
|
||||||
|
/// </summary>
|
||||||
|
public static LocalisableString PleaseInvestInAnOsuSupporterTagToViewThisLeaderboard => new TranslatableString(getKey(@"please_invest_in_an_osu_supporter_tag_to_view_this_leaderboard"), @"Please invest in an osu!supporter tag to view this leaderboard!");
|
||||||
|
|
||||||
|
private static string getKey(string key) => $@"{prefix}:{key}";
|
||||||
|
}
|
||||||
|
}
|
@ -22,6 +22,7 @@ using osu.Game.Online.API;
|
|||||||
using osu.Game.Online.Placeholders;
|
using osu.Game.Online.Placeholders;
|
||||||
using osuTK;
|
using osuTK;
|
||||||
using osuTK.Graphics;
|
using osuTK.Graphics;
|
||||||
|
using osu.Game.Localisation;
|
||||||
|
|
||||||
namespace osu.Game.Online.Leaderboards
|
namespace osu.Game.Online.Leaderboards
|
||||||
{
|
{
|
||||||
@ -311,25 +312,28 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
switch (state)
|
switch (state)
|
||||||
{
|
{
|
||||||
case LeaderboardState.NetworkFailure:
|
case LeaderboardState.NetworkFailure:
|
||||||
return new ClickablePlaceholder(@"Couldn't fetch scores!", FontAwesome.Solid.Sync)
|
return new ClickablePlaceholder(LeaderboardStrings.CouldntFetchScores, FontAwesome.Solid.Sync)
|
||||||
{
|
{
|
||||||
Action = RefetchScores
|
Action = RefetchScores
|
||||||
};
|
};
|
||||||
|
|
||||||
case LeaderboardState.NoneSelected:
|
case LeaderboardState.NoneSelected:
|
||||||
return new MessagePlaceholder(@"Please select a beatmap!");
|
return new MessagePlaceholder(LeaderboardStrings.PleaseSelectABeatmap);
|
||||||
|
|
||||||
case LeaderboardState.Unavailable:
|
case LeaderboardState.RulesetUnavailable:
|
||||||
return new MessagePlaceholder(@"Leaderboards are not available for this beatmap!");
|
return new MessagePlaceholder(LeaderboardStrings.LeaderboardsAreNotAvailableForThisRuleset);
|
||||||
|
|
||||||
|
case LeaderboardState.BeatmapUnavailable:
|
||||||
|
return new MessagePlaceholder(LeaderboardStrings.LeaderboardsAreNotAvailableForThisBeatmap);
|
||||||
|
|
||||||
case LeaderboardState.NoScores:
|
case LeaderboardState.NoScores:
|
||||||
return new MessagePlaceholder(@"No records yet!");
|
return new MessagePlaceholder(LeaderboardStrings.NoRecordsYet);
|
||||||
|
|
||||||
case LeaderboardState.NotLoggedIn:
|
case LeaderboardState.NotLoggedIn:
|
||||||
return new LoginPlaceholder(@"Please sign in to view online leaderboards!");
|
return new LoginPlaceholder(LeaderboardStrings.PleaseSignInToViewOnlineLeaderboards);
|
||||||
|
|
||||||
case LeaderboardState.NotSupporter:
|
case LeaderboardState.NotSupporter:
|
||||||
return new MessagePlaceholder(@"Please invest in an osu!supporter tag to view this leaderboard!");
|
return new MessagePlaceholder(LeaderboardStrings.PleaseInvestInAnOsuSupporterTagToViewThisLeaderboard);
|
||||||
|
|
||||||
case LeaderboardState.Retrieving:
|
case LeaderboardState.Retrieving:
|
||||||
return null;
|
return null;
|
||||||
|
@ -8,7 +8,8 @@ namespace osu.Game.Online.Leaderboards
|
|||||||
Success,
|
Success,
|
||||||
Retrieving,
|
Retrieving,
|
||||||
NetworkFailure,
|
NetworkFailure,
|
||||||
Unavailable,
|
BeatmapUnavailable,
|
||||||
|
RulesetUnavailable,
|
||||||
NoneSelected,
|
NoneSelected,
|
||||||
NoScores,
|
NoScores,
|
||||||
NotLoggedIn,
|
NotLoggedIn,
|
||||||
|
@ -3,6 +3,7 @@
|
|||||||
|
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Graphics.Sprites;
|
using osu.Framework.Graphics.Sprites;
|
||||||
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Overlays;
|
using osu.Game.Overlays;
|
||||||
|
|
||||||
namespace osu.Game.Online.Placeholders
|
namespace osu.Game.Online.Placeholders
|
||||||
@ -12,7 +13,7 @@ namespace osu.Game.Online.Placeholders
|
|||||||
[Resolved(CanBeNull = true)]
|
[Resolved(CanBeNull = true)]
|
||||||
private LoginOverlay login { get; set; }
|
private LoginOverlay login { get; set; }
|
||||||
|
|
||||||
public LoginPlaceholder(string actionMessage)
|
public LoginPlaceholder(LocalisableString actionMessage)
|
||||||
: base(actionMessage, FontAwesome.Solid.UserLock)
|
: base(actionMessage, FontAwesome.Solid.UserLock)
|
||||||
{
|
{
|
||||||
Action = () => login?.Show();
|
Action = () => login?.Show();
|
||||||
|
@ -7,9 +7,9 @@ using System.Linq;
|
|||||||
using System.Text;
|
using System.Text;
|
||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Extensions;
|
||||||
using osu.Game.IO.Legacy;
|
using osu.Game.IO.Legacy;
|
||||||
using osu.Game.Replays.Legacy;
|
using osu.Game.Replays.Legacy;
|
||||||
using osu.Game.Rulesets;
|
|
||||||
using osu.Game.Rulesets.Replays;
|
using osu.Game.Rulesets.Replays;
|
||||||
using osu.Game.Rulesets.Replays.Types;
|
using osu.Game.Rulesets.Replays.Types;
|
||||||
using SharpCompress.Compressors.LZMA;
|
using SharpCompress.Compressors.LZMA;
|
||||||
@ -48,7 +48,7 @@ namespace osu.Game.Scoring.Legacy
|
|||||||
if (beatmap == null && !score.Replay.Frames.All(f => f is LegacyReplayFrame))
|
if (beatmap == null && !score.Replay.Frames.All(f => f is LegacyReplayFrame))
|
||||||
throw new ArgumentException(@"Beatmap must be provided if frames are not already legacy frames.", nameof(beatmap));
|
throw new ArgumentException(@"Beatmap must be provided if frames are not already legacy frames.", nameof(beatmap));
|
||||||
|
|
||||||
if (score.ScoreInfo.Ruleset.OnlineID < 0 || score.ScoreInfo.Ruleset.OnlineID > ILegacyRuleset.MAX_LEGACY_RULESET_ID)
|
if (!score.ScoreInfo.Ruleset.IsLegacyRuleset())
|
||||||
throw new ArgumentException(@"Only scores in the osu, taiko, catch, or mania rulesets can be encoded to the legacy score format.", nameof(score));
|
throw new ArgumentException(@"Only scores in the osu, taiko, catch, or mania rulesets can be encoded to the legacy score format.", nameof(score));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -4,10 +4,10 @@
|
|||||||
using System;
|
using System;
|
||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
|
using osu.Game.Extensions;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.Rooms;
|
using osu.Game.Online.Rooms;
|
||||||
using osu.Game.Online.Solo;
|
using osu.Game.Online.Solo;
|
||||||
using osu.Game.Rulesets;
|
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
|
|
||||||
namespace osu.Game.Screens.Play
|
namespace osu.Game.Screens.Play
|
||||||
@ -32,7 +32,7 @@ namespace osu.Game.Screens.Play
|
|||||||
if (beatmapId <= 0)
|
if (beatmapId <= 0)
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
if (rulesetId < 0 || rulesetId > ILegacyRuleset.MAX_LEGACY_RULESET_ID)
|
if (!Ruleset.Value.IsLegacyRuleset())
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
return new CreateSoloScoreRequest(beatmapId, rulesetId, Game.VersionHash);
|
return new CreateSoloScoreRequest(beatmapId, rulesetId, Game.VersionHash);
|
||||||
|
@ -11,6 +11,7 @@ using osu.Framework.Bindables;
|
|||||||
using osu.Framework.Extensions;
|
using osu.Framework.Extensions;
|
||||||
using osu.Game.Beatmaps;
|
using osu.Game.Beatmaps;
|
||||||
using osu.Game.Database;
|
using osu.Game.Database;
|
||||||
|
using osu.Game.Extensions;
|
||||||
using osu.Game.Online.API;
|
using osu.Game.Online.API;
|
||||||
using osu.Game.Online.API.Requests;
|
using osu.Game.Online.API.Requests;
|
||||||
using osu.Game.Online.Leaderboards;
|
using osu.Game.Online.Leaderboards;
|
||||||
@ -98,6 +99,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
protected override APIRequest FetchScores(CancellationToken cancellationToken)
|
protected override APIRequest FetchScores(CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
var fetchBeatmapInfo = BeatmapInfo;
|
var fetchBeatmapInfo = BeatmapInfo;
|
||||||
|
var fetchRuleset = ruleset.Value ?? fetchBeatmapInfo.Ruleset;
|
||||||
|
|
||||||
if (fetchBeatmapInfo == null)
|
if (fetchBeatmapInfo == null)
|
||||||
{
|
{
|
||||||
@ -117,9 +119,15 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!fetchRuleset.IsLegacyRuleset())
|
||||||
|
{
|
||||||
|
SetErrorState(LeaderboardState.RulesetUnavailable);
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
if (fetchBeatmapInfo.OnlineID <= 0 || fetchBeatmapInfo.Status <= BeatmapOnlineStatus.Pending)
|
if (fetchBeatmapInfo.OnlineID <= 0 || fetchBeatmapInfo.Status <= BeatmapOnlineStatus.Pending)
|
||||||
{
|
{
|
||||||
SetErrorState(LeaderboardState.Unavailable);
|
SetErrorState(LeaderboardState.BeatmapUnavailable);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -137,7 +145,7 @@ namespace osu.Game.Screens.Select.Leaderboards
|
|||||||
else if (filterMods)
|
else if (filterMods)
|
||||||
requestMods = mods.Value;
|
requestMods = mods.Value;
|
||||||
|
|
||||||
var req = new GetScoresRequest(fetchBeatmapInfo, ruleset.Value ?? fetchBeatmapInfo.Ruleset, Scope, requestMods);
|
var req = new GetScoresRequest(fetchBeatmapInfo, fetchRuleset, Scope, requestMods);
|
||||||
|
|
||||||
req.Success += r =>
|
req.Success += r =>
|
||||||
{
|
{
|
||||||
|
Loading…
Reference in New Issue
Block a user