A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
UI: Settings gets a graphics quality choice, Automatic / High / Low (refs #40) (#983)
Beri60342317048e
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex c2d75a6a2..50b13e91c 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -12,6 +12,13 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIBunder the monthly turn) join the yishuv sites in `content/sites.yaml`, each with a field site in its hex; thefounding days are the owner's (#785), and the rows stay draft. The reference player builds them in id order, soMefalsim is built in March 1950 and the goldens move (refs #785, #782).+- Settings: a graphics quality choice, Automatic, High or Low (refs #40, second slice; owner decision of 18 Oct 2026).+ Automatic is what the game did before: the tier the device gets, and on the web the frame-time fallback steps down+ when frames are slow. High is the PC tier at render scale 1.0 and Low the Mobile tier at 0.8, both fixed, so the+ fallback holds while one is set. It applies at once and is kept in `settings.txt` beside the blur option, never in the+ sim or the save, so the goldens do not move. `?nofallback`, `?shot`, `?profile` and `?vprofile` (on the desktop+ `-shot`, `-profile` and `-vprofile`) still get the tier's own look whatever is stored. The Mobile tier now ships in+ desktop builds too (`QualitySettings`), so Low works there.### Fixed- Event city effects preserve the city's housing condition when changing its housing capacity or job slots (#1000).diff --git a/docs/visual-v1.md b/docs/visual-v1.mdindex 732b13f4b..f67cdce02 100644--- a/docs/visual-v1.md+++ b/docs/visual-v1.md@@ -789,6 +789,9 @@ The Deferred row "Runtime quality fallback" (review I1), sized by the DPR-2 strechange the URP asset. Even on WebGL it stays off under `?vprofile`, `?profile` and `?shot` (instruments that must see thetier as configured) and with `?nofallback`; every change logs `QUALITY level=<n> scale=<s> tiltshift=<on|off>p95_ms=<ms>`.+- **The player's quality choice (#40).** Automatic in Settings is this behaviour. High (the PC tier at render scale 1.0)+ and Low (the Mobile tier at 0.8) fix the quality: the fallback holds while one is set (`QualityFallbackDriver.Feed`),+ and every switch starts it again from the top (`GraphicsQuality.Changed`).- **Presentation only:** it reads no sim state and writes only the render scale and the tilt-shift flag, so turns, hashesand saves cannot change. The goldens and the 5-turn smoke match with it in the build: `uv run tools/web_check.pyunity/Builds/Web-disabled --query "golden&smoke=5"` with the three `--expect` values from `docs/determinism.md`: PASS.diff --git a/unity/Assets/Scripts/Map/CameraRig.cs b/unity/Assets/Scripts/Map/CameraRig.csindex b8a47b94f..55732da77 100644--- a/unity/Assets/Scripts/Map/CameraRig.cs+++ b/unity/Assets/Scripts/Map/CameraRig.cs@@ -58,6 +58,9 @@ namespace Statecraft.Game.Mapif (TiltShift.OffRequested()) TiltShift.Enabled = false;// The runtime quality fallback (WebGL only); its undo removes the driver and restores the tier's render scale.TeardownActions.Add(QualityFallbackDriver.Attach(gameObject, FallbackWanted()));+ // A quality switch in Settings (#40) changes the URP asset: refit its shadow distance now, not at the next move.+ GraphicsQuality.Changed += Apply;+ TeardownActions.Add(() => GraphicsQuality.Changed -= Apply);initialised = true;Apply();}diff --git a/unity/Assets/Scripts/Map/GraphicsQuality.cs b/unity/Assets/Scripts/Map/GraphicsQuality.csnew file mode 100644index 000000000..a7f22b760--- /dev/null+++ b/unity/Assets/Scripts/Map/GraphicsQuality.cs@@ -0,0 +1,72 @@+#nullable enable+using System;+using System.Linq;+using UnityEngine;+using UnityEngine.Rendering.Universal;++namespace Statecraft.Game.Map+{+ /// <summary>The player's graphics quality (#40, owner decision of 18 Oct 2026), the same three choices on the web and the+ /// desktop. Auto is today's behaviour: the tier the device picked (the per-platform default quality level) at its own+ /// render scale, with the WebGL fallback (QualityFallback) stepping down when frames are slow. High is the PC tier at+ /// render scale 1.0, Low the Mobile tier at 0.8 (the fallback's lowest scale), both fixed: the fallback holds while one is+ /// set (QualityFallbackDriver.Feed). Presentation only: never the sim or the save. The tilt-shift stays its own option.</summary>+ public static class GraphicsQuality+ {+ public enum Choice { Auto, High, Low }++ public const string HighTier = "PC", LowTier = "Mobile";+ public const float HighRenderScale = 1f, LowRenderScale = 0.8f;++ public static Choice Current { get; private set; } = Choice.Auto;++ /// <summary>After a tier switch (CameraRig refits the new tier's shadow distance, which ShadowFit keeps per asset).</summary>+ public static event Action? Changed;++ static int bootLevel = -1; // the level the device picked, which Auto goes back to++#if UNITY_EDITOR+ // In the editor the URP assets are project files: leaving Play mode puts every tier's own scale and the editor's+ // level back, so a choice made while playing is never saved into Assets/Settings.+ [UnityEditor.InitializeOnLoadMethod]+ static void PutTheTiersBackOnExit() => UnityEditor.EditorApplication.playModeStateChanged += state =>+ {+ if (state != UnityEditor.PlayModeStateChange.ExitingPlayMode || Current == Choice.Auto) return;+ Apply(Choice.Auto);+ int low = Array.IndexOf(QualitySettings.names, LowTier);+ if (low >= 0 && QualitySettings.GetRenderPipelineAssetAt(low) is UniversalRenderPipelineAsset mobile)+ mobile.renderScale = QualityTierValues.WebRenderScale;+ };+#endif++ /// <summary>The choice a stored value names; anything else (no file, a value the game does not know) is Auto.</summary>+ public static Choice Parse(string? stored) => stored == "high" ? Choice.High : stored == "low" ? Choice.Low : Choice.Auto;++ public static string Format(Choice c) => c == Choice.High ? "high" : c == Choice.Low ? "low" : "auto";++ /// <summary>The choice to apply at start: the stored one, except under an instrument that must see the tier's own+ /// look, which wins over the file as it does over the fallback: on the web ?vprofile, ?profile, ?shot or+ /// ?nofallback; on the desktop -vprofile, -profile or -shot (FrameProfile, PixelErrorProfile, VisualShots).</summary>+ public static Choice AtStart(string? stored, string? url, string[] args, bool webgl) =>+ (webgl ? !QualityFallback.Wanted(url, webgl: true) : args.Any(a => a == "-vprofile" || a == "-profile" || a == "-shot"))+ ? Choice.Auto : Parse(stored);++ /// <summary>Switches to <paramref name="c"/> at once: the quality level (and with it the URP asset) and the active+ /// asset's render scale. A tier missing from this build keeps the current one (a warning, never a failed start).</summary>+ public static void Apply(Choice c)+ {+ if (bootLevel < 0) bootLevel = QualitySettings.GetQualityLevel();+ int level = c == Choice.Auto ? bootLevel : Array.IndexOf(QualitySettings.names, c == Choice.High ? HighTier : LowTier);+ if (level < 0) { Debug.LogWarning($"Settings: no {c} tier in this build; the quality stays as it is"); return; }+ Current = c;+ if (QualitySettings.GetQualityLevel() != level) QualitySettings.SetQualityLevel(level, true);+ var asset = UniversalRenderPipeline.asset;+ // Auto puts the tier's own scale back (QualityTiers.Apply: Mobile at WebRenderScale, PC at 1.0).+ if (asset != null)+ asset.renderScale = c == Choice.High ? HighRenderScale : c == Choice.Low ? LowRenderScale+ : QualitySettings.names[level] == LowTier ? QualityTierValues.WebRenderScale : 1f;+ TiltShift.FallbackOff = false; // a fixed choice ends the fallback's last step; Auto starts it again from the top+ Changed?.Invoke();+ }+ }+}diff --git a/unity/Assets/Scripts/Map/GraphicsQuality.cs.meta b/unity/Assets/Scripts/Map/GraphicsQuality.cs.metanew file mode 100644index 000000000..df53990f5--- /dev/null+++ b/unity/Assets/Scripts/Map/GraphicsQuality.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: baac3719aabb4de6bf45a5618cde7d68\ No newline at end of filediff --git a/unity/Assets/Scripts/Map/QualityFallback.cs b/unity/Assets/Scripts/Map/QualityFallback.csindex 0355b3272..6d5b288fb 100644--- a/unity/Assets/Scripts/Map/QualityFallback.cs+++ b/unity/Assets/Scripts/Map/QualityFallback.cs@@ -132,7 +132,7 @@ namespace Statecraft.Game.Map/// to the map camera through Attach, whose undo (run by the map's teardown) removes it and puts both back.</summary>public sealed class QualityFallbackDriver : MonoBehaviour{- public QualityFallback Controller { get; } = new QualityFallback();+ public QualityFallback Controller { get; private set; } = new QualityFallback();/// <summary>Whether the page is hidden now (tests replace it).</summary>public Func<bool> Hidden { get; set; } = DocumentHidden;float tierScale = 1f;@@ -148,8 +148,12 @@ namespace Statecraft.Game.Mapdriver.tierScale = asset != null ? asset.renderScale : 1f;driver.setScale = s => { if (asset != null) asset.renderScale = s; };var tierScale = driver.tierScale;+ // Every quality switch (#40) put the tier's own look or a fixed one in place: the fallback starts again from the top.+ Action restart = () => driver.Controller = new QualityFallback();+ GraphicsQuality.Changed += restart;return () =>{+ GraphicsQuality.Changed -= restart;if (asset != null) asset.renderScale = tierScale;TiltShift.FallbackOff = false;if (driver != null) { if (Application.isPlaying) Destroy(driver); else DestroyImmediate(driver); }@@ -159,6 +163,8 @@ namespace Statecraft.Game.Map/// <summary>Feeds one frame (tests call it; Update feeds the real frames).</summary>public void Feed(float frameMs){+ // High or Low in Settings (#40) fixes the quality: GraphicsQuality.Apply set the scale and ended FallbackOff.+ if (GraphicsQuality.Current != GraphicsQuality.Choice.Auto) return;if (!Controller.Feed(frameMs)) return;var step = Controller.Current;setScale(Mathf.Min(tierScale, step.RenderScale));diff --git a/unity/Assets/Scripts/UI/SettingsPresenter.cs b/unity/Assets/Scripts/UI/SettingsPresenter.csindex 9f13e1e40..3b9da76bc 100644--- a/unity/Assets/Scripts/UI/SettingsPresenter.cs+++ b/unity/Assets/Scripts/UI/SettingsPresenter.cs@@ -7,15 +7,17 @@ using UnityEngine.UIElements;namespace Statecraft.Game.UI{- /// <summary>The Settings screen (#40), opened from the left column's gear like the other screens (ScreenNav). Its one- /// option so far turns the tilt-shift blur off and on: applied at once (TiltShift.Enabled, what the "tiltshift" toggle- /// sets) and kept in the SettingsStore, so it holds after a reload. A stored "off" only ever turns the blur off, so- /// ?notiltshift still boots without it. The button says what is set ("On" / "Off"), not only a colour: the player's- /// choice (Enabled), not the web tier's automatic last fallback step (TiltShift.FallbackOff), which it never changes.</summary>+ /// <summary>The Settings screen (#40), opened from the left column's gear like the other screens (ScreenNav). Its options:+ /// the graphics quality (GraphicsQuality: Auto / High / Low) and the tilt-shift blur. The blur option turns it off and+ /// on: applied at once (TiltShift.Enabled, what the "tiltshift" toggle sets) and kept in the SettingsStore, so it+ /// holds after a reload. A stored "off" only ever turns the blur off, so ?notiltshift still boots without it. The+ /// button says what is set ("On" / "Off"), not only a colour: the player's choice (Enabled), not the web tier's+ /// automatic last fallback step (TiltShift.FallbackOff), which it never changes.</summary>public sealed class SettingsPresenter : IDisposable{- public const string TiltShiftKey = "tiltshift";+ public const string TiltShiftKey = "tiltshift", QualityKey = "quality", SelectedClass = "settings-choice-selected";readonly SettingsStore? store; readonly UiText text; readonly VisualElement screen; readonly Button tiltShift;+ readonly (Button button, GraphicsQuality.Choice choice, Action pick)[] quality;/// <param name="store">Where the choice is kept; null keeps nothing (the option still works until the page closes).</param>public SettingsPresenter(VisualElement root, UiText text, SettingsStore? store)@@ -27,6 +29,22 @@ namespace Statecraft.Game.UItiltShift = screen.Q<Button>("settings-tiltshift");if (store?.Read(TiltShiftKey) == "off") TiltShift.Enabled = false;tiltShift.clicked += Flip;+ // Graphics quality (#40): three buttons, the one that is set marked. A stored choice is applied at start unless+ // an instrument flag must see the tier's own look (GraphicsQuality.AtStart); Auto at start changes nothing.+ screen.Q<Label>("settings-quality-label").text = text["settings.quality"];+ var choices = new[] { GraphicsQuality.Choice.Auto, GraphicsQuality.Choice.High, GraphicsQuality.Choice.Low };+ quality = Array.ConvertAll(choices, c =>+ {+ var key = GraphicsQuality.Format(c);+ var b = screen.Q<Button>("settings-quality-" + key);+ b.text = text["settings.quality." + key];+ Action pick = () => Pick(c);+ b.clicked += pick;+ return (b, c, pick);+ });+ var start = GraphicsQuality.AtStart(store?.Read(QualityKey), Application.absoluteURL, Environment.GetCommandLineArgs(),+ Application.platform == RuntimePlatform.WebGLPlayer);+ if (start != GraphicsQuality.Current) GraphicsQuality.Apply(start);ScreenNav.OnOpened(screen, Show); // a dev toggle may have changed it while the screen was shutShow();}@@ -34,6 +52,7 @@ namespace Statecraft.Game.UIpublic void Dispose(){tiltShift.clicked -= Flip;+ foreach (var (b, _, pick) in quality) b.clicked -= pick;if (screen.userData is Action) screen.userData = null;}@@ -48,6 +67,22 @@ namespace Statecraft.Game.UI}}- void Show() => tiltShift.text = text[TiltShift.Enabled ? "settings.on" : "settings.off"];+ void Pick(GraphicsQuality.Choice c)+ {+ if (c == GraphicsQuality.Current) return; // pressing Automatic again must not undo the fallback's step down+ GraphicsQuality.Apply(c);+ Show();+ try { store?.Write(QualityKey, GraphicsQuality.Format(GraphicsQuality.Current)); }+ catch (Exception e) when (e is IOException || e is UnauthorizedAccessException)+ {+ Debug.LogWarning($"Settings: could not keep the quality choice ({e.Message}); it holds until the page is closed");+ }+ }++ void Show()+ {+ tiltShift.text = text[TiltShift.Enabled ? "settings.on" : "settings.off"];+ foreach (var (b, c, _) in quality) b.EnableInClassList(SelectedClass, c == GraphicsQuality.Current);+ }}}diff --git a/unity/Assets/Tests/EditMode/HebrewUiTests.cs b/unity/Assets/Tests/EditMode/HebrewUiTests.csindex b354f430a..2ae78e803 100644--- a/unity/Assets/Tests/EditMode/HebrewUiTests.cs+++ b/unity/Assets/Tests/EditMode/HebrewUiTests.cs@@ -223,6 +223,8 @@ public class HebrewUiTests("defence-screen-title", "defence.title"), ("de-escalate", "defence.lower"), ("escalate", "defence.raise"),("why-screen-title", "why.title"),("nav-settings", "hud.nav.settings"), ("settings-screen-title", "settings.title"), ("settings-tiltshift-label", "settings.tiltshift"),+ ("settings-quality-label", "settings.quality"), ("settings-quality-auto", "settings.quality.auto"),+ ("settings-quality-high", "settings.quality.high"), ("settings-quality-low", "settings.quality.low"),("start-source", "start.source"), ("start-recording-credit", "start.recording_credit"),("start-continue", "start.continue"), ("start-new-game", "start.new_game"),};diff --git a/unity/Assets/Tests/EditMode/QualityFallbackTests.cs b/unity/Assets/Tests/EditMode/QualityFallbackTests.csindex 5d4ec2c44..bd5a7c5cc 100644--- a/unity/Assets/Tests/EditMode/QualityFallbackTests.cs+++ b/unity/Assets/Tests/EditMode/QualityFallbackTests.cs@@ -294,4 +294,48 @@ public class QualityFallbackTests}finally { Object.DestroyImmediate(go); }}++ /// <summary>High or Low in Settings (#40) fixes the quality: the fallback holds (no step, the render scale and the+ /// tilt-shift are the choice's). Back on Automatic it starts again from the tier's own look, not from the level it had+ /// reached before.</summary>+ [Test]+ public void AFixedQualityChoiceHoldsTheFallbackAndAutomaticStartsItAgain()+ {+ var go = new GameObject("cam");+ int level = QualitySettings.GetQualityLevel();+ var asset = UniversalRenderPipeline.asset!;+ float tierScale = asset.renderScale;+ var mobile = (UniversalRenderPipelineAsset)QualitySettings.GetRenderPipelineAssetAt(System.Array.IndexOf(QualitySettings.names, "Mobile"));+ float mobileScale = mobile.renderScale;+ try+ {+ var undo = QualityFallbackDriver.Attach(go, wanted: true);+ var driver = go.GetComponent<QualityFallbackDriver>();+ GraphicsQuality.Apply(GraphicsQuality.Choice.High);+ for (float t = 0; t < 60_000f; t += Slow) driver.Feed(Slow);+ Assert.AreEqual(0, driver.Controller.Level, "slow frames move nothing while High is set");+ Assert.AreEqual(1f, asset.renderScale, 1e-6f);+ Assert.IsFalse(TiltShift.FallbackOff);++ GraphicsQuality.Apply(GraphicsQuality.Choice.Auto);+ for (float t = 0; t < 60_000f; t += Slow) driver.Feed(Slow);+ Assert.AreEqual(3, driver.Controller.Level, "on Automatic the fallback steps down as before");+ Assert.IsTrue(TiltShift.FallbackOff);++ GraphicsQuality.Apply(GraphicsQuality.Choice.Low);+ Assert.IsFalse(TiltShift.FallbackOff, "a fixed choice ends the fallback's last step");+ GraphicsQuality.Apply(GraphicsQuality.Choice.Auto);+ Assert.AreEqual(tierScale, asset.renderScale, 1e-6f, "Automatic puts the tier's own scale back");+ driver.Feed(Fine);+ Assert.AreEqual(0, driver.Controller.Level, "and the fallback starts again from the top");+ undo();+ }+ finally+ {+ GraphicsQuality.Apply(GraphicsQuality.Choice.Auto);+ QualitySettings.SetQualityLevel(level, true);+ asset.renderScale = tierScale; mobile.renderScale = mobileScale;+ Object.DestroyImmediate(go);+ }+ }}diff --git a/unity/Assets/Tests/EditMode/SettingsScreenTests.cs b/unity/Assets/Tests/EditMode/SettingsScreenTests.csindex 0b2fa9487..195483627 100644--- a/unity/Assets/Tests/EditMode/SettingsScreenTests.cs+++ b/unity/Assets/Tests/EditMode/SettingsScreenTests.cs@@ -7,7 +7,9 @@ using Statecraft.Game.Map;using Statecraft.Game.UI;using Statecraft.Sim;using UnityEditor;+using UnityEditor.SceneManagement;using UnityEngine;+using UnityEngine.Rendering.Universal;using UnityEngine.TestTools;using UnityEngine.UIElements;using Object = UnityEngine.Object;@@ -21,18 +23,29 @@ public class SettingsScreenTestsstatic UiText He => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");string dir = "";+ int level;+ float[] scales = new float[0];++ static UniversalRenderPipelineAsset Tier(int i) => (UniversalRenderPipelineAsset)QualitySettings.GetRenderPipelineAssetAt(i);[SetUp]public void SetUp(){dir = Path.Combine(Path.GetTempPath(), "sc-settings-" + System.Guid.NewGuid().ToString("N"));TiltShift.Enabled = true;+ level = QualitySettings.GetQualityLevel();+ scales = new float[QualitySettings.names.Length];+ for (int i = 0; i < scales.Length; i++) scales[i] = Tier(i).renderScale;}[TearDown]public void TearDown(){TiltShift.Enabled = true;+ // The editor's quality level and the URP assets are the project's: put back what a quality test switched.+ GraphicsQuality.Apply(GraphicsQuality.Choice.Auto);+ QualitySettings.SetQualityLevel(level, true);+ for (int i = 0; i < scales.Length; i++) Tier(i).renderScale = scales[i];if (Directory.Exists(dir)) Directory.Delete(dir, true);}@@ -94,6 +107,157 @@ public class SettingsScreenTestsAssert.AreEqual(En["settings.off"], ui.Q<Button>("settings-tiltshift").text);}+ static readonly (string button, GraphicsQuality.Choice choice)[] QualityButtons =+ {+ ("settings-quality-auto", GraphicsQuality.Choice.Auto), ("settings-quality-high", GraphicsQuality.Choice.High),+ ("settings-quality-low", GraphicsQuality.Choice.Low),+ };++ /// <summary>The owner's three choices (#40, 18 Oct 2026): High is the PC tier at render scale 1.0, Low the Mobile tier+ /// at 0.8, Automatic the tier the device picked at its own scale. Each takes effect at once, the button of the choice+ /// that is set carries the selected mark, and the choice is kept in the SettingsStore.</summary>+ [Test]+ public void EachQualityChoiceSetsItsTierAndRenderScaleAtOnce([Values(false, true)] bool hebrew)+ {+ var text = hebrew ? He : En;+ int device = QualitySettings.GetQualityLevel();+ using var ui = new UiTestKit();+ using var settings = new SettingsPresenter(ui.Root, text, new SettingsStore(dir));+ Assert.AreEqual(GraphicsQuality.Choice.Auto, GraphicsQuality.Current, "Automatic by default, with no file");+ Assert.AreEqual(device, QualitySettings.GetQualityLevel(), "and the device's tier is left alone");+ AssertSelected(ui, GraphicsQuality.Choice.Auto);++ UiTestKit.Press(ui.Q<Button>("settings-quality-low"));+ Assert.AreEqual("Mobile", QualitySettings.names[QualitySettings.GetQualityLevel()]);+ Assert.AreEqual(0.8f, UniversalRenderPipeline.asset!.renderScale, 1e-6f);+ AssertSelected(ui, GraphicsQuality.Choice.Low);+ Assert.AreEqual("low", new SettingsStore(dir).Read(SettingsPresenter.QualityKey));++ UiTestKit.Press(ui.Q<Button>("settings-quality-high"));+ Assert.AreEqual("PC", QualitySettings.names[QualitySettings.GetQualityLevel()]);+ Assert.AreEqual(1f, UniversalRenderPipeline.asset!.renderScale, 1e-6f);+ AssertSelected(ui, GraphicsQuality.Choice.High);+ Assert.AreEqual("high", new SettingsStore(dir).Read(SettingsPresenter.QualityKey));++ UiTestKit.Press(ui.Q<Button>("settings-quality-auto"));+ Assert.AreEqual(device, QualitySettings.GetQualityLevel(), "Automatic goes back to the device's tier");+ Assert.AreEqual(QualitySettings.names[device] == "Mobile" ? QualityTierValues.WebRenderScale : 1f, UniversalRenderPipeline.asset!.renderScale, 1e-6f, "at its own scale");+ AssertSelected(ui, GraphicsQuality.Choice.Auto);+ Assert.AreEqual("auto", new SettingsStore(dir).Read(SettingsPresenter.QualityKey));+ }++ [Test]+ public void TheQualityChoiceSurvivesAReload()+ {+ using (var ui = new UiTestKit())+ using (new SettingsPresenter(ui.Root, En, new SettingsStore(dir)))+ UiTestKit.Press(ui.Q<Button>("settings-quality-low"));+ GraphicsQuality.Apply(GraphicsQuality.Choice.Auto); // the reload: the device's tier again, only the file remains+ using (var ui = new UiTestKit())+ using (new SettingsPresenter(ui.Root, En, new SettingsStore(dir)))+ {+ Assert.AreEqual(GraphicsQuality.Choice.Low, GraphicsQuality.Current);+ Assert.AreEqual("Mobile", QualitySettings.names[QualitySettings.GetQualityLevel()]);+ Assert.AreEqual(0.8f, UniversalRenderPipeline.asset!.renderScale, 1e-6f);+ AssertSelected(ui, GraphicsQuality.Choice.Low);+ }+ }++ /// <summary>Pressing Automatic while it is set changes nothing: a step the fallback took for a slow device stays.</summary>+ [Test]+ public void PressingAutomaticAgainKeepsTheFallbacksStep()+ {+ var cam = new GameObject("cam");+ var undo = QualityFallbackDriver.Attach(cam, wanted: true);+ try+ {+ var driver = cam.GetComponent<QualityFallbackDriver>();+ using var ui = new UiTestKit();+ using var settings = new SettingsPresenter(ui.Root, En, new SettingsStore(dir));+ for (float t = 0; t < 60_000f; t += 45f) driver.Feed(45f);+ int level = driver.Controller.Level;+ Assert.Greater(level, 0, "slow frames stepped down");+ ui.Press("settings-quality-auto");+ Assert.AreEqual(level, driver.Controller.Level);+ Assert.AreEqual(QualityFallback.Steps[level].TiltShift, !TiltShift.FallbackOff);+ }+ finally { undo(); Object.DestroyImmediate(cam); }+ }++ /// <summary>The instruments that must see the tier's own look win over a stored choice, as they win over the fallback:+ /// ?vprofile, ?profile, ?shot and ?nofallback on the web, -vprofile, -profile and -shot on the desktop. A value the game+ /// does not know is Automatic.</summary>+ [Test]+ public void TheInstrumentFlagsWinOverAStoredQualityChoice()+ {+ const string page = "http://localhost:8000/";+ var none = new string[0];+ Assert.AreEqual(GraphicsQuality.Choice.Low, GraphicsQuality.AtStart("low", page, none, webgl: true));+ Assert.AreEqual(GraphicsQuality.Choice.High, GraphicsQuality.AtStart("high", page + "?golden", none, webgl: true));+ Assert.AreEqual(GraphicsQuality.Choice.High, GraphicsQuality.AtStart("high", "", new[] { "Statecraft", "-seed", "7" }, webgl: false));+ foreach (var flag in new[] { "vprofile", "profile", "shot", "nofallback" })+ Assert.AreEqual(GraphicsQuality.Choice.Auto, GraphicsQuality.AtStart("low", page + "?bootlog&" + flag, none, webgl: true), flag);+ foreach (var arg in new[] { "-vprofile", "-profile", "-shot" })+ Assert.AreEqual(GraphicsQuality.Choice.Auto, GraphicsQuality.AtStart("low", "", new[] { "Statecraft", arg }, webgl: false), arg);+ Assert.AreEqual(GraphicsQuality.Choice.Auto, GraphicsQuality.AtStart(null, page, none, webgl: true));+ Assert.AreEqual(GraphicsQuality.Choice.Auto, GraphicsQuality.AtStart("ultra", page, none, webgl: true));+ }++ /// <summary>"The same choices apply on web and desktop" (#40): both tiers must be in the WebGL and the desktop builds,+ /// or Low would have no Mobile tier to switch to in a desktop player.</summary>+ [Test]+ public void BothTiersShipOnTheWebAndTheDesktop()+ {+ foreach (var tier in new[] { GraphicsQuality.HighTier, GraphicsQuality.LowTier })+ {+ int i = System.Array.IndexOf(QualitySettings.names, tier);+ Assert.GreaterOrEqual(i, 0, tier);+ foreach (var platform in new[] { "WebGL", "Standalone" })+ Assert.IsTrue(QualitySettings.IsPlatformIncluded(platform, i), $"{tier} on {platform}");+ }+ }++ /// <summary>The labels Beri (a native speaker) approved on #40 (issuecomment-6241626427).</summary>+ [Test]+ public void TheQualityLabelsAreTheApprovedOnes()+ {+ Assert.AreEqual("Quality", En["settings.quality"]);+ Assert.AreEqual(("Automatic", "High", "Low"), (En["settings.quality.auto"], En["settings.quality.high"], En["settings.quality.low"]));+ Assert.AreEqual("איכות גרפית", He["settings.quality"]);+ Assert.AreEqual(("אוטומטית", "גבוהה", "נמוכה"), (He["settings.quality.auto"], He["settings.quality.high"], He["settings.quality.low"]));+ }++ static void AssertSelected(UiTestKit ui, GraphicsQuality.Choice set)+ {+ foreach (var (name, choice) in QualityButtons)+ Assert.AreEqual(choice == set, ui.Q<Button>(name).ClassListContains(SettingsPresenter.SelectedClass), $"{name} marked while {set} is set");+ }++ /// <summary>A tier switch refits the new tier's shadow distance at once (ShadowFit keeps one per URP asset): the map+ /// must not wait for the camera to move to draw its shadows right.</summary>+ [Test]+ public void ATierSwitchRefitsTheShadowsAtOnce()+ {+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);+ var map = Object.FindFirstObjectByType<MapScene>();+ try+ {+ map.Build();+ var cam = Camera.main!;+ foreach (var choice in new[] { GraphicsQuality.Choice.Low, GraphicsQuality.Choice.High })+ {+ GraphicsQuality.Apply(choice);+ var asset = UniversalRenderPipeline.asset!;+ Assert.AreEqual(ShadowFit.Distance(cam, asset.cascadeBorder), asset.shadowDistance, 1e-3f, choice.ToString());+ }+ }+ finally+ {+ map.Clear(go => Object.DestroyImmediate(go));+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);+ }+ }+/// <summary>A file the game cannot use (another key, a value it does not know, a line without "=") is no reason to fail/// a start: the option keeps its default.</summary>[Test]@@ -153,13 +317,22 @@ public class SettingsScreenTestsvar screen = root.Q("screen-settings").worldBound;Assert.IsTrue(Inside(screen, root.worldBound), $"{at}: the screen {screen} leaves the window {root.worldBound}");Assert.GreaterOrEqual(screen.yMin, root.Q("top-bar").worldBound.yMax - 0.5f, at + ": the screen starts below the top bar");- foreach (var name in new[] { "settings-screen-title", "settings-tiltshift-label", "settings-tiltshift" })+ foreach (var name in new[] { "settings-screen-title", "settings-tiltshift-label", "settings-tiltshift",+ "settings-quality-label", "settings-quality-auto", "settings-quality-high", "settings-quality-low" }){var e = root.Q<TextElement>(name);Assert.IsFalse(string.IsNullOrWhiteSpace(e.text), $"{at}: {name} has its text");Assert.IsTrue(Inside(e.worldBound, screen), $"{at}: {name} {e.worldBound} leaves the screen {screen}");Assert.IsTrue(UiLayoutTests.TextFits(e), $"{at}: {name} '{e.text}' is cut ({e.contentRect})");}+ // The set choice reads as set while it has the focus a press leaves on it: dark text on the gold fill.+ var low = root.Q<Button>("settings-quality-low");+ using (var e = NavigationSubmitEvent.GetPooled()) { e.target = low; low.SendEvent(e); }+ low.Focus();+ for (int i = 0; i < 3; i++) yield return null;+ var ink = low.resolvedStyle.color; var fill = low.resolvedStyle.backgroundColor;+ Assert.Less(Luminance(ink), 0.1f, $"{at}: the selected button's text {ink} is dark");+ Assert.Greater(Luminance(fill), 0.3f, $"{at}: on the gold fill {fill}");}finally{@@ -169,6 +342,8 @@ public class SettingsScreenTests}}+ static float Luminance(Color c) => 0.2126f * c.linear.r + 0.7152f * c.linear.g + 0.0722f * c.linear.b;+static bool Inside(Rect inner, Rect outer) =>inner.xMin >= outer.xMin - 0.5f && inner.xMax <= outer.xMax + 0.5f && inner.yMin >= outer.yMin - 0.5f && inner.yMax <= outer.yMax + 0.5f;}diff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxmlindex 04beb0c1d..587e64194 100644--- a/unity/Assets/UI/Game.uxml+++ b/unity/Assets/UI/Game.uxml@@ -302,6 +302,15 @@<ui:Label name="settings-tiltshift-label" text="Blur at the top and bottom of the map" class="settings-name" /><ui:Button name="settings-tiltshift" class="settings-switch" /></ui:VisualElement>+ <!-- Graphics quality (GraphicsQuality): three buttons, the one that is set carries .settings-choice-selected. -->+ <ui:VisualElement class="row settings-row">+ <ui:Label name="settings-quality-label" text="Quality" class="settings-name" />+ <ui:VisualElement class="row settings-choices">+ <ui:Button name="settings-quality-auto" text="Automatic" class="settings-switch" />+ <ui:Button name="settings-quality-high" text="High" class="settings-switch" />+ <ui:Button name="settings-quality-low" text="Low" class="settings-switch" />+ </ui:VisualElement>+ </ui:VisualElement><Statecraft.Game.UI.UiFrame /></ui:VisualElement><!-- The End Turn outcome clip (OutcomePresenter): the historical order the player gave, as a 3.5 s silent clip in thediff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.ussindex dfc7ac3ab..8f31f351f 100644--- a/unity/Assets/UI/Statecraft.uss+++ b/unity/Assets/UI/Statecraft.uss@@ -400,6 +400,13 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);.settings-row { margin-top: 8px; }.settings-name { flex-grow: 1; flex-shrink: 1; min-width: 0; white-space: normal; }.settings-switch { flex-shrink: 0; min-width: 96px; -unity-text-align: middle-center; }+/* The quality choice's buttons sit side by side; the one that is set is marked by a gold fill and dark text, not only a+ border colour, and keeps it while hovered or focused (Button:hover and :focus would otherwise win). */+.settings-choices { flex-shrink: 0; }+.settings-choice-selected, .settings-choice-selected:hover, .settings-choice-selected:focus { background-color: var(--gold); color: var(--navy-solid); }+/* The regular cut's thin strokes fade on the gold. Only as specific as ".lang-he Button", which comes later and keeps+ the Hebrew face in Hebrew. */+Button.settings-choice-selected { -unity-font-definition: url("project://database/Assets/UI/Fonts/EBGaramond-SemiBold.ttf"); }/* The toast sits in the map's free top-left corner, above the info panel: opaque, and never over an open screen's title orthe minimap column (B7). */diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlindex 4532113f2..da7b92655 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -53,6 +53,10 @@ settings.title: "Settings"settings.tiltshift: "Blur at the top and bottom of the map"settings.on: "On"settings.off: "Off"+settings.quality: "Quality"+settings.quality.auto: "Automatic"+settings.quality.high: "High"+settings.quality.low: "Low"event.draft: "DRAFT"start.source: "From the Declaration of the Establishment of the State of Israel (Official Gazette No. 1, 14 May 1948) and its official English translation. Painting: AI-generated."start.recording_credit: "Recording: Ralph Hellinger, Israel State Archives"diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yamlindex ff122ba2d..abd4ea70f 100644--- a/unity/Assets/UI/strings.he.yaml+++ b/unity/Assets/UI/strings.he.yaml@@ -45,6 +45,12 @@ settings.title: "הגדרות"settings.tiltshift: "טשטוש בחלק העליון ובחלק התחתון של המפה"settings.on: "מופעל"settings.off: "כבוי"+# The graphics quality choice (#40). Adjectives in the feminine, agreeing with "איכות". Approved by Beri, a native+# speaker, on #40 (17 Oct 2026). For the native reviewer (#564).+settings.quality: "איכות גרפית"+settings.quality.auto: "אוטומטית"+settings.quality.high: "גבוהה"+settings.quality.low: "נמוכה"event.draft: "טיוטה"start.source: "מתוך ההכרזה על הקמת מדינת ישראל (עיתון רשמי מס׳ 1, 14 במאי 1948) ותרגומה הרשמי לאנגלית. הציור נוצר בבינה מלאכותית."# The recordist's name as the Israel State Archives spells it in its own description of itemdiff --git a/unity/ProjectSettings/QualitySettings.asset b/unity/ProjectSettings/QualitySettings.assetindex f55198a74..a6c230260 100644--- a/unity/ProjectSettings/QualitySettings.asset+++ b/unity/ProjectSettings/QualitySettings.asset@@ -58,8 +58,7 @@ QualitySettings:terrainBillboardStart: 50terrainFadeLength: 5terrainMaxTrees: 50- excludedTargetPlatforms:- - Standalone+ excludedTargetPlatforms: []- serializedVersion: 4name: PCpixelLightCount: 2