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: re-review fixes for the promo HUD

eyalgolan36e9003cfffe
diff --git a/CHANGELOG.md b/CHANGELOG.md
index d00bb3152..5aabce97c 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -23,6 +23,18 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
again. Presentation only; `?nofallback` turns it off (#44).
### Changed
+- The interface is restyled to the promo art (`promo/final/03`, `04`, `05`, `08`):
+ - navy panels with gold trim, corner brackets and a soft shadow;
+ - an icon for each indicator in the top bar, with its value and its change since the last turn;
+ - a framed date badge;
+ - round icon buttons for the screens, with their names under them;
+ - signs on the event options;
+ - a terrain sign in the hex panel (still no tile yields);
+ - the Cabinet as a grid of portrait cards.
+
+ Narrower windows get a compact top bar, and windows narrower than about square get a taller one that puts each change
+ under its value. Keyboard focus has a fill at least 3:1 against the unfocused button, and a mouse click leaves no
+ focus behind. Presentation only.
- The historical AI no longer sends an order the turn's attention cannot cover (the rule the UI's order queue applies),
so the sim never has to refuse one; the golden playthroughs are unchanged.
- The browser build downloads a smaller heightmap: `heightmap.r16z` (4.1 MB, packed losslessly: row deltas in byte
diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.cs
index 897d797e9..9b1c3b2ad 100644
--- a/unity/Assets/Scripts/UI/GameRoot.cs
+++ b/unity/Assets/Scripts/UI/GameRoot.cs
@@ -131,7 +131,8 @@ namespace Statecraft.Game.UI
// The toast first: the autosave (below) must report a failed write after the toast has shown the turn's refusals.
var toast = Own(new ToastPresenter(root, bridge, text));
Own(new HudPresenter(root, bridge, text));
- Own(new ScreenNav(root)); // every screen starts hidden (USS); ScreenNav opens one at a time
+ Own(new ScreenNav(root));
+ Own(new PointerBlur(root)); // a mouse click leaves no focus fill behind (keyboard keeps it) // every screen starts hidden (USS); ScreenNav opens one at a time
if (DiagLog.Nav) Own(new NavEventLog(root)); // ?navlog: every UI pointer/submit event (playtest 2, P2-4)
var card = Own(new EventCardPresenter(root, bridge, text, portraits));
Own(new DefencePresenter(root, bridge, text));
diff --git a/unity/Assets/Scripts/UI/HudPresenter.cs b/unity/Assets/Scripts/UI/HudPresenter.cs
index 1a276c6e5..7f1032a9b 100644
--- a/unity/Assets/Scripts/UI/HudPresenter.cs
+++ b/unity/Assets/Scripts/UI/HudPresenter.cs
@@ -8,12 +8,19 @@ namespace Statecraft.Game.UI
{
readonly VisualElement root; readonly SimBridge bridge; readonly UiText text;
readonly Button endTurn; readonly System.Action onEndTurn;
- readonly VisualElement bar;
+ readonly VisualElement bar, hudRoot;
/// <summary>Below this top-bar width (logical px) the meters drop their icons (Statecraft.uss .top-bar--compact): six
- /// meters with icons, the date badge, the screen buttons and End Turn need about this much.</summary>
- public const float CompactBelowPx = 1800f;
+ /// meters with icons and their widest changes, the date badge, the screen buttons and End Turn need about this much: 16:9
+ /// (1920 logical) keeps the icons, 16:10 (about 1821) does not (PromoHudTests.EveryWindowShapeFitsTheBarAfterATurn).</summary>
+ public const float CompactBelowPx = 1900f;
public const string CompactClass = "top-bar--compact";
+ /// <summary>Below this width the HUD's root also gets NarrowClass: a taller bar whose meters stack the change under the
+ /// value, and the panels below it move down to match (Statecraft.uss .hud-narrow). Without the icons the bar still
+ /// cannot hold six values with their widest changes side by side below about 1900 px (PromoHudTests
+ /// .EveryWindowShapeFitsTheBarAfterATurn), so the two tiers share the threshold.</summary>
+ public const float NarrowBelowPx = CompactBelowPx;
+ public const string NarrowClass = "hud-narrow";
public HudPresenter(VisualElement root, SimBridge bridge, UiText text)
{
@@ -23,6 +30,7 @@ namespace Statecraft.Game.UI
endTurn.clicked += onEndTurn;
endTurn.generateVisualContent += PaintHourglass;
bar = root.Q<VisualElement>("top-bar");
+ hudRoot = root.Q<VisualElement>("root");
bar.RegisterCallback<GeometryChangedEvent>(OnBarGeometry);
SetCompact(bar.layout.width); // the bar may already be laid out (the loading screen shows it) and never resize
bridge.Changed += Render;
@@ -34,19 +42,25 @@ namespace Statecraft.Game.UI
{
bridge.Changed -= Render; endTurn.clicked -= onEndTurn; endTurn.generateVisualContent -= PaintHourglass;
bar.UnregisterCallback<GeometryChangedEvent>(OnBarGeometry);
+ bar.RemoveFromClassList(CompactClass); hudRoot.RemoveFromClassList(NarrowClass);
}
// The bar's width does not depend on the class, so this settles in one pass.
void OnBarGeometry(GeometryChangedEvent e) => SetCompact(e.newRect.width);
- void SetCompact(float width) { if (width > 0) bar.EnableInClassList(CompactClass, width < CompactBelowPx); } // NaN before layout: wait for it
+ void SetCompact(float width)
+ {
+ if (!(width > 0)) return; // NaN before layout: wait for it
+ bar.EnableInClassList(CompactClass, width < CompactBelowPx);
+ hudRoot.EnableInClassList(NarrowClass, width < NarrowBelowPx);
+ }
/// <summary>End Turn's hourglass, in the button's left padding (Statecraft.uss .end-turn), painted into the button so it
/// stays a leaf sized by its text (UiIcon.Paint).</summary>
static void PaintHourglass(MeshGenerationContext m)
{
if (!m.visualElement.enabledInHierarchy) return; // no bright sign on a disabled End Turn (game over)
- UiIcon.Paint(m, "hourglass", new UnityEngine.Rect(10f, (m.visualElement.layout.height - 22f) / 2f, 22f, 22f));
+ UiIcon.Paint(m, "hourglass", new UnityEngine.Rect(10f, (m.visualElement.layout.height - 22f) / 2f, 22f, 22f), UiIcon.IsFocused(m.visualElement));
}
void Set(string name, string value) => root.Q<Label>(name).text = value;
diff --git a/unity/Assets/Scripts/UI/PointerBlur.cs b/unity/Assets/Scripts/UI/PointerBlur.cs
new file mode 100644
index 000000000..51ca8a9b5
--- /dev/null
+++ b/unity/Assets/Scripts/UI/PointerBlur.cs
@@ -0,0 +1,20 @@
+#nullable enable
+using UnityEngine.UIElements;
+
+namespace Statecraft.Game.UI
+{
+ /// <summary>Keeps the focus look for the keyboard only. UI Toolkit focuses a Button on pointer-down and has no
+ /// :focus-visible, so after a mouse click the button would keep the focus fill (Statecraft.uss Button:focus) until
+ /// something else took focus. One ClickEvent callback at the UI root blurs the clicked Button: every Button, the ones
+ /// made at runtime (event options, Cabinet seats, Budget rows) included. Enter and Space raise NavigationSubmitEvent,
+ /// not ClickEvent, so keyboard focus stays.</summary>
+ public sealed class PointerBlur : System.IDisposable
+ {
+ readonly VisualElement root;
+ static readonly EventCallback<ClickEvent> OnClick = e => (e.target as VisualElement)?.GetFirstOfType<Button>()?.Blur();
+
+ public PointerBlur(VisualElement root) { this.root = root; root.RegisterCallback(OnClick); }
+
+ public void Dispose() => root.UnregisterCallback(OnClick);
+ }
+}
diff --git a/unity/Assets/Scripts/UI/PointerBlur.cs.meta b/unity/Assets/Scripts/UI/PointerBlur.cs.meta
new file mode 100644
index 000000000..b34e1bd9d
--- /dev/null
+++ b/unity/Assets/Scripts/UI/PointerBlur.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: b9f8ed5665ee646b5addd606f88d082c
\ No newline at end of file
diff --git a/unity/Assets/Scripts/UI/ScreenNav.cs b/unity/Assets/Scripts/UI/ScreenNav.cs
index aa966ff33..ff9531981 100644
--- a/unity/Assets/Scripts/UI/ScreenNav.cs
+++ b/unity/Assets/Scripts/UI/ScreenNav.cs
@@ -15,9 +15,6 @@ namespace Statecraft.Game.UI
public const string OpenClass = "nav-open";
readonly VisualElement root;
readonly List<(Button, System.Action)> hooks = new List<(Button, System.Action)>();
- // A pointer click leaves the button focused (UI Toolkit focuses on pointer-down and has no :focus-visible); blurring it
- // keeps the focus ring for the keyboard only, so a screen just closed with the mouse does not still look selected.
- static readonly EventCallback<ClickEvent> BlurOnClick = e => (e.currentTarget as VisualElement)?.Blur();
public ScreenNav(VisualElement root)
{
@@ -28,13 +25,12 @@ namespace Statecraft.Game.UI
var b = root.Q<Button>("nav-" + screen);
System.Action h = () => Toggle(screen);
b.clicked += h;
- b.RegisterCallback(BlurOnClick);
hooks.Add((b, h));
}
Open(null);
}
- public void Dispose() { foreach (var (b, h) in hooks) { b.clicked -= h; b.UnregisterCallback(BlurOnClick); } hooks.Clear(); }
+ public void Dispose() { foreach (var (b, h) in hooks) b.clicked -= h; hooks.Clear(); }
/// <summary>The open screen's name, or null.</summary>
public string? Current { get; private set; }
diff --git a/unity/Assets/Scripts/UI/UiIcon.cs b/unity/Assets/Scripts/UI/UiIcon.cs
index 66ff08670..094cc34f7 100644
--- a/unity/Assets/Scripts/UI/UiIcon.cs
+++ b/unity/Assets/Scripts/UI/UiIcon.cs
@@ -30,7 +30,7 @@ namespace Statecraft.Game.UI
}
// The palette: the promo's gold, beige figures, blue shield and globe, and a sage banknote.
- static readonly Color Gold = new Color32(214, 176, 98, 255), GoldDark = new Color32(132, 96, 44, 255),
+ static readonly Color GoldBase = new Color32(214, 176, 98, 255), GoldDark = new Color32(132, 96, 44, 255),
GoldLight = new Color32(244, 214, 146, 255), Beige = new Color32(226, 206, 166, 255), BeigeDark = new Color32(176, 154, 116, 255),
Blue = new Color32(92, 138, 200, 255), BlueLight = new Color32(206, 224, 246, 255), Sage = new Color32(126, 168, 120, 255),
SageLight = new Color32(214, 236, 204, 255), Navy = new Color32(14, 22, 38, 200);
@@ -46,12 +46,29 @@ namespace Statecraft.Game.UI
["biome-mountains"] = Mountains, ["biome-valley"] = Valley, ["biome-desert"] = Dunes,
};
- void Draw(MeshGenerationContext mgc) => Paint(mgc, glyph, contentRect);
+ // The line colour of the gold glyphs: gold, or gold-light while lit (on the focus fill, review N4).
+ static Color Gold = GoldBase;
+
+ /// <summary>The gold glyphs' line colour, plain or lit (PromoHudTests checks lit stays >= 3:1 on the focus fill).</summary>
+ public static Color LineColour(bool lit) => lit ? GoldLight : GoldBase;
+
+ /// <summary>True when <paramref name="e"/>, or the Button it sits in, has the keyboard focus. Focus changes the element's
+ /// style (Statecraft.uss), which repaints it, so a glyph that reads this is redrawn when focus comes or goes.</summary>
+ public static bool IsFocused(VisualElement e)
+ {
+ var b = e as Button ?? e.GetFirstAncestorOfType<Button>();
+ return b != null && b.focusController?.focusedElement == b;
+ }
+
+ /// <summary>Lit while its Button has the keyboard focus.</summary>
+ public bool Lit => IsFocused(this);
+
+ void Draw(MeshGenerationContext mgc) => Paint(mgc, glyph, contentRect, Lit);
/// <summary>Draws <paramref name="glyph"/> centred in <paramref name="box"/> (the element's local coordinates). For a
/// text element (a Button) the sign is painted into the element itself rather than added as a child: a child would
/// make it a non-leaf node, and Yoga measures only leaf nodes' text, so the button would stop growing to fit its text.</summary>
- public static void Paint(MeshGenerationContext mgc, string glyph, Rect box)
+ public static void Paint(MeshGenerationContext mgc, string glyph, Rect box, bool lit = false)
{
if (!Painters.TryGetValue(glyph, out var paint)) return;
if (!(box.width > 0) || !(box.height > 0)) return;
@@ -59,7 +76,9 @@ namespace Statecraft.Game.UI
var origin = new Vector2(box.x + (box.width - 24f * s) / 2f, box.y + (box.height - 24f * s) / 2f);
var p = mgc.painter2D;
p.lineJoin = LineJoin.Round; p.lineCap = LineCap.Round;
- paint(p, (x, y) => origin + new Vector2(x, y) * s, s);
+ Gold = LineColour(lit); // UI painting runs on the main thread, one element at a time
+ try { paint(p, (x, y) => origin + new Vector2(x, y) * s, s); }
+ finally { Gold = GoldBase; }
}
/// <summary>A round navy disc with a gold rim and <paramref name="glyph"/> inside it, centred on <paramref name="centre"/>
diff --git a/unity/Assets/Tests/EditMode/PromoHudTests.cs b/unity/Assets/Tests/EditMode/PromoHudTests.cs
index 6f32bb133..6ca1a9a1a 100644
--- a/unity/Assets/Tests/EditMode/PromoHudTests.cs
+++ b/unity/Assets/Tests/EditMode/PromoHudTests.cs
@@ -127,14 +127,19 @@ public class PromoHudTests
}
}
- /// <summary>The icons need a wide bar: a 5:4 window (1280x1024, about 1585 logical px) gets the compact bar without them,
- /// 16:9 keeps them; either way every meter's labels stay inside the meter.</summary>
+ /// <summary>The bar at every window shape, after a turn has played and with the widest realistic changes and date:
+ /// 16:9 (1920 logical px) keeps the icons; 16:10 (~1821), 5:4, 4:3 and windows narrower than about square (1280x1024 ~1585,
+ /// 1024x768 ~1662, 1024x1024 ~1440, a browser snapped to half a 1080p screen ~1358, 800x1000 ~1288) get the compact,
+ /// narrow HUD: no icons, and a taller bar whose meters stack the change under the value. Everywhere: every meter label stays inside its meter and the bar, no two meters'
+ /// labels overlap, the meters end before the screen buttons, the date badge holds its widest line inside its trim at a
+ /// fixed width, and the panels start below the bar (review N2, N3 and the narrow-window follow-up).</summary>
[UnityTest]
- public IEnumerator ANarrowWindowDropsTheMeterIcons()
+ public IEnumerator EveryWindowShapeFitsTheBarAfterATurn()
{
- // Logical widths (1080p reference, match 0.5): 1280x1024 ~1585, 1024x768 ~1662, 1024x1024 ~1440 (the compact bar's
- // floor), 1366x768 and 1280x720 1920, 1920x1080 1920.
- foreach (var (w, h, compact) in new[] { (1280, 1024, true), (1024, 768, true), (1024, 1024, true), (1920, 1080, false), (1280, 720, false), (1366, 768, false) })
+ foreach (var (w, h, compact, narrow) in new[] { (1920, 1080, false, false), (1280, 720, false, false), (1366, 768, false, false),
+ (1920, 1200, true, true), (1440, 900, true, true),
+ (1280, 1024, true, true), (1024, 768, true, true), (1024, 1024, true, true),
+ (960, 1080, true, true), (800, 1000, true, true) })
{
var rt = new RenderTexture(w, h, 0);
var ps = Object.Instantiate(AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel));
@@ -151,21 +156,54 @@ public class PromoHudTests
{
// As in the game: the bar is laid out (the loading screen) before the HUD is made, and the window never resizes.
for (int i = 0; i < 20 && !(root.Q("top-bar").worldBound.width > 0); i++) yield return null;
- hud = new HudPresenter(root, new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), Text), Text);
- // The widest real date line: a three-digit turn and the longest month.
+ root.Q("root").RemoveFromClassList("loading");
+ var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), Text);
+ hud = new HudPresenter(root, bridge, Text);
+ bridge.EndTurn(); // real changes on every meter that moved
+ // 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)),
+ ("security", "-10%"), ("support", "-10%"), ("standing", "+10%"), ("fx", PlayerText.MoneyChange(C, "fx_reserves", 12.5)) })
+ root.Q<Label>(name + "-delta").text = delta;
root.Q<Label>("turn").text = Text.Format("hud.turn", 120);
root.Q<Label>("date").text = Text.Format("hud.date", PlayerText.Date(new System.DateTime(1956, 9, 30)));
- yield return null; yield return null; yield return null;
- var badge = root.Q(className: "date-box").worldBound;
- foreach (var l in root.Q(className: "date-box").Query<Label>().ToList())
- Assert.LessOrEqual(l.worldBound.xMax, badge.xMax - 4f, $"{w}x{h}: '{l.text}' {l.worldBound} runs under the badge's trim {badge}");
- var bar = root.Q("top-bar");
- Assert.AreEqual(compact, bar.ClassListContains(HudPresenter.CompactClass), $"{w}x{h}: bar {bar.worldBound.width:0} px");
+ for (int i = 0; i < 3; i++) yield return null;
+ var bar = root.Q("top-bar"); var barRect = bar.worldBound;
+ var where = $"{w}x{h} (bar {barRect.width:0} px)";
+ Assert.AreEqual(compact, bar.ClassListContains(HudPresenter.CompactClass), where + ": compact");
+ Assert.AreEqual(narrow, root.Q("root").ClassListContains(HudPresenter.NarrowClass), where + ": narrow");
foreach (var icon in root.Q("meters").Query<UiIcon>().ToList())
- Assert.AreEqual(compact ? DisplayStyle.None : DisplayStyle.Flex, icon.resolvedStyle.display, $"{w}x{h}: {icon.Glyph}");
+ Assert.AreEqual(compact ? DisplayStyle.None : DisplayStyle.Flex, icon.resolvedStyle.display, $"{where}: {icon.Glyph}");
+ var badge = root.Q(className: "date-box");
+ foreach (var l in badge.Query<Label>().ToList())
+ Assert.LessOrEqual(l.worldBound.xMax, badge.worldBound.xMax - 4f, $"{where}: '{l.text}' {l.worldBound} runs under the badge's trim {badge.worldBound}");
+ var labels = new System.Collections.Generic.List<(string meter, Label label)>();
foreach (var m in root.Q("meters").Children())
- foreach (var l in m.Query<Label>().ToList())
- Assert.LessOrEqual(l.worldBound.xMax, m.worldBound.xMax + 0.5f, $"{w}x{h}: '{l.text}' leaves {m.name}");
+ foreach (var l in m.Query<Label>().ToList().Where(l => !string.IsNullOrEmpty(l.text)))
+ {
+ labels.Add((m.name, l));
+ var r = l.worldBound;
+ Assert.LessOrEqual(r.xMax, m.worldBound.xMax + 0.5f, $"{where}: '{l.text}' {r} leaves {m.name} {m.worldBound} on the right");
+ Assert.GreaterOrEqual(r.xMin + 0.5f, m.worldBound.xMin, $"{where}: '{l.text}' leaves {m.name} on the left");
+ Assert.GreaterOrEqual(r.yMin, barRect.yMin + 1f, $"{where}: '{l.text}' leaves the bar at the top");
+ Assert.LessOrEqual(r.yMax, barRect.yMax - 1f, $"{where}: '{l.text}' leaves the bar at the bottom");
+ }
+ foreach (var a in labels)
+ foreach (var b in labels)
+ if (a.meter != b.meter && a.label.worldBound.Overlaps(b.label.worldBound))
+ Assert.Fail($"{where}: '{a.label.text}' ({a.meter}) overlaps '{b.label.text}' ({b.meter})");
+ Assert.LessOrEqual(root.Q("meters").worldBound.xMax, root.Q("nav").worldBound.xMin + 0.5f, where + ": the meters run into the screen buttons");
+ Assert.GreaterOrEqual(root.Q("right-column").worldBound.yMin, barRect.yMax, where + ": the event column starts under the bar");
+ var screen = root.Q("screen-why");
+ screen.style.display = DisplayStyle.Flex; // opened, as ScreenNav does
+ for (int i = 0; i < 2; i++) yield return null;
+ Assert.GreaterOrEqual(screen.worldBound.yMin, barRect.yMax, where + ": the screens start under the bar");
+ screen.style.display = DisplayStyle.None;
+ // The badge keeps its width for a short date line, so nothing shifts when the month changes.
+ var wide = badge.worldBound.width;
+ root.Q<Label>("turn").text = Text.Format("hud.turn", 1);
+ root.Q<Label>("date").text = Text.Format("hud.date", PlayerText.Date(new System.DateTime(1948, 5, 1)));
+ for (int i = 0; i < 2; i++) yield return null;
+ Assert.AreEqual(wide, badge.worldBound.width, 0.5f, where + ": the badge's width follows its text");
}
finally { hud?.Dispose(); Object.DestroyImmediate(go); Object.DestroyImmediate(ps); rt.Release(); Object.DestroyImmediate(rt); }
}
@@ -191,6 +229,10 @@ public class PromoHudTests
{
using var ui = new UiTestKit();
var nav = new ScreenNav(ui.Root);
+ var blur = new PointerBlur(ui.Root);
+ var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);
+ while (!g.State.PendingEvents.Contains("armistice_egypt")) g.Step(new Command[0]);
+ var card = new EventCardPresenter(ui.Root, new SimBridge(g, Text), Text, null);
ui.Q<VisualElement>("root").RemoveFromClassList("loading"); // ready: a hidden (loading) button takes no focus
try
{
@@ -210,14 +252,31 @@ public class PromoHudTests
var budget = ui.Q<Button>("nav-budget");
budget.Focus();
nav.Toggle("budget");
- using (var e = ClickEvent.GetPooled()) { e.target = budget; budget.SendEvent(e); }
+ using (var e = ClickEvent.GetPooled()) { e.target = budget; budget.SendEvent(e); } // bubbles to PointerBlur
yield return null; yield return null;
Assert.AreNotSame(budget, budget.focusController.focusedElement, "a pointer click leaves no focus behind");
Assert.IsFalse(budget.ClassListContains(ScreenNav.OpenClass));
Near(new Color(196 / 255f, 160 / 255f, 92 / 255f), Disc("budget").resolvedStyle.borderTopColor, "the closed button's rim is unlit");
Assert.AreEqual(Disc("defence").resolvedStyle.borderTopWidth, Disc("budget").resolvedStyle.borderTopWidth, "the closed button looks like the others");
+
+ // Every other Button too (review N1), the runtime-made event option included: a pointer click leaves no focus
+ // fill. The click lands on the button's own text or on a child (the disc), and bubbles to the root's handler.
+ var navy = new Color(9 / 255f, 14 / 255f, 26 / 255f);
+ foreach (var (name, part) in new[] { ("end-turn", ""), ("new-game", "nav-disc"), ("option-sign", "") })
+ {
+ var b = ui.Q<Button>(name);
+ VisualElement look = part == "" ? b : b.Q(className: part);
+ b.Focus();
+ for (int i = 0; i < 10 && b.focusController.focusedElement != b; i++) yield return null;
+ Assert.AreSame(b, b.focusController.focusedElement, name + ": precondition, focused");
+ VisualElement target = part == "" ? b : b.Q(className: part);
+ using (var e = ClickEvent.GetPooled()) { e.target = target; target.SendEvent(e); }
+ yield return null; yield return null;
+ Assert.AreNotSame(b, b.focusController.focusedElement, name + ": a pointer click leaves no focus behind");
+ Near(navy, look.resolvedStyle.backgroundColor, name + ": no focus fill after the click");
+ }
}
- finally { nav.Dispose(); }
+ finally { nav.Dispose(); blur.Dispose(); card.Dispose(); }
}
/// <summary>Review I3: keyboard focus changes End Turn, an event option and a screen button by at least 3:1 (WCAG 2.4.13).</summary>
@@ -245,6 +304,14 @@ public class PromoHudTests
var after = target.resolvedStyle;
var change = Mathf.Max(Contrast(bgBefore, after.backgroundColor), Contrast(rimBefore, after.borderTopColor));
Assert.GreaterOrEqual(change, 3f, $"{name}: focus changes it by {change:0.00}:1");
+ // The gold glyph on it (End Turn's hourglass, the disc's icon) turns gold-light: >= 3:1 on the focus fill (review N4).
+ if (name != "option-sign")
+ {
+ var glyphOn = part == "" ? (VisualElement)b : target;
+ Assert.IsTrue(UiIcon.IsFocused(glyphOn), name + ": its glyph is drawn lit");
+ var glyph = Contrast(UiIcon.LineColour(true), after.backgroundColor);
+ Assert.GreaterOrEqual(glyph, 3f, $"{name}: the lit glyph on the focus fill is {glyph:0.00}:1");
+ }
b.Blur();
}
}
diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.uss
index 0315fd972..7675476f5 100644
--- a/unity/Assets/UI/Statecraft.uss
+++ b/unity/Assets/UI/Statecraft.uss
@@ -79,7 +79,8 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
.top-bar Label { padding-top: 0; padding-bottom: 0; margin-top: 0; margin-bottom: 0; }
/* The date badge: a raised, trimmed box at the left, as the promo's "1936 / Turn 1 / January 1936" plate. */
.date-box {
- flex-shrink: 0; min-width: 150px; height: 82px; /* sized to its widest line ("Turn 120 30 September 1956") */ justify-content: center;
+ flex-shrink: 0; width: 230px; height: 82px; /* fixed, and wide enough for the widest line ("Turn 120 30 September 1956"),
+ so the meters never shift when the month changes */ justify-content: center;
padding: 0 12px 0 18px; margin-right: 10px;
background-color: var(--navy-raised); border-width: 1px; border-color: var(--gold-dim); border-radius: 2px;
}
@@ -121,11 +122,19 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
/* A window too narrow for the icons (HudPresenter sets top-bar--compact below HudPresenter.CompactBelowPx): the meters
drop their icons and tighten, as the bar was before the icons. */
.top-bar--compact .meter-icon { display: none; }
-.top-bar--compact .date-box { padding: 0 10px 0 12px; margin-right: 6px; }
+.top-bar--compact .date-box { width: 226px; padding: 0 10px 0 12px; margin-right: 6px; }
.top-bar--compact .date-row Label { font-size: 16px; margin-right: 6px; }
.top-bar--compact .meter { padding: 0 8px; }
.top-bar--compact .nav-button { width: 62px; }
.top-bar--compact .nav-disc { left: 6px; }
+/* The narrow HUD (HudPresenter sets hud-narrow on the root, with the compact bar): a taller bar whose meters put the
+ change under the value, so no change runs into its neighbour; the panels below the bar move down with it. */
+.hud-narrow .top-bar { height: 124px; }
+.hud-narrow .right-column, .hud-narrow .screen, .hud-narrow .toast { top: 140px; }
+.hud-narrow .meter { min-width: 96px; padding: 0 6px; }
+.hud-narrow .meter-row { flex-direction: column; align-items: flex-start; }
+.hud-narrow .meter-value { font-size: 22px; }
+.hud-narrow .meter-delta { margin-left: 0; font-size: 15px; }
.turn-box { width: 190px; flex-shrink: 1; min-width: 150px; align-items: flex-end; }
#attention { font-size: 16px; }
.end-turn {