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: on a phone upright the three-row top bar shrinks to fit its rows (Fixes #1089) (#1180)

Beri288b46fe49a3
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 3f52b2dc7..b9f6c0acb 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -56,6 +56,9 @@ checks this (see `CONTRIBUTING.md`).
### Fixed
- Money negatives and changes put the sign next to the number, not the currency ("IL -3.0m", "IL +1.2m"), everywhere the player sees money - top bar, Budget, Why?, the turn report and tooltips - in English and Hebrew (player feedback, 19 October 2026, refs #1107).
+- On a phone held upright the three-row top bar shrinks to fit its rows instead of keeping a fixed 440 px, so no
+ empty band is left between the stats and the map, and Attention and End Turn sit at the bar's bottom; the panels
+ under it move up with it. 440 px is no longer reserved; smaller phones whose rows need more still grow it (#1089).
- Fractional site and city-project carry is hashed as IEEE bits on every runtime, avoiding different decimal spellings on .NET and Unity Mono; gameplay progress is unchanged.
- Site construction forecasts use the current minister rate and saved fractional work, including pioneer promotion.
- On a notched phone the HUD and the panels keep clear of the notch and the home indicator: the root is padded by
diff --git a/unity/Assets/Scripts/UI/HudPresenter.cs b/unity/Assets/Scripts/UI/HudPresenter.cs
index 4d306337d..2f7bd7f99 100644
--- a/unity/Assets/Scripts/UI/HudPresenter.cs
+++ b/unity/Assets/Scripts/UI/HudPresenter.cs
@@ -113,7 +113,7 @@ namespace Statecraft.Game.UI
readonly MeterTip? meterTip;
/// <summary>The panels under the bar (Statecraft.uss: top 456 px under the three-row bar), which PlaceUnderBar moves
- /// down by what the three-row bar grows past its 440 px.</summary>
+ /// by what the three-row bar grows past, or shrinks under, its 440 px (#1089).</summary>
readonly List<VisualElement> underBar;
/// <summary>The bar's items, whose rows set the three-row bar's height (RowsHeight).</summary>
readonly List<VisualElement> barItems;
@@ -340,18 +340,21 @@ namespace Statecraft.Game.UI
plate.style.paddingLeft = Px(PlateSidePx); plate.style.paddingRight = Px(PlateSidePx);
}
- /// <summary>The three-row bar takes its rows' height when that is more than its 440 px (Statecraft.uss), so the raised
- /// text of a smaller phone fits it (#642, the owner: "down to 375x667"), and the panels under it move down by what it
- /// grew: a top margin, not a top, so the stylesheet's other placements (the toast at the bottom beside a wide screen)
- /// still apply. Set here, not as height: auto in the stylesheet: there Yoga sized the wrapping bar as if each quarter-width
- /// meter took a line of its own (about 1300 px). Its items' geometry events re-run this (OnRowGeometry), and so does SetCompact.</summary>
+ /// <summary>The three-row bar takes its rows' height, so the raised text of a smaller phone fits it when that is more than
+ /// its 440 px (Statecraft.uss; #642, the owner: "down to 375x667"), and on a phone whose rows come in shorter no empty band
+ /// is left between the stats and the map (#1089, the owner: "the three-row bar shrinks to fit its rows"). The panels under
+ /// it move by what it grew or shrank: a top margin (negative when it shrank), not a top, so the stylesheet's other
+ /// placements (the toast at the bottom beside a wide screen) still apply. Set here, not as height: auto in the stylesheet:
+ /// there Yoga sized the wrapping bar as if each quarter-width meter took a line of its own (about 1300 px). Its items'
+ /// geometry events re-run this (OnRowGeometry), and so does SetCompact.</summary>
void PlaceUnderBar()
{
// A hidden bar (the start screen) moves nothing: the start screen's toast keeps its own top (review of #859).
var rows = hudRoot.ClassListContains(ThreeRowClass) && bar.resolvedStyle.display != DisplayStyle.None ? RowsHeight() : 0f;
- var grown = rows - ThreeRowBarPx;
- bar.style.height = grown > 0.5f ? new StyleLength(rows) : new StyleLength(StyleKeyword.Null);
- var margin = grown > 0.5f ? new StyleLength(grown) : new StyleLength(StyleKeyword.Null);
+ var grown = rows > 0f ? rows - ThreeRowBarPx : 0f; // NaN before layout or 0 off the three-row bar: the stylesheet's height
+ var fit = UnityEngine.Mathf.Abs(grown) > 0.5f;
+ bar.style.height = fit ? new StyleLength(rows) : new StyleLength(StyleKeyword.Null);
+ var margin = fit ? new StyleLength(grown) : new StyleLength(StyleKeyword.Null);
foreach (var e in underBar) e.style.marginTop = margin;
}
@@ -369,6 +372,7 @@ namespace Statecraft.Game.UI
top = t; bottom = b;
}
if (bottom > top) total += bottom - top;
+ if (!(total > 0f)) return float.NaN; // no laid-out row yet: not just the padding, which would collapse the bar (#1089)
var s = bar.resolvedStyle;
return total + s.paddingTop + s.paddingBottom + s.borderTopWidth + s.borderBottomWidth;
}
diff --git a/unity/Assets/Tests/EditMode/TopBarTests.cs b/unity/Assets/Tests/EditMode/TopBarTests.cs
index 6cdceb546..98fb42f4f 100644
--- a/unity/Assets/Tests/EditMode/TopBarTests.cs
+++ b/unity/Assets/Tests/EditMode/TopBarTests.cs
@@ -582,6 +582,39 @@ public class TopBarTests
Assert.IsEmpty(problems, string.Join("\n", problems));
}
+ /// <summary>#1089 (the owner's ruling, 20 October 2026): on a phone held upright the three-row bar shrinks to fit its rows,
+ /// so no empty band lies between the stats and the map. Its last row (the screen buttons, Attention and End Turn) ends at
+ /// the bar's bottom, the panels under it move up with it (they start at most the stylesheet's 16 px below it; the panel's
+ /// pixel snapping reads it as 14 to 17), and at 390x844 it is at most 440 px tall (the snapping reads 440 as 440.8, hence
+ /// the 441 bound, not an overshoot); in both languages, with turn 1's values and with the widest.</summary>
+ [UnityTest]
+ public IEnumerator OnAPhoneTheBarEndsAtItsLastRow()
+ {
+ var problems = new List<string>();
+ foreach (var hebrew in new[] { false, true })
+ foreach (var widest in new[] { false, true })
+ foreach (var (w, h) in new[] { (390, 844), (360, 800), (375, 667) })
+ yield return Rendered(w, h, hebrew, (root, text) =>
+ {
+ string at = $"{(hebrew ? "he" : "en")} {w}x{h}{(widest ? " widest" : " turn 1")}";
+ if (!root.Q("root").ClassListContains(HudPresenter.ThreeRowClass)) { problems.Add($"{at}: precondition: the three-row bar"); return; }
+ var barEl = root.Q("top-bar");
+ var bar = barEl.worldBound;
+ var s = barEl.resolvedStyle;
+ float last = barEl.Children().Where(k => k.resolvedStyle.position == Position.Relative && Shown(k))
+ .Max(k => k.worldBound.yMax + k.resolvedStyle.marginBottom);
+ float slack = bar.yMax - s.paddingBottom - s.borderBottomWidth - last;
+ var turnBox = root.Q(className: "turn-box").worldBound;
+ var column = root.Q("left-column").worldBound;
+ TestContext.WriteLine($"{at}: bar {barEl.layout.height:0.0} px, last row ends {slack:0.0} px above its bottom, turn box {turnBox}, column top {column.yMin - bar.yMax:0.0} px below it");
+ if (slack > 1f) problems.Add($"{at}: an empty band of {slack:0.0} px between the bar's last row and its bottom {bar.yMax:0.0}");
+ if (!Inside(turnBox, bar)) problems.Add($"{at}: Attention and End Turn {turnBox} leave the bar {bar}");
+ if (column.yMin < bar.yMax - 0.5f || column.yMin > bar.yMax + 18f) problems.Add($"{at}: the column starts {column.yMin - bar.yMax:0.0} px below the bar, not about 16");
+ if (w == 390 && barEl.layout.height > 441f) problems.Add($"{at}: the bar is {barEl.layout.height:0.0} px, over the 440 px maximum");
+ }, widest: widest);
+ Assert.IsEmpty(problems, string.Join("\n", problems));
+ }
+
/// <summary>The audit's Tab order is kept: the side-menu screens, New Game, End Turn, then the
/// minimap's buttons.</summary>
[UnityTest]
diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.uss
index 92f8f8f03..7f621566a 100644
--- a/unity/Assets/UI/Statecraft.uss
+++ b/unity/Assets/UI/Statecraft.uss
@@ -172,7 +172,9 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
changes its rows end at about 431 px; each meter line already holds two caption lines, Security's level or "International
support", so a caption that wraps once more does not add to it). Smaller phones raise it further (26 px at 360x800, 30 px
at 375x667; the owner: the floor holds "down to 375x667", and the bar grows taller to fit, review of #859): the bar takes
- its rows' height when that is more than 440 px, and the panels under it move down by what it grew (HudPresenter.PlaceUnderBar). */
+ its rows' height when that is more than 440 px, and the panels under it move down by what it grew (HudPresenter.PlaceUnderBar).
+ When its rows come in shorter (390x844 with turn 1's values, or in Hebrew), it shrinks to them and the panels move up, so
+ no empty band lies between the stats and the map (#1089, the owner: 440 px "stays as the maximum, not a fixed height"). */
.hud-three-row .top-bar { height: 440px; }
.hud-three-row .meters { width: 100%; flex-wrap: wrap; }
/* Each meter a quarter of the row, so the seven always take two lines (four, then three) and the bar's second line is