From 096ad0c413bee4bc50833d739cfaea831d7d861f Mon Sep 17 00:00:00 2001 From: atlimit8 Date: Sat, 7 Feb 2026 14:27:10 -0600 Subject: [PATCH] =?UTF-8?q?add=20handing=20=C2=B1=E2=88=9E=20to=20PerfGrap?= =?UTF-8?q?hWidget.SixCharacterFormatFloat()?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- OpenRA.Mods.Common/Widgets/PerfGraphWidget.cs | 8 +++++++- OpenRA.Test/OpenRA.Mods.Common/PerfGraphWidgetTest.cs | 7 +++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/OpenRA.Mods.Common/Widgets/PerfGraphWidget.cs b/OpenRA.Mods.Common/Widgets/PerfGraphWidget.cs index 4684b61f30..3acd02d84d 100644 --- a/OpenRA.Mods.Common/Widgets/PerfGraphWidget.cs +++ b/OpenRA.Mods.Common/Widgets/PerfGraphWidget.cs @@ -40,15 +40,21 @@ namespace OpenRA.Mods.Common.Widgets int GetTextWidth(string text) => font.Measure(text).X; + // Try to keep the text at 6 characters long to align columns. public void SixCharacterFormatFloat(StringBuilder output, double value) { - // Try to keep the text at 6 characters long to align columns. if (double.IsNaN(value)) { output.Append("NaN "); return; } + if (double.IsInfinity(value)) + { + output.Append(double.IsPositiveInfinity(value) ? "+Inf " : "-Inf "); + return; + } + if (value < 0) { output.Append("<0 "); diff --git a/OpenRA.Test/OpenRA.Mods.Common/PerfGraphWidgetTest.cs b/OpenRA.Test/OpenRA.Mods.Common/PerfGraphWidgetTest.cs index 26352992c3..2260579863 100644 --- a/OpenRA.Test/OpenRA.Mods.Common/PerfGraphWidgetTest.cs +++ b/OpenRA.Test/OpenRA.Mods.Common/PerfGraphWidgetTest.cs @@ -34,6 +34,13 @@ namespace OpenRA.Test AssertThat(double.NaN, "NaN "); } + [TestCase(TestName = "Infinities are reported with 2 padding spaces after.")] + public void Infinity() + { + AssertThat(double.PositiveInfinity, "+Inf "); + AssertThat(double.NegativeInfinity, "-Inf "); + } + [TestCase(TestName = "Negative numbers are discarded as \"<0\" with 4 padding spaces after.")] public void Negative() {