A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
UI: the selected Cabinet seat carries a "Selected" tag, not only a colour change (a11y M6, refs #41) (#773)
Beri823ab3a251e0
diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 4cadc9bba..802eee796 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -759,6 +759,10 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIBCabinet's "Ordered:" line wraps, and on short windows the Prime Minister's portrait gives way, framed again for its newheight, so the candidate list keeps two rows; at 32:9 the list's floor follows the room left (M7). Presentation only:no golden moves.+- The selected Cabinet seat carries a "Selected" tag across the foot of its card's plate (Hebrew "מסומן"), so it stands+ out without its colour, also once keyboard focus moves to another card; the fill and rim alone differed by 1.2:1 and+ 2.4:1 (accessibility audit M6, refs #41). The tag sits over the plate, so no card moves. An office the Prime Minister+ holds himself, a button under his card, doubles its rim when selected instead. Presentation only: no golden moves.- Keyboard focus that lands on something scrolled out of view, such as a Cabinet card below the first row or acandidate far down the list, now scrolls its list to it (accessibility audit H1, refs #41). Focus that follows a mousepress leaves the list where it is. Presentation only: no golden moves.diff --git a/unity/Assets/Scripts/UI/PersonCard.cs b/unity/Assets/Scripts/UI/PersonCard.csindex f54c587e8..5928f555c 100644--- a/unity/Assets/Scripts/UI/PersonCard.cs+++ b/unity/Assets/Scripts/UI/PersonCard.cs@@ -36,6 +36,11 @@ namespace Statecraft.Game.UIvar plate = Element(prefix + "-plate", "card-plate");plate.Add(Element(prefix + "-portrait", PortraitClass));plate.Add(Text(prefix + "-initials", InitialsClass));+ // The selected seat's word, shown only under .seat-selected (Statecraft.uss): a mark that is not a colour+ // change, since the selected fill and rim differ from the rest by 1.2:1 and 2.4:1 (#41 M6).+ var selected = Text(prefix + "-selected", "card-selected");+ selected.text = text["card.selected"];+ plate.Add(selected);card.Add(plate);card.Add(Text(prefix + "-holder", NameClass));card.Add(Text(prefix + "-office", OfficeClass));diff --git a/unity/Assets/Tests/EditMode/PromoScreensTests.cs b/unity/Assets/Tests/EditMode/PromoScreensTests.csindex d5271d47b..75853d7b8 100644--- a/unity/Assets/Tests/EditMode/PromoScreensTests.cs+++ b/unity/Assets/Tests/EditMode/PromoScreensTests.cs@@ -505,6 +505,102 @@ public class PromoScreensTestsfinally { cabinet.Dispose(); blur.Dispose(); }}+ /// <summary>#41 M6 (WCAG 1.4.11): the selected Cabinet seat carries a mark that is not a colour change, a tag on its+ /// plate reading "Selected" (Hebrew מסומן) at 4.5:1, which stays when keyboard focus moves to another card; the other+ /// cards show none, and selecting moves nothing on the card. For a grid card and the Prime Minister's, English and+ /// Hebrew.</summary>+ [UnityTest]+ public IEnumerator TheSelectedSeatIsTaggedWithoutMovingItsCard()+ {+ var he = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");+ foreach (var (text, hebrew) in new[] { (Text, false), (he, true) })+ {+ using var ui = new UiTestKit();+ var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);+ var cabinet = new CabinetPresenter(ui.Root, new SimBridge(g, text), text, null);+ ui.Q<VisualElement>("root").RemoveFromClassList("loading");+ ui.Q<VisualElement>("root").EnableInClassList(UiLanguage.HebrewClass, hebrew);+ new ScreenNav(ui.Root).Open("cabinet");+ try+ {+ for (int i = 0; i < 4; i++) yield return null;+ foreach (var (office, other) in new[] { ("finance_minister", "seat-foreign_minister"), ("prime_minister", "seat-finance_minister") })+ {+ var where = $"{text["ui.lang"]} {office}";+ var card = ui.Q<Button>("seat-" + office);+ // Another seat first, so the candidate list is open in both states: it opening squeezes the Prime+ // Minister's portrait (M7), which is not what this measures.+ cabinet.Select(other.Substring("seat-".Length));+ for (int i = 0; i < 4; i++) yield return null;+ var rects = card.Children().Select(e => e.layout).Prepend(card.layout).ToList();+ cabinet.Select(office);+ for (int i = 0; i < 4; i++) yield return null;+ Assert.IsTrue(card.ClassListContains("seat-selected"), where + ": precondition, selected");+ Label? Tag(VisualElement c) => c.Query<Label>(className: "card-selected").ToList()+ .FirstOrDefault(l => l.resolvedStyle.display == DisplayStyle.Flex && l.worldBound.width > 0);+ var tag = Tag(card);+ Assert.IsNotNull(tag, where + ": the selected card carries a visible tag");+ Assert.AreEqual(text["card.selected"], tag!.text, where);+ Assert.IsTrue(card.worldBound.Contains(tag.worldBound.min) && card.worldBound.Contains(tag.worldBound.max - Vector2.one), where + ": the tag is on the card");+ Assert.GreaterOrEqual(Contrast(tag.resolvedStyle.color, tag.resolvedStyle.backgroundColor, Deep), 4.5f, where + ": the tag's text");+ foreach (var c in ui.Root.Query<Button>(className: "seat").ToList().Append(ui.Q<Button>("seat-" + CabinetPresenter.PrimeMinister)).Where(c => c != card))+ Assert.IsNull(Tag(c), where + ": " + c.name + " is not tagged");+ var after = card.Children().Select(e => e.layout).Prepend(card.layout).ToList();+ for (int i = 0; i < rects.Count; i++)+ Assert.IsTrue(Vector2.Distance(rects[i].position, after[i].position) < 0.5f && Vector2.Distance(rects[i].size, after[i].size) < 0.5f,+ $"{where}: element {i} moved, {rects[i]} -> {after[i]}");++ var next = ui.Q<Button>(other);+ next.Focus();+ for (int i = 0; i < 10 && next.focusController.focusedElement != next; i++) yield return null;+ yield return null; yield return null;+ Assert.AreSame(next, next.focusController.focusedElement, where + ": precondition, focus moved on");+ Assert.IsNotNull(Tag(card), where + ": the tag stays once focus moves on");+ next.Blur();+ }+ }+ finally { cabinet.Dispose(); }+ }+ }++ /// <summary>#41 M6: an office the Prime Minister holds himself (Defense, at the start) is a plain button under his card,+ /// with no plate for the tag; selected, its rim doubles and the button keeps its size. On a 3840x2160 panel, so a+ /// logical pixel is wider than a screen pixel and 1 px and 2 px do not snap to the same width.</summary>+ [UnityTest]+ public IEnumerator ThePrimeMinistersSelectedOfficeDoublesItsRim()+ {+ var rt = new RenderTexture(3840, 2160, 0);+ var ps = Object.Instantiate(AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel));+ ps.targetTexture = rt;+ var go = new GameObject("PmOfficeTest");+ go.SetActive(false);+ var doc = go.AddComponent<UIDocument>();+ doc.panelSettings = ps;+ doc.visualTreeAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(UiPaths.GameUxml);+ go.SetActive(true);+ var root = doc.rootVisualElement;+ var cabinet = new CabinetPresenter(root, new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), Text), Text, null);+ var nav = new ScreenNav(root);+ try+ {+ root.Q("root").RemoveFromClassList("loading");+ nav.Open("cabinet");+ for (int i = 0; i < 4; i++) yield return null;+ var offices = root.Query<Button>(className: "pm-office").ToList();+ Assert.IsNotEmpty(offices, "precondition: the Prime Minister holds another office");+ var office = offices[0];+ Assert.IsFalse(office.ClassListContains("seat-selected"), "precondition: not selected");+ float thin = office.resolvedStyle.borderTopWidth; var size = office.worldBound.size;+ Assert.Greater(thin, 0f, "precondition: an office not selected has a rim");+ cabinet.Select(office.name.Substring("seat-".Length));+ for (int i = 0; i < 4; i++) yield return null;+ Assert.IsTrue(office.ClassListContains("seat-selected"), "precondition: the office is selected");+ Assert.AreEqual(2f * thin, office.resolvedStyle.borderTopWidth, 0.25f * thin, "the selected office's rim doubles");+ Assert.Less(Vector2.Distance(size, office.worldBound.size), 0.5f, $"the selected office keeps its size, {size} -> {office.worldBound.size}");+ }+ finally { nav.Dispose(); cabinet.Dispose(); Object.DestroyImmediate(go); Object.DestroyImmediate(ps); rt.Release(); Object.DestroyImmediate(rt); }+ }+/// <summary>Both screens at the window shapes the HUD supports (16:9 at 1920x1080 and 1366x768, 16:10, 4:3, 5:4, the/// wide-and-short browser, square and narrower): each opens under the top bar, clear of the minimap column and the/// minimap (over the info panel, which it is drawn above), and nothing on it leaves it or its panel sideways; everydiff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.ussindex d51b76d61..71c98e1cd 100644--- a/unity/Assets/UI/Statecraft.uss+++ b/unity/Assets/UI/Statecraft.uss@@ -409,6 +409,14 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);.card-stat-name { width: 82px; flex-shrink: 0; font-size: 14px; color: var(--ink-dim); -unity-text-align: middle-left; padding: 0; margin: 0; }.card-stat-value { width: 24px; flex-shrink: 0; font-size: 16px; color: var(--ink); -unity-text-align: middle-right; padding: 0; margin: 0; }.seat-selected { border-color: var(--gold-light); background-color: var(--navy-raised); }+/* The selected seat's tag (#41 M6): a gold band with a word across the foot of the plate, the mark that is not a colour.+ Absolute, so the card's layout does not move; not a thicker rim, which the border-box would take out of the content+ and which the audit's L3 proposes for focus. Not in the .seat:focus text list below: it keeps its colours under focus. */+.card-selected {+ display: none; position: absolute; left: 0; right: 0; bottom: 0; height: 22px; padding: 0; margin: 0;+ background-color: var(--gold-light); color: var(--navy-deep); font-size: 15px; -unity-text-align: middle-center;+}+.seat-selected .card-selected { display: flex; }.seat-vacant .card-name { color: var(--ink-dim); }.appointed { color: var(--gold); }/* A keyboard-focused card takes the warm focus fill (Button:focus); its dim and gold text turn light to stay legible on it. */@@ -439,6 +447,9 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);#cabinet-pick-title { white-space: normal; }.pm-offices { flex-direction: row; flex-wrap: wrap; margin: -2px 0 8px 0; flex-shrink: 0; }.pm-office { font-size: 15px; padding: 3px 10px; margin: 0 6px 4px 0; border-color: rgba(196, 160, 92, 0.6); }+/* A selected office the Prime Minister holds himself has no plate for the tag (#41 M6): its rim doubles instead, a mark+ that is not a colour. The padding gives the pixel back, so the button keeps its size. */+.pm-office.seat-selected { border-width: 2px; padding: 2px 9px; }.cabinet-house {flex-direction: row; flex-wrap: wrap; align-items: center; flex-shrink: 0; margin: 0 5px 8px 5px; padding: 10px 14px;background-color: rgba(5, 9, 18, 0.55); border-width: 1px; border-color: var(--gold-dim); border-radius: 2px;diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlindex 7ea559743..3b2c77609 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -157,6 +157,8 @@ card.loyalty: "Loyalty"card.party: "Party: {0}"card.appointed_name: "{0} (your appointee)"card.offices_separator: " · "+# The tag on the selected Cabinet seat's card (PersonCard; #41 M6).+card.selected: "Selected"# Defence (promo 08): the Ministry of Defense's share of budget spending (the Budget screen's line).defence.budget_share: "{0} of budget spending"defence.budget_none: "No defence line in the budget"diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yamlindex 4477b5ae2..2f572145e 100644--- a/unity/Assets/UI/strings.he.yaml+++ b/unity/Assets/UI/strings.he.yaml@@ -157,6 +157,9 @@ card.loyalty: "נאמנות"card.party: "מפלגה: {0}"card.appointed_name: "{0} (מינוי שלך)"card.offices_separator: " · "+# The tag on the selected Cabinet seat's card (PersonCard; #41 M6). Not "נבחר": on a minister's card in a game about the+# Knesset it reads as "elected". "מסומן" agrees with the card (כרטיס), masculine. For the native reviewer (#564).+card.selected: "מסומן"info.hint: "יש ללחוץ על המפה כדי לבדוק משושה"info.off_map: "מחוץ למפה"info.hex: "{0} · גובה {1:N0} מ׳"