From a3301dc7ffb0a6e4958065f8b8210a3b98c1fdc4 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Fri, 28 Jul 2023 23:22:28 -0700 Subject: [PATCH 1/6] Fix accuracy break info decimal separator being incorrect in certain languages --- osu.Game/Screens/Play/Break/BreakInfoLine.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/osu.Game/Screens/Play/Break/BreakInfoLine.cs b/osu.Game/Screens/Play/Break/BreakInfoLine.cs index 7261155c9445..b8696352e883 100644 --- a/osu.Game/Screens/Play/Break/BreakInfoLine.cs +++ b/osu.Game/Screens/Play/Break/BreakInfoLine.cs @@ -58,7 +58,7 @@ public BreakInfoLine(LocalisableString name, string prefix = @"") private void currentValueChanged(ValueChangedEvent e) { - string newText = prefix + Format(e.NewValue); + LocalisableString newText = LocalisableString.Interpolate($"{prefix}{Format(e.NewValue)}"); if (valueText.Text == newText) return; From 9d928c0225d3b86257f1cf8cd71a606c46038892 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sat, 29 Jul 2023 10:39:50 -0700 Subject: [PATCH 2/6] Apply NRT to `BreakInfoLine` --- osu.Game/Screens/Play/Break/BreakInfoLine.cs | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/osu.Game/Screens/Play/Break/BreakInfoLine.cs b/osu.Game/Screens/Play/Break/BreakInfoLine.cs index b8696352e883..c6a0ca0ef68b 100644 --- a/osu.Game/Screens/Play/Break/BreakInfoLine.cs +++ b/osu.Game/Screens/Play/Break/BreakInfoLine.cs @@ -1,8 +1,6 @@ // Copyright (c) ppy Pty Ltd . Licensed under the MIT Licence. // See the LICENCE file in the repository root for full licence text. -#nullable disable - using System; using osu.Framework.Allocation; using osu.Framework.Bindables; @@ -71,7 +69,7 @@ protected virtual LocalisableString Format(T count) if (count is Enum countEnum) return countEnum.GetDescription(); - return count.ToString(); + return count.ToString() ?? string.Empty; } [BackgroundDependencyLoader] From 740898dffb910d5d6e8306c746e9578b383b47d0 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sat, 29 Jul 2023 10:40:18 -0700 Subject: [PATCH 3/6] Remove unnecessary prefix parameter --- osu.Game/Screens/Play/Break/BreakInfoLine.cs | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/osu.Game/Screens/Play/Break/BreakInfoLine.cs b/osu.Game/Screens/Play/Break/BreakInfoLine.cs index c6a0ca0ef68b..cfdf6cc65137 100644 --- a/osu.Game/Screens/Play/Break/BreakInfoLine.cs +++ b/osu.Game/Screens/Play/Break/BreakInfoLine.cs @@ -24,12 +24,8 @@ public partial class BreakInfoLine : Container private readonly OsuSpriteText text; private readonly OsuSpriteText valueText; - private readonly string prefix; - - public BreakInfoLine(LocalisableString name, string prefix = @"") + public BreakInfoLine(LocalisableString name) { - this.prefix = prefix; - AutoSizeAxes = Axes.Y; Children = new Drawable[] { @@ -45,7 +41,7 @@ public BreakInfoLine(LocalisableString name, string prefix = @"") { Anchor = Anchor.Centre, Origin = Anchor.CentreLeft, - Text = prefix + @"-", + Text = @"-", Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 17), Margin = new MarginPadding { Left = margin } } @@ -56,7 +52,7 @@ public BreakInfoLine(LocalisableString name, string prefix = @"") private void currentValueChanged(ValueChangedEvent e) { - LocalisableString newText = LocalisableString.Interpolate($"{prefix}{Format(e.NewValue)}"); + LocalisableString newText = Format(e.NewValue); if (valueText.Text == newText) return; @@ -82,8 +78,8 @@ private void load(OsuColour colours) public partial class PercentageBreakInfoLine : BreakInfoLine { - public PercentageBreakInfoLine(LocalisableString name, string prefix = "") - : base(name, prefix) + public PercentageBreakInfoLine(LocalisableString name) + : base(name) { } From 6ebfafa9c3b1f24cc89ec72a577e70a799b052d1 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sat, 29 Jul 2023 11:02:04 -0700 Subject: [PATCH 4/6] Remove unnecessary text comparison --- osu.Game/Screens/Play/Break/BreakInfoLine.cs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) diff --git a/osu.Game/Screens/Play/Break/BreakInfoLine.cs b/osu.Game/Screens/Play/Break/BreakInfoLine.cs index cfdf6cc65137..3357963fac00 100644 --- a/osu.Game/Screens/Play/Break/BreakInfoLine.cs +++ b/osu.Game/Screens/Play/Break/BreakInfoLine.cs @@ -47,17 +47,7 @@ public BreakInfoLine(LocalisableString name) } }; - Current.ValueChanged += currentValueChanged; - } - - private void currentValueChanged(ValueChangedEvent e) - { - LocalisableString newText = Format(e.NewValue); - - if (valueText.Text == newText) - return; - - valueText.Text = newText; + Current.ValueChanged += text => valueText.Text = Format(text.NewValue); } protected virtual LocalisableString Format(T count) From 4ddf05602f1f117f8ab0248c937a2487e76f59a3 Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Sat, 29 Jul 2023 11:05:15 -0700 Subject: [PATCH 5/6] Update `BreakInfoLine` to formatting standards --- osu.Game/Screens/Play/Break/BreakInfoLine.cs | 34 ++++++++++++-------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/osu.Game/Screens/Play/Break/BreakInfoLine.cs b/osu.Game/Screens/Play/Break/BreakInfoLine.cs index 3357963fac00..147650ca07a2 100644 --- a/osu.Game/Screens/Play/Break/BreakInfoLine.cs +++ b/osu.Game/Screens/Play/Break/BreakInfoLine.cs @@ -21,21 +21,30 @@ public partial class BreakInfoLine : Container public Bindable Current = new Bindable(); - private readonly OsuSpriteText text; - private readonly OsuSpriteText valueText; + private readonly LocalisableString name; + + private OsuSpriteText valueText = null!; public BreakInfoLine(LocalisableString name) { + this.name = name; + AutoSizeAxes = Axes.Y; + } + + [BackgroundDependencyLoader] + private void load(OsuColour colours) + { Children = new Drawable[] { - text = new OsuSpriteText + new OsuSpriteText { Anchor = Anchor.Centre, Origin = Anchor.CentreRight, Text = name, Font = OsuFont.GetFont(size: 17), - Margin = new MarginPadding { Right = margin } + Margin = new MarginPadding { Right = margin }, + Colour = colours.Yellow, }, valueText = new OsuSpriteText { @@ -43,11 +52,17 @@ public BreakInfoLine(LocalisableString name) Origin = Anchor.CentreLeft, Text = @"-", Font = OsuFont.GetFont(weight: FontWeight.Bold, size: 17), - Margin = new MarginPadding { Left = margin } + Margin = new MarginPadding { Left = margin }, + Colour = colours.YellowLight, } }; + } - Current.ValueChanged += text => valueText.Text = Format(text.NewValue); + protected override void LoadComplete() + { + base.LoadComplete(); + + Current.BindValueChanged(text => valueText.Text = Format(text.NewValue), true); } protected virtual LocalisableString Format(T count) @@ -57,13 +72,6 @@ protected virtual LocalisableString Format(T count) return count.ToString() ?? string.Empty; } - - [BackgroundDependencyLoader] - private void load(OsuColour colours) - { - text.Colour = colours.Yellow; - valueText.Colour = colours.YellowLight; - } } public partial class PercentageBreakInfoLine : BreakInfoLine From aab462fd95534417aa5b3b65918d021a9907885c Mon Sep 17 00:00:00 2001 From: Joseph Madamba Date: Wed, 2 Aug 2023 09:40:22 -0700 Subject: [PATCH 6/6] Fix `valueText` being replaced even if current is not binding to anything --- osu.Game/Screens/Play/Break/BreakInfoLine.cs | 7 +------ osu.Game/Screens/Play/BreakOverlay.cs | 17 +++++++++-------- 2 files changed, 10 insertions(+), 14 deletions(-) diff --git a/osu.Game/Screens/Play/Break/BreakInfoLine.cs b/osu.Game/Screens/Play/Break/BreakInfoLine.cs index 147650ca07a2..df71767f82f4 100644 --- a/osu.Game/Screens/Play/Break/BreakInfoLine.cs +++ b/osu.Game/Screens/Play/Break/BreakInfoLine.cs @@ -56,13 +56,8 @@ private void load(OsuColour colours) Colour = colours.YellowLight, } }; - } - - protected override void LoadComplete() - { - base.LoadComplete(); - Current.BindValueChanged(text => valueText.Text = Format(text.NewValue), true); + Current.BindValueChanged(text => valueText.Text = Format(text.NewValue)); } protected virtual LocalisableString Format(T count) diff --git a/osu.Game/Screens/Play/BreakOverlay.cs b/osu.Game/Screens/Play/BreakOverlay.cs index 4927800059b8..3ca82ec00b60 100644 --- a/osu.Game/Screens/Play/BreakOverlay.cs +++ b/osu.Game/Screens/Play/BreakOverlay.cs @@ -46,13 +46,14 @@ public IReadOnlyList Breaks private readonly Container remainingTimeBox; private readonly RemainingTimeCounter remainingTimeCounter; private readonly BreakArrows breakArrows; + private readonly ScoreProcessor scoreProcessor; + private readonly BreakInfo info; public BreakOverlay(bool letterboxing, ScoreProcessor scoreProcessor) { + this.scoreProcessor = scoreProcessor; RelativeSizeAxes = Axes.Both; - BreakInfo info; - Child = fadeContainer = new Container { Alpha = 0, @@ -102,18 +103,18 @@ public BreakOverlay(bool letterboxing, ScoreProcessor scoreProcessor) } } }; - - if (scoreProcessor != null) - { - info.AccuracyDisplay.Current.BindTo(scoreProcessor.Accuracy); - info.GradeDisplay.Current.BindTo(scoreProcessor.Rank); - } } protected override void LoadComplete() { base.LoadComplete(); initializeBreaks(); + + if (scoreProcessor != null) + { + info.AccuracyDisplay.Current.BindTo(scoreProcessor.Accuracy); + info.GradeDisplay.Current.BindTo(scoreProcessor.Rank); + } } private void initializeBreaks()