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.

UI: the Cabinet's party chips grouped under Coalition and Opposition (a11y M5, refs #41) (#719)

Berib6f09f386b62
diff --git a/CHANGELOG.md b/CHANGELOG.md
index fbbc318c8..a55b9cb19 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -753,6 +753,11 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
- Keyboard focus that lands on something scrolled out of view, such as a Cabinet card below the first row or a
candidate far down the list, now scrolls its list to it (accessibility audit H1, refs #41). Focus that follows a mouse
press leaves the list where it is. Presentation only: no golden moves.
+- The Cabinet's party chips say which side each party is on, not only by the swatch's blue or grey: they sit in two
+ groups headed "Coalition" and "Opposition", קואליציה and אופוזיציה in Hebrew (accessibility audit M5, refs #41). The
+ Hebrew waits for the native reviewer (#564). The chips also follow a coalition change in the middle of a government
+ (`coalition_changes`, such as 25 May 1953), where before they kept their old colours. Presentation only: no golden
+ moves.
- Wheel zoom in the web build: one small wheel delta, such as a touchpad's half pixel, made every later frame zoom 27%,
since Unity's player takes the smallest delta it has seen as one notch. The camera now counts the browser's wheel
events itself (`WheelInput.jslib`): a touchpad's small pixel deltas zoom by how far the fingers move (100 px to a
diff --git a/unity/Assets/Scripts/UI/CabinetPresenter.cs b/unity/Assets/Scripts/UI/CabinetPresenter.cs
index dd7ac05a4..b3761f17e 100644
--- a/unity/Assets/Scripts/UI/CabinetPresenter.cs
+++ b/unity/Assets/Scripts/UI/CabinetPresenter.cs
@@ -285,11 +285,26 @@ namespace Statecraft.Game.UI
screen.Q<Label>("cabinet-majority").text = text.Format("cabinet.majority", hemicycle.Majority, unit);
var largest = blocks.OrderByDescending(b => b.Seats).FirstOrDefault();
screen.Q<Label>("cabinet-largest").text = largest.Seats > 0 ? text.Format("cabinet.largest", c.Parties.First(p => p.Id == largest.Party).Name, largest.Seats, unit) : "";
- var key = leg.Id + "/" + (gov?.Id ?? "");
+ // The coalition's parties, not the government's id: a government's coalition_changes move parties between the
+ // sides mid-term (governments.yaml, 25 May 1953), and the chips must follow the half circle (#41 M5).
+ var key = leg.Id + "/" + string.Join(",", blocks.Where(b => b.Coalition).Select(b => b.Party));
if (key == chipsFor) return;
chipsFor = key;
chips.Clear();
- foreach (var b in blocks) chips.Add(Chip("party-" + b.Party, b.Colour, text.Format("cabinet.party_seats", c.Parties.First(p => p.Id == b.Party).Name, b.Seats), false));
+ // Two groups, each opened by its side's name: the swatch's blue or grey alone (1.72:1 apart) does not say which
+ // side a party is on (#41 M5, WCAG 1.4.1). Two words in all, not one per chip, so the legend barely grows.
+ foreach (var coalition in new[] { true, false })
+ {
+ if (!blocks.Any(b => b.Coalition == coalition)) continue;
+ var group = new VisualElement { pickingMode = PickingMode.Ignore };
+ group.AddToClassList("party-group");
+ var heading = new Label(text[coalition ? "cabinet.coalition_group" : "cabinet.opposition_group"]) { pickingMode = PickingMode.Ignore };
+ heading.AddToClassList("party-group-heading");
+ group.Add(heading);
+ foreach (var b in blocks.Where(b => b.Coalition == coalition))
+ group.Add(Chip("party-" + b.Party, b.Colour, text.Format("cabinet.party_seats", c.Parties.First(p => p.Id == b.Party).Name, b.Seats), false));
+ chips.Add(group);
+ }
var unrecorded = leg.Size - blocks.Sum(b => b.Seats);
if (unrecorded > 0) chips.Add(Chip("party-unrecorded", Color.clear, text.Format("cabinet.party_seats", text["cabinet.unrecorded"], unrecorded), true));
}
diff --git a/unity/Assets/Tests/EditMode/PromoScreensTests.cs b/unity/Assets/Tests/EditMode/PromoScreensTests.cs
index fd6e43ab7..d5271d47b 100644
--- a/unity/Assets/Tests/EditMode/PromoScreensTests.cs
+++ b/unity/Assets/Tests/EditMode/PromoScreensTests.cs
@@ -85,6 +85,75 @@ public class PromoScreensTests
}
}
+ /// <summary>#41 M5 (WCAG 1.4.1): whether a party is in the coalition is readable without the swatch's colour. Each
+ /// party's chip sits in a group whose first child is a heading naming its side, "Coalition" or "Opposition" (Hebrew
+ /// קואליציה, אופוזיציה), the side the half circle seats it on; in each legislature, English and Hebrew.</summary>
+ [Test]
+ public void EachPartyChipSaysWhetherThePartyIsInTheCoalition()
+ {
+ var he = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");
+ foreach (var (text, coalition, opposition) in new[] { (Text, "Coalition", "Opposition"), (he, "קואליציה", "אופוזיציה") })
+ foreach (var date in OneDatePerLegislature())
+ {
+ var g = At(date);
+ using var ui = new UiTestKit();
+ var cabinet = new CabinetPresenter(ui.Root, new SimBridge(g, text), text, null);
+ var leg = Offices.Legislature(C, g.State.Date)!;
+ var blocks = CabinetPresenter.Blocks(C, leg, Offices.Government(C, g.State.Date), g.State.Date);
+ Assert.IsTrue(blocks.Any(b => b.Coalition) && blocks.Any(b => !b.Coalition), $"{date:yyyy-MM-dd}: precondition, both sides seated");
+ foreach (var b in blocks)
+ {
+ var where = $"{text["ui.lang"]} {g.State.Date:yyyy-MM-dd} {b.Party}";
+ var group = ui.Q<VisualElement>("party-" + b.Party).parent;
+ Assert.IsTrue(group.ClassListContains("party-group"), where + ": the chip sits in a labelled group");
+ var heading = group.Children().First() as Label;
+ Assert.IsNotNull(heading, where + ": the group opens with its heading");
+ Assert.AreEqual(b.Coalition ? coalition : opposition, heading!.text, where);
+ }
+ cabinet.Dispose();
+ }
+ }
+
+ /// <summary>#41 M5: the groups follow a coalition change inside one government and one legislature (governments.yaml
+ /// coalition_changes, 25 May 1953: the General Zionists, the Sephardim and the Yemenite Association leave) on the same
+ /// screen, as the half circle does. The date is set directly: play stops in January 1952, the content goes on. Seats the
+ /// content does not record are on neither side, and a side without a party gets no heading. No legislature in the
+ /// content has either today, so the second half takes the start's opposition seats away from a copy of the content.</summary>
+ [Test]
+ public void ThePartyGroupsFollowACoalitionChangeAndLeaveUnrecordedSeatsOut()
+ {
+ var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);
+ var change = new DateTime(1953, 5, 25);
+ g.State.Date = change.AddDays(-1);
+ using (var ui = new UiTestKit())
+ {
+ var cabinet = new CabinetPresenter(ui.Root, new SimBridge(g, Text), Text, null);
+ string Side(string party) => ((Label)ui.Q<VisualElement>("party-" + party).parent.Children().First()).text;
+ var leaving = new[] { "general_zionists", "sephardim", "yemenite_association" };
+ foreach (var p in leaving) Assert.AreEqual("Coalition", Side(p), "24 May 1953: " + p);
+ g.State.Date = change;
+ cabinet.Render();
+ foreach (var p in leaving) Assert.AreEqual("Opposition", Side(p), "25 May 1953, the same screen: " + p);
+ Assert.AreEqual("Coalition", Side("mapai"), "25 May 1953: mapai");
+ cabinet.Dispose();
+ }
+
+ var c = ContentLoader.Load(Paths.Content); // a copy: the shared content stays as it is
+ var start = GameSession.New(c, GoldenRun.Seed, Mode.Historical);
+ var leg = Offices.Legislature(c, start.State.Date)!;
+ var coalition = Offices.Government(c, start.State.Date)!.CoalitionOn(start.State.Date);
+ foreach (var party in leg.Seats.Keys.Where(k => !coalition.Contains(k)).ToList()) leg.Seats[party] = 0;
+ using (var ui = new UiTestKit())
+ {
+ var cabinet = new CabinetPresenter(ui.Root, new SimBridge(start, Text), Text, null);
+ var parties = ui.Q<VisualElement>("cabinet-parties");
+ Assert.AreSame(parties, ui.Q<VisualElement>("party-unrecorded").parent, "the seats not recorded are on neither side");
+ CollectionAssert.AreEqual(new[] { "Coalition" }, parties.Query<Label>(className: "party-group-heading").ToList().Select(l => l.text),
+ "no heading over an opposition without a party");
+ cabinet.Dispose();
+ }
+ }
+
/// <summary>Review I1: the majority line runs, row by row, between the last seat of a majority and the next, clear of
/// every dot, on the 37-seat Provisional State Council (promo 04) and the 120-seat Knesset; the layout keeps dots apart.</summary>
[Test]
diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.uss
index a5959ad7a..d51b76d61 100644
--- a/unity/Assets/UI/Statecraft.uss
+++ b/unity/Assets/UI/Statecraft.uss
@@ -452,7 +452,13 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
.house-coalition { font-size: 20px; color: var(--ink); white-space: normal; }
.house-stability { flex-grow: 0; height: 8px; margin: 3px 0 6px 0; max-width: 360px; }
.house-legend > Label { padding-top: 0; padding-bottom: 0; }
-.party-chips { flex-direction: row; flex-wrap: wrap; margin-top: 6px; }
+/* The chips in two groups, coalition then opposition, each a wrapping row opened by its side's name (#41 M5). */
+.party-chips { flex-direction: column; margin-top: 6px; }
+.party-group { flex-direction: row; flex-wrap: wrap; align-items: center; }
+.party-group-heading {
+ -unity-font-definition: url("project://database/Assets/UI/Fonts/EBGaramond-SemiBold.ttf");
+ font-size: 14px; color: var(--ink); padding: 0; margin: 0 10px 2px 0;
+}
.party-chip { flex-direction: row; align-items: center; margin: 0 12px 2px 0; }
.party-chip > Label { font-size: 14px; color: var(--ink-dim); padding: 0; margin: 0; }
.party-swatch { width: 11px; height: 11px; border-radius: 6px; margin-right: 5px; }
@@ -622,7 +628,7 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
in it. Each rule above that names EB Garamond is listed here; HebrewUiTests fails for one that is missed, including the
classes only presenters add (it gives a label each). */
.lang-he, .lang-he .title, .lang-he .button, .lang-he Button, .lang-he .year, .lang-he .end-turn, .lang-he .draft,
-.lang-he .why-group, .lang-he .section-title, .lang-he .card-initials, .lang-he .card-name, .lang-he .house-size,
+.lang-he .why-group, .lang-he .party-group-heading, .lang-he .section-title, .lang-he .card-initials, .lang-he .card-name, .lang-he .house-size,
.lang-he .big-figure, .lang-he .map-label, .lang-he .map-label-tooltip, .lang-he .start-title, .lang-he .start-button {
-unity-font-definition: url("project://database/Assets/UI/Fonts/FrankRuhlLibre/FrankRuhlLibre-Medium.ttf");
-unity-text-generator: advanced;
@@ -640,7 +646,7 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
.lang-he .card-stat-value { -unity-text-align: middle-left; }
.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 .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-chips, .lang-he .party-chip, .lang-he .defence-row, .lang-he .leaders, .lang-he .rung,
+.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 { flex-direction: row-reverse; }
.lang-he.hud-narrow .meter-row { flex-direction: column; align-items: flex-end; }
.lang-he .turn-box { align-items: flex-start; }
@@ -662,6 +668,7 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
.lang-he .pm-office { margin: 0 0 4px 6px; }
.lang-he .hemicycle-box { margin-right: 0; margin-left: 18px; }
.lang-he .party-chip { margin: 0 0 2px 12px; }
+.lang-he .party-group-heading { margin: 0 0 2px 10px; }
.lang-he .party-swatch { margin-right: 0; margin-left: 5px; }
.lang-he .rung { border-left-width: 0; border-right-width: 3px; }
.lang-he .rung-target { border-left-width: 1px; border-right-width: 3px; }
diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yaml
index dac5774e6..7ea559743 100644
--- a/unity/Assets/UI/strings.en.yaml
+++ b/unity/Assets/UI/strings.en.yaml
@@ -139,6 +139,10 @@ cabinet.opposition: "Opposition: {0} {1}"
cabinet.majority: "Majority: {0} {1}"
cabinet.largest: "Largest party: {0}, {1} {2}"
cabinet.party_seats: "{0} {1}"
+# The headings of the two groups of party chips under the half circle (CabinetPresenter.RenderHouse), so a chip's
+# side is read, not only seen in its swatch's colour (#41 M5).
+cabinet.coalition_group: "Coalition"
+cabinet.opposition_group: "Opposition"
cabinet.unrecorded: "Not recorded"
cabinet.members_unit: "members"
# The unit of a seat count above ({3}, {1} or {2}), by the body (CabinetPresenter.SeatUnit): an elected body's
diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yaml
index 2db31f39a..4477b5ae2 100644
--- a/unity/Assets/UI/strings.he.yaml
+++ b/unity/Assets/UI/strings.he.yaml
@@ -142,6 +142,11 @@ cabinet.opposition: "אופוזיציה: {0} {1}"
cabinet.majority: "רוב: {0} {1}"
cabinet.largest: "המפלגה הגדולה: {0}, {1} {2}"
cabinet.party_seats: "{0} {1}"
+# The headings of the two groups of party chips under the half circle (CabinetPresenter.RenderHouse), so a chip's
+# side is read, not only seen in its swatch's colour (#41 M5). The same nouns as cabinet.coalition and
+# cabinet.opposition, with no adjective to agree. For the native reviewer (#564).
+cabinet.coalition_group: "קואליציה"
+cabinet.opposition_group: "אופוזיציה"
cabinet.unrecorded: "לא תועד"
cabinet.members_unit: "חברים"
cabinet.seats: "מנדטים"