A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
HUD: a resumed game keeps all six top-bar changes; each meter's change in words in its tooltip (refs #398) (#523)
Eyal Golan37df39aa1a24
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 16a3f059d..ce24922fa 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -40,6 +40,11 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIBa click, Enter or Space skips it, and Esc skips them all. A counterfactual option, a delegated answer, a refused orderand Deport get none, and there is none in automated runs. The Horev clip waits for the owner's sensitivity reviewbefore a shareable build. Presentation only: no golden moves.+- Top bar (refs #398): each meter's tooltip holds its value and the change since last turn in words, for example+ "Treasury: IL 18.6 million, down IL 1.4 million since last turn", with captions from the strings (English and Hebrew).+ It is kept for a later accessibility layer: no screen reader reads a runtime tooltip yet. A resumed game now shows+ the same changes as before the reload on all six meters: `GameSession` keeps the step before the last+ (`BeforeLast`), so Immigration's change survives a load too. Not part of the state or the save: no golden moves.- Decision videos, phase 2 (#434 follow-up). On 11 decision cards an Illustration switch over the photograph plays ashort, silent AI-generated loop. It is labelled "AI-generated illustration" in place of the credit and carries a smallburned-in bilingual label. The photograph always shows first; nothing plays until the player asks, and the choice holdsdiff --git a/sim/Statecraft.Sim.Tests/PlayerTextTests.cs b/sim/Statecraft.Sim.Tests/PlayerTextTests.csindex b1c3b069f..fa4f88e1e 100644--- a/sim/Statecraft.Sim.Tests/PlayerTextTests.cs+++ b/sim/Statecraft.Sim.Tests/PlayerTextTests.cs@@ -374,6 +374,10 @@ public class PlayerTextTestsAssert.Equal("0%", PlayerText.PercentChange(-0.004, 0));Assert.Equal("-IL 3.0m", PlayerText.Money(Real, "treasury", -3));Assert.Equal("IL 0.0m", PlayerText.Money(Real, "treasury", -0.04));+ // #398 review N2: the parts Money is built from, for the top bar's words ("IL 18.6 million").+ Assert.Equal(("-", "IL ", "3.0"), PlayerText.MoneyParts(Real, "treasury", -3));+ Assert.Equal(("", "IL ", "0.0"), PlayerText.MoneyParts(Real, "treasury", -0.04));+ Assert.Equal(("", "$", "41.5"), PlayerText.MoneyParts(Real, "fx_reserves", 41.46));Assert.Equal("$41.5m", PlayerText.Money(Real, "fx_reserves", 41.5));Assert.Equal("+IL 1.2m", PlayerText.MoneyChange(Real, "treasury", 1.23));Assert.Equal("-$0.4m", PlayerText.MoneyChange(Real, "fx_reserves", -0.4));diff --git a/sim/Statecraft.Sim.Tests/SaveGameTests.cs b/sim/Statecraft.Sim.Tests/SaveGameTests.csindex 09d11d4d1..6b60fdee7 100644--- a/sim/Statecraft.Sim.Tests/SaveGameTests.cs+++ b/sim/Statecraft.Sim.Tests/SaveGameTests.cs@@ -49,6 +49,27 @@ public class SaveGameTestsAssert.Equal(played.Previous!.Hash(), loaded.Previous!.Hash()); // "since last turn" survives a load}+ /// <summary>#398 review S1: a load also keeps the step before the last, so a change that compares two steps (the top+ /// bar's arrivals) is the one the player saw before the reload. A new session and one step have none.</summary>+ [Fact]+ public void ALoadKeepsTheStepBeforeTheLast()+ {+ var c = Fixture1();+ var played = Played(c);+ var loaded = GameSession.Load(c, played.Save.Write(), out _);+ Assert.NotNull(played.BeforeLast);+ Assert.Equal(played.BeforeLast!.State.Hash(), loaded.BeforeLast!.State.Hash());+ Assert.Equal(played.BeforeLast.Why.Select(w => (w.System, w.Delta)), loaded.BeforeLast.Why.Select(w => (w.System, w.Delta)));+ Assert.Equal(played.Last!.State.Hash(), loaded.Last!.State.Hash());+ var fresh = GameSession.New(c, 99, Mode.Historical);+ Assert.Null(fresh.BeforeLast);+ fresh.Step(new Command[0]);+ Assert.Null(fresh.BeforeLast);+ var first = fresh.Last;+ fresh.Step(new Command[0]);+ Assert.Same(first, fresh.BeforeLast);+ }+[Fact]public void TheSaveRecordsTheHeaderAndExactNumbers(){diff --git a/sim/Statecraft.Sim/GameSession.cs b/sim/Statecraft.Sim/GameSession.csindex f210248c7..d6d86bc49 100644--- a/sim/Statecraft.Sim/GameSession.cs+++ b/sim/Statecraft.Sim/GameSession.cs@@ -13,6 +13,10 @@ namespace Statecraft.Simpublic GameState? Previous { get; private set; }/// <summary>The last step's result (null before the first): its Why and Rejected lists.</summary>public StepResult? Last { get; private set; }+ /// <summary>The step before Last (null before the second step), for a change that compares two steps' results (the+ /// top bar's arrivals). A loaded session has it from its replay, like Previous and Last. Not part of the state or+ /// the save.</summary>+ public StepResult? BeforeLast { get; private set; }public SaveGame Save { get; }GameSession(Content c, GameState s, SaveGame save) { Content = c; State = s; Save = save; }@@ -29,7 +33,7 @@ namespace Statecraft.Sim{var r = Simulation.Step(Content, State, commands);Save.Record(commands, r.State);- Previous = State; State = r.State; Last = r;+ Previous = State; State = r.State; BeforeLast = Last; Last = r;return r;}diff --git a/sim/Statecraft.Sim/PlayerText.cs b/sim/Statecraft.Sim/PlayerText.csindex 788cd6b32..52358a6e7 100644--- a/sim/Statecraft.Sim/PlayerText.cs+++ b/sim/Statecraft.Sim/PlayerText.cs@@ -69,9 +69,17 @@ namespace Statecraft.Sim/// <summary>An amount in millions with its currency: "IL 18.6m", "-IL 3.0m", "$41.5m"; zero is "IL 0.0m".</summary>public static string Money(Content c, string id, double millions)+ {+ var (sign, prefix, amount) = MoneyParts(c, id, millions);+ return sign + prefix + amount + "m";+ }++ /// <summary>The parts Money is built from, rounded as it rounds: the sign ("-", or "" for a value that rounds to zero+ /// or above), the currency prefix from content, and the amount ("18.6"). The top bar says them in words.</summary>+ public static (string Sign, string Prefix, string Amount) MoneyParts(Content c, string id, double millions){var r = Math.Round(Finite(millions, nameof(millions)), 1, MidpointRounding.AwayFromZero);- return Signed(r, Account(c, id).Prefix, Fixed(Math.Abs(r), 1) + "m", signed: false);+ return (r < 0 ? "-" : "", Account(c, id).Prefix, Fixed(Math.Abs(r), 1));}/// <summary>A change in millions with its currency, sign first: "+IL 1.2m", "-$0.4m"; zero is "IL 0.0m".</summary>diff --git a/unity/Assets/Scripts/UI/HudModel.cs b/unity/Assets/Scripts/UI/HudModel.csindex ef704651d..5ce94a8cc 100644--- a/unity/Assets/Scripts/UI/HudModel.cs+++ b/unity/Assets/Scripts/UI/HudModel.cs@@ -5,13 +5,15 @@ using Statecraft.Sim;namespace Statecraft.Game.UI{- /// <summary>One top-bar indicator: its value and the change since the last turn (empty when there is none).</summary>+ /// <summary>One top-bar indicator: its value and the change since the last turn (empty when there is none), and the+ /// two again in words (HudModel.Spoken): SayValue, and SayChange without its sign (empty when there is no change).</summary>public readonly struct Meter{- public readonly string Value, Delta;+ public readonly string Value, Delta, SayValue, SayChange;/// <summary>+1 up, -1 down, 0 unchanged or unknown.</summary>public readonly int Sign;- public Meter(string value, string delta, int sign) { Value = value; Delta = delta; Sign = sign; }+ public Meter(string value, string delta, int sign, string sayValue, string sayChange)+ { Value = value; Delta = delta; Sign = sign; SayValue = sayValue; SayChange = sayChange; }}/// <summary>What the top bar shows, computed from simulation state only (no UI types), so it is testable on its own.@@ -24,32 +26,50 @@ namespace Statecraft.Game.UIstatic double Arrivals(StepResult? r) => r == null ? 0 : r.Why.Where(w => w.System == "population").Sum(w => w.Delta);+ /// <summary>The meter in words, kept as its tooltip for a later accessibility layer (as the event card's alt text;+ /// no screen reader reads a runtime tooltip yet, #398): "Treasury: IL 18.6 million, down IL 1.4 million since last+ /// turn"; with no change, the caption and the value only.</summary>+ public static string Spoken(UiText t, string name, Meter m) =>+ m.SayChange.Length == 0 ? t.Format("hud.say", name, m.SayValue)+ : t.Format(m.Sign > 0 ? "hud.say_up" : "hud.say_down", name, m.SayValue, m.SayChange);+public static HudModel From(SimBridge b, UiText t){+ // After a reload the changes are the ones the player saw: GameSession.Load replays the save's own commands and+ // checks the final hash, so Previous, Last and BeforeLast are the player's last turns (#398).var c = b.Content; var s = b.State; var prev = b.Session.Previous;// Each meter: its value and, after the first turn, the change rounded as shown (a change that rounds to zero is// not shown). Money comes with its currency (PlayerText.Money: IL or $ from content); the 0..1 values are on the// 0-100 scale with "%" (PlayerText.Scale), as everywhere the player sees them (fix round 1, I2).+ // In words: money in millions, from the parts PlayerText.Money is built from ("IL 18.6 million"); the change+ // without its sign; the 0-100 meters' change in points (the shown "+2%" is two points on the 0-100 scale).+ string Millions(string id, double millions)+ {+ var (sign, prefix, amount) = PlayerText.MoneyParts(c, id, millions);+ return t.Format("hud.say_million", sign + prefix, amount);+ }Meter Money(string id, double now, double? before){- var value = PlayerText.Money(c, id, now);- if (before == null) return new Meter(value, "", 0);+ var value = PlayerText.Money(c, id, now); var say = Millions(id, now);+ if (before == null) return new Meter(value, "", 0, say, "");var d = Math.Round(now - before.Value, 1, MidpointRounding.AwayFromZero);- return d == 0 ? new Meter(value, "", 0) : new Meter(value, PlayerText.MoneyChange(c, id, d), Math.Sign(d));+ return d == 0 ? new Meter(value, "", 0, say, "") : new Meter(value, PlayerText.MoneyChange(c, id, d), Math.Sign(d), say, Millions(id, Math.Abs(d)));}Meter Points(double now, double? before){var value = PlayerText.Percent(now); // the one formatter (fix round 2, N4)- if (before == null) return new Meter(value, "", 0);+ if (before == null) return new Meter(value, "", 0, value, "");// The difference of the two shown values, so the change always agrees with them (fix round 3, m-1).var points = PlayerText.ShownPoints(now) - PlayerText.ShownPoints(before.Value);- return points == 0 ? new Meter(value, "", 0) : new Meter(value, PlayerText.PercentChangeShown(before.Value, now), Math.Sign(points));+ var said = t.Format(Math.Abs(points) == 1 ? "hud.say_point" : "hud.say_points", Math.Abs(points));+ return points == 0 ? new Meter(value, "", 0, value, "") : new Meter(value, PlayerText.PercentChangeShown(before.Value, now), Math.Sign(points), value, said);}Meter People(double now, double? before){- if (before == null) return new Meter(t.Format("hud.people", now), "", 0);+ var value = t.Format("hud.people", now);+ if (before == null) return new Meter(value, "", 0, value, "");var d = Math.Round(now - before.Value, 0, MidpointRounding.AwayFromZero);- return d == 0 ? new Meter(t.Format("hud.people", now), "", 0) : new Meter(t.Format("hud.people", now), t.Format("hud.delta_people", d), Math.Sign(d));+ return d == 0 ? new Meter(value, "", 0, value, "") : new Meter(value, t.Format("hud.delta_people", d), Math.Sign(d), value, t.Format("hud.people", Math.Abs(d)));}return new HudModel{diff --git a/unity/Assets/Scripts/UI/HudPresenter.cs b/unity/Assets/Scripts/UI/HudPresenter.csindex 9027c4f70..45959f38e 100644--- a/unity/Assets/Scripts/UI/HudPresenter.cs+++ b/unity/Assets/Scripts/UI/HudPresenter.cs@@ -11,6 +11,9 @@ namespace Statecraft.Game.UIreadonly Button endTurn; readonly System.Action onEndTurn;readonly VisualElement bar, hudRoot, nav;readonly System.Collections.Generic.List<VisualElement> meters;+ /// <summary>Each meter's element and its caption in the UI's language, for the words in its tooltip (#398).</summary>+ readonly System.Collections.Generic.Dictionary<string, (VisualElement element, string caption)> said =+ new System.Collections.Generic.Dictionary<string, (VisualElement, string)>();// Three tiers by the bar's logical width (1080p reference, match 0.5: logical width = sqrt(aspect x 1920 x 1080)).// Each threshold sits well clear of a common window shape, so a small window change does not flip a tier:@@ -64,6 +67,8 @@ namespace Statecraft.Game.UImeters = root.Q<VisualElement>("meters").Children().ToList();nav = root.Q<VisualElement>("nav");foreach (var m in meters) m.RegisterCallback<GeometryChangedEvent>(OnMeterGeometry);+ foreach (var id in new[] { "treasury", "immigration", "security", "support", "standing", "fx" })+ said[id] = (root.Q<VisualElement>("meter-" + id), text["hud.caption." + id]);SetCompact(bar.layout.width); // the bar may already be laid out (the loading screen shows it) and never resizebridge.Changed += Render;Render();@@ -139,6 +144,9 @@ namespace Statecraft.Game.UIdelta.text = m.Delta;delta.EnableInClassList("delta-up", m.Sign > 0);delta.EnableInClassList("delta-down", m.Sign < 0);+ // The meter in words, under its caption in the UI's language (#398).+ var (element, caption) = said[meter];+ element.tooltip = HudModel.Spoken(text, caption, m);}public void Render()diff --git a/unity/Assets/Scripts/UI/SimBridge.cs b/unity/Assets/Scripts/UI/SimBridge.csindex fc7e1619b..8ad350810 100644--- a/unity/Assets/Scripts/UI/SimBridge.cs+++ b/unity/Assets/Scripts/UI/SimBridge.cs@@ -23,8 +23,9 @@ namespace Statecraft.Game.UIpublic IReadOnlyList<Command> LastBatch { get; private set; } = Array.Empty<Command>();/// <summary>The game date when the last turn's orders were given (the date before that turn ran).</summary>public DateTime LastBatchDate { get; private set; }- /// <summary>The step before Session.Last (null until two turns have run), for "change since last turn".</summary>- public StepResult? BeforeLast { get; private set; }+ /// <summary>The step before Session.Last (null until two turns have run), for "change since last turn". The session+ /// keeps it, so a loaded save has it from its replay (#398).</summary>+ public StepResult? BeforeLast => Session.BeforeLast;/// <summary>Raised after every change the screens show: an order queued or withdrawn, a turn, a load.</summary>public event Action? Changed;/// <summary>Raised after End Turn with the orders the simulation refused (possibly none).</summary>@@ -117,7 +118,6 @@ namespace Statecraft.Game.UIpublic StepResult EndTurn(){StepResult r;- var before = Session.Last;var batch = queue.ToList();var date = State.Date;try { r = step(Session, batch); }@@ -134,7 +134,6 @@ namespace Statecraft.Game.UITurnEnded?.Invoke(failed.Rejected);return failed;}- BeforeLast = before;LastBatch = batch; LastBatchDate = date;queue.Clear();Changed?.Invoke();@@ -146,7 +145,7 @@ namespace Statecraft.Game.UIpublic void Replace(GameSession session){Session = session ?? throw new ArgumentNullException(nameof(session));- BeforeLast = null; LastBatch = Array.Empty<Command>();+ LastBatch = Array.Empty<Command>();queue.Clear();Changed?.Invoke();}diff --git a/unity/Assets/Tests/EditMode/HudTests.cs b/unity/Assets/Tests/EditMode/HudTests.csindex 8c2e2e476..588b54400 100644--- a/unity/Assets/Tests/EditMode/HudTests.cs+++ b/unity/Assets/Tests/EditMode/HudTests.cs@@ -451,4 +451,127 @@ public class HudTestsAssert.AreEqual("+1%", m.Security.Delta);Assert.AreEqual(1, m.Security.Sign);}++ static readonly string[] MeterIds = { "treasury", "immigration", "security", "support", "standing", "fx" };+ static string Inv(System.FormattableString f) => System.FormattableString.Invariant(f);+ static UiText He => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings.Replace("strings.en.yaml", "strings.he.yaml")).text, "strings.he.yaml");++ /// <summary>Ends turns until Immigration shows a change (it compares two turns' arrivals), so every meter can show one.+ /// Fails if none comes within 30 turns, so a test built on it never passes by checking nothing.</summary>+ static void PlayUntilImmigrationChanges(SimBridge bridge)+ {+ for (int i = 0; i < 30 && HudModel.From(bridge, Text).Immigration.Sign == 0; i++) bridge.EndTurn();+ Assert.AreNotEqual(0, HudModel.From(bridge, Text).Immigration.Sign, "no Immigration change within 30 turns");+ }++ /// <summary>#398: each meter's tooltip says its value and the change since last turn in words: money in millions+ /// with its currency, the 0-100 meters in points, a count as shown; with no change (turn 0, or one that rounds to+ /// zero) only the caption and the value. The caption is the strings file's (the UI's language).</summary>+ [Test]+ public void EachMeterSaysItsValueAndTheChangeSinceLastTurn()+ {+ using var ui = new UiTestKit();+ var bridge = NewBridge();+ var hud = new HudPresenter(ui.Root, bridge, Text);+ Assert.AreEqual("Treasury: IL 20.0 million", ui.Q<VisualElement>("meter-treasury").tooltip); // turn 0: no change+ Assert.AreEqual("Foreign Currency: $40.0 million", ui.Q<VisualElement>("meter-fx").tooltip);+ Assert.AreEqual("Security: 30%", ui.Q<VisualElement>("meter-security").tooltip);+ bridge.EndTurn();+ var prev = bridge.Session.Previous!; var now = bridge.State;+ prev.Treasury = now.Treasury - now.Debt + prev.Debt + 1.4; // down by 1.4+ prev.FxReserves = now.FxReserves - 2; // up by 2+ prev.Indicators["security"] = now.Indicators["security"] - 0.05; // up 5 points+ prev.Indicators["intl_standing"] = now.Indicators["intl_standing"] + 0.01; // down 1 point+ hud.Render();+ var net = System.Math.Round(now.Treasury - now.Debt, 1, System.MidpointRounding.AwayFromZero);+ Assert.Greater(net, 0, "the test expects a positive net position after one turn");+ Assert.AreEqual(Inv($"Treasury: IL {net:0.0} million, down IL 1.4 million since last turn"), ui.Q<VisualElement>("meter-treasury").tooltip);+ Assert.AreEqual(Inv($"Foreign Currency: ${now.FxReserves:0.0} million, up $2.0 million since last turn"), ui.Q<VisualElement>("meter-fx").tooltip);+ Assert.AreEqual($"Security: {ui.Q<Label>("security-value").text}, up 5 points since last turn", ui.Q<VisualElement>("meter-security").tooltip);+ Assert.AreEqual($"International Standing: {ui.Q<Label>("standing-value").text}, down 1 point since last turn", ui.Q<VisualElement>("meter-standing").tooltip);+ // Immigration after one turn has no change yet (it needs two turns of arrivals): the caption and the count only.+ Assert.AreEqual($"Immigration: {ui.Q<Label>("immigration-value").text}", ui.Q<VisualElement>("meter-immigration").tooltip);+ // Every tooltip agrees with the meter's shown change: "up" with a gain, "down" with a loss, neither without one.+ foreach (var id in MeterIds)+ {+ var tip = ui.Q<VisualElement>("meter-" + id).tooltip; var delta = ui.Q<Label>(id + "-delta");+ StringAssert.StartsWith(Text["hud.caption." + id] + ": ", tip, id);+ Assert.AreEqual(delta.ClassListContains("delta-up"), tip.Contains(", up "), id + ": " + tip);+ Assert.AreEqual(delta.ClassListContains("delta-down"), tip.Contains(", down "), id + ": " + tip);+ }+ }++ /// <summary>#398 review S3: the spoken captions are strings (so a Hebrew UI says Hebrew captions), and the English ones+ /// are the captions the bar shows, so the two cannot drift apart.</summary>+ [Test]+ public void TheSpokenCaptionsAreTheBarsCaptions()+ {+ using var ui = new UiTestKit();+ foreach (var id in MeterIds)+ Assert.AreEqual(ui.Q<VisualElement>("meter-" + id).Q<Label>(className: "meter-name").text, Text["hud.caption." + id], id);+ }++ /// <summary>#398: a negative net position, a people count and a Hebrew UI, each through the real path (the+ /// presenter with the UI's own strings). Hebrew uses neutral words for a rise and a fall: on Immigration "עלייה"+ /// and "ירידה" would read as aliyah and emigration (review S2).</summary>+ [Test]+ public void TheSpokenTextCoversNegativeMoneyCountsAndHebrew()+ {+ var bridge = NewBridge();+ PlayUntilImmigrationChanges(bridge);+ var m = HudModel.From(bridge, Text);+ Assert.AreEqual(m.Immigration.Value, m.Immigration.SayValue, "a count is said as shown");+ Assert.AreEqual(m.Immigration.Delta.Substring(1), m.Immigration.SayChange, "a count's change is said without its sign");+ var prev = bridge.Session.Previous!; var now = bridge.State;+ now.Debt = now.Treasury + 3; // net -3.0+ prev.Debt = prev.Treasury - 1; // net +1.0 before: down by 4+ m = HudModel.From(bridge, Text);+ Assert.AreEqual("Treasury: -IL 3.0 million, down IL 4.0 million since last turn", HudModel.Spoken(Text, "Treasury", m.Treasury));+ using var ui = new UiTestKit();+ var he = He;+ new HudPresenter(ui.Root, bridge, he);+ var said = ui.Q<VisualElement>("meter-treasury").tooltip;+ Assert.AreEqual("אוצר: -IL 3.0 מיליון, קיטון של IL 4.0 מיליון מאז התור הקודם", said);+ foreach (var id in MeterIds)+ {+ var tip = ui.Q<VisualElement>("meter-" + id).tooltip;+ StringAssert.StartsWith(he["hud.caption." + id] + ": ", tip, id);+ Assert.IsFalse(System.Text.RegularExpressions.Regex.IsMatch(tip, "[A-Za-z]{3,}"), $"{id}: English words in the Hebrew text: {tip}");+ Assert.IsFalse(tip.Contains("עלייה של") || tip.Contains("ירידה של"), $"{id}: {tip}");+ }+ }++ /// <summary>#398 review S1: a resumed game shows the changes the player saw before the reload, on all six meters.+ /// GameSession.Load replays the save's own commands and checks the hash, so the replay's last two steps are the+ /// player's; Immigration needs the step before the last, which the session now keeps. Both ways a save arrives: at+ /// start (a new bridge) and through Replace.</summary>+ [Test]+ public void AResumedGameShowsTheChangesOfTheSessionThatSavedIt()+ {+ var played = NewBridge();+ PlayUntilImmigrationChanges(played);+ using var saved = new UiTestKit();+ new HudPresenter(saved.Root, played, Text);+ var saveText = played.Session.Save.Write();+ foreach (var how in new[] { "start", "replace" })+ {+ using var ui = new UiTestKit();+ var loaded = GameSession.Load(C, saveText, out var warnings);+ Assert.IsEmpty(warnings, how);+ SimBridge bridge;+ if (how == "start") bridge = new SimBridge(loaded, Text);+ else { bridge = NewBridge(); bridge.EndTurn(); bridge.EndTurn(); bridge.Replace(loaded); }+ new HudPresenter(ui.Root, bridge, Text);+ Assert.AreEqual(played.State.Turn, bridge.State.Turn, how);+ foreach (var id in MeterIds)+ {+ var before = saved.Q<Label>(id + "-delta"); var after = ui.Q<Label>(id + "-delta");+ Assert.AreEqual(before.text, after.text, $"{how}: {id}");+ Assert.AreEqual(before.ClassListContains("delta-up"), after.ClassListContains("delta-up"), $"{how}: {id}");+ Assert.AreEqual(before.ClassListContains("delta-down"), after.ClassListContains("delta-down"), $"{how}: {id}");+ Assert.AreEqual(saved.Q<VisualElement>("meter-" + id).tooltip, ui.Q<VisualElement>("meter-" + id).tooltip, $"{how}: {id}");+ }+ Assert.AreNotEqual("", ui.Q<Label>("immigration-delta").text, how + ": Immigration's change survives the reload");+ }+ }}diff --git a/unity/Assets/Tests/EditMode/PromoHudTests.cs b/unity/Assets/Tests/EditMode/PromoHudTests.csindex bd38a6c1f..e34d7e6ce 100644--- a/unity/Assets/Tests/EditMode/PromoHudTests.cs+++ b/unity/Assets/Tests/EditMode/PromoHudTests.cs@@ -136,14 +136,16 @@ public class PromoHudTests[UnityTest]public IEnumerator EveryWindowShapeFitsTheBarAfterATurn(){- // (window, icons, stacked changes, two rows): 16:9 fullscreen; a 16:9 window; a 16:10 MacBook browser (~1911- // logical); 16:10 fullscreen (~1821) keeps the icons on the stacked bar; 4:3 and 5:4 drop them; square and narrower wrap.- foreach (var (w, h, icons, narrow, twoRow) in new[] { (1920, 1080, true, false, false), (1280, 720, true, false, false),- (1366, 768, true, false, false), (1760, 1000, true, false, false),- (1920, 1200, true, true, false), (1440, 900, true, true, false),- (1024, 768, false, true, false), (1280, 1024, false, true, false),- (1024, 1024, false, true, true), (960, 1080, false, true, true),- (800, 1000, false, true, true) })+ // (window, icons, stacked changes, two rows, three rows): 16:9 fullscreen; a 16:9 window; a 16:10 MacBook browser+ // (~1911 logical); 21:9 ultrawide (~2217); 16:10 fullscreen (~1821) keeps the icons on the stacked bar; 4:3 and 5:4+ // drop them; square and narrower wrap; a phone upright (390x844, ~790) takes three rows (#398).+ foreach (var (w, h, icons, narrow, twoRow, threeRow) in new[] { (1920, 1080, true, false, false, false), (1280, 720, true, false, false, false),+ (1366, 768, true, false, false, false), (1760, 1000, true, false, false, false),+ (2560, 1080, true, false, false, false),+ (1920, 1200, true, true, false, false), (1440, 900, true, true, false, false),+ (1024, 768, false, true, false, false), (1280, 1024, false, true, false, false),+ (1024, 1024, false, true, true, false), (960, 1080, false, true, true, false),+ (800, 1000, false, true, true, false), (390, 844, false, true, true, true) }){var rt = new RenderTexture(w, h, 0);var ps = Object.Instantiate(AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel));@@ -165,17 +167,18 @@ public class PromoHudTestshud = new HudPresenter(root, bridge, Text);bridge.EndTurn(); // real changes on every meter that movedfor (int i = 0; i < 6; i++) yield return null;- if (w == 1920 && h == 1080)+ if ((w, h) == (1920, 1080) || (w, h) == (2560, 1080)){- // Review P1: with typical (turn-1) values at 16:9 the bar has room for the promo's sizes.- Assert.IsTrue(root.Q("top-bar").ClassListContains(HudPresenter.RoomyClass), "1920x1080: roomy with typical values");+ // Review P1: with typical (turn-1) values at 16:9, and at 21:9 (#398), the bar has room for the promo's sizes.+ var at = $"{w}x{h}";+ Assert.IsTrue(root.Q("top-bar").ClassListContains(HudPresenter.RoomyClass), at + ": roomy with typical values");foreach (var icon in root.Q("meters").Query<UiIcon>().ToList())- Assert.GreaterOrEqual(icon.worldBound.width, 36f, $"1920x1080: the {icon.Glyph} icon is promo-sized");+ Assert.GreaterOrEqual(icon.worldBound.width, 36f, $"{at}: the {icon.Glyph} icon is promo-sized");foreach (var v in root.Q("meters").Query<Label>(className: "meter-value").ToList())- Assert.GreaterOrEqual(v.resolvedStyle.fontSize, 24f, $"1920x1080: '{v.text}' is promo-sized");+ Assert.GreaterOrEqual(v.resolvedStyle.fontSize, 24f, $"{at}: '{v.text}' is promo-sized");// Integration bug B8: on the roomy bar every caption keeps one line, as in the promo.foreach (var c in root.Q("meters").Query<Label>(className: "meter-name").ToList().Where(c => c.name != "security-level"))- Assert.Less(c.worldBound.height, c.resolvedStyle.fontSize * 2f, $"1920x1080: '{c.text}' wraps");+ Assert.Less(c.worldBound.height, c.resolvedStyle.fontSize * 2f, $"{at}: '{c.text}' wraps");}// The widest realistic changes, formatted as HudModel formats them, and the widest date line.foreach (var (name, delta) in new[] { ("treasury", PlayerText.MoneyChange(C, "treasury", -12.4)), ("immigration", Text.Format("hud.delta_people", 12345.0)),@@ -194,6 +197,7 @@ public class PromoHudTestsAssert.AreEqual(!icons, bar.ClassListContains(HudPresenter.CompactClass), where + ": compact (no icons)");Assert.AreEqual(narrow, root.Q("root").ClassListContains(HudPresenter.NarrowClass), where + ": narrow");Assert.AreEqual(twoRow, root.Q("root").ClassListContains(HudPresenter.TwoRowClass), where + ": two rows");+ Assert.AreEqual(threeRow, root.Q("root").ClassListContains(HudPresenter.ThreeRowClass), where + ": three rows");foreach (var icon in root.Q("meters").Query<UiIcon>().ToList())Assert.AreEqual(icons ? DisplayStyle.Flex : DisplayStyle.None, icon.resolvedStyle.display, $"{where}: {icon.Glyph}");var badge = root.Q(className: "date-box");diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlindex 43e8f9abc..17e0b7cee 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -9,6 +9,22 @@ hud.attention: "Attention {0:0.0} of {1:0.0}"hud.people: "{0:N0}"hud.level: "Level {0} of 5"hud.delta_people: "{0:+#,##0;-#,##0}"+# A top-bar meter in words, kept as its tooltip for a later accessibility layer (HudModel.Spoken): {0} the caption, {1}+# the value, {2} the change without its sign. Money: {0} the sign and the currency prefix from content ("IL ", "-IL ",+# "$"), {1} the amount, already rounded ("18.6"). Points: a change of a 0-100 meter, shown as "+2%".+hud.say: "{0}: {1}"+hud.say_up: "{0}: {1}, up {2} since last turn"+hud.say_down: "{0}: {1}, down {2} since last turn"+hud.say_million: "{0}{1} million"+hud.say_point: "{0:0} point"+hud.say_points: "{0:0} points"+# The top-bar captions, as Game.uxml shows them (HudTests.TheSpokenCaptionsAreTheBarsCaptions), for the words above.+hud.caption.treasury: "Treasury"+hud.caption.immigration: "Immigration"+hud.caption.security: "Security"+hud.caption.support: "Public Support"+hud.caption.standing: "International Standing"+hud.caption.fx: "Foreign Currency"toast.refused: "Not done: {0}"event.office: "{0}: {1}"event.more: "{0} more decision(s) waiting"diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yamlindex dd69b796e..ba4398597 100644--- a/unity/Assets/UI/strings.he.yaml+++ b/unity/Assets/UI/strings.he.yaml@@ -8,6 +8,18 @@ hud.attention: "תשומת לב {0:0.0} מתוך {1:0.0}"hud.people: "{0:N0}"hud.level: "דרגה {0} מתוך 5"hud.delta_people: "{0:+#,##0;-#,##0}"+hud.say: "{0}: {1}"+hud.say_up: "{0}: {1}, גידול של {2} מאז התור הקודם"+hud.say_down: "{0}: {1}, קיטון של {2} מאז התור הקודם"+hud.say_million: "{0}{1} מיליון"+hud.say_point: "{0:0} נקודה"+hud.say_points: "{0:0} נקודות"+hud.caption.treasury: "אוצר"+hud.caption.immigration: "עלייה"+hud.caption.security: "ביטחון"+hud.caption.support: "תמיכה ציבורית"+hud.caption.standing: "מעמד בינלאומי"+hud.caption.fx: "מטבע חוץ"toast.refused: "לא בוצע: {0}"event.office: "{0}: {1}"event.more: "החלטות ממתינות נוספות: {0}"