mirror of
https://github.com/ppy/osu.git
synced 2025-02-06 20:22:56 +08:00
Merge pull request #31084 from NicholasChin28/mania-profile-overlay-tooltip
Add missing mania tooltip overlay for 4k and 7k
This commit is contained in:
commit
d72a0b04b8
@ -4,12 +4,14 @@
|
|||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using osu.Framework.Allocation;
|
using osu.Framework.Allocation;
|
||||||
using osu.Framework.Bindables;
|
using osu.Framework.Bindables;
|
||||||
|
using osu.Framework.Extensions;
|
||||||
using osu.Framework.Extensions.LocalisationExtensions;
|
using osu.Framework.Extensions.LocalisationExtensions;
|
||||||
using osu.Framework.Graphics;
|
using osu.Framework.Graphics;
|
||||||
using osu.Framework.Graphics.Containers;
|
using osu.Framework.Graphics.Containers;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Graphics;
|
using osu.Game.Graphics;
|
||||||
using osu.Game.Graphics.Sprites;
|
using osu.Game.Graphics.Sprites;
|
||||||
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
using osu.Game.Online.Leaderboards;
|
using osu.Game.Online.Leaderboards;
|
||||||
using osu.Game.Resources.Localisation.Web;
|
using osu.Game.Resources.Localisation.Web;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
@ -162,18 +164,77 @@ namespace osu.Game.Overlays.Profile.Header.Components
|
|||||||
scoreRankInfo.Value.RankCount = user?.Statistics?.GradesCount[scoreRankInfo.Key] ?? 0;
|
scoreRankInfo.Value.RankCount = user?.Statistics?.GradesCount[scoreRankInfo.Key] ?? 0;
|
||||||
|
|
||||||
detailGlobalRank.Content = user?.Statistics?.GlobalRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";
|
detailGlobalRank.Content = user?.Statistics?.GlobalRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";
|
||||||
|
detailGlobalRank.ContentTooltipText = getGlobalRankTooltipText(user);
|
||||||
var rankHighest = user?.RankHighest;
|
|
||||||
|
|
||||||
detailGlobalRank.ContentTooltipText = rankHighest != null
|
|
||||||
? UsersStrings.ShowRankHighest(rankHighest.Rank.ToLocalisableString("\\##,##0"), rankHighest.UpdatedAt.ToLocalisableString(@"d MMM yyyy"))
|
|
||||||
: string.Empty;
|
|
||||||
|
|
||||||
detailCountryRank.Content = user?.Statistics?.CountryRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";
|
detailCountryRank.Content = user?.Statistics?.CountryRank?.ToLocalisableString("\\##,##0") ?? (LocalisableString)"-";
|
||||||
|
detailCountryRank.ContentTooltipText = getCountryRankTooltipText(user);
|
||||||
|
|
||||||
rankGraph.Statistics.Value = user?.Statistics;
|
rankGraph.Statistics.Value = user?.Statistics;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static LocalisableString getGlobalRankTooltipText(APIUser? user)
|
||||||
|
{
|
||||||
|
var rankHighest = user?.RankHighest;
|
||||||
|
var variants = user?.Statistics?.Variants;
|
||||||
|
|
||||||
|
LocalisableString? result = null;
|
||||||
|
|
||||||
|
if (variants?.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var variant in variants)
|
||||||
|
{
|
||||||
|
if (variant.GlobalRank != null)
|
||||||
|
{
|
||||||
|
var variantText = LocalisableString.Interpolate($"{variant.VariantType.GetLocalisableDescription()}: {variant.GlobalRank.ToLocalisableString("\\##,##0")}");
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
result = variantText;
|
||||||
|
else
|
||||||
|
result = LocalisableString.Interpolate($"{result}\n{variantText}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rankHighest != null)
|
||||||
|
{
|
||||||
|
var rankHighestText = UsersStrings.ShowRankHighest(
|
||||||
|
rankHighest.Rank.ToLocalisableString("\\##,##0"),
|
||||||
|
rankHighest.UpdatedAt.ToLocalisableString(@"d MMM yyyy"));
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
result = rankHighestText;
|
||||||
|
else
|
||||||
|
result = LocalisableString.Interpolate($"{result}\n{rankHighestText}");
|
||||||
|
}
|
||||||
|
|
||||||
|
return result ?? default;
|
||||||
|
}
|
||||||
|
|
||||||
|
private static LocalisableString getCountryRankTooltipText(APIUser? user)
|
||||||
|
{
|
||||||
|
var variants = user?.Statistics?.Variants;
|
||||||
|
|
||||||
|
LocalisableString? result = null;
|
||||||
|
|
||||||
|
if (variants?.Count > 0)
|
||||||
|
{
|
||||||
|
foreach (var variant in variants)
|
||||||
|
{
|
||||||
|
if (variant.CountryRank != null)
|
||||||
|
{
|
||||||
|
var variantText = LocalisableString.Interpolate($"{variant.VariantType.GetLocalisableDescription()}: {variant.CountryRank.ToLocalisableString("\\##,##0")}");
|
||||||
|
|
||||||
|
if (result == null)
|
||||||
|
result = variantText;
|
||||||
|
else
|
||||||
|
result = LocalisableString.Interpolate($"{result}\n{variantText}");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return result ?? default;
|
||||||
|
}
|
||||||
|
|
||||||
private partial class ScoreRankInfo : CompositeDrawable
|
private partial class ScoreRankInfo : CompositeDrawable
|
||||||
{
|
{
|
||||||
private readonly OsuSpriteText rankCount;
|
private readonly OsuSpriteText rankCount;
|
||||||
|
@ -4,9 +4,14 @@
|
|||||||
#nullable disable
|
#nullable disable
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Runtime.Serialization;
|
||||||
|
using JetBrains.Annotations;
|
||||||
using Newtonsoft.Json;
|
using Newtonsoft.Json;
|
||||||
|
using Newtonsoft.Json.Converters;
|
||||||
using osu.Framework.Localisation;
|
using osu.Framework.Localisation;
|
||||||
using osu.Game.Online.API.Requests.Responses;
|
using osu.Game.Online.API.Requests.Responses;
|
||||||
|
using osu.Game.Resources.Localisation.Web;
|
||||||
using osu.Game.Scoring;
|
using osu.Game.Scoring;
|
||||||
using osu.Game.Utils;
|
using osu.Game.Utils;
|
||||||
|
|
||||||
@ -74,6 +79,10 @@ namespace osu.Game.Users
|
|||||||
[JsonProperty(@"grade_counts")]
|
[JsonProperty(@"grade_counts")]
|
||||||
public Grades GradesCount;
|
public Grades GradesCount;
|
||||||
|
|
||||||
|
[JsonProperty(@"variants")]
|
||||||
|
[CanBeNull]
|
||||||
|
public List<Variant> Variants;
|
||||||
|
|
||||||
public struct Grades
|
public struct Grades
|
||||||
{
|
{
|
||||||
[JsonProperty(@"ssh")]
|
[JsonProperty(@"ssh")]
|
||||||
@ -118,5 +127,35 @@ namespace osu.Game.Users
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public enum RulesetVariant
|
||||||
|
{
|
||||||
|
[EnumMember(Value = "4k")]
|
||||||
|
[LocalisableDescription(typeof(BeatmapsStrings), nameof(BeatmapsStrings.VariantMania4k))]
|
||||||
|
FourKey,
|
||||||
|
|
||||||
|
[EnumMember(Value = "7k")]
|
||||||
|
[LocalisableDescription(typeof(BeatmapsStrings), nameof(BeatmapsStrings.VariantMania7k))]
|
||||||
|
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 RulesetVariant VariantType;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user