1
0
mirror of https://github.com/ppy/osu.git synced 2025-02-21 06:52:55 +08:00

Add missing mania tooltip overlay for 4k and 7k

This commit is contained in:
Nicholas Chin 2024-12-11 23:15:05 +08:00
parent 4e4a99decc
commit 26f15def70
3 changed files with 97 additions and 3 deletions

View File

@ -179,6 +179,16 @@ namespace osu.Game.Localisation
/// </summary>
public static LocalisableString CopyLink => new TranslatableString(getKey(@"copy_link"), @"Copy link");
/// <summary>
/// "4K"
/// </summary>
public static LocalisableString FourKey => new TranslatableString(getKey(@"four_key"), @"4K");
/// <summary>
/// "7K"
/// </summary>
public static LocalisableString SevenKey => new TranslatableString(getKey(@"seven_key"), @"7K");
private static string getKey(string key) => $@"{prefix}:{key}";
}
}
}

View File

@ -2,6 +2,7 @@
// See the LICENCE file in the repository root for full licence text.
using System.Collections.Generic;
using System.Linq;
using osu.Framework.Allocation;
using osu.Framework.Bindables;
using osu.Framework.Extensions.LocalisationExtensions;
@ -164,13 +165,56 @@ namespace osu.Game.Overlays.Profile.Header.Components
detailGlobalRank.Content = user?.Statistics?.GlobalRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";
var rankHighest = user?.RankHighest;
var variants = user?.Statistics.Variants;
detailGlobalRank.ContentTooltipText = rankHighest != null
? UsersStrings.ShowRankHighest(rankHighest.Rank.ToLocalisableString("\\##,##0"), rankHighest.UpdatedAt.ToLocalisableString(@"d MMM yyyy"))
#region Global rank tooltip
var tooltipParts = new List<LocalisableString>();
if (variants?.Count > 0)
{
foreach (var variant in variants)
{
if (variant.GlobalRank != null)
{
tooltipParts.Add($"{variant.VariantDisplay}: {variant.GlobalRank.ToLocalisableString("\\##,##0")}");
}
}
}
if (rankHighest != null)
{
tooltipParts.Add(UsersStrings.ShowRankHighest(
rankHighest.Rank.ToLocalisableString("\\##,##0"),
rankHighest.UpdatedAt.ToLocalisableString(@"d MMM yyyy"))
);
}
detailGlobalRank.ContentTooltipText = tooltipParts.Any()
? string.Join("\n", tooltipParts)
: string.Empty;
#endregion
detailCountryRank.Content = user?.Statistics?.CountryRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";
#region Country rank tooltip
var countryTooltipParts = new List<LocalisableString>();
if (variants?.Count > 0)
{
foreach (var variant in variants)
{
if (variant.CountryRank != null)
{
countryTooltipParts.Add($"{variant.VariantDisplay}: {variant.CountryRank.Value.ToLocalisableString("\\##,##0")}");
}
}
}
detailCountryRank.ContentTooltipText = countryTooltipParts.Any()
? string.Join("\n", countryTooltipParts)
: string.Empty;
#endregion
rankGraph.Statistics.Value = user?.Statistics;
}

View File

@ -4,8 +4,12 @@
#nullable disable
using System;
using System.Collections.Generic;
using System.Runtime.Serialization;
using Newtonsoft.Json;
using Newtonsoft.Json.Converters;
using osu.Framework.Localisation;
using osu.Game.Localisation;
using osu.Game.Online.API.Requests.Responses;
using osu.Game.Scoring;
using osu.Game.Utils;
@ -74,6 +78,9 @@ namespace osu.Game.Users
[JsonProperty(@"grade_counts")]
public Grades GradesCount;
[JsonProperty(@"variants")]
public List<Variant> Variants = null!;
public struct Grades
{
[JsonProperty(@"ssh")]
@ -118,5 +125,38 @@ namespace osu.Game.Users
}
}
}
public enum GameVariant
{
[EnumMember(Value = "4k")]
FourKey,
[EnumMember(Value = "7k")]
SevenKey
}
public class Variant
{
[JsonProperty("country_rank")]
public int? CountryRank;
[JsonProperty("global_rank")]
public int? GlobalRank;
[JsonProperty("mode")]
public string Mode;
[JsonProperty("pp")]
public decimal PP;
[JsonProperty("variant")]
[JsonConverter(typeof(StringEnumConverter))]
public GameVariant? VariantType;
public LocalisableString VariantDisplay => VariantType switch
{
GameVariant.FourKey => CommonStrings.FourKey,
GameVariant.SevenKey => CommonStrings.SevenKey,
_ => string.Empty
};
}
}
}