A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Hebrew decision-card guards, and the pointer path that locates the stuck backdrop (#1728) (#1735)
EllaSharakanskib56011baa501
diff --git a/changelog.d/1728-hebrew-scrim-guards.md b/changelog.d/1728-hebrew-scrim-guards.mdnew file mode 100644index 000000000..5ec343091--- /dev/null+++ b/changelog.d/1728-hebrew-scrim-guards.md@@ -0,0 +1,5 @@+### Changed++- Two EditMode guards for the Hebrew decision-card path (#1728): answering one card, and answering two in sequence,+ must leave the backdrop gone, `event-open` off the root, and the info panel's area pickable. The existing coverage+ only collapsed the card with Hide, and only in English. No player code changes.diff --git a/changelog.d/1728-navlog-root-classes.md b/changelog.d/1728-navlog-root-classes.mdnew file mode 100644index 000000000..521f2dff6--- /dev/null+++ b/changelog.d/1728-navlog-root-classes.md@@ -0,0 +1,6 @@+### Changed++- `?navlog` now prints the pressed element and every ancestor above it, each with its classes, on every UI pointer+ down (#1728). A press that lands on an element nobody expected is usually a full-screen layer in front of the+ panels, and the rules that show those layers are descendant selectors, so the class that displays one can sit on+ any ancestor rather than only the HUD root. Diagnostic only, behind the existing flag.diff --git a/unity/Assets/Scripts/UI/NavEventLog.cs b/unity/Assets/Scripts/UI/NavEventLog.csindex 96e5cbf4d..9c39649f0 100644--- a/unity/Assets/Scripts/UI/NavEventLog.cs+++ b/unity/Assets/Scripts/UI/NavEventLog.cs@@ -33,7 +33,30 @@ namespace Statecraft.Game.UIstatic string Name(IEventHandler? t) => t is VisualElement v ? (string.IsNullOrEmpty(v.name) ? v.GetType().Name : v.name) : "?";- void OnDown(PointerDownEvent e) => DiagLog.NavLine($"ui pointerdown id={e.pointerId} at ({e.position.x:0}, {e.position.y:0}) target={Name(e.target)}");+ /// <summary>The classes on one element, sorted so two lines can be compared by eye.</summary>+ static string Classes(VisualElement v)+ {+ var names = new List<string>(v.GetClasses());+ names.Sort(System.StringComparer.Ordinal);+ return names.Count == 0 ? "" : "." + string.Join(".", names);+ }++ /// <summary>The pressed element and every ancestor above it, each with its classes, innermost first. A press that+ /// lands somewhere nobody expected is usually a full-screen layer in front of the panels, and the rules that show+ /// those layers are descendant selectors (Statecraft.uss, ".event-open .event-scrim"), so the class that displays+ /// the backdrop may sit on any ancestor, not only the HUD root — the whole chain is what settles it. #1728: in+ /// Hebrew a press on the unit panel's Skip reaches `event-scrim` with nothing dimmed, which needs the backdrop to+ /// be both displayed and invisible; this says whether it was displayed, and from where.</summary>+ static string Path(IEventHandler? target)+ {+ if (target is not VisualElement v) return "?";+ var parts = new List<string>();+ for (var e = v; e != null && parts.Count < 12; e = e.parent)+ parts.Add((string.IsNullOrEmpty(e.name) ? e.GetType().Name : e.name) + Classes(e));+ return string.Join(" < ", parts);+ }++ void OnDown(PointerDownEvent e) => DiagLog.NavLine($"ui pointerdown id={e.pointerId} at ({e.position.x:0}, {e.position.y:0}) target={Name(e.target)} path={Path(e.target)}");void OnUp(PointerUpEvent e) => DiagLog.NavLine($"ui pointerup id={e.pointerId} at ({e.position.x:0}, {e.position.y:0}) target={Name(e.target)}");void OnClick(ClickEvent e) => DiagLog.NavLine($"ui click count={e.clickCount} target={Name(e.target)}");void OnButtonUp(PointerUpEvent e) => DiagLog.NavLine($"button pointerup at ({e.position.x:0}, {e.position.y:0}) on={Name(e.currentTarget)} inside={((VisualElement)e.currentTarget).worldBound.Contains(e.position)}");diff --git a/unity/Assets/Tests/EditMode/DecisionCardTests.cs b/unity/Assets/Tests/EditMode/DecisionCardTests.csindex bd02d4c59..b7467525c 100644--- a/unity/Assets/Tests/EditMode/DecisionCardTests.cs+++ b/unity/Assets/Tests/EditMode/DecisionCardTests.cs@@ -26,7 +26,7 @@ public class DecisionCardTestspublic readonly VisualElement Root; public readonly SimBridge Bridge; public readonly ScreenNav Nav; public readonly EventCardPresenter Card;readonly GameObject go; readonly PanelSettings ps; readonly RenderTexture rt; readonly List<System.IDisposable> owned = new List<System.IDisposable>();- public Rig(int w, int h, string eventId, bool photos = false, UiText? text = null)+ public Rig(int w, int h, string eventId, bool photos = false, UiText? text = null, string? second = null){var t = text ?? Text;rt = new RenderTexture(w, h, 0);@@ -41,7 +41,7 @@ public class DecisionCardTestsRoot = doc.rootVisualElement;Root.Q("root").RemoveFromClassList("loading");Root.Q("root").EnableInClassList(UiLanguage.HebrewClass, t["ui.lang"] == UiLanguage.Hebrew); // as GameRoot- Bridge = new SimBridge(Pending(eventId), t);+ Bridge = new SimBridge(Pending(eventId, second), t);owned.Add(new HudPresenter(Root, Bridge, t));Nav = new ScreenNav(Root); owned.Add(Nav);owned.Add(new InfoPanelPresenter(Root, Bridge, t, C.SettlementHexes.ToDictionary(x => x.Id, x => x.Id)));@@ -64,12 +64,14 @@ public class DecisionCardTestspublic bool Shows(string name) => Root.Q(name).resolvedStyle.display == DisplayStyle.Flex;}- /// <summary>A new game in the event's own time with only that event pending.</summary>- static GameSession Pending(string eventId)+ /// <summary>A new game in the event's own time with only that event pending, or with <paramref name="second"/>+ /// queued behind it (#1728: the repro answers two cards, and the state between them is the interesting one).</summary>+ static GameSession Pending(string eventId, string? second = null){var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);g.State.Date = C.Events.First(e => e.Id == eventId).From;g.State.PendingEvents.Clear(); g.State.PendingEvents.Add(eventId);+ if (second != null) g.State.PendingEvents.Add(second);return g;}@@ -112,6 +114,71 @@ public class DecisionCardTests$"header {photo.layout.width}x{photo.layout.height}, card {card.layout}, original {outer}");}+ /// <summary>#1728, red first: in Hebrew, once the pending event is answered the backdrop must stop taking pointer+ /// events over the info panel, where the unit panel's "Skip this turn" sits. The report says a click there reaches+ /// `event-scrim` and nothing happens, while the same step in English reaches `info-skip`.+ /// <para>The existing coverage next door takes the card away with Hide, which collapses it, and runs in English.+ /// This answers the card instead, which is what a player does, and in Hebrew. If the backdrop clears here, the+ /// fault is not in the answer path and the search moves to what the rig does not model.</para></summary>+ [UnityTest]+ public IEnumerator AnsweringInHebrewLeavesTheInfoPanelClickable()+ {+ var he = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");+ foreach (var (w, h) in new[] { (1920, 1080), (960, 1080) })+ {+ using var r = new Rig(w, h, "law_of_return", text: he);+ yield return Frames(4);+ var where = $"{w}x{h} he";+ Assert.IsTrue(r.Hud.ClassListContains(UiLanguage.HebrewClass), $"{where}: precondition, the UI is Hebrew");+ Assert.IsTrue(r.Shows("event-scrim"), $"{where}: precondition, the backdrop shows while the card is open");++ Press(r.FirstOption); // answer it, as a player does+ yield return Frames(4);++ Assert.IsFalse(r.Shows("event-card"), $"{where}: the answered card is gone");+ Assert.IsFalse(r.Shows("event-scrim"), $"{where}: and so is the backdrop");+ Assert.IsFalse(r.Hud.ClassListContains(EventCardPresenter.OpenClass), $"{where}: the root no longer says event-open");++ // The point a player aims at for Skip: the info panel's own area. Whatever takes it, it must not be the backdrop.+ var panel = r.Root.Q("info-panel").worldBound;+ var at = new Vector2(panel.center.x, panel.yMin + 8f);+ var hit = r.Root.panel.Pick(at);+ Assert.AreNotSame(r.Root.Q("event-scrim"), hit, $"{where}: the backdrop must not take the pointer at {at}; it was {hit?.name}");+ Assert.AreNotSame(r.Root.Q("event-scrim-top"), hit, $"{where}: nor its band under the bar; it was {hit?.name}");+ }+ }++ /// <summary>#1728, the repro's own sequence: two cards, answered one after the other, in Hebrew. The one-card test+ /// above showed the backdrop clears on an answer, so this is the next candidate — the state between the two answers,+ /// where `event-open` legitimately stays on for the second card. If the class survives the last answer, that is the+ /// bug; if it clears, the fault is outside the card path and the turn report is the remaining lead.</summary>+ [UnityTest]+ public IEnumerator AnsweringTwoCardsInHebrewLeavesTheInfoPanelClickable()+ {+ var he = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");+ using var r = new Rig(1920, 1080, "law_of_return", text: he, second: "first_truce");+ yield return Frames(4);+ Assert.IsTrue(r.Shows("event-scrim"), "precondition: the first card's backdrop shows");+ Assert.AreEqual(2, r.Bridge.State.PendingEvents.Count, "precondition: two cards are pending");++ Press(r.FirstOption); // the first answer: the second card should take its place+ yield return Frames(4);+ Assert.IsTrue(r.Shows("event-card"), "the second card is open");+ Assert.IsTrue(r.Shows("event-scrim"), "and its backdrop, correctly, still shows");++ Press(r.FirstOption); // the second answer: now nothing is pending+ yield return Frames(4);+ Assert.IsFalse(r.Shows("event-card"), "both answered: no card");+ Assert.IsFalse(r.Shows("event-scrim"), "both answered: no backdrop");+ Assert.IsFalse(r.Hud.ClassListContains(EventCardPresenter.OpenClass), "both answered: event-open is off the root");++ var panel = r.Root.Q("info-panel").worldBound;+ var at = new Vector2(panel.center.x, panel.yMin + 8f);+ var hit = r.Root.panel.Pick(at);+ Assert.AreNotSame(r.Root.Q("event-scrim"), hit, $"the backdrop must not take the pointer at {at}; it was {hit?.name}");+ Assert.AreNotSame(r.Root.Q("event-scrim-top"), hit, $"nor its band; it was {hit?.name}");+ }+/// <summary>#380: the taller two- and three-row bars raise the centred card (the event layer keeps room at its bottom), and/// the backdrop must still reach the window's bottom and right edges, so no strip of map stays live under an open card.</summary>[UnityTest]