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.

HUD: the Hebrew top bar gets the roomy tier when it has the room (Fixes #2688) (#2691)

Eyal Golan3c5a14f265bc
diff --git a/changelog.d/2688.md b/changelog.d/2688.md
new file mode 100644
index 000000000..f277f5e77
--- /dev/null
+++ b/changelog.d/2688.md
@@ -0,0 +1,3 @@
+### Fixed
+
+- Size the Hebrew top bar's indicators and values up when it has the same spare room as the English bar.
diff --git a/unity/Assets/Scripts/UI/HudPresenter.cs b/unity/Assets/Scripts/UI/HudPresenter.cs
index 8d7bcce53..f7073ce81 100644
--- a/unity/Assets/Scripts/UI/HudPresenter.cs
+++ b/unity/Assets/Scripts/UI/HudPresenter.cs
@@ -339,9 +339,11 @@ namespace Statecraft.Game.UI
if (meters.Count == 0) return;
var oneRow = !hudRoot.ClassListContains(NarrowClass) && !bar.ClassListContains(CompactClass);
// Panel coordinates (logical px), so the meters and the screen buttons compare directly.
- float first = meters[0].worldBound.xMin, last = meters[meters.Count - 1].worldBound.xMax, limit = nav.worldBound.xMin;
- if (!oneRow || float.IsNaN(first) || float.IsNaN(limit)) { bar.RemoveFromClassList(RoomyClass); return; }
- var used = last - first; var spare = limit - last;
+ float left = meters.Min(m => m.worldBound.xMin), right = meters.Max(m => m.worldBound.xMax);
+ var rtl = UiLanguage.Within(bar);
+ var limit = rtl ? nav.worldBound.xMax : nav.worldBound.xMin;
+ if (!oneRow || float.IsNaN(left) || float.IsNaN(right) || float.IsNaN(limit)) { bar.RemoveFromClassList(RoomyClass); return; }
+ var used = right - left; var spare = rtl ? left - limit : limit - right;
if (bar.ClassListContains(RoomyClass))
{
if (spare < SpareShare * used) bar.RemoveFromClassList(RoomyClass);
diff --git a/unity/Assets/Tests/EditMode/HebrewUiTests.cs b/unity/Assets/Tests/EditMode/HebrewUiTests.cs
index 83b0512ba..ced075df0 100644
--- a/unity/Assets/Tests/EditMode/HebrewUiTests.cs
+++ b/unity/Assets/Tests/EditMode/HebrewUiTests.cs
@@ -87,6 +87,33 @@ public class HebrewUiTests
static VisualElement Ui => Object.FindFirstObjectByType<UIDocument>().rootVisualElement;
+ /// <summary>#2688: the roomy tier reads physical meter bounds and the gap on the navigation's side, so mirroring the
+ /// top-bar rows does not change whether it fits. This boots each language through GameRoot.Begin on the same panel size.
+ /// Red-first: UpdateRoomy measured from the first to last meter and always towards nav.xMin, so Hebrew never added it.</summary>
+ [UnityTest]
+ public IEnumerator TheHebrewTopBarIsRoomyExactlyWhenTheEnglishTopBarIs()
+ {
+ var roomy = new Dictionary<string, bool>();
+ foreach (var language in new[] { UiLanguage.English, UiLanguage.Hebrew })
+ {
+ var restore = OnTexture(1920, 1080);
+ try
+ {
+ var game = Object.FindFirstObjectByType<GameRoot>();
+ game.Store = new SaveStore(saveDir);
+ game.Language = language;
+ game.Begin(Inputs, 0);
+ for (int i = 0; i < 30 && !(Ui.Q("top-bar").worldBound.width > 0); i++) yield return null;
+ for (int i = 0; i < 6; i++) yield return null; // geometry and the roomy class settle
+ roomy[language] = Ui.Q("top-bar").ClassListContains(HudPresenter.RoomyClass);
+ }
+ finally { restore(); }
+ }
+
+ Assert.IsTrue(roomy[UiLanguage.English], "1920x1080 English is roomy (PromoHudTests' pinned expectation)");
+ Assert.AreEqual(roomy[UiLanguage.English], roomy[UiLanguage.Hebrew], "1920x1080 Hebrew matches English");
+ }
+
// #2045: every Orders.Check refusal (its Refused* constants) has a string in both files, and the Hebrew one is Hebrew,
// not the sim's English. A missing key throws in UiText's lookup.
[Test]