From 626d06ebc189d92ea216ed0d259883eb603ca222 Mon Sep 17 00:00:00 2001 From: Erik Date: Sun, 14 Jun 2026 14:25:21 +0200 Subject: [PATCH] feat(D.2b): RuntimeOptions.RetailUi + AcDir toggles MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Adds two startup-time env toggles that Phase D.2b's retail-UI panel frame will read: - ACDREAM_RETAIL_UI=1 → opts.RetailUi (bool, default false) - ACDREAM_AC_DIR= → opts.AcDir (string?, default null) Both follow the existing helper conventions (IsExactlyOne / NullIfEmpty). No call sites broke because the only construction site in RuntimeOptions.cs already uses named arguments. Co-Authored-By: Claude Opus 4.8 (1M context) --- src/AcDream.App/RuntimeOptions.cs | 8 ++++-- .../RuntimeOptionsRetailUiTests.cs | 28 +++++++++++++++++++ 2 files changed, 34 insertions(+), 2 deletions(-) create mode 100644 tests/AcDream.App.Tests/RuntimeOptionsRetailUiTests.cs diff --git a/src/AcDream.App/RuntimeOptions.cs b/src/AcDream.App/RuntimeOptions.cs index a1ceb4db..9be7601d 100644 --- a/src/AcDream.App/RuntimeOptions.cs +++ b/src/AcDream.App/RuntimeOptions.cs @@ -39,7 +39,9 @@ public sealed record RuntimeOptions( bool RetailCloseDegrades, bool DumpSceneryZ, bool DumpLiveSpawns, - int? LegacyStreamRadius) + int? LegacyStreamRadius, + bool RetailUi, + string? AcDir) { /// /// Build options from the process environment. Used by @@ -81,7 +83,9 @@ public sealed record RuntimeOptions( DumpLiveSpawns: IsExactlyOne(env("ACDREAM_DUMP_LIVE_SPAWNS")), // Legacy override for ACDREAM_STREAM_RADIUS. Caller applies it on // top of the quality preset's radii. Null when unset or invalid. - LegacyStreamRadius: TryParseNonNegativeInt(env("ACDREAM_STREAM_RADIUS"))); + LegacyStreamRadius: TryParseNonNegativeInt(env("ACDREAM_STREAM_RADIUS")), + RetailUi: IsExactlyOne(env("ACDREAM_RETAIL_UI")), + AcDir: NullIfEmpty(env("ACDREAM_AC_DIR"))); } /// True iff live-mode credentials are present and valid for connecting. diff --git a/tests/AcDream.App.Tests/RuntimeOptionsRetailUiTests.cs b/tests/AcDream.App.Tests/RuntimeOptionsRetailUiTests.cs new file mode 100644 index 00000000..b18590ae --- /dev/null +++ b/tests/AcDream.App.Tests/RuntimeOptionsRetailUiTests.cs @@ -0,0 +1,28 @@ +using System.Collections.Generic; +using AcDream.App; + +namespace AcDream.App.Tests; + +public class RuntimeOptionsRetailUiTests +{ + [Fact] + public void Parse_ReadsRetailUiAndAcDir() + { + var env = new Dictionary + { + ["ACDREAM_RETAIL_UI"] = "1", + ["ACDREAM_AC_DIR"] = @"C:\Turbine\Asheron's Call", + }; + var opts = RuntimeOptions.Parse("dats", k => env.GetValueOrDefault(k)); + Assert.True(opts.RetailUi); + Assert.Equal(@"C:\Turbine\Asheron's Call", opts.AcDir); + } + + [Fact] + public void Parse_DefaultsRetailUiOffAndAcDirNull() + { + var opts = RuntimeOptions.Parse("dats", _ => null); + Assert.False(opts.RetailUi); + Assert.Null(opts.AcDir); + } +}