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.

Hebrew: mirror the Security caption row, the cause indent and the advisor X in playback (Fixes #2594) (#2687)

Eyal Golan2235db468f3f
diff --git a/changelog.d/2594.md b/changelog.d/2594.md
new file mode 100644
index 000000000..9d29689e4
--- /dev/null
+++ b/changelog.d/2594.md
@@ -0,0 +1,3 @@
+### Fixed
+
+- Mirror the Security caption, turn-report cause indentation, and inline advisor close button in Hebrew.
diff --git a/unity/Assets/Tests/EditMode/AdvisorMediaTests.cs b/unity/Assets/Tests/EditMode/AdvisorMediaTests.cs
index 5def811e5..01ee81985 100644
--- a/unity/Assets/Tests/EditMode/AdvisorMediaTests.cs
+++ b/unity/Assets/Tests/EditMode/AdvisorMediaTests.cs
@@ -44,12 +44,15 @@ public class AdvisorMediaTests
static readonly AdvisorCatalog.Media Row = new AdvisorCatalog.Media
{
- Picture = "x.mp4", Narration = new Dictionary<string, string> { ["en"] = "x.en.wav" },
- Cues = new Dictionary<string, List<double>> { ["en"] = new List<double> { 0.0, 2.5 } }, Label = "lab",
+ Picture = "x.mp4", Narration = new Dictionary<string, string> { ["en"] = "x.en.wav", ["he"] = "x.he.wav" },
+ Cues = new Dictionary<string, List<double>> { ["en"] = new List<double> { 0.0, 2.5 }, ["he"] = new List<double> { 0.0, 2.5 } }, Label = "lab",
};
static UiText Text => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text +
"\nadvisor.t.teach.text: \"Teach.\"\nadvisor.t.warn.text: \"Warn.\"\nadvisor.t.crit.text: \"Critical.\"\nadvisor.x.cue.1: \"First.\"\nadvisor.x.cue.2: \"Second.\"\nlab: \"Label.\"\n" +
"advisor.t.teach.cue.1: \"Teach one.\"\nadvisor.t.teach.cue.2: \"Teach two.\"\n");
+ static UiText HebrewText => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text +
+ "\nadvisor.t.teach.text: \"לימוד.\"\nadvisor.t.warn.text: \"אזהרה.\"\nadvisor.t.crit.text: \"קריטי.\"\nadvisor.x.cue.1: \"ראשון.\"\nadvisor.x.cue.2: \"שני.\"\nlab: \"תווית.\"\n" +
+ "advisor.t.teach.cue.1: \"לימוד ראשון.\"\nadvisor.t.teach.cue.2: \"לימוד שני.\"\n", "strings.he.yaml");
readonly List<AdvisorMedia> owned = new List<AdvisorMedia>();
[TearDown] public void Clean() { foreach (var media in owned) media.Dispose(); owned.Clear(); }
@@ -291,42 +294,58 @@ public class AdvisorMediaTests
[UnityTest]
public System.Collections.IEnumerator InlineKeepsItsXAndAPhoneStopsItBeforeUsingTheOverlay()
{
- var wide = new RenderTexture(1280, 720, 0);
- var panel = UnityEngine.Object.Instantiate(AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel)); panel.targetTexture = wide;
- var go = new GameObject("AdvisorMediaGeometry"); go.SetActive(false);
- var doc = go.AddComponent<UIDocument>(); doc.panelSettings = panel;
- doc.visualTreeAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(UiPaths.GameUxml); go.SetActive(true);
- var root = doc.rootVisualElement; var hudRoot = root.Q("root"); hudRoot.RemoveFromClassList("loading");
- var bridge = new SimBridge(GameSession.New(ContentLoader.Load(Paths.Content), GoldenRun.Seed, Mode.Historical), Text);
- var hud = new HudPresenter(root, bridge, Text); var nav = new ScreenNav(root);
- var card = new EventCardPresenter(root, bridge, Text, null); card.Collapse(takeFocus: false);
- var session = new AdvisorSession(AdvisorCatalog.Parse(AdvisorPopupTests.Fixture), new AdvisorSettings(null), true);
- var advisor = new AdvisorPresenter(root, bridge, Text, session, hooks: new AdvisorHooks { Card = card });
- var pic = new FakePicture { Ready = true }; var output = new FakeOutput();
- advisor.Media = new AdvisorMedia(Text, pic, null, Immediate, output);
- try
+ foreach (var hebrew in new[] { false, true })
{
- advisor.NewGame(); for (int i = 0; i < 6; i++) yield return null;
- advisor.ForceInline = true; advisor.Watch(Row, "advisor.x"); advisor.Media.Tick(); output.Position = 0.1f;
- for (int i = 0; i < 4; i++) yield return null;
- Assert.IsTrue(AdvisorTargets.Shown(root.Q("advisor-close")), "inline keeps X usable");
- // A runtime targetTexture swap does not resize an EditMode panel (it stayed 1920x1080 panel px for 30 frames), so the
- // HUD root takes an upright phone's size in panel px (390x844 at the 1280x720 panel's 1.5 panel px per pixel).
- advisor.ForceInline = null; hudRoot.style.width = 585; hudRoot.style.height = 1266;
- for (int i = 0; i < 6; i++) yield return null;
- Assert.IsTrue(hudRoot.ClassListContains(HudPresenter.ThreeRowClass));
- Assert.IsFalse(advisor.Media.Playing, "inline stops when the new tier has no room; no automatic replay");
- advisor.ForceInline = false; advisor.Watch(Row, "advisor.x"); advisor.Media.Tick(); output.Position = 0.1f;
- for (int i = 0; i < 6; i++) yield return null;
- var picture = root.Q("advisor-overlay-media").worldBound;
- Assert.Greater(picture.height, 0); Assert.AreEqual(EventCardPresenter.MediaAspect, picture.width / picture.height, 0.02f);
- Assert.GreaterOrEqual(root.Q("advisor-overlay-caption").resolvedStyle.fontSize * root.panel.scaledPixelsPerPoint, HudPresenter.TextFloorPx - 0.01f);
- }
- finally
- {
- advisor.Dispose(); card.Dispose(); nav.Dispose(); hud.Dispose();
- UnityEngine.Object.DestroyImmediate(go); UnityEngine.Object.DestroyImmediate(panel);
- wide.Release(); UnityEngine.Object.DestroyImmediate(wide);
+ var text = hebrew ? HebrewText : Text;
+ var wide = new RenderTexture(1280, 720, 0);
+ var panel = UnityEngine.Object.Instantiate(AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel)); panel.targetTexture = wide;
+ var go = new GameObject("AdvisorMediaGeometry"); go.SetActive(false);
+ var doc = go.AddComponent<UIDocument>(); doc.panelSettings = panel;
+ doc.visualTreeAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(UiPaths.GameUxml); go.SetActive(true);
+ var root = doc.rootVisualElement; var hudRoot = root.Q("root"); hudRoot.RemoveFromClassList("loading");
+ hudRoot.EnableInClassList(UiLanguage.HebrewClass, text["ui.lang"] == UiLanguage.Hebrew); // as GameRoot
+ var bridge = new SimBridge(GameSession.New(ContentLoader.Load(Paths.Content), GoldenRun.Seed, Mode.Historical), text);
+ var hud = new HudPresenter(root, bridge, text); var nav = new ScreenNav(root);
+ var card = new EventCardPresenter(root, bridge, text, null); card.Collapse(takeFocus: false);
+ // Hebrew shows only approved lines (AdvisorCatalog.ApprovedIn): approve the fixture's, as AdvisorPopupLayoutTests does.
+ var session = new AdvisorSession(AdvisorCatalog.Parse(AdvisorPopupTests.Fixture.Replace("level: new,", "level: new, he_review: approved,")), new AdvisorSettings(null), true);
+ var advisor = new AdvisorPresenter(root, bridge, text, session, hooks: new AdvisorHooks { Card = card });
+ var direction = hebrew ? new UiDirection(root, bridge) : null;
+ var pic = new FakePicture { Ready = true }; var output = new FakeOutput();
+ advisor.Media = new AdvisorMedia(text, pic, null, Immediate, output);
+ try
+ {
+ advisor.NewGame(); for (int i = 0; i < 6; i++) yield return null;
+ var popupBounds = root.Q("advisor-popup").worldBound; var closeBounds = root.Q("advisor-close").worldBound;
+ float beforeLeft = closeBounds.xMin - popupBounds.xMin, beforeRight = popupBounds.xMax - closeBounds.xMax;
+ if (hebrew) Assert.Less(beforeLeft, beforeRight, "Hebrew: X starts at the left corner");
+ else Assert.Less(beforeRight, beforeLeft, "English: X starts at the right corner");
+ advisor.ForceInline = true; advisor.Watch(Row, "advisor.x"); advisor.Media.Tick(); output.Position = 0.1f;
+ for (int i = 0; i < 4; i++) yield return null;
+ Assert.IsTrue(AdvisorTargets.Shown(root.Q("advisor-close")), "inline keeps X usable");
+ Assert.IsTrue(root.Q("advisor-popup").ClassListContains(AdvisorPresenter.WatchingClass), "precondition: inline picture playback");
+ popupBounds = root.Q("advisor-popup").worldBound; closeBounds = root.Q("advisor-close").worldBound;
+ float leftGap = closeBounds.xMin - popupBounds.xMin, rightGap = popupBounds.xMax - closeBounds.xMax;
+ if (hebrew) Assert.Less(leftGap, rightGap, "Hebrew: inline X stays at the left corner");
+ else Assert.Less(rightGap, leftGap, "English: inline X stays at the right corner");
+ // A runtime targetTexture swap does not resize an EditMode panel (it stayed 1920x1080 panel px for 30 frames), so the
+ // HUD root takes an upright phone's size in panel px (390x844 at the 1280x720 panel's 1.5 panel px per pixel).
+ advisor.ForceInline = null; hudRoot.style.width = 585; hudRoot.style.height = 1266;
+ for (int i = 0; i < 6; i++) yield return null;
+ Assert.IsTrue(hudRoot.ClassListContains(HudPresenter.ThreeRowClass));
+ Assert.IsFalse(advisor.Media.Playing, "inline stops when the new tier has no room; no automatic replay");
+ advisor.ForceInline = false; advisor.Watch(Row, "advisor.x"); advisor.Media.Tick(); output.Position = 0.1f;
+ for (int i = 0; i < 6; i++) yield return null;
+ var picture = root.Q("advisor-overlay-media").worldBound;
+ Assert.Greater(picture.height, 0); Assert.AreEqual(EventCardPresenter.MediaAspect, picture.width / picture.height, 0.02f);
+ Assert.GreaterOrEqual(root.Q("advisor-overlay-caption").resolvedStyle.fontSize * root.panel.scaledPixelsPerPoint, HudPresenter.TextFloorPx - 0.01f);
+ }
+ finally
+ {
+ direction?.Dispose(); advisor.Dispose(); card.Dispose(); nav.Dispose(); hud.Dispose();
+ UnityEngine.Object.DestroyImmediate(go); UnityEngine.Object.DestroyImmediate(panel);
+ wide.Release(); UnityEngine.Object.DestroyImmediate(wide);
+ }
}
}
diff --git a/unity/Assets/Tests/EditMode/TopBarTests.cs b/unity/Assets/Tests/EditMode/TopBarTests.cs
index b0e4a29b0..c160181e3 100644
--- a/unity/Assets/Tests/EditMode/TopBarTests.cs
+++ b/unity/Assets/Tests/EditMode/TopBarTests.cs
@@ -71,7 +71,7 @@ public class TopBarTests
doc.visualTreeAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(UiPaths.GameUxml);
go.SetActive(true);
var root = doc.rootVisualElement;
- if (hebrew) root.Q("root").AddToClassList(UiLanguage.HebrewClass);
+ root.Q("root").EnableInClassList(UiLanguage.HebrewClass, text["ui.lang"] == UiLanguage.Hebrew); // as GameRoot
HudPresenter? hud = null; UiDirection? dir = null; EventCardPresenter? card = null; ScreenNav? nav = null;
try
{
@@ -617,6 +617,16 @@ public class TopBarTests
{
string at = $"{(hebrew ? "he" : "en")} {w}x{h}{(widest ? " widest" : " turn 1")}";
if (!root.Q("root").ClassListContains("hud-three-row")) { problems.Add($"{at}: precondition: the three-row bar"); return; }
+ var captionRow = root.Q(className: "meter-caption-row");
+ var expectedDirection = hebrew ? FlexDirection.RowReverse : FlexDirection.Row;
+ if (captionRow.resolvedStyle.flexDirection != expectedDirection)
+ problems.Add($"{at}: Security caption row is {captionRow.resolvedStyle.flexDirection}, expected {expectedDirection}");
+ var levelStyle = root.Q<Label>("security-level").resolvedStyle;
+ float expectedLeft = hebrew ? 0f : 6f, expectedRight = hebrew ? 6f : 0f;
+ // The panel snaps layout to whole screen pixels, so a stylesheet px reads within one screen pixel of itself.
+ float snap = 1f / HudPresenter.ScreenPxPerPanelPx(root.panel) + 0.01f;
+ if (Mathf.Abs(levelStyle.marginLeft - expectedLeft) > snap || Mathf.Abs(levelStyle.marginRight - expectedRight) > snap)
+ problems.Add($"{at}: Security level margins are {levelStyle.marginLeft}px left and {levelStyle.marginRight}px right, expected {expectedLeft}px and {expectedRight}px");
int seen = 0;
foreach (var l in root.Q("top-bar").Query<Label>(className: "meter-name").ToList())
{
diff --git a/unity/Assets/Tests/EditMode/TurnReportTests.cs b/unity/Assets/Tests/EditMode/TurnReportTests.cs
index 1e6922c1a..cf8fed536 100644
--- a/unity/Assets/Tests/EditMode/TurnReportTests.cs
+++ b/unity/Assets/Tests/EditMode/TurnReportTests.cs
@@ -580,20 +580,27 @@ public class TurnReportTests
go.SetActive(true);
var root = doc.rootVisualElement;
root.Q("root").RemoveFromClassList("loading");
- if (hebrew) root.Q("root").AddToClassList(UiLanguage.HebrewClass);
var text = hebrew ? He : En;
+ root.Q("root").EnableInClassList(UiLanguage.HebrewClass, text["ui.lang"] == UiLanguage.Hebrew); // as GameRoot
var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), text);
var owned = new List<System.IDisposable>();
owned.Add(new HudPresenter(root, bridge, text));
var nav = new ScreenNav(root); owned.Add(nav);
owned.Add(new EventCardPresenter(root, bridge, text, null));
var report = new TurnReportPresenter(root, bridge, text, nav); owned.Add(report);
+ if (hebrew) owned.Add(new UiDirection(root, bridge));
try
{
bridge.EndTurn();
for (int i = 0; i < 30 && !(root.Q("turn-report-panel").layout.width > 0); i++) yield return null;
for (int i = 0; i < 3; i++) yield return null;
var window = root.worldBound; var panel = root.Q("turn-report-panel").worldBound;
+ var causesStyle = root.Q("turn-report-causes-security").resolvedStyle;
+ float expectedLeft = hebrew ? 2f : 14f, expectedRight = hebrew ? 14f : 2f;
+ // The panel snaps layout to whole screen pixels, so a stylesheet px reads within one screen pixel of itself.
+ float snap = 1f / HudPresenter.ScreenPxPerPanelPx(root.panel) + 0.01f;
+ if (Mathf.Abs(causesStyle.paddingLeft - expectedLeft) > snap || Mathf.Abs(causesStyle.paddingRight - expectedRight) > snap)
+ problems.Add($"{at}: Security causes padding is {causesStyle.paddingLeft}px left and {causesStyle.paddingRight}px right, expected {expectedLeft}px and {expectedRight}px");
if (!(panel.width > 0 && panel.height > 0)) problems.Add($"{at}: the report is not shown");
if (panel.xMin < window.xMin - 0.5f || panel.yMin < window.yMin - 0.5f || panel.xMax > window.xMax + 0.5f || panel.yMax > window.yMax + 0.5f)
problems.Add($"{at}: the report {panel} leaves the window {window}");
diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.uss
index a219b6b6c..8345fbcb9 100644
--- a/unity/Assets/UI/Statecraft.uss
+++ b/unity/Assets/UI/Statecraft.uss
@@ -115,7 +115,7 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
/* In the bar a long caption wraps rather than widen its meter; on the roomy bar it keeps one line, as in the promo (B8). */
.meter .meter-name { max-width: 120px; }
.top-bar--roomy .meter .meter-name { max-width: none; white-space: nowrap; }
-#security-level { font-size: 15px; color: var(--ink-dim); margin-left: 6px; white-space: nowrap; flex-shrink: 0; }
+#security-level { font-size: 15px; color: var(--ink-dim); margin-left: 6px; margin-right: 0; white-space: nowrap; flex-shrink: 0; } /* margin-right: 0, or the default theme's Label margin stays on the far side (#2687) */
.meter-row { flex-direction: row; align-items: flex-end; }
.meter-value { font-size: 21px; color: var(--ink); }
.meter-delta { font-size: 16px; margin-left: 7px; }
@@ -194,7 +194,7 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
/* In Hebrew each caption, and Security's wrapped caption row, ends at the text column's right edge (review of #859: the
wrapped row had moved to the column's left). */
.lang-he.hud-three-row .meter-body { align-items: flex-end; }
-.lang-he.hud-three-row .meter-caption-row { justify-content: flex-end; }
+.lang-he.hud-three-row .meter-caption-row { justify-content: flex-start; }
.hud-three-row .right-column, .hud-three-row .left-column, .hud-three-row .event-gutter, .hud-three-row .event-layer, .hud-three-row .screen, .hud-three-row .toast { top: 456px; }
/* The owner's ruling on #859 (17 October 2026): on a phone no rail button sits under the decision card, Why? and Settings
included. The card starts right of the column (the layer's left padding, from its 16 px: the column's 60 px and a 12 px gap; padding, so
@@ -1009,7 +1009,7 @@ Button.settings-choice-selected { -unity-font-definition: url("project://databas
/* The Hebrew plate shows the first name's initial and the surname ("י. ידין", PersonCard.InitialAndSurname), not two
letters: at 36 px the longest, "פ. ברנשטיין", fits the narrowest plate (measured by PromoScreensTests). */
.lang-he .card-initials { font-size: 36px; }
-.lang-he .top-bar, .lang-he .year-row, .lang-he .date-row, .lang-he .meters, .lang-he .meter, .lang-he .meter-row, .lang-he .nav, .lang-he .row,
+.lang-he .top-bar, .lang-he .year-row, .lang-he .date-row, .lang-he .meters, .lang-he .meter, .lang-he .meter-caption-row, .lang-he .meter-row, .lang-he .nav, .lang-he .row,
.lang-he .event-foot, .lang-he .event-head, .lang-he .info-panel, .lang-he .info-row, .lang-he .card-stat, .lang-he .pm-offices,
.lang-he .cabinet-house, .lang-he .party-group, .lang-he .party-chip, .lang-he .defence-row, .lang-he .leaders, .lang-he .rung,
.lang-he .defence-budget, .lang-he #cabinet-seats .unity-scroll-view__content-container, .lang-he .start-recording,
@@ -1021,6 +1021,7 @@ Button.settings-choice-selected { -unity-font-definition: url("project://databas
.lang-he .date-row Label { margin-right: 0; margin-left: 8px; }
.lang-he .meter { border-right-width: 0; border-left-width: 1px; padding: 0 3px 0 4px; }
.lang-he .meter-icon { margin-right: 0; margin-left: 5px; }
+.lang-he #security-level { margin-left: 0; margin-right: 6px; }
.lang-he .meter-delta { margin-left: 0; margin-right: 7px; }
.lang-he.hud-narrow .meter-delta { margin-right: 0; }
.lang-he .meter-delta.delta-up, .lang-he .meter-delta.delta-down { padding-left: 0; padding-right: 9px; }
@@ -1030,6 +1031,7 @@ Button.settings-choice-selected { -unity-font-definition: url("project://databas
.lang-he .info-row-sign { margin: 3px 0 0 10px; }
.lang-he .info-body > .row Button { margin-right: 0; margin-left: 6px; }
.lang-he .why-line { padding-left: 0; padding-right: 12px; }
+.lang-he .turn-report-causes { padding: 4px 14px 4px 2px; }
.lang-he .section-title { margin: 0 2px 8px 0; }
.lang-he .cabinet-side { margin-right: 0; margin-left: 14px; }
.lang-he .pm-office { margin: 0 0 4px 6px; }
@@ -1210,6 +1212,7 @@ Button.settings-choice-selected { -unity-font-definition: url("project://databas
.advisor-overlay-words { flex-shrink: 1; min-height: 0; }
.advisor-watching .advisor-head { position: absolute; right: 8px; top: 8px; margin: 0; }
+.lang-he .advisor-watching .advisor-head { right: auto; left: 8px; }
.advisor-no-portrait.advisor-has-media .advisor-portrait { display: flex; }
.advisor-watching .advisor-head > .advisor-portrait, .advisor-watching .advisor-head > .advisor-names { display: none; }