Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

Unity: Settings offers 125% and 150% UI scales on the window shapes the layout tests cover (Refs #40) (#2219)

Beri6efdef91835f
diff --git a/changelog.d/40-ui-scale-offered.md b/changelog.d/40-ui-scale-offered.md
new file mode 100644
index 000000000..b5fb4c720
--- /dev/null
+++ b/changelog.d/40-ui-scale-offered.md
@@ -0,0 +1,2 @@
+- Settings now offers the 125% and 150% UI scales on every window shape the layout tests cover, from 360x800 to
+ 2560x1080; outside that range it still offers 100% only (#40).
diff --git a/unity/Assets/Scripts/UI/SettingsPresenter.cs b/unity/Assets/Scripts/UI/SettingsPresenter.cs
index 8d1875329..449c1477c 100644
--- a/unity/Assets/Scripts/UI/SettingsPresenter.cs
+++ b/unity/Assets/Scripts/UI/SettingsPresenter.cs
@@ -24,11 +24,17 @@ namespace Statecraft.Game.UI
/// <summary>The owner's ruling on #1011 (19 Oct 2026): Settings offers only the UI scales verified to fit, and 100% always,
/// as the fallback. A scale above 100% is verified on the window shapes (width / height, narrowest to widest) where
/// the layout suites pass with the panel at that scale: UiLayoutTests, InfoPanelLayoutTests, TopBarScoreLayoutTests,
- /// HebrewUiTests, LeftColumnTests, PromoScreensTests and TopBarTests, whose windows run from 360x800 to 2560x1080.
- /// None is yet: at 125% and 150% those suites fail on every window shape (PR #1011, 18 Oct 2026), so the game offers
- /// 100% only. To offer a scale, run the suites at it and enter the narrowest and widest shapes where they all pass.
+ /// HebrewUiTests, LeftColumnTests, PromoScreensTests and TopBarTests, with the turn report (TurnReportTests) and the
+ /// encyclopedia (EncyclopediaScreenTests) as the owner ruled on #2219. Since #1853 they pass at 125% and at 150% (#40,
+ /// 2 Nov 2026), and the screens, the event card, the info panel, the turn report and the encyclopedia all run in
+ /// English and Hebrew at both ends of the range, 360x800 and 2560x1080 (the budget rows' own test runs 1920 and 390
+ /// wide), so both scales are verified on the shapes between them. A layout change that breaks a suite at a scale narrows or removes its entry.
/// Tests enter shapes here to drive the rule and put the table back.</summary>
- public static readonly Dictionary<int, (float narrowest, float widest)> VerifiedShapes = new Dictionary<int, (float, float)>();
+ public static readonly Dictionary<int, (float narrowest, float widest)> VerifiedShapes = new Dictionary<int, (float, float)>
+ {
+ [125] = (360f / 800f, 2560f / 1080f),
+ [150] = (360f / 800f, 2560f / 1080f),
+ };
/// <summary>The sound effects' volume steps (#39): the stored word and GameAudio's volume. With no stored choice, "high".</summary>
public static readonly (string level, float volume)[] SoundLevels = { ("off", 0f), ("low", 0.35f), ("high", 1f) };
readonly SettingsStore? store; readonly UiText text; readonly VisualElement root, screen; readonly Button tiltShift;
@@ -253,7 +259,9 @@ namespace Statecraft.Game.UI
if (percent == UiScales[0]) return true;
if (!VerifiedShapes.TryGetValue(percent, out var shapes)) return false;
float shape = root.layout.width / root.layout.height;
- return !(shape > 0) || (shape >= shapes.narrowest && shape <= shapes.widest);
+ // A tolerance on both ends (#2219 review): the root's layout is in panel units after scaling, so a window exactly
+ // at an end of the range can come out a last bit outside it.
+ return !(shape > 0) || (shape >= shapes.narrowest - 1e-4f && shape <= shapes.widest + 1e-4f);
}
void OnGeometry(GeometryChangedEvent e)
diff --git a/unity/Assets/Tests/EditMode/EncyclopediaScreenTests.cs b/unity/Assets/Tests/EditMode/EncyclopediaScreenTests.cs
index d6697ad86..20757ce12 100644
--- a/unity/Assets/Tests/EditMode/EncyclopediaScreenTests.cs
+++ b/unity/Assets/Tests/EditMode/EncyclopediaScreenTests.cs
@@ -189,12 +189,13 @@ public class EncyclopediaScreenTests
}
[UnityTest]
- public IEnumerator TheEncyclopediaFitsLaptopAndPhoneInBothLanguages([Values(SaveGame.GddRuleset, SaveGame.Gdd03Ruleset)] string ruleset)
+ public IEnumerator TheEncyclopediaFitsLaptopAndPhoneInBothLanguages([Values(SaveGame.GddRuleset, SaveGame.Gdd03Ruleset)] string ruleset,
+ [Values(100, 125, 150)] int uiScale) // #40: at the Settings scale choices (#2219 review)
{
var problems = new List<string>();
foreach (var hebrew in new[] { false, true })
- foreach (var size in new[] { new Vector2Int(1280, 720), new Vector2Int(390, 844) })
- yield return Rendered(size.x, size.y, hebrew, (root, pedia) => Fits(root, problems, $"{ruleset} {(hebrew ? "he" : "en")} {size.x}x{size.y}", pedia, ruleset), ruleset);
+ foreach (var size in new[] { new Vector2Int(1280, 720), new Vector2Int(390, 844), new Vector2Int(360, 800), new Vector2Int(2560, 1080) }) // and the ends of the verified range
+ yield return Rendered(size.x, size.y, hebrew, (root, pedia) => Fits(root, problems, $"{ruleset} {(hebrew ? "he" : "en")} {size.x}x{size.y} at {uiScale}%", pedia, ruleset), ruleset, uiScale);
Assert.IsEmpty(problems, string.Join("\n", problems));
}
@@ -261,11 +262,12 @@ public class EncyclopediaScreenTests
/// <summary>The whole HUD as the game lays it out, the encyclopedia open on its list, with an advisor so Show me shows.
/// The Hebrew is the test's approved copy (every shipped page is approved since 1 Nov 2026).</summary>
static IEnumerator Rendered(int width, int height, bool hebrew, System.Func<VisualElement, EncyclopediaPresenter, IEnumerable> check,
- string ruleset = SaveGame.GddRuleset)
+ string ruleset = SaveGame.GddRuleset, int uiScale = 100)
{
var rt = new RenderTexture(width, height, 0);
var ps = Object.Instantiate(AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel));
ps.targetTexture = rt;
+ if (uiScale != 100) ps.referenceResolution = new Vector2Int(Mathf.RoundToInt(1920f * 100f / uiScale), Mathf.RoundToInt(1080f * 100f / uiScale)); // #40: the panel as the Settings scale choice sets it
var go = new GameObject("EncyclopediaLayoutTest");
go.SetActive(false);
var doc = go.AddComponent<UIDocument>();
diff --git a/unity/Assets/Tests/EditMode/HebrewUiTests.cs b/unity/Assets/Tests/EditMode/HebrewUiTests.cs
index e416fc5bf..dbe982618 100644
--- a/unity/Assets/Tests/EditMode/HebrewUiTests.cs
+++ b/unity/Assets/Tests/EditMode/HebrewUiTests.cs
@@ -36,7 +36,6 @@ public class HebrewUiTests
{
EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);
if (Directory.Exists(saveDir)) Directory.Delete(saveDir, true);
- SettingsPresenter.VerifiedShapes.Remove(150); // the language switch's stand-in (the game ships none)
}
// --- The flag ---------------------------------------------------------------------------------------------------
@@ -195,7 +194,6 @@ public class HebrewUiTests
game.Store = new SaveStore(saveDir);
var settings = new SettingsStore(Path.Combine(saveDir, "settings"));
game.Settings = settings;
- SettingsScreenTests.VerifyOnEveryShape(150); // the game verifies no scale above 100% yet (#1011)
game.Begin(Inputs, 0); // no file and no flag: English
Assert.IsFalse(Ui.Q("root").ClassListContains(UiLanguage.HebrewClass));
Assert.IsTrue(Ui.Q<Button>("settings-language-en").ClassListContains(SettingsPresenter.SelectedClass), "English is marked");
@@ -759,11 +757,12 @@ public class HebrewUiTests
/// screen at 1920x1080, and the screen scrolled sideways).</summary>
[UnityTest]
public IEnumerator NoBudgetRowIsWiderThanItsScreen(
- [Values(UiLanguage.Hebrew, UiLanguage.English)] string language, [Values(1920, 390)] int width)
+ [Values(UiLanguage.Hebrew, UiLanguage.English)] string language, [Values(1920, 390)] int width, [Values(100, 125, 150)] int uiScale) // #40: at the Settings scale choices
{
var restore = OnTexture(width, width == 1920 ? 1080 : 844);
try
{
+ if (uiScale != 100) Object.FindFirstObjectByType<UIDocument>().panelSettings.referenceResolution = new Vector2Int(Mathf.RoundToInt(1920f * 100f / uiScale), Mathf.RoundToInt(1080f * 100f / uiScale)); // #40: the panel as the Settings scale choice sets it
var game = Object.FindFirstObjectByType<GameRoot>();
game.Store = new SaveStore(saveDir);
game.Language = language;
@@ -777,14 +776,14 @@ public class HebrewUiTests
Assert.Greater(rows.Count, 3);
foreach (var row in rows)
{
- Assert.LessOrEqual(row.layout.width, room + 0.5f, $"{language} {width}: '{row[0].name}' is wider than the screen");
+ Assert.LessOrEqual(row.layout.width, room + 0.5f, $"{language} {width} {uiScale}%: '{row[0].name}' is wider than the screen");
foreach (var part in row.Children())
{
- Assert.LessOrEqual(part.layout.xMax, row.layout.width + 0.5f, $"{language} {width}: '{part.name}' runs past its row's end");
- Assert.GreaterOrEqual(part.layout.xMin, -0.5f, $"{language} {width}: '{part.name}' runs past its row's start");
+ Assert.LessOrEqual(part.layout.xMax, row.layout.width + 0.5f, $"{language} {width} {uiScale}%: '{part.name}' runs past its row's end");
+ Assert.GreaterOrEqual(part.layout.xMin, -0.5f, $"{language} {width} {uiScale}%: '{part.name}' runs past its row's start");
}
}
- Assert.LessOrEqual(list.contentContainer.layout.width, room + 0.5f, $"{language} {width}: the rows scroll sideways");
+ Assert.LessOrEqual(list.contentContainer.layout.width, room + 0.5f, $"{language} {width} {uiScale}%: the rows scroll sideways");
// The control: without the wrapping class the long Hebrew row is wider than the screen at 1920 (so this test can fail).
// Its own text no longer is since its date turned Hebrew (#701, "10 במרץ 1949" is shorter than "10 March 1949"),
// so the control triples the longest office name: the class, not one string's width, is what is checked.
diff --git a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
index 47db464ed..6fd883fd1 100644
--- a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
+++ b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
@@ -28,7 +28,7 @@ public class InfoPanelLayoutTests
internal static readonly (int w, int h)[] Windows =
{
(1920, 1080), (1280, 720), (1366, 768), (1760, 1000), (1920, 1200), (1440, 900), (1680, 1050), (1024, 768), (1280, 1024),
- (1024, 1024), (960, 1080), (800, 1000), (1531, 784), (2560, 1080), (1920, 900), (1600, 757), (1366, 657), (960, 600), (390, 844),
+ (1024, 1024), (960, 1080), (800, 1000), (1531, 784), (2560, 1080), (1920, 900), (1600, 757), (1366, 657), (960, 600), (390, 844), (360, 800),
};
/// <summary>Windows where the city's own hex must show its projects behind the toggle (owner ruling on #1150, 21 Oct 2026):
diff --git a/unity/Assets/Tests/EditMode/SettingsScreenTests.cs b/unity/Assets/Tests/EditMode/SettingsScreenTests.cs
index 6867233f5..ce8c9e691 100644
--- a/unity/Assets/Tests/EditMode/SettingsScreenTests.cs
+++ b/unity/Assets/Tests/EditMode/SettingsScreenTests.cs
@@ -286,7 +286,7 @@ public class SettingsScreenTests
[Test]
public void EachUiScaleTakesEffectAtOnceAndSurvivesAReload([Values(false, true)] bool hebrew)
{
- VerifyOnEveryShape(125, 150); // the mechanism a scale gets once it is verified; the game verifies none yet
+ VerifyOnEveryShape(125, 150); // every window shape, not only the game's verified range
var text = hebrew ? He : En;
using (var ui = new UiTestKit())
{
@@ -331,7 +331,7 @@ public class SettingsScreenTests
}
/// <summary>As if the layout suites passed at these scales on every window shape: what a test of the scale's mechanism
- /// needs now that the game offers only verified scales (SettingsPresenter.VerifiedShapes, empty for now). TearDown puts
+ /// needs now that the game offers only verified scales (SettingsPresenter.VerifiedShapes). TearDown puts
/// the table back.</summary>
public static void VerifyOnEveryShape(params int[] percents)
{
@@ -339,20 +339,23 @@ public class SettingsScreenTests
}
/// <summary>The owner's ruling on #1011 (19 Oct 2026), case 1: only the scales verified to fit are offered, 100% always.
- /// No scale above 100% is verified yet (at 125% and 150% the layout suites fail on every window shape), so on each
- /// shape the suites cover Settings offers 100% alone, marked. When a scale is verified, this test changes with it.</summary>
+ /// Since #1853 the layout suites pass at 125% and 150% on every window they cover, 360x800 to 2560x1080 (#40, 2 Nov 2026),
+ /// so both are verified on that range of shapes and offered on each window inside it. Outside it (narrower than
+ /// 360x800 or wider than 2560x1080) Settings offers 100% alone. 100% stays marked: it is the default.</summary>
[UnityTest]
public IEnumerator OnlyTheVerifiedUiScalesAreOffered()
{
- Assert.IsEmpty(SettingsPresenter.VerifiedShapes, "no scale above 100% is verified yet");
- foreach (var (w, h) in new[] { (1920, 1080), (1280, 720), (1024, 768), (960, 1080), (360, 800), (2560, 1080) })
+ foreach (var percent in new[] { 125, 150 })
+ Assert.AreEqual((360f / 800f, 2560f / 1080f), SettingsPresenter.VerifiedShapes[percent], $"{percent}% is verified from 360x800 to 2560x1080");
+ foreach (var (w, h) in new[] { (1920, 1080), (1280, 720), (1024, 768), (960, 1080), (360, 800), (2560, 1080), (320, 800), (1280, 400) })
{
var window = new Window(w, h, dir);
+ var inside = w / (float)h >= 360f / 800f && w / (float)h <= 2560f / 1080f;
try
{
yield return window.Settle();
foreach (var (name, percent) in UiScaleButtons)
- Assert.AreEqual(percent == 100, window.Root.Q<Button>(name).resolvedStyle.display == DisplayStyle.Flex, $"{w}x{h}: {percent}% offered");
+ Assert.AreEqual(percent == 100 || inside, window.Root.Q<Button>(name).resolvedStyle.display == DisplayStyle.Flex, $"{w}x{h}: {percent}% offered");
Assert.IsTrue(window.Root.Q<Button>("settings-uiscale-100").ClassListContains(SettingsPresenter.SelectedClass), $"{w}x{h}: 100% marked");
}
finally { window.Dispose(); }
@@ -364,6 +367,7 @@ public class SettingsScreenTests
[Test]
public void ASavedScaleThatIsNotVerifiedFallsBackTo100OnLoad([Values(125, 150)] int saved)
{
+ SettingsPresenter.VerifiedShapes.Remove(saved); // as if not verified; TearDown puts the table back
new SettingsStore(dir).Write(SettingsPresenter.UiScaleKey, saved.ToString());
using var ui = new UiTestKit();
using var settings = new SettingsPresenter(ui.Root, En, new SettingsStore(dir), panel: ui.Doc.panelSettings);
@@ -372,13 +376,14 @@ public class SettingsScreenTests
Assert.AreEqual(saved.ToString(), new SettingsStore(dir).Read(SettingsPresenter.UiScaleKey), "the choice is kept");
}
- /// <summary>Case 3: the fit follows the window. With 150% verified only on shapes from 1:2 to 1:1 (a stand-in: the
- /// game verifies none yet), a saved 150% holds on 960x1080; a resize to 16:9 drops the panel to 100% and stops
- /// offering 150%; back on 960x1080 the kept choice returns.</summary>
+ /// <summary>Case 3: the fit follows the window. With 150% verified only on shapes from 1:2 to 1:1 and 125% not at all
+ /// (stand-ins narrower than the game's table), a saved 150% holds on 960x1080; a resize to 16:9 drops the panel to
+ /// 100% and stops offering 150%; back on 960x1080 the kept choice returns.</summary>
[UnityTest]
public IEnumerator ResizingOutOfAVerifiedShapeFallsBackTo100()
{
SettingsPresenter.VerifiedShapes[150] = (0.5f, 1f);
+ SettingsPresenter.VerifiedShapes.Remove(125);
new SettingsStore(dir).Write(SettingsPresenter.UiScaleKey, "150");
var window = new Window(960, 1080, dir);
try
diff --git a/unity/Assets/Tests/EditMode/TopBarScoreLayoutTests.cs b/unity/Assets/Tests/EditMode/TopBarScoreLayoutTests.cs
index 59de899a2..bb05f9865 100644
--- a/unity/Assets/Tests/EditMode/TopBarScoreLayoutTests.cs
+++ b/unity/Assets/Tests/EditMode/TopBarScoreLayoutTests.cs
@@ -54,7 +54,7 @@ public class TopBarScoreLayoutTests
static bool Apart(Rect a, Rect b) => !Rect.MinMaxRect(a.xMin + 0.5f, a.yMin + 0.5f, a.xMax - 0.5f, a.yMax - 0.5f).Overlaps(b);
[UnityTest]
- public IEnumerator AWorstCaseScoreStaysInsideTheDateBox()
+ public IEnumerator AWorstCaseScoreStaysInsideTheDateBox([Values(100, 125, 150)] int uiScale) // #40: at the Settings scale choices
{
var problems = new List<string>();
foreach (var (language, text, hebrew, turns) in new[] { ("en", En, false, 0), ("en", En, false, 2), ("he", He, true, 0), ("he", He, true, 2) })
@@ -63,6 +63,7 @@ public class TopBarScoreLayoutTests
var rt = new RenderTexture(w, h, 0);
var ps = Object.Instantiate(AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel));
ps.targetTexture = rt;
+ if (uiScale != 100) ps.referenceResolution = new Vector2Int(Mathf.RoundToInt(1920f * 100f / uiScale), Mathf.RoundToInt(1080f * 100f / uiScale)); // #40: the panel as the Settings scale choice sets it
var go = new GameObject("ScoreLayoutTest");
go.SetActive(false);
var doc = go.AddComponent<UIDocument>();
diff --git a/unity/Assets/Tests/EditMode/TurnReportTests.cs b/unity/Assets/Tests/EditMode/TurnReportTests.cs
index 8a84d213e..58e11a878 100644
--- a/unity/Assets/Tests/EditMode/TurnReportTests.cs
+++ b/unity/Assets/Tests/EditMode/TurnReportTests.cs
@@ -403,16 +403,17 @@ public class TurnReportTests
/// <summary>At a laptop's 1280x720 and a phone's 390x844, in English and Hebrew: the report lies in the window, every
/// line within its panel, its two buttons shown, and the keyboard focus on Close.</summary>
[UnityTest]
- public IEnumerator ItFitsLaptopAndPhoneInBothLanguages()
+ public IEnumerator ItFitsLaptopAndPhoneInBothLanguages([Values(100, 125, 150)] int uiScale) // #40: at the Settings scale choices (#2219 review)
{
var problems = new List<string>();
foreach (var hebrew in new[] { false, true })
- foreach (var (w, h) in new[] { (1280, 720), (390, 844) })
+ foreach (var (w, h) in new[] { (1280, 720), (390, 844), (360, 800), (2560, 1080) }) // and the ends of the verified range (SettingsPresenter.VerifiedShapes)
{
- string at = $"{(hebrew ? "he" : "en")} {w}x{h}";
+ string at = $"{(hebrew ? "he" : "en")} {w}x{h} at {uiScale}%";
var rt = new RenderTexture(w, h, 0);
var ps = Object.Instantiate(AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel));
ps.targetTexture = rt;
+ if (uiScale != 100) ps.referenceResolution = new Vector2Int(Mathf.RoundToInt(1920f * 100f / uiScale), Mathf.RoundToInt(1080f * 100f / uiScale)); // #40: the panel as the Settings scale choice sets it
var go = new GameObject("TurnReportLayout"); go.SetActive(false);
var doc = go.AddComponent<UIDocument>(); doc.panelSettings = ps;
doc.visualTreeAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(UiPaths.GameUxml);
diff --git a/unity/Assets/Tests/EditMode/UiLayoutTests.cs b/unity/Assets/Tests/EditMode/UiLayoutTests.cs
index 2c55ba06f..73073165a 100644
--- a/unity/Assets/Tests/EditMode/UiLayoutTests.cs
+++ b/unity/Assets/Tests/EditMode/UiLayoutTests.cs
@@ -426,8 +426,11 @@ public class UiLayoutTests
g.Step(new Command[0]);
}
var problems = new List<string>();
- foreach (var (w, h) in new[] { (1920, 1080), (1280, 720), (1920, 960), (1600, 757), (1366, 657), (390, 844), (960, 600) }) // #210: and narrow windows
+ foreach (var hebrew in new[] { false, true }) // #2219 review: the scaled screens in Hebrew too
+ foreach (var (w, h) in new[] { (1920, 1080), (1280, 720), (1920, 960), (1600, 757), (1366, 657), (390, 844), (960, 600), (360, 800), (2560, 1080) }) // #210: and narrow windows; #2219: the ends of the verified range
{
+ var at = $"{(hebrew ? "he" : "en")} {w}x{h}";
+ var t = hebrew ? He : text;
var rt = new RenderTexture(w, h, 0);
var ps = Object.Instantiate(AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel));
ps.targetTexture = rt;
@@ -439,16 +442,17 @@ public class UiLayoutTests
doc.visualTreeAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(UiPaths.GameUxml);
go.SetActive(true);
var root = doc.rootVisualElement;
- var bridge = new SimBridge(g, text);
+ root.Q("root").EnableInClassList(UiLanguage.HebrewClass, hebrew);
+ var bridge = new SimBridge(g, t);
var disposables = new List<System.IDisposable>
{
- new HudPresenter(root, bridge, text), new EventCardPresenter(root, bridge, text, null),
- new CabinetPresenter(root, bridge, text, null), new BudgetPresenter(root, bridge, text),
- new DefencePresenter(root, bridge, text), new WhyPresenter(root, bridge, text),
- new ObjectivesPresenter(root, bridge, text),
+ new HudPresenter(root, bridge, t), new EventCardPresenter(root, bridge, t, null),
+ new CabinetPresenter(root, bridge, t, null), new BudgetPresenter(root, bridge, t),
+ new DefencePresenter(root, bridge, t), new WhyPresenter(root, bridge, t),
+ new ObjectivesPresenter(root, bridge, t),
};
var nav = new ScreenNav(root);
- disposables.Add(new EncyclopediaPresenter(root, text, AdvisorCatalog.Load(), nav, null));
+ disposables.Add(new EncyclopediaPresenter(root, t, AdvisorCatalog.Load(), nav, null));
try
{
for (int i = 0; i < 20 && float.IsNaN(root.Q("minimap").worldBound.width); i++) yield return null;
@@ -457,23 +461,23 @@ public class UiLayoutTests
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;
var bar = root.Q("top-bar");
var plate = root.Q(className: "date-box"); // hangs below the one-row bar, as promo 03's (HUD round 2, part 3)
- if (!Inside(R(plate), R(root))) problems.Add($"{w}x{h}: the plate {R(plate)} leaves the window");
+ if (!Inside(R(plate), R(root))) problems.Add($"{at}: the plate {R(plate)} leaves the window");
foreach (var l in bar.Query<VisualElement>().ToList().Where(e => e != bar && e.resolvedStyle.display == DisplayStyle.Flex))
{
var holder = l == plate || plate.Contains(l) ? (l == plate ? bar : plate) : bar;
if (l == plate) continue;
- if (!Inside(R(l), R(holder))) problems.Add($"{w}x{h}: top bar child {l.name}/{(l as Label)?.text ?? l.GetClasses().FirstOrDefault()} {R(l)} leaves the {(holder == plate ? "plate" : "bar")} {R(holder)}");
+ if (!Inside(R(l), R(holder))) problems.Add($"{at}: top bar child {l.name}/{(l as Label)?.text ?? l.GetClasses().FirstOrDefault()} {R(l)} leaves the {(holder == plate ? "plate" : "bar")} {R(holder)}");
}
var card = root.Q("event-card");
- if (!Inside(R(card), R(root.Q("event-layer")))) problems.Add($"{w}x{h}: event card {R(card)} leaves the decision layer {R(root.Q("event-layer"))}");
- if (R(card).yMin < R(bar).yMax - 0.5f) problems.Add($"{w}x{h}: event card {R(card)} starts over the top bar {R(bar)}");
+ if (!Inside(R(card), R(root.Q("event-layer")))) problems.Add($"{at}: event card {R(card)} leaves the decision layer {R(root.Q("event-layer"))}");
+ if (R(card).yMin < R(bar).yMax - 0.5f) problems.Add($"{at}: event card {R(card)} starts over the top bar {R(bar)}");
foreach (var s in ScreenNav.Screens)
{
nav.Open(s);
for (int i = 0; i < 3; i++) yield return null;
var screen = root.Q("screen-" + s);
foreach (var e in screen.Children().Concat(screen.Query<ScrollView>().ToList()).Where(e => e.resolvedStyle.display == DisplayStyle.Flex))
- if (!Inside(R(e), R(screen))) problems.Add($"{w}x{h}: {s} child {e.name}/{e.GetClasses().FirstOrDefault()} {R(e)} leaves the screen {R(screen)}");
+ if (!Inside(R(e), R(screen))) problems.Add($"{at}: {s} child {e.name}/{e.GetClasses().FirstOrDefault()} {R(e)} leaves the screen {R(screen)}");
}
nav.Open(null);
}
@@ -504,6 +508,7 @@ public class UiLayoutTests
{
(1920, 1080), (1280, 720), (1366, 768), (1760, 1000), (1920, 1200), (1440, 900), (1024, 768), (1280, 1024),
(1024, 1024), (960, 1080), (800, 1000), (390, 844), (960, 600), (1531, 784), (1568, 752), (2560, 1080), (1920, 900), (1366, 657),
+ (360, 800), // #2219: the narrowest verified shape
};
/// <summary>Decision cards (2026-10-13), after Task 24 review I2: every real event, the tallest included, fits the
@@ -514,8 +519,11 @@ public class UiLayoutTests
public IEnumerator EveryEventCardFitsTheDecisionLayer([Values(100, 125, 150)] int uiScale) // #40: at the Settings scale choices
{
var problems = new List<string>();
+ foreach (var hebrew in new[] { false, true }) // #2219 review: the scaled cards in Hebrew too
foreach (var (w, h) in CardWindows)
{
+ var at = $"{(hebrew ? "he" : "en")} {w}x{h}";
+ var t = hebrew ? He : Text;
var rt = new RenderTexture(w, h, 0);
var ps = Object.Instantiate(AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel));
ps.targetTexture = rt;
@@ -527,15 +535,16 @@ public class UiLayoutTests
doc.visualTreeAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(UiPaths.GameUxml);
go.SetActive(true);
var root = doc.rootVisualElement;
- var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), Text);
+ root.Q("root").EnableInClassList(UiLanguage.HebrewClass, hebrew);
+ var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), t);
// The real portraits: a minister's portrait adds the 200 px image row, so the tallest card is a portrait card.
var portraits = AssetDatabase.LoadAssetAtPath<PortraitCatalog>("Assets/UI/Portraits/PortraitCatalog.asset");
Assert.IsNotNull(portraits);
// And the real event photographs: a photograph card adds the 200 px header band and its credit line.
var photos = AssetDatabase.LoadAssetAtPath<EventImageCatalog>("Assets/Resources/EventImageCatalog.asset");
Assert.IsNotNull(photos);
- var hud = new HudPresenter(root, bridge, Text); // the bar's tier (one, two or three rows) sets the layer's top
- var card = new EventCardPresenter(root, bridge, Text, portraits, photos);
+ var hud = new HudPresenter(root, bridge, t); // the bar's tier (one, two or three rows) sets the layer's top
+ var card = new EventCardPresenter(root, bridge, t, portraits, photos);
float tallest = 0; string tallestId = "";
try
{
@@ -549,8 +558,8 @@ public class UiLayoutTests
if (e.Objective != "") g.State.Objectives[e.Objective] = new System.DateTime(1948, 11, 30);
bridge.Replace(g);
for (int i = 0; i < 4; i++) yield return null; // the fourth: a photograph dropped for height settles
- CheckPhoto($"{w}x{h}: {e.Id}", root, card, problems);
- CheckCard($"{w}x{h}: {e.Id}", root, problems);
+ CheckPhoto($"{at}: {e.Id}", root, card, problems);
+ CheckCard($"{at}: {e.Id}", root, problems);
var c = root.Q("event-card").worldBound;
if (c.height > tallest) { tallest = c.height; tallestId = e.Id; }
var scroll = root.Q<ScrollView>("event-scroll");
@@ -563,13 +572,13 @@ public class UiLayoutTests
scroll.ScrollTo(b);
yield return null;
if (!Inside(b.worldBound, scroll.contentViewport.worldBound))
- problems.Add($"{w}x{h}: {e.Id}: option '{b.text}' {b.worldBound} cannot be scrolled whole into the body {scroll.contentViewport.worldBound}");
+ problems.Add($"{at}: {e.Id}: option '{b.text}' {b.worldBound} cannot be scrolled whole into the body {scroll.contentViewport.worldBound}");
}
if (b.worldBound.yMax > c.yMax + 0.5f || b.worldBound.yMin < c.yMin - 0.5f || b.worldBound.xMax > c.xMax + 0.5f || b.worldBound.xMin < c.xMin - 0.5f)
- problems.Add($"{w}x{h}: {e.Id}: option '{b.text}' {b.worldBound} is cut off by the card {c}");
+ problems.Add($"{at}: {e.Id}: option '{b.text}' {b.worldBound} is cut off by the card {c}");
// Playtest 2, P2-2: the option's text lies inside its button (it wraps; it is never cut at the edge).
if (!TextFits(b))
- problems.Add($"{w}x{h}: {e.Id}: option text '{b.text}' does not fit its button {b.contentRect}");
+ problems.Add($"{at}: {e.Id}: option text '{b.text}' does not fit its button {b.contentRect}");
}
scroll.scrollOffset = Vector2.zero;
// Playtest 2, P2-3: in a window at least as tall (logically) as 1366x657, the body and the options fit
@@ -579,10 +588,10 @@ public class UiLayoutTests
// The narrow-card fallback is at 150% only; Hide and the options are still checked above at every size.
if (CardBodyScrollsTooMuch(uiScale, root.Q("event-card").worldBound.width, logicalHeight,
scroll.contentContainer.layout.height, scroll.contentViewport.layout.height))
- problems.Add($"{w}x{h} (logical height {logicalHeight:0}): {e.Id}: the body scrolls ({scroll.contentContainer.layout.height:0} px of text in {scroll.contentViewport.layout.height:0} px)");
+ problems.Add($"{at} (logical height {logicalHeight:0}): {e.Id}: the body scrolls ({scroll.contentContainer.layout.height:0} px of text in {scroll.contentViewport.layout.height:0} px)");
}
- Debug.Log($"I2 {w}x{h}: tallest card {tallestId} {tallest:0} px");
- Assert.Greater(tallest, 300f, $"{w}x{h}: the cards were laid out (a short window shrinks the tallest to fit)");
+ Debug.Log($"I2 {at}: tallest card {tallestId} {tallest:0} px");
+ Assert.Greater(tallest, 300f, $"{at}: the cards were laid out (a short window shrinks the tallest to fit)");
}
finally
{