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.

HUD round 2: the top bar at promo 03's 6.5%, the date plate hanging below it (refs #398) (#624)

Eyal Golan3a6f7556048d
diff --git a/CHANGELOG.md b/CHANGELOG.md
index a9b18dd83..4a15c7a01 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -73,6 +73,14 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
- GDD v0.1 Phase 1, a dev flag and the score (refs #380): `?mvp=1` in the WebGL page's URL loads the content through
`MvpSlice.Overlay` (the GDD slice) for playtests. The golden check and the smoke run ignore it, and a slice game never
reads, sets aside or writes the player's autosave (and has no New Game). In the GDD loop the top bar shows the score.
+- The top bar at promo 03's height (HUD round 2, part 3, refs #398): 70 px, 6.5% of a 16:9 frame (it was 96, 8.8%), with
+ the date plate hanging below it as promo 03's does, two-line meters (Security's level beside its caption), New Game a
+ round icon named in a tip, and a smaller End Turn. With the screen buttons in the left column (#602) the bar needs about
+ 248 px less, so 16:10 and 4:3 windows keep the one-row bar, and 5:4 the stacked bar with its icons. The decision card's
+ backdrop reaches up to the bar at every tier, so no strip of map stays live under a card. The bar's small text (captions,
+ Security's level, the attention line, the plate's turn and date) stays at least 12 px on screen at small windows, the owner's floor: it is set
+ larger as the panel scales down, and the bar takes a taller tier when it needs the room. Presentation only: no golden
+ moves.
- The left icon column (HUD round 2, part 2, refs #398): the four screens' buttons (Cabinet, Budget, Defence, Why?) move
from the top bar to promo 03's column of round icons at the left edge, icon-only, each named in a tip beside it on hover
and on keyboard focus. No new action. Tab still runs Cabinet, Budget, Defence, Why?, New Game, End Turn; the column stays
diff --git a/docs/visual-v1.md b/docs/visual-v1.md
index 91bd25301..446b4d916 100644
--- a/docs/visual-v1.md
+++ b/docs/visual-v1.md
@@ -3121,6 +3121,73 @@ Diorama02 `none` is 0.35-0.4 ms lower on the branch in both positions, outside t
equal (27.91 / 27.87). It is not explained (the branch draws four fewer captioned buttons in the bar, but that is not
measured on its own), so it is not claimed as a gain.
+## HUD round 2, part 3: the top bar (#398)
+
+T54 measured the bar at 8.8% of the frame's height against promo 03's and T29's 6.5%. The one-row bar is now 70 px:
+- The date plate hangs below it, as promo 03's "1936 / Turn 1 / January 1936" plate does. It is at least 98 px tall and
+ grows if the date wraps to a third line. #598's "Score {n}" stays at the far end of the year line.
+- The meters keep two lines, caption then value and change. Security's "Level 5 of 5" sits beside its caption; it was a
+ third line. Captions are 15 px, values 21 px (24 on the roomy bar), with the icons as before.
+- New Game is a round icon with no caption, as promo 03's bar buttons are. Its name is its text, drawn clear (the event
+ log reads it), and its tooltip, which `HoverTip` shows beside it on hover and on focus.
+- End Turn is 20 px with its attention line at 14 px.
+- With the four screen buttons in the left column (#602) the bar needs about 248 px less, so each width tier starts that
+ much narrower (`HudPresenter`). Logical width is the window's width over the panel's scale, which is the plain mean of
+ the two ratios, (w/1920 + h/1080) / 2 (logged by `TopBarTests`). The one-row edge is 1640, between a fullscreen 5:4 and
+ 4:3 (review of #624 asked whether a fullscreen 5:4 could keep the one-row bar; at 1563-1612 it wrapped "Public Support"
+ and "International Standing" (the captions' names then; #622 and #683 renamed them) with the widest values, while at 1635 it still fit, so 1640 is a margin, not a limit). So 16:10 (~1819) and 4:3 (~1646) keep the one-row bar with its icons,
+ a fullscreen 5:4 (~1585) takes the stacked bar with them, and a square window (~1382) the stacked bar without. The
+ taller tiers' heights are unchanged.
+- The panels under the bar keep their 112 px top, which clears the hanging plate. Under a decision card a full-width band
+ of the backdrop runs from the bar's bottom to the column's top (`event-scrim-top`), so no strip of map stays live and
+ the hanging plate is dimmed evenly; the column's strip starts at the column's top (`TopBarTests.WithACardOpenTheBackdropMeetsTheBar`).
+- The plate is a label occluder (`date-plate` in `MapLabelsPresenter.OccluderNames`), since the bar's box no longer covers
+ it (`MapLabelTests.APillUnderTheHangingPlateIsHidden`).
+- Security's level and the attention line are 15 px, the accessibility audit's floor (H4); they were 13 and 14.
+- The owner's text floor (15 October 2026): the bar's small text stays at least 12 px on screen at small windows. The panel
+ scales with the window (0.67 at 1280x720, 0.62 at 1024x768), so `HudPresenter` sets it to the whole px that keeps 12 on
+ screen (18 px at 1280x720, 20 at 1024x768; in a browser, CSS px: the panel's scale over `devicePixelRatio`). Raised
+ captions stay on one line, the turn box widens with them, and the tiers read the bar's width less the room this takes
+ (`FloorGrowth`), so 1024x768 takes the stacked bar without icons; above 18 px the one-row bar's turn box no longer fits
+ its 70 px, so 1366x657 takes the stacked bar. The phone tier (three rows) keeps 15 px: its fixed rows have no room for
+ 25 px captions (a follow-up, by the owner's answer). The plate's turn and date line takes the same floor (the owner's
+ second answer): the plate keeps its 230 px width, the turn and the date take a line each,
+ and the plate's padding (18 px at the sides, 9 at the top and bottom) keeps every line inside its gilt frame's inner
+ rule and at least 0 px from the 18 px corner zones (the scrolls' reach of about 14 px, plus 4; the score sits on a
+ zone's edge at 1280x720, 4 px clear of the scroll); the plate grows to hold them, taller and, where the date needs it (23 px at 960x600), wider
+ than 230 px, and the tiers count the extra width.
+- In Hebrew the bar's row mirrors (#550): the plate is at the right and End Turn at the left. The left column and the
+ minimap keep their corners.
+
+Measured on the WebGL `?shot` frames (`measure_bar.py`: the rows from the top until the frame's middle third stops being
+dark; promo 03 and T29 include a 3 px gold rule):
+
+| frame | bar | share of height | plate bottom | share | plate below the bar |
+|---|---|---|---|---|---|
+| promo 03 | 103 px | 6.7% | 130 px | 8.5% | 27 px |
+| demo2 T29 | 73 px | 6.8% | 91 px | 8.4% | 18 px |
+| before (#602), gameplay03 and diorama02, EN and HE | 95 px | 8.8% | 95 px | 8.8% | 0 |
+| after, gameplay03 and diorama02, EN and HE | 69 px | 6.4% | 97 px | 9.0% | 28 px |
+
+At 21:9 (2560x1080) the panel scales by the plain mean of the two ratios, so the 70 px bar is 7.6% of the frame.
+
+Frame time (`?vprofile` headless 1920x1080 with a temporary, uncommitted all/none-only FrameProfile patch on both builds,
+then a headed DPR 2 pair) and boot (`headed.py boot --runs 3`), one `--exclusive` slot of 8 minutes, interleaved base,
+branch, branch, base; base is #602's head 192fdf31. Median avg ms (spread):
+
+| | base | branch | branch | base |
+|---|---|---|---|---|
+| gameplay03 all | 8.19 (0.07) | 8.14 (0.07) | 8.12 (0.04) | 8.19 (0.04) |
+| gameplay03 none | 7.02 (0.06) | 6.96 (0.07) | 6.94 (0.05) | 7.02 (0.07) |
+| diorama02 all | 15.75 (0.39) | 15.72 (0.41) | 15.74 (0.54) | 15.55 (0.38) |
+| diorama02 none | 10.74 (0.05) | 10.69 (0.10) | 10.74 (0.11) | 10.72 (0.11) |
+| boot map_build / first_frame, cpu 1 | 540 / 3761 ms | 567 / 3786 ms | 562 / 3792 ms | 541 / 3779 ms |
+
+DPR 2 headed, branch then base (spread): gameplay03 all 19.09 (0.24) / 19.10 (0.20), none 17.75 (0.02) / 17.85 (0.02);
+diorama02 all 33.96 (0.27) / 33.79 (0.19), none 28.08 (0.14) / 27.97 (0.10). Frame time is equal within the spreads.
+Boot's `map_build` median is about 24 ms higher on the branch in both positions, but its single runs overlap base's (base
+524-552 ms, branch 546-570 ms), the change touches no map code, and both are far inside the 743 ms budget at cpu 1.
+
## Issue #391: the terrain shader's frame-time cliff (warm land shade, not shipped)
#391 asked for the shaded hill ground to read warm brown, as promo 03's does (about (67, 53, 46)), rather than olive-grey.
The look was solved; the cost was not, so nothing shipped. What was measured is a constraint on any future addition to
diff --git a/unity/Assets/Scripts/UI/DevicePixelRatio.jslib b/unity/Assets/Scripts/UI/DevicePixelRatio.jslib
new file mode 100644
index 000000000..de4e2b959
--- /dev/null
+++ b/unity/Assets/Scripts/UI/DevicePixelRatio.jslib
@@ -0,0 +1,5 @@
+// The browser's devicePixelRatio: the canvas is drawn in device pixels, so HudPresenter's text floor divides the panel's
+// scale by it to count CSS pixels, the size the player sees (#624).
+mergeInto(LibraryManager.library, {
+ StatecraftDevicePixelRatio: function () { return typeof window !== "undefined" && window.devicePixelRatio > 0 ? window.devicePixelRatio : 1; },
+});
diff --git a/unity/Assets/Scripts/UI/DevicePixelRatio.jslib.meta b/unity/Assets/Scripts/UI/DevicePixelRatio.jslib.meta
new file mode 100644
index 000000000..ac0ad2fb8
--- /dev/null
+++ b/unity/Assets/Scripts/UI/DevicePixelRatio.jslib.meta
@@ -0,0 +1,32 @@
+fileFormatVersion: 2
+guid: 5b3f7e2a9c1d4e6f8a0b2c4d6e8f0a13
+PluginImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ iconMap: {}
+ executionOrder: {}
+ defineConstraints: []
+ isPreloaded: 0
+ isOverridable: 0
+ isExplicitlyReferenced: 0
+ validateReferences: 1
+ platformData:
+ - first:
+ Any:
+ second:
+ enabled: 0
+ settings: {}
+ - first:
+ Editor: Editor
+ second:
+ enabled: 0
+ settings:
+ DefaultValueInitialized: true
+ - first:
+ WebGL: WebGL
+ second:
+ enabled: 1
+ settings: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Scripts/UI/HudPresenter.cs b/unity/Assets/Scripts/UI/HudPresenter.cs
index b9dec9921..8c2cac0a0 100644
--- a/unity/Assets/Scripts/UI/HudPresenter.cs
+++ b/unity/Assets/Scripts/UI/HudPresenter.cs
@@ -16,26 +16,29 @@ namespace Statecraft.Game.UI
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:
- // 16:9 fullscreen 1920, a 16:10 MacBook browser ~1910 | NarrowBelowPx 1860 | 16:10 fullscreen ~1821
- // | CompactBelowPx 1700 | 4:3 ~1662, 5:4 ~1585 | TwoRowBelowPx 1500 | square ~1440, half a 1080p screen ~1358.
+ // Three tiers by the bar's logical width (1080p reference, match 0.5: the panel's scale is the plain mean of the two
+ // ratios, (w/1920 + h/1080) / 2, so logical width = w / that; TopBarTests logs it). HUD round 2 moved the four screen
+ // buttons to the left column (#602), about 248 px out of the bar, so every tier starts narrower (part 3). The one-row
+ // edge sits between a fullscreen 5:4 and 4:3 (review of #624): the first run found the one-row bar wrapping two
+ // captions with the widest values at 1563-1612; TopBarTests holds one row at 1642 and the stacked bar at 1635:
+ // 16:9 1920, 16:10 ~1819, 4:3 ~1646 | NarrowBelowPx 1640 | 5:4 ~1585 | CompactBelowPx 1452 | square ~1382
+ // | TwoRowBelowPx 1370 | half a 1080p screen (960x1080) ~1280.
// PromoHudTests.EveryWindowShapeFitsTheBarAfterATurn proves each tier holds the widest late-game values and changes.
/// <summary>Below this width the HUD's root gets NarrowClass: a taller bar (124 px) whose meters stack the change under
- /// the value, and the panels below it move down to match (Statecraft.uss .hud-narrow). Above it, six values and their
- /// changes fit side by side with the icons.</summary>
- public const float NarrowBelowPx = 1860f;
+ /// the value, and the panels below it move down to match (Statecraft.uss .hud-narrow). Above it, the 70 px one-row bar
+ /// (promo 03's 6.5%) holds six values and their changes side by side with the icons.</summary>
+ public const float NarrowBelowPx = 1640f;
public const string NarrowClass = "hud-narrow";
- /// <summary>Below this width the meters also drop their icons (Statecraft.uss .top-bar--compact): 16:10 keeps them on the
- /// stacked bar; 4:3 and 5:4 do not have the room.</summary>
- public const float CompactBelowPx = 1700f;
+ /// <summary>Below this width the meters also drop their icons (Statecraft.uss .top-bar--compact): a square window does not
+ /// have the room for them on the stacked bar.</summary>
+ public const float CompactBelowPx = 1452f;
public const string CompactClass = "top-bar--compact";
/// <summary>Below this width (windows narrower than about square, e.g. a browser snapped to half a 1080p screen, about
- /// 1360 logical px) one row cannot hold the badge, six meters, the screen buttons and End Turn: the root also gets
+ /// 1360 logical px) one row cannot hold the badge, six meters, New Game and End Turn: the root also gets
/// TwoRowClass, and the bar wraps into two rows, the date and the meters above, the screen buttons and End Turn
/// below (Statecraft.uss .hud-two-row).</summary>
- public const float TwoRowBelowPx = 1500f;
+ public const float TwoRowBelowPx = 1370f;
public const string TwoRowClass = "hud-two-row";
/// <summary>Below this width (a phone held upright: 390x844 is about 790 logical px) the badge and six meters do not
/// fit one row either: the root also gets ThreeRowClass, and the bar takes three rows, the badge, the meters, then the
@@ -63,9 +66,38 @@ namespace Statecraft.Game.UI
("nav-why", "hud.nav.why"), ("new-game", "hud.new_game"), ("end-turn", "hud.end_turn"),
};
+ /// <summary>The owner's text floor (#624, 15 October 2026): the bar's small text (the six captions, Security's level
+ /// and the attention line, SmallTextPx in the stylesheet) stays at least this many pixels on screen. The panel scales
+ /// with the window (about 0.67 at 1280x720, 0.62 at 1024x768), so at small windows the text is set larger in panel
+ /// px (SmallTextSize).</summary>
+ public const float TextFloorPx = 12f;
+ /// <summary>The bar's small text in the stylesheet (Statecraft.uss .meter-name, #security-level, #attention).</summary>
+ public const float SmallTextPx = 15f;
+
+ /// <summary>The small text's size in panel px when one panel px is <paramref name="screenPxPerPanelPx"/> pixels on
+ /// screen: the stylesheet's SmallTextPx, or the whole px that keeps it at TextFloorPx on screen if that is larger.</summary>
+ public static float SmallTextSize(float screenPxPerPanelPx) =>
+ screenPxPerPanelPx > 0f ? UnityEngine.Mathf.Max(SmallTextPx, UnityEngine.Mathf.Ceil(TextFloorPx / screenPxPerPanelPx - 0.01f)) : SmallTextPx;
+
+ readonly List<Label> smallText;
+ /// <summary>The plate's turn and date line (Statecraft.uss .date-row Label, 15 px): raised with the bar's small text (the
+ /// owner's second answer, 15 October 2026). The plate keeps its width; the turn and the date take a line each, and the
+ /// plate grows.</summary>
+ readonly List<Label> plateText;
+ readonly VisualElement? dateRow;
+ /// <summary>The plate's padding while the floor raises its text (the stylesheet's is 2 px top and bottom, 10-12 at the
+ /// sides): PlateSidePx at both sides keeps every line at least 0 px from the 18 px corner zones (TopBarTests), each the
+ /// corner scrolls' reach (about 14 px in) plus 4, and PlateEdgePx at the top and bottom keeps it inside the frame's
+ /// inner rule (7 px in). The plate grows to
+ /// hold them (its height is a minimum), rather than shift its lines.</summary>
+ public const float PlateSidePx = 18f, PlateEdgePx = 9f;
+ readonly VisualElement turnBox;
+ readonly IVisualElementScheduledItem floorCheck;
+ float smallTextSize = SmallTextPx;
+
/// <summary>The left icon column (promo 03): the four screens' buttons.</summary>
public const string RailName = "left-column";
- readonly HoverTip? railTips;
+ readonly HoverTip? railTips, barTips;
public HudPresenter(VisualElement root, SimBridge bridge, UiText text)
{
@@ -86,12 +118,31 @@ namespace Statecraft.Game.UI
var rail = root.Q<VisualElement>(RailName)?.Query<Button>().ToList() ?? new List<Button>();
foreach (var b in rail) b.tooltip = b.text;
if (rail.Count > 0 && root.Q<Label>(HoverTip.TipName) != null) railTips = new HoverTip(root, rail, () => HoverTip.Side.Right);
+ // New Game in the bar is icon-only too (HUD round 2, part 3); its tip opens toward the bar's middle: left of it,
+ // or right of it in the mirrored Hebrew bar.
+ var newGame = root.Q<Button>("new-game");
+ if (newGame != null)
+ {
+ newGame.tooltip = newGame.text;
+ if (root.Q<Label>(HoverTip.TipName) != null)
+ barTips = new HoverTip(root, new[] { newGame }, () => hudRoot.ClassListContains(UiLanguage.HebrewClass) ? HoverTip.Side.Right : HoverTip.Side.Left);
+ }
foreach (var id in new[] { "treasury", "immigration", "security", "support", "standing", "fx" })
{
var meter = root.Q<VisualElement>("meter-" + id); var caption = text["hud.caption." + id];
meter.Q<Label>(className: "meter-name").text = caption; // the bar shows the words its tooltip says
said[id] = (meter, caption);
}
+ // The text floor: checked now and twice a second, since a window resized at the same shape changes the panel's
+ // scale without changing its layout (no geometry event).
+ smallText = bar.Query<Label>(className: "meter-name").ToList(); // the six captions and Security's level
+ smallText.Add(root.Q<Label>("attention"));
+ turnBox = bar.Q<VisualElement>(className: "turn-box");
+ dateRow = bar.Q<VisualElement>(className: "date-row");
+ plateText = dateRow?.Query<Label>().ToList() ?? new List<Label>();
+ dateRow?.parent?.RegisterCallback<GeometryChangedEvent>(OnPlateGeometry); // a wider raised plate needs room in the bar
+ ApplyTextFloor();
+ floorCheck = root.schedule.Execute(ApplyTextFloor).Every(500);
SetCompact(bar.layout.width); // the bar may already be laid out (the loading screen shows it) and never resize
bridge.Changed += Render;
Render();
@@ -100,9 +151,15 @@ namespace Statecraft.Game.UI
/// <summary>Unsubscribes from the bridge and the button (the owner calls this when it is disabled).</summary>
public void Dispose()
{
- railTips?.Dispose();
+ railTips?.Dispose(); barTips?.Dispose();
+ floorCheck.Pause();
+ foreach (var l in smallText) { l.style.fontSize = StyleKeyword.Null; l.style.whiteSpace = StyleKeyword.Null; l.style.maxWidth = StyleKeyword.Null; }
+ turnBox.style.width = StyleKeyword.Null; turnBox.style.minWidth = StyleKeyword.Null;
+ foreach (var l in plateText) { l.style.fontSize = StyleKeyword.Null; l.style.whiteSpace = StyleKeyword.Null; }
+ if (dateRow != null) { dateRow.style.flexDirection = StyleKeyword.Null; if (dateRow.parent != null) PadPlate(dateRow.parent, false); }
bridge.Changed -= Render; endTurn.clicked -= onEndTurn; endTurn.generateVisualContent -= PaintHourglass;
bar.UnregisterCallback<GeometryChangedEvent>(OnBarGeometry);
+ dateRow?.parent?.UnregisterCallback<GeometryChangedEvent>(OnPlateGeometry);
foreach (var m in meters) m.UnregisterCallback<GeometryChangedEvent>(OnMeterGeometry);
bar.RemoveFromClassList(RoomyClass);
bar.RemoveFromClassList(CompactClass); hudRoot.RemoveFromClassList(NarrowClass); hudRoot.RemoveFromClassList(TwoRowClass); hudRoot.RemoveFromClassList(ThreeRowClass);
@@ -112,6 +169,10 @@ namespace Statecraft.Game.UI
// The bar's width does not depend on the class, so this settles in one pass.
void OnBarGeometry(GeometryChangedEvent e) => SetCompact(e.newRect.width);
+ // The raised plate sizes to its widest line (PadPlate), so the tiers re-read the room it takes (FloorGrowth). The
+ // plate's width does not depend on the tier, so this settles in one pass.
+ void OnPlateGeometry(GeometryChangedEvent e) { if (smallTextSize > SmallTextPx && e.oldRect.width != e.newRect.width) SetCompact(bar.layout.width); }
+
void OnMeterGeometry(GeometryChangedEvent e) => UpdateRoomy();
/// <summary>Roomy only on the one-row bar with icons; see RoomyClass.</summary>
@@ -141,13 +202,116 @@ namespace Statecraft.Game.UI
}
}
+ /// <summary>Sets the small text to SmallTextSize for the panel's current scale and re-picks the tier, since larger
+ /// captions need more room (TierWidth).</summary>
+ void ApplyTextFloor()
+ {
+ var p = root.panel;
+ if (p == null) return;
+ var size = SmallTextSize(p.scaledPixelsPerPoint / DevicePixelRatio());
+ if (size == smallTextSize) return;
+ smallTextSize = size;
+ SetCompact(bar.layout.width);
+ }
+
+ /// <summary>Whether the floor raises the text at this bar width. Not on the three-row bar (a phone held upright, about
+ /// 0.49 scale): its fixed rows have no room for 25 px captions, so it keeps the stylesheet's size (a follow-up, by the owner's answer).</summary>
+ bool FloorRaises(float width) => smallTextSize > SmallTextPx && !(width < ThreeRowBelowPx);
+
+ /// <summary>The room the raised text takes beyond what the tiers were set for (the 15 px captions, wrapped at their 120 px
+ /// max-width, and the 150 px turn box): each caption on one line at the larger size (text width scales with font
+ /// size), and the turn box widened in step. The one-row and icon tiers read the bar's width less this.</summary>
+ float FloorGrowth()
+ {
+ float growth = TurnBoxPx * (smallTextSize / SmallTextPx - 1f) + (RaisedPlateWidth() - PlateWidthPx);
+ foreach (var l in smallText)
+ {
+ if (l.name == "attention" || string.IsNullOrEmpty(l.text)) continue;
+ var current = l.resolvedStyle.fontSize;
+ if (!(current > 0f)) continue;
+ var oneLine = l.MeasureTextSize(l.text, 0, VisualElement.MeasureMode.Undefined, 0, VisualElement.MeasureMode.Undefined).x;
+ growth += oneLine * smallTextSize / current - UnityEngine.Mathf.Min(oneLine * SmallTextPx / current, CaptionMaxPx);
+ }
+ return UnityEngine.Mathf.Max(0f, growth);
+ }
+ // Statecraft.uss .turn-box width, .meter .meter-name max-width, .date-box width.
+ const float TurnBoxPx = 150f, CaptionMaxPx = 120f, PlateWidthPx = 230f;
+
+ /// <summary>The raised plate's laid-out width (PadPlate lets it size to its widest line, at least the stylesheet's 230 px;
+ /// at 23 px, 960x600, the date is wider), or 230 before it is laid out.</summary>
+ float RaisedPlateWidth()
+ {
+ var w = dateRow?.parent?.layout.width ?? float.NaN;
+ return w > PlateWidthPx ? w : PlateWidthPx;
+ }
+
+ /// <summary>The largest raised small text the 70 px one-row bar holds: the attention line above End Turn is taller with
+ /// it, and at 19 px (1366x657) the Hebrew turn box leaves the bar (TopBarTests.TheBarFitsEveryWindowInEnglishAndHebrew),
+ /// so above this the bar takes the stacked tier.</summary>
+ public const float OneRowSmallMaxPx = 18f;
+
+ /// <summary>Inline styles for the floor, only while it raises the text: its size; the captions on one line on the one-row
+ /// and stacked bars (a wrapped caption at the larger size would leave the bar), where FloorGrowth has made room (the
+ /// two-row bar keeps the stylesheet's wrapping); and the turn box widened so the attention line fits.</summary>
+ void StyleSmallText(bool raised)
+ {
+ bool oneLine = raised && !hudRoot.ClassListContains(TwoRowClass);
+ foreach (var l in smallText)
+ {
+ l.style.fontSize = raised ? new StyleLength(smallTextSize) : new StyleLength(StyleKeyword.Null);
+ if (l.name == "attention") continue;
+ l.style.whiteSpace = oneLine ? new StyleEnum<WhiteSpace>(WhiteSpace.NoWrap) : new StyleEnum<WhiteSpace>(StyleKeyword.Null);
+ l.style.maxWidth = oneLine ? new StyleLength(StyleKeyword.None) : new StyleLength(StyleKeyword.Null);
+ }
+ foreach (var l in plateText)
+ {
+ l.style.fontSize = raised ? new StyleLength(smallTextSize) : new StyleLength(StyleKeyword.Null);
+ // One line each; the plate widens for them (PadPlate).
+ l.style.whiteSpace = raised ? new StyleEnum<WhiteSpace>(WhiteSpace.NoWrap) : new StyleEnum<WhiteSpace>(StyleKeyword.Null);
+ }
+ // Raised, the turn and the date take a line each (a raised date squeezed beside the turn was clipped in Hebrew),
+ // and the plate's padding keeps every line inside its gilt frame's inner rule and at least 0 px from the 18 px corner
+ // zones, which keep 4 px clear of the scrolls (PlateSidePx, PlateEdgePx; reviews of #624 in WebGL); the plate grows
+ // to hold them.
+ if (dateRow != null)
+ {
+ dateRow.style.flexDirection = raised ? new StyleEnum<FlexDirection>(FlexDirection.Column) : new StyleEnum<FlexDirection>(StyleKeyword.Null);
+ if (dateRow.parent != null) PadPlate(dateRow.parent, raised);
+ }
+ var box = TurnBoxPx * smallTextSize / SmallTextPx;
+ turnBox.style.width = raised ? new StyleLength(box) : new StyleLength(StyleKeyword.Null);
+ turnBox.style.minWidth = raised ? new StyleLength(box) : new StyleLength(StyleKeyword.Null);
+ }
+
+ void PadPlate(VisualElement plate, bool raised)
+ {
+ // Raised, the plate sizes to its widest line (the turn and the date, a line each, never wrapped), at least 230 px.
+ plate.style.width = raised ? new StyleLength(StyleKeyword.Auto) : new StyleLength(StyleKeyword.Null);
+ plate.style.minWidth = raised ? new StyleLength(PlateWidthPx) : new StyleLength(StyleKeyword.Null);
+ StyleLength Px(float v) => raised ? new StyleLength(v) : new StyleLength(StyleKeyword.Null);
+ plate.style.paddingTop = Px(PlateEdgePx); plate.style.paddingBottom = Px(PlateEdgePx);
+ plate.style.paddingLeft = Px(PlateSidePx); plate.style.paddingRight = Px(PlateSidePx);
+ }
+
+#if UNITY_WEBGL && !UNITY_EDITOR
+ // The panel scales by the canvas's device pixels, so a screen pixel here is a CSS pixel: the device's pixels / the
+ // browser's devicePixelRatio (DevicePixelRatio.jslib).
+ [System.Runtime.InteropServices.DllImport("__Internal")] static extern float StatecraftDevicePixelRatio();
+ static float DevicePixelRatio() { var r = StatecraftDevicePixelRatio(); return r > 0f ? r : 1f; }
+#else
+ static float DevicePixelRatio() => 1f;
+#endif
+
void SetCompact(float width)
{
if (!(width > 0)) return; // NaN before layout: wait for it
- bar.EnableInClassList(CompactClass, width < CompactBelowPx);
- hudRoot.EnableInClassList(NarrowClass, width < NarrowBelowPx);
+ var raised = FloorRaises(width);
+ var tierWidth = raised ? width - FloorGrowth() : width; // the owner's text floor needs room (#624)
+ bar.EnableInClassList(CompactClass, tierWidth < CompactBelowPx);
+ hudRoot.EnableInClassList(NarrowClass, tierWidth < NarrowBelowPx || raised && smallTextSize > OneRowSmallMaxPx);
hudRoot.EnableInClassList(TwoRowClass, width < TwoRowBelowPx);
hudRoot.EnableInClassList(ThreeRowClass, width < ThreeRowBelowPx);
+ StyleSmallText(raised);
ScreenNav.DisableCovered(hudRoot); // two rows or one: what an open screen covers changes with it (#400)
}
diff --git a/unity/Assets/Scripts/UI/MapLabelsPresenter.cs b/unity/Assets/Scripts/UI/MapLabelsPresenter.cs
index fe2441365..3cebf3b70 100644
--- a/unity/Assets/Scripts/UI/MapLabelsPresenter.cs
+++ b/unity/Assets/Scripts/UI/MapLabelsPresenter.cs
@@ -31,7 +31,7 @@ namespace Statecraft.Game.UI
/// place (village, kibbutz, moshav) beyond DeclutterDistanceM, or when no spot fits. Its anchor class (USS) picks which
/// of the three spots above the kit is tried first; the spots are applied as a pixel shift on the slot's translate (no
/// class change, so no style pass). A spot fits when the pill lies wholly on screen and clear of every panel
- /// (OccluderNames: the top bar, the left icon column, the info panel, the minimap and its map-layer caption, the event card), does not
+ /// (OccluderNames: the top bar and its hanging date plate, the left icon column, the info panel, the minimap and its map-layer caption, the event card), does not
/// overlap an already placed pill (its last laid-out size plus MarginPx), covers at most MaxKitCover of its own kit's
/// rectangle and of every other visible kit's, and is more than twice as far from every other visible marker's top as
/// from its own kit (the kit alone, not the tokens on it), plus MarginPx, so no name reads as a neighbour's. Whatever
@@ -75,7 +75,7 @@ namespace Statecraft.Game.UI
/// visible kit's.</summary>
public const float MaxKitCover = 0.1f;
/// <summary>The panels a pill never sits under (Game.uxml names).</summary>
- public static readonly string[] OccluderNames = { "top-bar", "left-column", "info-panel", "minimap", "map-layer", "event-card" };
+ public static readonly string[] OccluderNames = { "top-bar", "date-plate", "left-column", "info-panel", "minimap", "map-layer", "event-card" };
const string Centre = "anchor-lower-centre", Left = "anchor-lower-left", Right = "anchor-lower-right";
diff --git a/unity/Assets/Tests/EditMode/DecisionCardTests.cs b/unity/Assets/Tests/EditMode/DecisionCardTests.cs
index ac6f77d15..471da27ca 100644
--- a/unity/Assets/Tests/EditMode/DecisionCardTests.cs
+++ b/unity/Assets/Tests/EditMode/DecisionCardTests.cs
@@ -100,12 +100,15 @@ public class DecisionCardTests
Assert.IsTrue(r.Shows("event-scrim"), $"{where}: the backdrop shows");
Covered(r, true, where);
// A point of the map clear of every panel: the backdrop takes it, so a map click or drag stops there.
- // (The window's left edge just under the bar, inside the left icon column's strip: the backdrop's gutter takes it,
- // review of #602; and just right of the column the backdrop itself.)
+ // (The window's left edge just under the bar: the backdrop's full-width band takes it, review of #624; beside the
+ // left column's discs its strip does, review of #602; and just right of the column the backdrop itself.)
var bar = r.Root.Q("top-bar").worldBound.yMax;
var edge = new Vector2(4f, bar + 4f);
- Assert.AreSame(r.Root.Q("event-gutter"), r.Root.panel.Pick(edge), $"{where}: the backdrop's strip under the column takes the pointer at {edge}");
- var free = new Vector2(r.Root.Q("left-column").worldBound.xMax + 4f, bar + 4f);
+ Assert.AreSame(r.Root.Q("event-scrim-top"), r.Root.panel.Pick(edge), $"{where}: the backdrop's band under the bar takes the pointer at {edge}");
+ var cabinet = r.Root.Q("nav-cabinet").worldBound;
+ var beside = new Vector2(4f, cabinet.center.y);
+ Assert.AreSame(r.Root.Q("event-gutter"), r.Root.panel.Pick(beside), $"{where}: the backdrop's strip beside the column takes the pointer at {beside}");
+ var free = new Vector2(r.Root.Q("left-column").worldBound.xMax + 4f, r.Root.Q("left-column").worldBound.yMin + 4f);
Assert.AreSame(r.Root.Q("event-scrim"), r.Root.panel.Pick(free), $"{where}: the backdrop takes the pointer at {free}");
Assert.AreSame(r.CardElement, r.Focused, $"{where}: the new event's card has the focus, no option lit");
Assert.IsTrue(r.FirstOption.canGrabFocus, $"{where}: its options are in reach");
diff --git a/unity/Assets/Tests/EditMode/MapLabelTests.cs b/unity/Assets/Tests/EditMode/MapLabelTests.cs
index e5f3bd514..b4826de9d 100644
--- a/unity/Assets/Tests/EditMode/MapLabelTests.cs
+++ b/unity/Assets/Tests/EditMode/MapLabelTests.cs
@@ -877,6 +877,36 @@ public class MapLabelTests
finally { inset.Dispose(); labels.Dispose(); hd.Dispose(); }
}
+ /// <summary>Review of #624: the date plate hangs below the 70 px bar, so the bar's box no longer covers it, and a pill
+ /// under the plate must hide as under any panel. The plate is made larger here so that towns certainly lie under it
+ /// (checked first, so the test is not vacuous); no shown pill may overlap it.</summary>
+ [UnityTest]
+ public IEnumerator APillUnderTheHangingPlateIsHidden()
+ {
+ var hd = new HdPanel(cam);
+ var labels = new MapLabelsPresenter(hd.Root, map, cam);
+ try
+ {
+ PromoPose.Gameplay03.Apply(rig, map.Frame);
+ var plateEl = hd.Root.Q<VisualElement>("date-plate");
+ Assert.IsNotNull(plateEl, "the plate is named date-plate");
+ plateEl.style.height = 700f; plateEl.style.width = 900f; // over the coast and Tel Aviv's district at gameplay03
+ for (int i = 0; i < 4; i++) yield return null;
+ yield return Settle(labels);
+ var plate = plateEl.worldBound;
+ var bar = hd.Root.Q<VisualElement>("top-bar").worldBound;
+ var under = map.Settlements.Where(t => { var p = hd.ToPanel(MarkerTopOf(t.Id), out bool front); return front && plate.Contains(p) && p.y > bar.yMax; }).Select(t => t.Id).ToList();
+ TestContext.WriteLine($"plate {plate}; towns under it: {string.Join(", ", under)}");
+ Assert.IsNotEmpty(under, "precondition: some towns lie under the plate");
+ foreach (var slot in labels.Slots.Where(Shown))
+ {
+ var r = slot.Q<Label>().worldBound;
+ Assert.IsFalse(r.Overlaps(plate), $"{slot.name} {r} is shown under the hanging plate {plate}");
+ }
+ }
+ finally { labels.Dispose(); hd.Dispose(); }
+ }
+
/// <summary>One step of the camera sweep the refresh tests share: a turn of 1.5 degrees and a zoom from 60 km out to
/// the farthest, over 240 steps, so that every refresh sees a new view.</summary>
void SweepStep(int i)
diff --git a/unity/Assets/Tests/EditMode/PromoHudTests.cs b/unity/Assets/Tests/EditMode/PromoHudTests.cs
index 871dc772e..c2dff1477 100644
--- a/unity/Assets/Tests/EditMode/PromoHudTests.cs
+++ b/unity/Assets/Tests/EditMode/PromoHudTests.cs
@@ -139,12 +139,16 @@ public class PromoHudTests
// (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).
+ // HUD round 2 moved the four screen buttons to the left column (#602), so the bar holds about 248 px less and every
+ // tier starts that much narrower (part 3): 16:10 and 4:3 now keep the one-row bar with its icons; 5:4 the stacked bar
+ // with them. At 1024x768 the owner's text floor (#624) raises the small text to 20 px, and the bar takes the stacked
+ // tier without icons (HudPresenter.FloorGrowth).
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),
+ (1920, 1200, true, false, false, false), (1440, 900, true, false, false, false),
+ (1024, 768, false, true, false, false), (1280, 1024, true, true, false, false),
+ (1024, 1024, false, true, false, 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);
@@ -232,14 +236,16 @@ public class PromoHudTests
var used = meters[meters.Count - 1].worldBound.xMax - meters[0].worldBound.xMin;
var limit = twoRow ? barRect.xMax - 14f : root.Q("nav").worldBound.xMin;
Assert.GreaterOrEqual(limit - meters[meters.Count - 1].worldBound.xMax, 0.05f * used, $"{where}: the meters use {used:0} of {limit - meters[0].worldBound.xMin:0} px");
- // Review P2: every screen button's caption fits its button.
- foreach (var nb in root.Q("nav").Query<Button>().ToList())
+ // Review P2: every screen button's caption fits its button (an icon-only button draws no caption: part 3).
+ foreach (var nb in root.Q("nav").Query<Button>().ToList().Where(b => b.resolvedStyle.color.a > 0.01f))
{
var natural = nb.MeasureTextSize(nb.text, 0, VisualElement.MeasureMode.Undefined, 0, VisualElement.MeasureMode.Undefined);
Assert.LessOrEqual(natural.x, nb.contentRect.width + 0.5f, $"{where}: the caption '{nb.text}' ({natural.x:0} px) overflows its button ({nb.contentRect.width:0} px)");
}
- foreach (var e in new[] { root.Q("nav"), root.Q(className: "turn-box"), badge })
+ foreach (var e in new[] { root.Q("nav"), root.Q(className: "turn-box") })
Assert.LessOrEqual(e.worldBound.yMax, barRect.yMax + 0.5f, $"{where}: {e.name}{string.Join(".", e.GetClasses())} leaves the bar");
+ // The date plate may hang below the one-row bar, as promo 03's does (part 3), but never past the panels under it.
+ Assert.LessOrEqual(badge.worldBound.yMax, root.Q("left-column").worldBound.yMin, $"{where}: the plate {badge.worldBound} reaches the left column");
Assert.GreaterOrEqual(root.Q("right-column").worldBound.yMin, barRect.yMax, where + ": the minimap column starts under the bar");
var screen = root.Q("screen-why");
screen.style.display = DisplayStyle.Flex; // opened, as ScreenNav does
diff --git a/unity/Assets/Tests/EditMode/TopBarScoreLayoutTests.cs b/unity/Assets/Tests/EditMode/TopBarScoreLayoutTests.cs
index 2ee2073d6..a562014cf 100644
--- a/unity/Assets/Tests/EditMode/TopBarScoreLayoutTests.cs
+++ b/unity/Assets/Tests/EditMode/TopBarScoreLayoutTests.cs
@@ -36,8 +36,15 @@ public class TopBarScoreLayoutTests
inner.xMin >= outer.xMin - 0.5f && inner.xMax <= outer.xMax + 0.5f && inner.yMin >= outer.yMin - 0.5f && inner.yMax <= outer.yMax + 0.5f;
/// <summary>The label's text, measured on one line, fits its own box.</summary>
- static bool Whole(TextElement l) =>
- l.MeasureTextSize(l.text, 0, VisualElement.MeasureMode.Undefined, 0, VisualElement.MeasureMode.Undefined).x <= l.contentRect.width + 1f;
+ /// <summary>The label's text is not clipped: on one line, or (with #624's text floor, which lets the plate's date wrap at
+ /// the largest sizes) wrapped within its box's height.</summary>
+ static bool Whole(TextElement l)
+ {
+ var box = l.contentRect;
+ if (l.MeasureTextSize(l.text, 0, VisualElement.MeasureMode.Undefined, 0, VisualElement.MeasureMode.Undefined).x <= box.width + 1f) return true;
+ if (l.resolvedStyle.whiteSpace != WhiteSpace.Normal) return false;
+ return l.MeasureTextSize(l.text, box.width, VisualElement.MeasureMode.Exactly, 0, VisualElement.MeasureMode.Undefined).y <= box.height + 1f;
+ }
static bool Apart(Rect a, Rect b) => !Rect.MinMaxRect(a.xMin + 0.5f, a.yMin + 0.5f, a.xMax - 0.5f, a.yMax - 0.5f).Overlaps(b);
diff --git a/unity/Assets/Tests/EditMode/TopBarTests.cs b/unity/Assets/Tests/EditMode/TopBarTests.cs
new file mode 100644
index 000000000..b4b7a82d9
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/TopBarTests.cs
@@ -0,0 +1,434 @@
+#nullable enable
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using NUnit.Framework;
+using Statecraft.Game;
+using Statecraft.Game.UI;
+using Statecraft.Sim;
+using UnityEditor;
+using UnityEngine;
+using UnityEngine.TestTools;
+using UnityEngine.UIElements;
+
+/// <summary>HUD round 2, part 3 (#398): the top bar at about 6.5% of the frame's height, as promo/final/03 and demo2 T29 draw
+/// it: the date plate hangs below the bar at its start, the meters take one line of caption and one of value and change, New
+/// Game is a round icon named by its tip, and End Turn with the attention line fits the bar. Checked at InfoPanelLayoutTests'
+/// 19 window sizes in English and Hebrew (the Hebrew UI mirrors the bar's row, #550), after a turn, with the widest
+/// late-game values and date, and with the GDD loop's score on the plate's year line (#598), as wide as
+/// TopBarScoreLayoutTests'.</summary>
+public class TopBarTests
+{
+ static readonly Content C = ContentLoader.Load(Paths.Content);
+ static UiText En => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);
+ static UiText He => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");
+
+ static readonly (int w, int h)[] Windows =
+ {
+ (1920, 1080), (1280, 720), (1366, 768), (1760, 1000), (1920, 1200), (1440, 900), (1680, 1050), (1024, 768), (1280, 1024),
+ (1024, 1024), (960, 1080), (800, 1000), (1531, 784), (2560, 1080), (1920, 900), (1600, 757), (1366, 657), (960, 600), (390, 844),
+ };
+
+ /// <summary>Windows at the one-row tier's edge (review of #624), by their logical width. The panel scales by the plain mean of
+ /// the two ratios (match 0.5: scale = (w/1920 + h/1080) / 2, logged by TheOneRowBarReachesFiveByFour), so a fullscreen
+ /// 5:4 is 1585, 4:3 is 1646 and a square 1382, not the geometric mean's 1610, 1662 and 1440. Widths 1610, 1612 and 1662,
+ /// fullscreen 5:4 and 4:3, either side of NarrowBelowPx (1642 one row, 1635 stacked), and a square window. At 1563-1612
+ /// the one-row bar wrapped "Public Support" and "International Standing" (the captions' names then; #622 and #683 renamed them) with the widest values (this round's first
+ /// run), so 5:4 takes the stacked bar with its icons. (With the edge moved back to 1612, the one-row bar still fit at
+ /// 1635: the edge's place between 5:4 and 4:3 is a margin, not a measured limit.) A 4:3 window as large as 1600x1200
+ /// keeps the one-row bar; at 1024x768 the owner's text floor (TheBarsSmallTextKeepsTheFloorOnScreen) raises the small text
+ /// to 20 px, which takes the stacked bar without icons (HudPresenter.FloorGrowth).</summary>
+ static readonly (int w, int h, bool oneRow)[] Boundary =
+ { (1315, 1024, false), (1317, 1024, false), (1389, 1024, true), (1280, 1024, false), (1600, 1200, true), (1024, 768, false),
+ (1360, 1024, true), (1350, 1024, false), (1024, 1024, false) };
+
+ /// <summary>The 16:9 windows, promo 03's frame shape. (21:9 is drawn larger: the panel scales by the plain mean of the two
+ /// ratios, so a 2560x1080 window has 926 panel rows; its share is logged, not pinned.)</summary>
+ static readonly (int w, int h)[] PromoShapes = { (1920, 1080), (1280, 720), (1366, 768) };
+
+ /// <summary>The real Game.uxml on the real PanelSettings at w x h, in English or Hebrew, as the game builds it: the bar laid
+ /// out (the loading screen) before the HUD is made, a turn played, then the widest values, changes and date, and a
+ /// score in the plate. <paramref name="widest"/> false keeps the turn-1 values. <paramref name="collapsed"/> (with
+ /// <paramref name="withEvent"/>) hides the open card to its "Decision waiting" button, as Hide does.</summary>
+ static IEnumerator Rendered(int w, int h, bool hebrew, System.Action<VisualElement, UiText> check, bool widest = true, bool withEvent = false,
+ bool collapsed = false)
+ {
+ var text = hebrew ? He : En;
+ var rt = new RenderTexture(w, h, 0);
+ var ps = Object.Instantiate(AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel));
+ ps.targetTexture = rt;
+ var go = new GameObject("TopBarTest");
+ 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;
+ if (hebrew) root.Q("root").AddToClassList(UiLanguage.HebrewClass);
+ HudPresenter? hud = null; UiDirection? dir = null; EventCardPresenter? card = null; ScreenNav? nav = null;
+ try
+ {
+ for (int i = 0; i < 20 && !(root.Q("top-bar").worldBound.width > 0); i++) yield return null;
+ root.Q("root").RemoveFromClassList("loading");
+ var session = GameSession.New(C, GoldenRun.Seed, Mode.Historical);
+ var bridge = new SimBridge(session, text);
+ hud = new HudPresenter(root, bridge, text);
+ if (withEvent) { nav = new ScreenNav(root); card = new EventCardPresenter(root, bridge, text, null); }
+ if (hebrew) dir = new UiDirection(root, bridge);
+ bridge.EndTurn();
+ if (withEvent)
+ for (int t = 0; bridge.State.PendingEvents.Count == 0; t++) { if (t >= 50) Assert.Fail("no event within 50 turns"); bridge.EndTurn(); }
+ if (collapsed) card!.Collapse();
+ for (int i = 0; i < 6; i++) yield return null;
+ var toast = root.Q<Label>("toast");
+ toast.text = text["hud.new_game"]; toast.style.display = DisplayStyle.Flex; // shown, so its place is checked
+ // The GDD loop's score on the plate's year line (#598), at TopBarScoreLayoutTests' worst case.
+ var score = root.Q<Label>("score");
+ Assert.IsNotNull(score, "the plate has #598's score label");
+ score.text = hebrew ? "ניקוד 99,999" : "Score 99,999";
+ score.style.display = DisplayStyle.Flex;
+ if (widest)
+ {
+ 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;
+ foreach (var (name, value) in new[] { ("treasury", PlayerText.Money(C, "treasury", -123.4)), ("immigration", text.Format("hud.people", 123456.0)),
+ ("fx", PlayerText.Money(C, "fx_reserves", 123.4)), ("security", "100%"), ("support", "100%"), ("standing", "100%") })
+ root.Q<Label>(name + "-value").text = value;
+ root.Q<Label>("security-level").text = text.Format("hud.level", 5);
+ 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)));
+ root.Q<Label>("attention").text = text.Format("hud.attention", 4.0, 4.0);
+ }
+ dir?.Apply();
+ for (int i = 0; i < 8; i++) yield return null;
+ Assert.AreEqual(DisplayStyle.Flex, score.resolvedStyle.display, "precondition: the score shows, so its room is checked");
+ check(root, text);
+ }
+ finally
+ {
+ card?.Dispose(); dir?.Dispose(); hud?.Dispose();
+ Object.DestroyImmediate(go); Object.DestroyImmediate(ps); rt.Release(); Object.DestroyImmediate(rt);
+ }
+ }
+
+ /// <summary>A label's text fits its box: on one line, or wrapped within its height (InfoPanelLayoutTests).</summary>
+ static bool TextFits(TextElement l)
+ {
+ var box = l.contentRect;
+ var natural = l.MeasureTextSize(l.text, 0, VisualElement.MeasureMode.Undefined, 0, VisualElement.MeasureMode.Undefined);
+ if (natural.x <= box.width + 1f && natural.y <= box.height + 1f) return true;
+ if (l.resolvedStyle.whiteSpace != WhiteSpace.Normal) return false;
+ var wrapped = l.MeasureTextSize(l.text, box.width, VisualElement.MeasureMode.Exactly, 0, VisualElement.MeasureMode.Undefined);
+ return wrapped.y <= box.height + 1f;
+ }
+
+ static bool Inside(Rect inner, Rect outer, float slack = 0.5f) =>
+ inner.xMin >= outer.xMin - slack && inner.xMax <= outer.xMax + slack && inner.yMin >= outer.yMin - slack && inner.yMax <= outer.yMax + slack;
+
+ static bool Shown(VisualElement e)
+ {
+ for (var x = e; x != null; x = x.parent) if (x.resolvedStyle.display == DisplayStyle.None) return false;
+ return true;
+ }
+
+ /// <summary>Promo 03 and T29: the one-row bar is about 6.5% of the frame's height (T54: main's was 8.8%), and the date
+ /// plate hangs below it, as promo 03's "1936 / Turn 1 / January 1936" plate does (about 8.6% of the height).</summary>
+ [UnityTest]
+ public IEnumerator TheOneRowBarIsAboutSixAndAHalfPercentOfTheFrame()
+ {
+ var problems = new List<string>();
+ foreach (var hebrew in new[] { false, true })
+ foreach (var (w, h) in PromoShapes)
+ yield return Rendered(w, h, hebrew, (root, text) =>
+ {
+ string at = $"{(hebrew ? "he" : "en")} {w}x{h}";
+ var frame = root.worldBound;
+ var bar = root.Q("top-bar").worldBound;
+ float share = bar.height / frame.height;
+ TestContext.WriteLine($"{at}: bar {bar.height:0} of {frame.height:0} = {share:P1}; plate {root.Q(className: "date-box").worldBound}");
+ if (root.Q("root").ClassListContains(HudPresenter.NarrowClass) || root.Q("root").ClassListContains(HudPresenter.TwoRowClass))
+ problems.Add($"{at}: not the one-row bar");
+ if (share < 0.060f || share > 0.070f) problems.Add($"{at}: the bar is {share:P1} of the frame (promo 03 and T29: 6.5%)");
+ var plate = root.Q(className: "date-box").worldBound;
+ if (!(plate.yMax > bar.yMax + 4f)) problems.Add($"{at}: the date plate {plate} does not hang below the bar {bar}");
+ }, widest: false);
+ Assert.IsEmpty(problems, string.Join("\n", problems));
+ }
+
+ /// <summary>At every window size, in English and Hebrew, with the widest values: no text in the bar or the plate is
+ /// clipped (meters, date, score, Attention, End Turn, New Game's tip text aside); the meters, the plate, New Game and the
+ /// turn box do not overlap and stay in the window; the meters' labels stay in the bar; the row mirrors in Hebrew (the plate
+ /// at the bar's right end, End Turn at its left); and every panel under the bar, and under the hanging plate, starts below
+ /// them.</summary>
+ [UnityTest]
+ public IEnumerator TheBarFitsEveryWindowInEnglishAndHebrew()
+ {
+ var problems = new List<string>();
+ foreach (var hebrew in new[] { false, true })
+ foreach (var (w, h) in Windows.Concat(Boundary.Select(b => (b.w, b.h))).Distinct())
+ yield return Rendered(w, h, hebrew, (root, text) =>
+ {
+ string at = $"{(hebrew ? "he" : "en")} {w}x{h}";
+ var frame = root.worldBound;
+ var barEl = root.Q("top-bar");
+ var bar = barEl.worldBound;
+ var plateEl = root.Q(className: "date-box");
+ var plate = plateEl.worldBound;
+ var turnBox = root.Q(className: "turn-box").worldBound;
+ var newGame = root.Q("new-game").worldBound;
+ var meters = root.Q("meters").Children().ToList();
+ // Preconditions: nothing below is checked against an empty rect.
+ foreach (var (name, r) in new[] { ("bar", bar), ("plate", plate), ("turn box", turnBox), ("New Game", newGame) })
+ if (!(r.width > 0 && r.height > 0)) problems.Add($"{at}: precondition: the {name} is laid out");
+ foreach (var l in barEl.Query<Label>().ToList().Concat<TextElement>(barEl.Query<Button>().ToList().Where(b => b.name == "end-turn"))
+ .Where(l => !string.IsNullOrEmpty(l.text) && Shown(l)))
+ {
+ if (!TextFits(l)) problems.Add($"{at}: '{l.text}' ({l.name}) is clipped in {l.contentRect}");
+ if (!Inside(l.worldBound, frame)) problems.Add($"{at}: '{l.text}' {l.worldBound} leaves the window");
+ }
+ foreach (var l in plateEl.Query<Label>().ToList().Where(l => !string.IsNullOrEmpty(l.text) && Shown(l)))
+ if (!Inside(l.worldBound, plate)) problems.Add($"{at}: '{l.text}' {l.worldBound} leaves the plate {plate}");
+ foreach (var m in meters)
+ foreach (var l in m.Query<Label>().ToList().Where(l => !string.IsNullOrEmpty(l.text) && Shown(l)))
+ {
+ if (!Inside(l.worldBound, bar, 1f)) problems.Add($"{at}: '{l.text}' {l.worldBound} leaves the bar {bar}");
+ if (!Inside(l.worldBound, m.worldBound, 1f)) problems.Add($"{at}: '{l.text}' leaves {m.name} {m.worldBound}");
+ }
+ var blocks = new List<(string name, Rect r)> { ("the plate", plate), ("New Game", newGame), ("the turn box", turnBox) };
+ blocks.AddRange(meters.Select(m => (m.name, m.worldBound)));
+ // Neighbours in a row touch; a half-pixel inset keeps float rounding at a shared edge from counting as overlap.
+ static Rect In(Rect r) => new Rect(r.x + 0.5f, r.y + 0.5f, r.width - 1f, r.height - 1f);
+ for (int i = 0; i < blocks.Count; i++)
+ {
+ if (!Inside(blocks[i].r, frame)) problems.Add($"{at}: {blocks[i].name} {blocks[i].r} leaves the window");
+ for (int j = i + 1; j < blocks.Count; j++)
+ if (In(blocks[i].r).Overlaps(In(blocks[j].r))) problems.Add($"{at}: {blocks[i].name} {blocks[i].r} overlaps {blocks[j].name} {blocks[j].r}");
+ }
+ if (!Inside(newGame, bar) || !Inside(turnBox, bar)) problems.Add($"{at}: New Game {newGame} or the turn box {turnBox} leaves the bar {bar}");
+ // The row mirrors in Hebrew (#550): the plate at the reading start, End Turn at the end.
+ bool plateFirst = hebrew ? plate.center.x > turnBox.center.x : plate.center.x < turnBox.center.x;
+ if (!plateFirst) problems.Add($"{at}: the plate {plate} is not at the {(hebrew ? "right" : "left")} of End Turn {turnBox}");
+ // Everything under the bar starts below it, and below the plate where it lies under the plate.
+ var screen = root.Q("screen-why");
+ foreach (var name in new[] { "right-column", "left-column", "event-layer", "toast" })
+ {
+ var e = root.Q(name);
+ var r = e.worldBound;
+ if (!(r.height > 0)) problems.Add($"{at}: precondition: {name} is laid out");
+ if (r.yMin < bar.yMax - 0.5f) problems.Add($"{at}: {name} {r} starts in the bar {bar}");
+ if (r.xMin < plate.xMax && r.xMax > plate.xMin && r.yMin < plate.yMax - 0.5f && name != "event-layer" && name != "right-column")
+ problems.Add($"{at}: {name} {r} starts under the hanging plate {plate}");
+ }
+ });
+ Assert.IsEmpty(problems, string.Join("\n", problems));
+ }
+
+ /// <summary>With a card hidden, its "Decision waiting" button (the real element, laid out, review of #624: it was a guessed
+ /// 260 x 40 corner) is clear of the hanging plate and of the bar, at every window size and in both languages.</summary>
+ [UnityTest]
+ public IEnumerator DecisionWaitingIsClearOfThePlate()
+ {
+ var problems = new List<string>();
+ foreach (var hebrew in new[] { false, true })
+ foreach (var (w, h) in Windows.Concat(Boundary.Select(b => (b.w, b.h))).Distinct())
+ yield return Rendered(w, h, hebrew, (root, text) =>
+ {
+ string at = $"{(hebrew ? "he" : "en")} {w}x{h}";
+ var button = root.Q<Button>("event-reopen");
+ var waiting = button.worldBound;
+ if (button.resolvedStyle.display != DisplayStyle.Flex || !(waiting.width > 0) || !(waiting.height > 0) || button.text != text["event.reopen"])
+ { problems.Add($"{at}: precondition: Decision waiting shows ({waiting}, '{button.text}')"); return; }
+ var plate = root.Q("date-plate").worldBound;
+ var bar = root.Q("top-bar").worldBound;
+ if (waiting.Overlaps(plate)) problems.Add($"{at}: Decision waiting {waiting} lies under the plate {plate}");
+ if (waiting.Overlaps(bar)) problems.Add($"{at}: Decision waiting {waiting} lies under the bar {bar}");
+ }, withEvent: true, collapsed: true);
+ Assert.IsEmpty(problems, string.Join("\n", problems));
+ }
+
+ /// <summary>Review of #624: the one-row bar's edge. 4:3 (1646 logical px) and 1662 keep the one-row bar with its icons; a
+ /// fullscreen 5:4 (1585) and 1610 or 1612 take the stacked bar with its icons (the one-row bar does not hold the widest
+ /// values there); just above NarrowBelowPx (1642) one row, just below (1635) stacked; a square window (1382) the stacked
+ /// bar without icons. The logical widths are logged, the numbers HudPresenter's notes quote.</summary>
+ [UnityTest]
+ public IEnumerator TheOneRowBarReachesFiveByFour()
+ {
+ var problems = new List<string>();
+ foreach (var (w, h, oneRow) in Boundary)
+ yield return Rendered(w, h, false, (root, text) =>
+ {
+ var r = root.Q("root");
+ bool narrow = r.ClassListContains(HudPresenter.NarrowClass);
+ TestContext.WriteLine($"{w}x{h}: panel {root.worldBound.width:0.0} x {root.worldBound.height:0.0}, bar {root.Q("top-bar").worldBound.width:0.0}; narrow {narrow}, compact {root.Q("top-bar").ClassListContains(HudPresenter.CompactClass)}, two rows {r.ClassListContains(HudPresenter.TwoRowClass)}");
+ if (narrow == oneRow) problems.Add($"{w}x{h} ({root.Q("top-bar").worldBound.width:0} px): {(oneRow ? "not the one-row bar" : "the one-row bar")}");
+ if (oneRow && root.Q("top-bar").ClassListContains(HudPresenter.CompactClass)) problems.Add($"{w}x{h}: the one-row bar dropped its icons");
+ });
+ Assert.IsEmpty(problems, string.Join("\n", problems));
+ }
+
+ /// <summary>A smaller bar must not open a gap in the decision card's backdrop (the fail-open of #602's review): with a
+ /// card open, at every window size and in both languages, the backdrop's full-width band starts at the bar's bottom and
+ /// reaches the column's top, where the column's strip takes over; points just under the bar are the band's; and the
+ /// hanging date plate is dimmed evenly, by the band alone, across its width (review of #624: it was dimmed from x = 72
+ /// with a hard edge).</summary>
+ [UnityTest]
+ public IEnumerator WithACardOpenTheBackdropMeetsTheBar()
+ {
+ var problems = new List<string>();
+ foreach (var hebrew in new[] { false, true })
+ foreach (var (w, h) in Windows)
+ yield return Rendered(w, h, hebrew, (root, text) =>
+ {
+ string at = $"{(hebrew ? "he" : "en")} {w}x{h}";
+ if (!root.Q("root").ClassListContains(EventCardPresenter.ModalClass)) { problems.Add($"{at}: precondition: the card is open"); return; }
+ var bar = root.Q("top-bar").worldBound;
+ var band = root.Q("event-scrim-top").worldBound;
+ var scrim = root.Q("event-scrim").worldBound;
+ var gutter = root.Q("event-gutter").worldBound;
+ var column = root.Q("left-column").worldBound;
+ if (!(band.height > 0) || !(scrim.height > 0) || !(gutter.height > 0)) { problems.Add($"{at}: precondition: the backdrop shows"); return; }
+ if (Mathf.Abs(band.yMin - bar.yMax) > 0.5f) problems.Add($"{at}: the band starts at {band.yMin:0}, not at the bar's bottom {bar.yMax:0}");
+ if (band.xMin > root.worldBound.xMin + 0.5f || band.xMax < root.worldBound.xMax - 0.5f) problems.Add($"{at}: the band {band} is not the window's width");
+ if (band.yMax < scrim.yMin - 0.5f || band.yMax < gutter.yMin - 0.5f) problems.Add($"{at}: a gap between the band {band} and the backdrop {scrim} or the strip {gutter}");
+ if (band.yMax > column.yMin + 0.5f) problems.Add($"{at}: the band {band} reaches over the column's discs {column}");
+ foreach (var x in new[] { 0.1f, 0.5f, 0.9f })
+ {
+ var probe = new Vector2(root.worldBound.width * x, bar.yMax + 2f);
+ var picked = root.panel.Pick(probe);
+ if (picked != root.Q("event-scrim-top")) problems.Add($"{at}: {probe}, just under the bar, is {(picked == null ? "the map" : picked.name)}, not the band");
+ }
+ var plate = root.Q("date-plate").worldBound;
+ if (scrim.yMin < plate.yMax - 0.5f && scrim.xMin < plate.xMax && scrim.xMax > plate.xMin) problems.Add($"{at}: the backdrop {scrim} also dims the plate {plate}: two shades");
+ if (gutter.yMin < plate.yMax - 0.5f && gutter.xMax > plate.xMin) problems.Add($"{at}: the column's strip {gutter} lies under the plate {plate}");
+ if (plate.yMax > bar.yMax + 4f)
+ foreach (var x in new[] { plate.xMin + 6f, plate.center.x, plate.xMax - 6f })
+ {
+ var p = new Vector2(x, (bar.yMax + plate.yMax) / 2);
+ var picked = root.panel.Pick(p);
+ if (picked != root.Q("event-scrim-top")) problems.Add($"{at}: the plate's hanging band at {p} is under {picked?.name ?? "nothing"}, not the band alone");
+ }
+ }, widest: false, withEvent: true);
+ Assert.IsEmpty(problems, string.Join("\n", problems));
+ }
+
+ /// <summary>New Game is a round icon, as promo 03's bar buttons are: its name stays its text (the event log reads it) and
+ /// is its tooltip in both languages, shown beside it on hover and on focus; no caption shows.</summary>
+ [UnityTest]
+ public IEnumerator NewGameIsARoundIconNamedInBothLanguages()
+ {
+ var problems = new List<string>();
+ foreach (var hebrew in new[] { false, true })
+ yield return Rendered(1920, 1080, hebrew, (root, text) =>
+ {
+ string at = hebrew ? "he" : "en";
+ var b = root.Q<Button>("new-game");
+ if (b.text != text["hud.new_game"]) problems.Add($"{at}: its text is '{b.text}'");
+ if (b.tooltip != text["hud.new_game"] || string.IsNullOrWhiteSpace(b.tooltip)) problems.Add($"{at}: its tooltip is '{b.tooltip}'");
+ if (b.resolvedStyle.color.a > 0.01f) problems.Add($"{at}: its caption shows");
+ if (b.Q<UiIcon>(className: "nav-disc")?.Glyph != "restart") problems.Add($"{at}: no restart disc");
+ var tip = root.Q<Label>(HoverTip.TipName);
+ using (var e = PointerEnterEvent.GetPooled(new Event { type = EventType.MouseMove, mousePosition = b.worldBound.center })) { e.target = b; b.SendEvent(e); }
+ if (tip.style.display.value != DisplayStyle.Flex || tip.text != b.tooltip) problems.Add($"{at}: hovering shows no tip");
+ using (var e = PointerLeaveEvent.GetPooled(new Event { type = EventType.MouseMove, mousePosition = Vector2.zero })) { e.target = b; b.SendEvent(e); }
+ if (tip.style.display.value != DisplayStyle.None) problems.Add($"{at}: the tip stays after leave");
+ }, widest: false);
+ Assert.IsEmpty(problems, string.Join("\n", problems));
+ }
+
+ /// <summary>tools/headed.py clicks End Turn at a fixed point of its 1568x752 playtest window, and uses another bar point
+ /// as "a panel" for the wheel checks: both must still land on what they name now that the bar is 70 px (part 3).</summary>
+ [UnityTest]
+ public IEnumerator HeadedPyClicksLandOnTheBar()
+ {
+ var src = System.IO.File.ReadAllText(System.IO.Path.Combine(Paths.RepoRoot, "tools", "headed.py"));
+ Vector2 Point(string pattern)
+ {
+ var m = System.Text.RegularExpressions.Regex.Match(src, pattern);
+ Assert.IsTrue(m.Success, pattern);
+ return new Vector2(float.Parse(m.Groups[1].Value), float.Parse(m.Groups[2].Value));
+ }
+ var endTurn = Point(@"END_TURN, OPTION, MAP_UNDER_WHY = \((\d+), (\d+)\)");
+ var panel = Point(@"WHEEL_VIEWPORT, START_NEW, MAP, PANEL = \(1568, 752\), \(\d+, \d+\), \(\d+, \d+\), \((\d+), (\d+)\)");
+ yield return Rendered(1568, 752, false, (root, text) =>
+ {
+ float scale = 1568f / root.worldBound.width;
+ Rect Css(VisualElement e) { var r = e.worldBound; return new Rect(r.x * scale, r.y * scale, r.width * scale, r.height * scale); }
+ var button = Css(root.Q("end-turn"));
+ TestContext.WriteLine($"1568x752: End Turn at {button} CSS px, centre {button.center}; the bar {Css(root.Q("top-bar"))}");
+ Assert.IsTrue(button.Contains(endTurn), $"headed.py's END_TURN {endTurn} is not on End Turn {button} (centre {button.center})");
+ Assert.IsTrue(Css(root.Q("top-bar")).Contains(panel), $"headed.py's PANEL {panel} is not on the bar {Css(root.Q("top-bar"))}");
+ }, widest: false);
+ }
+
+ /// <summary>The owner's text floor (#624, 15 October 2026): the bar's small text (the six captions, Security's level,
+ /// the attention line, and, by the owner's second answer, the plate's turn and date line) is at least HudPresenter.TextFloorPx (12) on screen at small windows, 1280x720 and 1024x768, in
+ /// both languages; a 1080p window keeps the stylesheet's 15 px. The panel scales with the window, so on screen is the
+ /// font size times the window's pixels per panel pixel. (TheBarFitsEveryWindowInEnglishAndHebrew checks that nothing
+ /// collides at these sizes.)</summary>
+ [UnityTest]
+ public IEnumerator TheBarsSmallTextKeepsTheFloorOnScreen()
+ {
+ var problems = new List<string>();
+ foreach (var hebrew in new[] { false, true })
+ foreach (var (w, h) in new[] { (1280, 720), (1024, 768), (1920, 1080) })
+ yield return Rendered(w, h, hebrew, (root, text) =>
+ {
+ string at = $"{(hebrew ? "he" : "en")} {w}x{h}";
+ float perPanelPx = w / root.worldBound.width;
+ var bar = root.Q("top-bar");
+ var labels = bar.Query<Label>(className: "meter-name").ToList();
+ labels.Add(root.Q<Label>("attention")); // the captions' query also holds security-level (class meter-name)
+ labels.Add(root.Q<Label>("turn")); labels.Add(root.Q<Label>("date")); // the plate's date line
+ labels = labels.Distinct().ToList();
+ if (labels.Count != 10) problems.Add($"{at}: precondition: 10 small labels, found {labels.Count}");
+ foreach (var l in labels)
+ {
+ if (string.IsNullOrEmpty(l.text) || !(l.worldBound.height > 0)) { problems.Add($"{at}: precondition: {l.name} '{l.text}' shows"); continue; }
+ float onScreen = l.resolvedStyle.fontSize * perPanelPx;
+ TestContext.WriteLine($"{at}: {l.name}/{l.parent?.parent?.name} {l.resolvedStyle.fontSize:0.0} px, {onScreen:0.0} on screen");
+ if (onScreen < 12f - 0.05f) problems.Add($"{at}: {l.parent?.parent?.name} {l.name} '{l.text}' is {onScreen:0.0} px on screen, under the 12 px floor");
+ if (w == 1920 && Mathf.Abs(l.resolvedStyle.fontSize - 15f) > 0.01f) problems.Add($"{at}: {l.name} is {l.resolvedStyle.fontSize} px, not the stylesheet's 15");
+ }
+ // The plate's text keeps clear of its gilt frame (reviews of #624 in WebGL: the raised date, then the year,
+ // ran into the corner scrolls): every line, the score included, is at least the frame's inner rule (the inset
+ // plus the filigree's gap, and a pixel) from the plate's top and bottom, and at least 0 px from each of the
+ // four 18 px corner zones (Rect.Overlaps is strict, so a line touching a zone's edge passes: the score does,
+ // at 0.0); a zone is the scrolls' reach (about 14 px) plus 4, so a line at its edge is 4 px clear of a scroll.
+ var plate = root.Q("date-plate").worldBound;
+ float clear = 4f + UiFrame.FiligreeGap + 1f, zone = 14f + 4f;
+ var corners = new[] { new Rect(plate.xMin, plate.yMin, zone, zone), new Rect(plate.xMax - zone, plate.yMin, zone, zone),
+ new Rect(plate.xMin, plate.yMax - zone, zone, zone), new Rect(plate.xMax - zone, plate.yMax - zone, zone, zone) };
+ foreach (var name in new[] { "year", "score", "turn", "date" })
+ {
+ var label = root.Q<Label>(name);
+ var r = label.worldBound;
+ if (!(r.height > 0) || string.IsNullOrEmpty(label.text)) { problems.Add($"{at}: precondition: {name} shows"); continue; }
+ if (r.yMin < plate.yMin + clear - 0.05f) problems.Add($"{at}: {name} {r} starts {r.yMin - plate.yMin:0.0} px below the plate's top {plate.yMin:0.0}, inside its frame (needs {clear})");
+ if (r.yMax > plate.yMax - clear + 0.05f) problems.Add($"{at}: {name} {r} ends {plate.yMax - r.yMax:0.0} px above the plate's bottom {plate.yMax:0.0}, inside its frame (needs {clear})");
+ foreach (var c in corners)
+ if (r.Overlaps(c)) problems.Add($"{at}: {name} {r} enters the corner scroll's zone {c} of the plate {plate}");
+ // The measurements, for the review: the line's room to the plate's top and bottom, and to the nearer
+ // corner zone on either side (horizontal room where the line shares the zone's rows, else vertical).
+ float Room(Rect z) => r.yMax <= z.yMin || r.yMin >= z.yMax ? Mathf.Max(z.yMin - r.yMax, r.yMin - z.yMax) : Mathf.Max(z.xMin - r.xMax, r.xMin - z.xMax);
+ TestContext.WriteLine($"{at}: {name} top {r.yMin - plate.yMin:0.0}, bottom {plate.yMax - r.yMax:0.0}, corners TL {Room(corners[0]):0.0} TR {Room(corners[1]):0.0} BL {Room(corners[2]):0.0} BR {Room(corners[3]):0.0} (panel px; needs {clear} from the top and bottom, and >= 0 from each zone)");
+ }
+ });
+ Assert.IsEmpty(problems, string.Join("\n", problems));
+ }
+
+ /// <summary>The audit's Tab order is kept: Cabinet, Budget, Defence, Why? (the left column), New Game, End Turn, then the
+ /// minimap's buttons.</summary>
+ [UnityTest]
+ public IEnumerator TheTabOrderIsKept()
+ {
+ foreach (var hebrew in new[] { false, true })
+ yield return Rendered(1920, 1080, hebrew, (root, text) =>
+ {
+ var order = root.Query<Button>().ToList().Where(e => e.focusable && e.canGrabFocus && e.tabIndex >= 0)
+ .Select(e => e.name).Where(n => n.StartsWith("nav-") || n == "new-game" || n == "end-turn" || n.StartsWith("minimap-")).ToList();
+ CollectionAssert.AreEqual(new[] { "nav-cabinet", "nav-budget", "nav-defence", "nav-why", "new-game", "end-turn", "minimap-overview", "minimap-labels", "minimap-borders" },
+ order, (hebrew ? "he" : "en") + ": the Tab order");
+ }, widest: false);
+ }
+}
diff --git a/unity/Assets/Tests/EditMode/TopBarTests.cs.meta b/unity/Assets/Tests/EditMode/TopBarTests.cs.meta
new file mode 100644
index 000000000..577959a34
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/TopBarTests.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: ed7f2961aacf041b8bb900ef56d5ea61
\ No newline at end of file
diff --git a/unity/Assets/Tests/EditMode/UiLayoutTests.cs b/unity/Assets/Tests/EditMode/UiLayoutTests.cs
index 5ddd26c1f..767eb0591 100644
--- a/unity/Assets/Tests/EditMode/UiLayoutTests.cs
+++ b/unity/Assets/Tests/EditMode/UiLayoutTests.cs
@@ -280,9 +280,13 @@ public class UiLayoutTests
Assert.GreaterOrEqual(bar.yMin, -0.5f, $"{w}x{h}: the top bar starts above the window");
var labels = root.Q("top-bar").Query<Label>().ToList().Where(l => !string.IsNullOrEmpty(l.text)).ToList();
Assert.Greater(labels.Count, 10, "the HUD filled the bar");
+ // The date plate hangs below the one-row bar, as promo 03's does (HUD round 2, part 3): its lines stay in the plate.
+ var plate = root.Q(className: "date-box").worldBound;
+ Assert.IsTrue(Inside(plate, root.worldBound), $"{w}x{h}: the plate {plate} leaves the window");
foreach (var l in labels)
{
- Assert.IsTrue(Inside(l.worldBound, bar), $"{w}x{h}: '{l.text}' {l.worldBound} is outside the top bar {bar}");
+ bool inPlate = l.GetFirstAncestorOfType<VisualElement>() != null && root.Q(className: "date-box").Contains(l);
+ Assert.IsTrue(Inside(l.worldBound, inPlate ? plate : bar), $"{w}x{h}: '{l.text}' {l.worldBound} is outside the {(inPlate ? "plate " + plate : "top bar " + bar)}");
Assert.GreaterOrEqual(l.worldBound.yMin, bar.yMin + 2f, $"{w}x{h}: '{l.text}' sits flush against the top edge");
}
foreach (var name in new[] { "event-card", "screen-cabinet", "screen-budget", "screen-defence", "screen-why", "toast" })
@@ -337,7 +341,7 @@ public class UiLayoutTests
var inset = new TopBarInset(root, rig);
var bar = root.Q("top-bar").worldBound.height;
var screen = root.panel.visualTree.worldBound.height;
- Assert.Greater(bar, 90f, $"{w}x{h}: the bar is laid out");
+ Assert.Greater(bar, 60f, $"{w}x{h}: the bar is laid out (70 px one-row since HUD round 2, part 3)");
Assert.AreEqual(bar / screen, rig.TopInset, 1e-3f, $"{w}x{h}: the inset is the bar's share of the window");
inset.Dispose();
Assert.AreEqual(0f, rig.TopInset, $"{w}x{h}: disposing gives the screen back");
@@ -396,8 +400,14 @@ public class UiLayoutTests
Rect R(VisualElement e) => e.worldBound;
bool Inside(Rect inner, Rect outer) => inner.xMin >= outer.xMin - 0.5f && inner.xMax <= outer.xMax + 0.5f && inner.yMin >= outer.yMin - 0.5f && inner.yMax <= outer.yMax + 0.5f;
var bar = root.Q("top-bar");
+ var plate = root.Q(className: "date-box"); // hangs below the one-row bar, as promo 03's (HUD round 2, part 3)
+ if (!Inside(R(plate), R(root))) problems.Add($"{w}x{h}: the plate {R(plate)} leaves the window");
foreach (var l in bar.Query<VisualElement>().ToList().Where(e => e != bar && e.resolvedStyle.display == DisplayStyle.Flex))
- if (!Inside(R(l), R(bar))) problems.Add($"{w}x{h}: top bar child {l.name}/{(l as Label)?.text ?? l.GetClasses().FirstOrDefault()} {R(l)} leaves the bar {R(bar)}");
+ {
+ var holder = l == plate || plate.Contains(l) ? (l == plate ? bar : plate) : bar;
+ if (l == plate) continue;
+ if (!Inside(R(l), R(holder))) problems.Add($"{w}x{h}: top bar child {l.name}/{(l as Label)?.text ?? l.GetClasses().FirstOrDefault()} {R(l)} leaves the {(holder == plate ? "plate" : "bar")} {R(holder)}");
+ }
var card = root.Q("event-card");
if (!Inside(R(card), R(root.Q("event-layer")))) problems.Add($"{w}x{h}: event card {R(card)} leaves the decision layer {R(root.Q("event-layer"))}");
if (R(card).yMin < R(bar).yMax - 0.5f) problems.Add($"{w}x{h}: event card {R(card)} starts over the top bar {R(bar)}");
diff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxml
index 606cb6ff1..016b5bae3 100644
--- a/unity/Assets/UI/Game.uxml
+++ b/unity/Assets/UI/Game.uxml
@@ -20,7 +20,7 @@
</ui:VisualElement>
<ui:VisualElement name="top-bar" class="panel top-bar">
<Statecraft.Game.UI.UiFrame corners="false" rule="false" />
- <ui:VisualElement class="date-box">
+ <ui:VisualElement name="date-plate" class="date-box">
<ui:VisualElement class="year-row">
<ui:Label name="year" class="year" />
<ui:Label name="score" class="muted" />
@@ -52,9 +52,9 @@
<ui:VisualElement name="meter-security" class="meter">
<Statecraft.Game.UI.UiIcon glyph="shield" class="meter-icon" />
<ui:VisualElement class="meter-body">
- <ui:Label text="Security" class="meter-name" />
+ <!-- The level beside the caption (HUD round 2, part 3): the bar keeps two lines, as promo 03's meters do. -->
+ <ui:VisualElement class="meter-caption-row"><ui:Label text="Security" class="meter-name" /><ui:Label name="security-level" class="meter-name" /></ui:VisualElement>
<ui:VisualElement class="meter-row"><ui:Label name="security-value" class="meter-value" /><ui:Label name="security-delta" class="meter-delta" /></ui:VisualElement>
- <ui:Label name="security-level" class="meter-name" />
</ui:VisualElement>
</ui:VisualElement>
<ui:VisualElement name="meter-support" class="meter">
@@ -80,7 +80,7 @@
</ui:VisualElement>
</ui:VisualElement>
<ui:VisualElement name="nav" class="nav">
- <ui:Button name="new-game" text="New game" class="nav-button"><Statecraft.Game.UI.UiIcon glyph="restart" class="nav-disc" /></ui:Button>
+ <ui:Button name="new-game" text="New game" class="nav-button bar-button"><Statecraft.Game.UI.UiIcon glyph="restart" class="nav-disc" /></ui:Button>
</ui:VisualElement>
<ui:VisualElement class="turn-box">
<ui:Label name="attention" class="muted" />
@@ -136,6 +136,10 @@
event's photograph). Hidden under the start screen and any open screen (ScreenNav.DisableCovered). -->
<ui:VisualElement name="event-layer" class="event-layer" picking-mode="Ignore">
<ui:VisualElement name="event-scrim" class="event-scrim" />
+ <!-- The backdrop's band from the bar's bottom to the column's top, the window's full width: it dims the hanging date
+ plate evenly and leaves no live strip of map (review of #624). Above the left column's top, so it never
+ covers a disc. -->
+ <ui:VisualElement name="event-scrim-top" class="event-scrim-top" />
<ui:VisualElement name="event-card" class="panel event-card">
<!-- The 16:9 media header: an archival photograph of the event (EventImageCatalog), framed in gold, with its
credit line as a caption strip along its bottom edge, and, for an event with a clip, the Illustration
diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.uss
index d693a8929..a5959ad7a 100644
--- a/unity/Assets/UI/Statecraft.uss
+++ b/unity/Assets/UI/Statecraft.uss
@@ -69,28 +69,32 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
/* Top bar: the date badge, the national indicators (icon, name, value and change), the round screen buttons, attention
and End Turn. */
.top-bar {
- position: absolute; left: 0; right: 0; top: 0; height: 96px;
+ position: absolute; left: 0; right: 0; top: 0; height: 70px;
flex-direction: row; align-items: center;
border-width: 0 0 1px 0; border-radius: 0; padding: 0 14px 0 8px;
border-color: rgba(196, 160, 92, 0.75);
background-color: var(--navy-solid); /* opaque: map labels must not show through it (Task 24 review M7) */
}
-/* Everything in the bar must fit its 96px (EB Garamond lines are about 1.55 x the font size): labels lose their default
- vertical padding and margin, the year is 32px, and turn and date share one line. */
+/* HUD round 2, part 3 (#398): the one-row bar is 70 px, 6.5% of a 16:9 frame, as promo 03's and T29's (T54: it was 96,
+ 8.8%). Everything in it fits two lines (EB Garamond lines are about 1.55 x the font size): labels lose their default
+ vertical padding and margin; the date plate hangs below the bar, as promo 03's "1936 / Turn 1 / January 1936" does. */
.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; 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 10px 0 12px; margin-right: 10px;
+ /* A fixed width, wide enough for the widest line ("Turn 120 30 September 1956"), so the meters never shift when the
+ month changes; at least 98 px tall, so it hangs 28 px below the 70 px bar as promo 03's plate does, and grows if the
+ date wraps to a third line. */
+ flex-shrink: 0; width: 230px; min-height: 98px; align-self: flex-start; justify-content: center;
+ padding: 2px 10px 2px 12px; margin-right: 10px;
background-color: var(--navy-raised); border-width: 1px; border-color: var(--gold-dim); border-radius: 2px;
}
-.date-row { flex-direction: row; }
+/* Turn and date share a line; if they do not fit, the date wraps to a line of its own inside the plate, which grows. */
+.date-row { flex-direction: row; flex-wrap: wrap; }
/* The year, and the GDD loop's score at the line's far end (#380): the year line has the room the date line lacks. */
.year-row { flex-direction: row; justify-content: space-between; align-items: center; }
#score { font-size: 17px; flex-shrink: 0; }
-.date-row Label { font-size: 17px; margin-right: 8px; }
-.year { -unity-font-definition: url("project://database/Assets/UI/Fonts/EBGaramond-SemiBold.ttf"); font-size: 32px; color: var(--ink); }
+.date-row Label { font-size: 15px; margin-right: 8px; }
+.year { -unity-font-definition: url("project://database/Assets/UI/Fonts/EBGaramond-SemiBold.ttf"); font-size: 27px; color: var(--ink); }
.meters { flex-direction: row; flex-grow: 1; align-items: center; }
.meter {
flex-direction: row; align-items: center; min-width: 130px; flex-shrink: 1; padding: 0 7px 0 6px;
@@ -100,15 +104,16 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
.meter-icon { width: 30px; height: 30px; flex-shrink: 1; min-width: 24px; margin-right: 5px; }
/* With room to spare (HudPresenter sets top-bar--roomy on the one-row bar), the promo's sizes. */
.top-bar--roomy .meter-icon { width: 38px; height: 38px; margin-right: 7px; }
-.top-bar--roomy .meter-value { font-size: 25px; }
+.top-bar--roomy .meter-value { font-size: 24px; }
.meter-body { flex-shrink: 1; flex-grow: 1; min-width: 0; }
-.meter-name { font-size: 16px; color: var(--ink); white-space: normal; }
+.meter-name { font-size: 15px; color: var(--ink); white-space: normal; }
+.meter-caption-row { flex-direction: row; align-items: flex-end; }
/* In the bar a long caption wraps rather than widen its meter; on the roomy bar it keeps one line, as in the promo (B8). */
.meter .meter-name { max-width: 120px; }
.top-bar--roomy .meter .meter-name { max-width: none; white-space: nowrap; }
-#security-level { font-size: 14px; color: var(--ink-dim); }
+#security-level { font-size: 15px; color: var(--ink-dim); margin-left: 6px; white-space: nowrap; flex-shrink: 0; }
.meter-row { flex-direction: row; align-items: flex-end; }
-.meter-value { font-size: 22px; color: var(--ink); }
+.meter-value { font-size: 21px; color: var(--ink); }
.meter-delta { font-size: 16px; margin-left: 7px; }
/* The screen buttons: a round, gold-rimmed icon with its name under it (the name keeps them legible without tooltips). */
.nav { flex-direction: row; flex-shrink: 0; align-items: center; }
@@ -121,9 +126,11 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
position: absolute; top: 2px; left: 5px; width: 50px; height: 50px; padding: 11px;
border-radius: 25px; border-width: 1.5px; border-color: var(--gold-dim); background-color: var(--navy-deep);
}
-/* "New game" is the longest caption: its button is wider, its disc centred (PromoHudTests: every caption fits). */
-#new-game { width: 66px; }
-#new-game .nav-disc { left: 8px; }
+/* New Game in the bar, as promo 03's round bar buttons (HUD round 2, part 3): icon-only; its name is its text, drawn clear
+ (the event log reads it), and its tooltip, which HoverTip shows beside it on hover and on focus. */
+#new-game.bar-button { width: 52px; height: 52px; margin: 0 10px; padding: 0; font-size: 1px; color: rgba(0, 0, 0, 0); }
+#new-game.bar-button:hover, #new-game.bar-button:focus, #new-game.bar-button.nav-open { color: rgba(0, 0, 0, 0); }
+#new-game.bar-button .nav-disc { top: 0; left: 0; width: 52px; height: 52px; padding: 13px; border-radius: 26px; }
.nav-button:hover { background-color: rgba(0, 0, 0, 0); color: var(--ink); }
.nav-button:hover .nav-disc { border-color: var(--gold); background-color: var(--navy-raised); }
/* Two separate signals: "open" (ScreenNav's nav-open) is a gold-light rim on a raised disc with a gold caption; keyboard
@@ -136,12 +143,12 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
drop their icons and tighten, as the bar was before the icons. */
.top-bar--compact .meter-icon { display: none; }
.top-bar--compact .date-box { width: 226px; margin-right: 6px; }
-.top-bar--compact .date-row Label { font-size: 16px; margin-right: 6px; }
+.top-bar--compact .date-row Label { font-size: 15px; margin-right: 6px; }
.top-bar--compact .meter { padding: 0 8px; }
/* 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 .left-column, .hud-narrow .event-layer, .hud-narrow .screen, .hud-narrow .toast { top: 140px; }
+.hud-narrow .right-column, .hud-narrow .left-column, .hud-narrow .event-gutter, .hud-narrow .event-layer, .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; }
@@ -150,17 +157,17 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
(78% of the bar, so they always take the first row) above, the screen buttons and End Turn below; the panels move down. */
.hud-two-row .top-bar { height: 216px; padding-top: 6px; padding-bottom: 4px; flex-wrap: wrap; justify-content: space-between; align-content: space-around; }
.hud-two-row .meters { width: 78%; flex-grow: 1; }
-.hud-two-row .right-column, .hud-two-row .left-column, .hud-two-row .event-layer, .hud-two-row .screen, .hud-two-row .toast { top: 232px; }
+.hud-two-row .right-column, .hud-two-row .left-column, .hud-two-row .event-gutter, .hud-two-row .event-layer, .hud-two-row .screen, .hud-two-row .toast { top: 232px; }
/* Narrower still (a phone upright; HudPresenter adds hud-three-row with hud-two-row): the badge, the meters and the
screen buttons with End Turn take a row each, and the panels move down under the taller bar (#210). */
.hud-three-row .top-bar { height: 312px; }
.hud-three-row .meters { width: 100%; }
-.hud-three-row .right-column, .hud-three-row .left-column, .hud-three-row .event-layer, .hud-three-row .screen, .hud-three-row .toast { top: 328px; }
+.hud-three-row .right-column, .hud-three-row .left-column, .hud-three-row .event-gutter, .hud-three-row .event-layer, .hud-three-row .screen, .hud-three-row .toast { top: 328px; }
.turn-box { width: 150px; flex-shrink: 1; min-width: 150px; align-items: flex-end; }
-#attention { font-size: 16px; }
+#attention { font-size: 15px; } /* the audit's floor (H4): 15 px in the stylesheet */
.end-turn {
- -unity-font-definition: url("project://database/Assets/UI/Fonts/EBGaramond-SemiBold.ttf"); font-size: 22px;
- border-color: var(--gold); border-width: 1.5px; color: var(--gold-light); padding: 4px 14px 4px 40px;
+ -unity-font-definition: url("project://database/Assets/UI/Fonts/EBGaramond-SemiBold.ttf"); font-size: 20px;
+ border-color: var(--gold); border-width: 1.5px; color: var(--gold-light); padding: 2px 12px 2px 38px;
}
.end-turn:hover { border-color: var(--gold-light); }
@@ -176,7 +183,7 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
.left-column { position: absolute; left: 16px; top: 112px; width: 56px; align-items: center; }
/* The backdrop's strip under the column (review of #602): from the window's left edge to where the backdrop starts (72 px),
full height (the bar draws over its top), shown and taking the pointer only while the decision card is open. */
-.event-gutter { display: none; position: absolute; left: 0; top: 0; bottom: 0; width: 72px; background-color: rgba(5, 9, 18, 0.55); }
+.event-gutter { display: none; position: absolute; left: 0; top: 112px; bottom: 0; width: 72px; background-color: rgba(5, 9, 18, 0.55); }
.event-modal .event-gutter { display: flex; }
.left-column .rail-button { width: 56px; height: 56px; margin: 0 0 12px 0; padding: 0; font-size: 1px; color: rgba(0, 0, 0, 0); }
.left-column .rail-button:hover, .left-column .rail-button:focus, .left-column .nav-open { color: rgba(0, 0, 0, 0); }
@@ -188,8 +195,15 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
middle. Hide collapses the card to the "Decision
waiting" button at the layer's top right (EventCardPresenter), which takes no more room than itself. */
.event-layer { position: absolute; left: 16px; right: 16px; top: 112px; bottom: 16px; justify-content: center; align-items: center; }
-.event-scrim { display: none; position: absolute; left: 56px; right: -16px; top: -16px; bottom: -16px; background-color: rgba(5, 9, 18, 0.55); }
+.event-scrim { display: none; position: absolute; left: 56px; right: -16px; top: 0; bottom: -16px; background-color: rgba(5, 9, 18, 0.55); }
.event-open .event-scrim { display: flex; }
+/* The backdrop reaches up to the bar's bottom at every tier: a full-width band from the bar to the layer's top (42 px under the
+ 70 px one-row bar, where the date plate hangs; 16 px under the taller tiers' bars), then the layer's own part right of
+ the left column, and the column's strip (event-gutter) beside and below its discs. No strip of map stays live under a
+ card, and the hanging plate is dimmed evenly (review of #624). */
+.event-scrim-top { display: none; position: absolute; left: -16px; right: -16px; top: -42px; height: 42px; background-color: rgba(5, 9, 18, 0.55); }
+.event-open .event-scrim-top { display: flex; }
+.hud-narrow .event-scrim-top, .hud-two-row .event-scrim-top, .hud-three-row .event-scrim-top { top: -16px; height: 16px; }
.event-reopen {
display: none; position: absolute; right: 0; top: 0; margin: 0; padding: 6px 18px; font-size: 20px; -unity-text-align: middle-center;
background-color: var(--navy-solid); border-color: var(--gold); border-width: 1.5px; color: var(--gold-light);