A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Unity: meter tips explain each meter (Fixes #2200) (#2249)
Beri2efbbebd9179
diff --git a/changelog.d/laneQY-2200.md b/changelog.d/laneQY-2200.mdnew file mode 100644index 000000000..5bd890615--- /dev/null+++ b/changelog.d/laneQY-2200.md@@ -0,0 +1,6 @@+### Changed++- Each top-bar meter's tip now says what the meter is and what moves it, under its number in words (#2200): one+ `hud.tip.<id>` string per meter in English and Hebrew. Money, Immigration, Social cohesion and International support+ reuse sentences of their encyclopedia pages; Security, Public support and Foreign currency are written from the sim's+ rules. The new Hebrew awaits a native read (#564).diff --git a/unity/Assets/Scripts/UI/MeterTip.cs b/unity/Assets/Scripts/UI/MeterTip.csindex 71e995f3c..7547e7994 100644--- a/unity/Assets/Scripts/UI/MeterTip.cs+++ b/unity/Assets/Scripts/UI/MeterTip.cs@@ -87,12 +87,15 @@ namespace Statecraft.Game.UIpublic VisualElement? ShownFor => shownFor;/// <summary>The tip's lines for <paramref name="meter"/> (an element named "meter-" + a HudModel.MeterIds id): its- /// words, with the causes' heading when there are causes, and the causes, one a line (none when none).</summary>+ /// words and what the meter is (hud.tip.<id>, #2200), with the causes' heading when there are causes, and the+ /// causes, one a line (none when none).</summary>public (string words, IReadOnlyList<string> causes) Lines(VisualElement meter){- var causes = HudModel.Causes(bridge.Session.Last, meter.name.Substring("meter-".Length), bridge.Content,+ var id = meter.name.Substring("meter-".Length);+ var causes = HudModel.Causes(bridge.Session.Last, id, bridge.Content,w => CauseText.Line(w, bridge.Content, Array.Empty<Statecraft.Game.Map.Units.UnitEntry>(), text, TownNamesHe)); // no meter counts a unit line- return causes.Count == 0 ? (meter.tooltip, causes) : (meter.tooltip + "\n" + text["hud.causes"], causes);+ var words = meter.tooltip + "\n" + text["hud.tip." + id]; // the number alone does not say what moves it (#2200)+ return causes.Count == 0 ? (words, causes) : (words + "\n" + text["hud.causes"], causes);}/// <summary>Shows the tip for the hovered meter, else the tapped one, with today's words (HudPresenter.Render callsdiff --git a/unity/Assets/Tests/EditMode/MeterTipTests.cs b/unity/Assets/Tests/EditMode/MeterTipTests.csindex 9334573b3..3d617eb6d 100644--- a/unity/Assets/Tests/EditMode/MeterTipTests.cs+++ b/unity/Assets/Tests/EditMode/MeterTipTests.cs@@ -55,7 +55,7 @@ public class MeterTipTestsfor (int i = 0; i < 3; i++) yield return null; // the tip is placed once its width is laid outvar causes = HudModel.Causes(bridge.Session.Last, id, bridge.Content, w => CauseText.Line(w, bridge.Content, System.Array.Empty<Statecraft.Game.Map.Units.UnitEntry>(), text));if (!Shown(tip)) { problems.Add($"{at} {id}: hovering shows no tip"); continue; }- if (Words(root) != meter.tooltip + "\n" + text["hud.causes"]) problems.Add($"{at} {id}: the tip's words are '{Words(root)}', not its tooltip and the causes' heading");+ if (Words(root) != meter.tooltip + "\n" + text["hud.tip." + id] + "\n" + text["hud.causes"]) problems.Add($"{at} {id}: the tip's words are '{Words(root)}', not its tooltip, its explanation and the causes' heading");if (CausesLine(root) != string.Join("\n", causes)) problems.Add($"{at} {id}: the tip's causes are '{CausesLine(root)}', not the sim's '{string.Join(" | ", causes)}'");if (UiDirection.RightToLeft(Words(root)) != hebrew) problems.Add($"{at} {id}: the words are not in the UI's language");// B1: a keyed line is in the UI's language (#55: lines with no key stay English). Since #1565 Security's@@ -76,6 +76,45 @@ public class MeterTipTestsAssert.IsEmpty(problems, string.Join("\n", problems));}+ /// <summary>#2200: every top-bar meter's tip says what the meter is and what moves it (hud.tip.<id>, one key per+ /// HudModel.MeterIds id, in English and Hebrew) after its number in words (the tooltip), and the longer tip still fits+ /// in the window under the bar at each UI scale (100, 125 and 150%, SettingsPresenter.UiScales) and on a phone.</summary>+ [UnityTest]+ public IEnumerator EveryMeterTipExplainsItsMeterAndFits()+ {+ var problems = new List<string>();+ foreach (var id in HudModel.MeterIds)+ foreach (var (lang, t) in new[] { ("en", En), ("he", He) })+ if (!t.Has("hud.tip." + id) || t["hud.tip." + id].Trim().Length == 0) problems.Add($"{lang}: no hud.tip.{id}");+ if (problems.Count > 0) { Assert.Fail(string.Join("\n", problems)); yield break; }+ foreach (var hebrew in new[] { false, true })+ foreach (var (w, h, scale) in new[] { (1280, 720, 100), (1280, 720, 125), (1280, 720, 150), (390, 844, 100) })+ {+ string at = $"{(hebrew ? "he" : "en")} {w}x{h} {scale}%";+ yield return Rendered(w, h, hebrew, Check, scale);++ IEnumerator Check(VisualElement root, SimBridge bridge, UiText text)+ {+ var tip = root.Q(MeterTip.TipName);+ foreach (var id in HudModel.MeterIds)+ {+ var meter = root.Q("meter-" + id);+ Enter(meter);+ for (int i = 0; i < 3; i++) yield return null; // the tip is placed once its width is laid out+ if (!Shown(tip)) { problems.Add($"{at} {id}: hovering shows no tip"); Leave(meter); continue; }+ var expected = meter.tooltip + "\n" + text["hud.tip." + id];+ if (!Words(root).StartsWith(expected)) problems.Add($"{at} {id}: the tip's words are '{Words(root)}', not its number in words and then '{text["hud.tip." + id]}'");+ if (UiDirection.RightToLeft(Words(root)) != hebrew) problems.Add($"{at} {id}: the words are not in the UI's language");+ Rect r = tip.worldBound, m = meter.worldBound, win = root.worldBound;+ if (r.xMin < win.xMin - 0.5f || r.xMax > win.xMax + 0.5f || r.yMax > win.yMax + 0.5f) problems.Add($"{at} {id}: the tip {r} leaves the window {win}");+ if (r.yMin < m.yMax) problems.Add($"{at} {id}: the tip {r} is not under its number {m}");+ Leave(meter);+ }+ }+ }+ Assert.IsEmpty(problems, string.Join("\n", problems));+ }+/// <summary>A touchscreen has no hover: a tap pins the tip, a tap on another number moves it, a second tap closes it, and/// End Turn closes it; the meter's tooltip stays its words alone (the accessibility text, HudModel.Spoken).</summary>[UnityTest]@@ -138,12 +177,14 @@ public class MeterTipTestsAssert.IsEmpty(problems, string.Join("\n", problems));}- /// <summary>Renders Game.uxml at w x h with the HUD after one turn, then runs <paramref name="check"/>, which may wait frames.</summary>- internal static IEnumerator Rendered(int w, int h, bool hebrew, System.Func<VisualElement, SimBridge, UiText, IEnumerator> check)+ /// <summary>Renders Game.uxml at w x h with the HUD after one turn, then runs <paramref name="check"/>, which may wait frames.+ /// A <paramref name="uiScale"/> other than 100 sets the panel as the Settings scale choice does (#40).</summary>+ internal static IEnumerator Rendered(int w, int h, bool hebrew, System.Func<VisualElement, SimBridge, UiText, IEnumerator> check, int uiScale = 100){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(ps.referenceResolution.x * 100f / uiScale), Mathf.RoundToInt(ps.referenceResolution.y * 100f / uiScale));var go = new GameObject("MeterTipLayout"); go.SetActive(false);var doc = go.AddComponent<UIDocument>(); doc.panelSettings = ps;doc.visualTreeAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(UiPaths.GameUxml);diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlindex d6f0bc737..62de89c2c 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -32,6 +32,21 @@ hud.caption.standing: "International support"hud.caption.fx: "Foreign currency"# Social cohesion (the morale indicator, R-NAT-001), the GDD loop only; the owner's ruling of 15 October 2026 (#380).hud.caption.cohesion: "Social cohesion"+# Each meter's tip says what the meter is and what moves it, under its number in words (MeterTip, #2200; owner's option 1:+# one key per HudModel.MeterIds id). treasury, immigration, cohesion and standing are sentences of the encyclopedia pages+# (advisor.page.money_debt, .immigration, .national_meters), word for word. security, support and fx have no page yet and+# are written from the code: security from model.yaml's border_villages_secure effect (its office's competence and budget,+# EffectsSystem.Multiplier) and event shifts; support from EffectsSystem.Approval and model.yaml's voter_groups, with+# coalition stability moving toward it (PoliticsSystem.UpdateStability, R-GOV-001); fx from EconomySystem.Apply's flows,+# EconomySystem.ConvertDollars (R-MONEY-004) and fx_crisis, which stops the Food import (R-FOOD-002), and event effects on+# fx_reserves (R-EFX-001).+hud.tip.treasury: "Money comes in from taxes and from every filled job, and goes out on government spending, the upkeep of our military formations, training and building. When a cost is more than we have, it is still paid: Money stops at zero and the rest becomes debt."+hud.tip.immigration: "The immigrants arrive as the historical figures bring them, and each city takes a share in proportion to its people. They wait as refugees, and each turn some of them become civilians without work; how many depends on the minister in charge of immigration."+hud.tip.security: "Security moves with the choices made on event cards. Border villages add to it, more with an able and well-funded Minister of Agriculture."+hud.tip.support: "Public support is the average approval of the voter groups, each weighing two of Social cohesion, security, housing and Food. Coalition stability moves toward it every turn."+hud.tip.cohesion: "Social cohesion rises and falls with housing, work, Food, rationing and security."+hud.tip.standing: "International support moves with the choices made on event cards."+hud.tip.fx: "Foreign currency comes in from exports, donations and loans, and goes out on imports, which grow with the population, and on dollars converted into Money on the Defence screen during the war. Event cards can add to it or take from it. Once it runs out, the Food import stops until it recovers."# The other static texts of Game.uxml, each set by the presenter that owns its element (#193). Each English string is# the UXML's own text (HebrewUiTests.EachEnglishStaticTextIsTheUxmlsOwnText), so English shows what it always showed.# The top bar (HudPresenter):diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yamlindex f4e8e067b..54cce168a 100644--- a/unity/Assets/UI/strings.he.yaml+++ b/unity/Assets/UI/strings.he.yaml@@ -28,6 +28,23 @@ hud.caption.standing: "תמיכה בינלאומית"hud.caption.fx: "מטבע חוץ"# hud.caption.cohesion: Social cohesion; the GDD's Hebrew, kept by the owner (Q-HUD-3, 15 October 2026, #375; #380).hud.caption.cohesion: "לכידות חברתית"+# Each meter's tip (MeterTip, #2200), as hud.tip.* in strings.en.yaml. treasury, immigration, cohesion and standing are+# sentences of the reviewed encyclopedia pages (advisor.page.money_debt, .immigration, .national_meters), split from them;+# security, support and fx are new. Agent-drafted Hebrew, all seven: native-review-pending (#564).+# native-review-pending+hud.tip.treasury: "כסף נכנס ממסים ומכל משרה מאוישת, ויוצא על הוצאות הממשלה, על אחזקת העוצבות הצבאיות שלנו, על אימון ועל בנייה. כשעלות גבוהה ממה שיש לנו, היא משולמת בכל זאת: הכסף נעצר באפס והיתרה הופכת לחוב."+# native-review-pending+hud.tip.immigration: "העולים מגיעים לפי הנתונים ההיסטוריים, וכל עיר מקבלת חלק לפי מספר האנשים בה. הם ממתינים כפליטים, ובכל תור חלק מהם הופכים לאזרחים ללא עבודה; כמה מהם, תלוי בשר האחראי על העלייה."+# native-review-pending+hud.tip.security: "הביטחון זז בעקבות הבחירות בכרטיסי האירוע. יישובי הספר מוסיפים לו, ויותר מכך כששר החקלאות מוכשר ומשרדו מתוקצב היטב."+# native-review-pending+hud.tip.support: "התמיכה הציבורית היא ממוצע התמיכה של קבוצות הבוחרים, וכל קבוצה שוקלת שניים מבין הלכידות החברתית, הביטחון, הדיור והמזון. יציבות הקואליציה נעה לעברה בכל תור."+# native-review-pending+hud.tip.cohesion: "הלכידות החברתית עולה ויורדת עם הדיור, התעסוקה, המזון, הקיצוב והביטחון."+# native-review-pending+hud.tip.standing: "התמיכה הבינלאומית זזה בעקבות הבחירות בכרטיסי האירוע."+# native-review-pending+hud.tip.fx: "מטבע החוץ נכנס מיצוא, מתרומות ומהלוואות, ויוצא על יבוא שגדל עם האוכלוסייה ועל דולרים שמומרים לכסף במסך הביטחון בזמן המלחמה. כרטיסי האירוע יכולים להוסיף לו או לגרוע ממנו. כשהוא אוזל, יבוא המזון נעצר עד שהוא מתאושש."hud.nav.cabinet: "ממשלה"# The Cabinet disc's tip while a seat is vacant that the player can fill (#1109). For the native reviewer (#564).hud.nav.cabinet_vacant: "ממשלה: יש תפקיד פנוי. אפשר למנות אליו מישהו."