From b2a4cb13ae175b69487429bea2373479645f6d30 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Sun, 5 Nov 2023 16:34:40 +0100 Subject: [PATCH 1/3] Fix `FrameStatisticsViaTouch` to work as described in the wiki https://github.com/ppy/osu-framework/wiki/Environment-variables --- osu.Framework/FrameworkEnvironment.cs | 2 +- osu.Framework/Game.cs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/osu.Framework/FrameworkEnvironment.cs b/osu.Framework/FrameworkEnvironment.cs index 9bb0e43f48..8f57f2722f 100644 --- a/osu.Framework/FrameworkEnvironment.cs +++ b/osu.Framework/FrameworkEnvironment.cs @@ -23,7 +23,7 @@ static FrameworkEnvironment() StartupExecutionMode = Enum.TryParse(Environment.GetEnvironmentVariable("OSU_EXECUTION_MODE"), true, out var mode) ? mode : null; NoTestTimeout = Environment.GetEnvironmentVariable("OSU_TESTS_NO_TIMEOUT") == "1"; ForceTestGC = Environment.GetEnvironmentVariable("OSU_TESTS_FORCED_GC") == "1"; - FrameStatisticsViaTouch = Environment.GetEnvironmentVariable("OSU_FRAME_STATISTICS_VIA_TOUCH") == "1"; + FrameStatisticsViaTouch = Environment.GetEnvironmentVariable("OSU_FRAME_STATISTICS_VIA_TOUCH") != "0"; PreferredGraphicsSurface = Enum.TryParse(Environment.GetEnvironmentVariable("OSU_GRAPHICS_SURFACE"), true, out var surface) ? surface : null; PreferredGraphicsRenderer = Environment.GetEnvironmentVariable("OSU_GRAPHICS_RENDERER")?.ToLowerInvariant(); diff --git a/osu.Framework/Game.cs b/osu.Framework/Game.cs index 2ed0647d39..01042b525c 100644 --- a/osu.Framework/Game.cs +++ b/osu.Framework/Game.cs @@ -266,7 +266,7 @@ protected override void LoadComplete() FrameStatistics.BindValueChanged(e => performanceOverlay.State = e.NewValue, true); - if (FrameworkEnvironment.FrameStatisticsViaTouch || DebugUtils.IsDebugBuild) + if (FrameworkEnvironment.FrameStatisticsViaTouch && DebugUtils.IsDebugBuild) { base.AddInternal(new FrameStatisticsTouchReceptor(this) { From e08586370c5c90b273ddabdd30aabe01ddf1fbf5 Mon Sep 17 00:00:00 2001 From: Susko3 Date: Mon, 6 Nov 2023 20:36:54 +0100 Subject: [PATCH 2/3] Use a different way to specify the default value for a variable --- osu.Framework/FrameworkEnvironment.cs | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/osu.Framework/FrameworkEnvironment.cs b/osu.Framework/FrameworkEnvironment.cs index 8f57f2722f..2a3fcce837 100644 --- a/osu.Framework/FrameworkEnvironment.cs +++ b/osu.Framework/FrameworkEnvironment.cs @@ -2,6 +2,7 @@ // See the LICENCE file in the repository root for full licence text. using System; +using osu.Framework.Logging; using osu.Framework.Platform; namespace osu.Framework @@ -21,9 +22,9 @@ public static class FrameworkEnvironment static FrameworkEnvironment() { StartupExecutionMode = Enum.TryParse(Environment.GetEnvironmentVariable("OSU_EXECUTION_MODE"), true, out var mode) ? mode : null; - NoTestTimeout = Environment.GetEnvironmentVariable("OSU_TESTS_NO_TIMEOUT") == "1"; - ForceTestGC = Environment.GetEnvironmentVariable("OSU_TESTS_FORCED_GC") == "1"; - FrameStatisticsViaTouch = Environment.GetEnvironmentVariable("OSU_FRAME_STATISTICS_VIA_TOUCH") != "0"; + NoTestTimeout = parseBool(Environment.GetEnvironmentVariable("OSU_TESTS_NO_TIMEOUT")) ?? false; + ForceTestGC = parseBool(Environment.GetEnvironmentVariable("OSU_TESTS_FORCED_GC")) ?? false; + FrameStatisticsViaTouch = parseBool(Environment.GetEnvironmentVariable("OSU_FRAME_STATISTICS_VIA_TOUCH")) ?? true; PreferredGraphicsSurface = Enum.TryParse(Environment.GetEnvironmentVariable("OSU_GRAPHICS_SURFACE"), true, out var surface) ? surface : null; PreferredGraphicsRenderer = Environment.GetEnvironmentVariable("OSU_GRAPHICS_RENDERER")?.ToLowerInvariant(); @@ -33,7 +34,22 @@ static FrameworkEnvironment() if (int.TryParse(Environment.GetEnvironmentVariable("OSU_GRAPHICS_STAGING_BUFFER_TYPE"), out int stagingBufferImplementation)) StagingBufferType = stagingBufferImplementation; - NoStructuredBuffers = Environment.GetEnvironmentVariable("OSU_GRAPHICS_NO_SSBO") == "1"; + NoStructuredBuffers = parseBool(Environment.GetEnvironmentVariable("OSU_GRAPHICS_NO_SSBO")) ?? false; + } + + private static bool? parseBool(string? value) + { + switch (value) + { + case "0": + return false; + + case "1": + return true; + + default: + return bool.TryParse(value, out bool b) ? b : null; + } } } } From e2c8f7eb813902a397ab7561f284b9feb3ec407e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bart=C5=82omiej=20Dach?= Date: Fri, 10 Nov 2023 14:00:06 +0900 Subject: [PATCH 3/3] Remove unused using directive --- osu.Framework/FrameworkEnvironment.cs | 1 - 1 file changed, 1 deletion(-) diff --git a/osu.Framework/FrameworkEnvironment.cs b/osu.Framework/FrameworkEnvironment.cs index 2a3fcce837..a696754a8d 100644 --- a/osu.Framework/FrameworkEnvironment.cs +++ b/osu.Framework/FrameworkEnvironment.cs @@ -2,7 +2,6 @@ // See the LICENCE file in the repository root for full licence text. using System; -using osu.Framework.Logging; using osu.Framework.Platform; namespace osu.Framework