From 7ea9db1b72762a908bcbcb34ea83e1ce82c826e6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 6 Jun 2025 11:41:58 +0200 Subject: [PATCH] Fix leaderboard score display not respecting local timezone & user 12/24hr settings Closes https://github.com/ppy/osu/issues/33473. Cross-reference previous implementation: https://github.com/ppy/osu/blob/828e8da7726109888aa1a6a41921daad254b75c0/osu.Game/Online/Leaderboards/LeaderboardScoreTooltip.cs#L140-L141 --- .../BeatmapLeaderboardScore_Tooltip.cs | 25 +++++++++++++++++-- 1 file changed, 23 insertions(+), 2 deletions(-) diff --git a/osu.Game/Screens/SelectV2/BeatmapLeaderboardScore_Tooltip.cs b/osu.Game/Screens/SelectV2/BeatmapLeaderboardScore_Tooltip.cs index c6fe1e5f25..80ff3513e5 100644 --- a/osu.Game/Screens/SelectV2/BeatmapLeaderboardScore_Tooltip.cs +++ b/osu.Game/Screens/SelectV2/BeatmapLeaderboardScore_Tooltip.cs @@ -3,6 +3,7 @@ using System.Linq; using osu.Framework.Allocation; +using osu.Framework.Bindables; using osu.Framework.Extensions.Color4Extensions; using osu.Framework.Extensions.LocalisationExtensions; using osu.Framework.Graphics; @@ -12,6 +13,7 @@ using osu.Framework.Graphics.Cursor; using osu.Framework.Graphics.Effects; using osu.Framework.Graphics.Shapes; using osu.Framework.Localisation; +using osu.Game.Configuration; using osu.Game.Graphics; using osu.Game.Graphics.Containers; using osu.Game.Graphics.Sprites; @@ -88,17 +90,24 @@ namespace osu.Game.Screens.SelectV2 private DrawableDate relativeDate = null!; private FillFlowContainer statistics = null!; + private readonly Bindable prefer24HourTime = new Bindable(); + [Resolved] private OsuColour colours { get; set; } = null!; [Resolved] private OverlayColourProvider colourProvider { get; set; } = null!; + private ScoreInfo score = null!; + public ScoreInfo Score { + get => score; set { - absoluteDate.Text = value.Date.ToLocalisableString(@"dd MMMM yyyy h:mm tt"); + score = value; + + updateAbsoluteDate(); relativeDate.Date = value.Date; var judgementsStatistics = value.GetStatisticsForDisplay().Select(s => @@ -131,7 +140,7 @@ namespace osu.Game.Screens.SelectV2 } [BackgroundDependencyLoader] - private void load() + private void load(OsuConfigManager configManager) { RelativeSizeAxes = Axes.X; AutoSizeAxes = Axes.Y; @@ -205,7 +214,19 @@ namespace osu.Game.Screens.SelectV2 }, }, }; + + configManager.BindWith(OsuSetting.Prefer24HourTime, prefer24HourTime); } + + protected override void LoadComplete() + { + base.LoadComplete(); + + prefer24HourTime.BindValueChanged(_ => updateAbsoluteDate(), true); + } + + private void updateAbsoluteDate() + => absoluteDate.Text = score.Date.ToLocalTime().ToLocalisableString(prefer24HourTime.Value ? @"d MMMM yyyy HH:mm" : @"d MMMM yyyy h:mm tt"); } private partial class StatisticRow : CompositeDrawable