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: the top bar counts the exhausted turns, "1 of 3" (Refs #812) (#1961)

Beri642a7758a4ef
diff --git a/changelog.d/laneMC-812.md b/changelog.d/laneMC-812.md
new file mode 100644
index 000000000..6c8978648
--- /dev/null
+++ b/changelog.d/laneMC-812.md
@@ -0,0 +1,2 @@
+- The top bar counts the turns Money and Food have been exhausted together, "Money and Food ran out: turn 1 of 3" (R-END-002), from the
+ third-turn limit in the rules; it shows only while the count is above 0 (English and Hebrew; the Hebrew wording is the owner's) (Refs #812).
diff --git a/unity/Assets/Scripts/UI/HudModel.cs b/unity/Assets/Scripts/UI/HudModel.cs
index 0904a0896..410b36942 100644
--- a/unity/Assets/Scripts/UI/HudModel.cs
+++ b/unity/Assets/Scripts/UI/HudModel.cs
@@ -22,7 +22,7 @@ namespace Statecraft.Game.UI
/// number of immigrants who arrived during the last turn.</summary>
public sealed class HudModel
{
- public string Year = "", Turn = "", Date = "", Attention = "", SecurityLevel = "", Score = "";
+ public string Year = "", Turn = "", Date = "", Attention = "", SecurityLevel = "", Score = "", Exhausted = "";
public Meter Treasury, Immigration, Security, Support, Standing, Fx;
/// <summary>Social cohesion (the morale indicator, R-NAT-001) on the 0-100 scale, shown only in the GDD loop
/// (ShowsCohesion; the owner's ruling of 15 October 2026, #380). Empty in the legacy loop.</summary>
@@ -123,6 +123,10 @@ namespace Statecraft.Game.UI
Attention = c.UsesAttention ? t.Format("hud.attention", b.AttentionLeft!.Value, c.RulesAt(s.Date).AttentionPerTurn) : "",
SecurityLevel = t.Format("hud.level", s.Rung),
Score = c.IsGdd ? t.Format("hud.score", s.Score) : "", // the GDD loop only (#380); PR 6 moves it
+ // R-END-002: shown only while the count is above 0 (Q-DEF-2, #784), against the rules' defeat_turns, so the
+ // player sees how close the economic defeat is; the sim owns the count and the limit, nothing is computed here.
+ Exhausted = s.ExhaustedTurns > 0 && c.RulesAt(s.Date).Mvp?.DefeatTurns is int limit
+ ? t.Format("hud.exhausted", s.ExhaustedTurns, limit) : "",
Treasury = Money("treasury", s.Treasury - s.Debt, prev == null ? (double?)null : prev.Treasury - prev.Debt),
Immigration = People(Arrivals(b.Session.Last), b.BeforeLast == null ? (double?)null : Arrivals(b.BeforeLast)),
Security = Points(s.Indicators["security"], prev?.Indicators["security"]),
diff --git a/unity/Assets/Scripts/UI/HudPresenter.cs b/unity/Assets/Scripts/UI/HudPresenter.cs
index 54ae5e127..6c249e560 100644
--- a/unity/Assets/Scripts/UI/HudPresenter.cs
+++ b/unity/Assets/Scripts/UI/HudPresenter.cs
@@ -139,12 +139,20 @@ namespace Statecraft.Game.UI
/// plate grows.</summary>
readonly List<Label> plateText;
readonly VisualElement? dateRow, captionRow;
+ /// <summary>The exhausted-turn line under the date (Statecraft.uss #exhausted, 13 px, #812): floored like the date, but from
+ /// its own stylesheet size, since 13 px is already under the floor at the scales where 15 px is not (ExhaustedPx).</summary>
+ readonly Label? exhaustedLine;
+ public const float ExhaustedPx = 13f;
+ float exhaustedSize = ExhaustedPx;
/// <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;
+ /// <summary>The stylesheet's side padding of the plate (12 + 10 px, either language); the clearance that replaces it widens
+ /// the plate by the difference, so the turn and the date keep their one row at the 15 px size.</summary>
+ const float StylesheetPlatePadPx = 22f;
readonly VisualElement turnBox;
readonly IVisualElementScheduledItem floorCheck;
readonly EventCallback<GeometryChangedEvent> onRootGeometry;
@@ -238,6 +246,7 @@ namespace Statecraft.Game.UI
dateRow = bar.Q<VisualElement>(className: "date-row");
captionRow = bar.Q(className: "meter-caption-row");
plateText = dateRow?.Query<Label>().ToList() ?? new List<Label>();
+ exhaustedLine = root.Q<Label>("exhausted");
dateRow?.parent?.RegisterCallback<GeometryChangedEvent>(OnPlateGeometry); // a wider raised plate needs room in the bar
ApplyTextFloor();
floorCheck = root.schedule.Execute(ApplyTextFloor).Every(500);
@@ -261,6 +270,8 @@ namespace Statecraft.Game.UI
foreach (var e in underBar) e.style.marginTop = StyleKeyword.Null;
bar.style.height = StyleKeyword.Null;
foreach (var l in plateText) { l.style.fontSize = StyleKeyword.Null; l.style.whiteSpace = StyleKeyword.Null; }
+ exhaustedSize = ExhaustedPx; // so PadPlate below clears the plate's width
+ if (exhaustedLine != null) { exhaustedLine.style.fontSize = StyleKeyword.Null; exhaustedLine.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);
@@ -339,9 +350,12 @@ namespace Statecraft.Game.UI
{
var p = root.panel;
if (p == null) return;
- var size = SmallTextSize(ScreenPxPerPanelPx(p));
- if (size == smallTextSize) return;
+ var scale = ScreenPxPerPanelPx(p);
+ var size = SmallTextSize(scale);
+ var exhausted = FlooredTextSize(ExhaustedPx, scale);
+ if (size == smallTextSize && exhausted == exhaustedSize) return;
smallTextSize = size;
+ exhaustedSize = exhausted;
SetCompact(bar.layout.width);
}
@@ -408,6 +422,12 @@ namespace Statecraft.Game.UI
// One line each; the plate widens for them (PadPlate).
l.style.whiteSpace = raised ? new StyleEnum<WhiteSpace>(WhiteSpace.NoWrap) : new StyleEnum<WhiteSpace>(StyleKeyword.Null);
}
+ if (exhaustedLine != null)
+ {
+ var up = exhaustedSize > ExhaustedPx;
+ exhaustedLine.style.fontSize = up ? new StyleLength(exhaustedSize) : new StyleLength(StyleKeyword.Null);
+ exhaustedLine.style.whiteSpace = up ? 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
@@ -425,12 +445,16 @@ namespace Statecraft.Game.UI
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);
+ // The raised exhausted line (#812) is never wrapped either, so it too lets the plate size to it, but only while it
+ // shows (Render): a hidden line leaves the plate as it was (review of #1961).
+ var lineUp = exhaustedSize > ExhaustedPx && exhaustedLine != null && exhaustedLine.style.display == DisplayStyle.Flex;
+ plate.style.width = raised || lineUp ? new StyleLength(StyleKeyword.Auto) : new StyleLength(StyleKeyword.Null);
// At least the widest date line too, so the plate keeps its width when the month changes (PromoHudTests): at 25 px
// (a phone upright, #642) the Hebrew 31 October 1956 is about 196 px, wider than 230 px less the padding.
plate.style.minWidth = raised ? new StyleLength(UnityEngine.Mathf.Max(PlateWidthPx, DateLinePerPx * smallTextSize + 2f * PlateSidePx + 2f))
- : new StyleLength(StyleKeyword.Null);
- StyleLength Px(float v) => raised ? new StyleLength(v) : new StyleLength(StyleKeyword.Null);
+ : lineUp ? new StyleLength(PlateWidthPx + 2f * PlateSidePx - StylesheetPlatePadPx) : new StyleLength(StyleKeyword.Null);
+ // The frame clearance holds when either the 15 px text or the 13 px exhausted line is raised (they floor at different scales).
+ StyleLength Px(float v) => raised || lineUp ? 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);
}
@@ -711,6 +735,11 @@ namespace Statecraft.Game.UI
var score = root.Q<Label>("score"); // the GDD loop only (#380): hidden when HudModel gives none
score.text = m.Score;
score.style.display = m.Score.Length == 0 ? DisplayStyle.None : DisplayStyle.Flex;
+ var exhausted = root.Q<Label>("exhausted"); // hidden while ExhaustedTurns is 0 (R-END-002)
+ exhausted.text = m.Exhausted;
+ var wasShown = exhausted.style.display == DisplayStyle.Flex;
+ exhausted.style.display = m.Exhausted.Length == 0 ? DisplayStyle.None : DisplayStyle.Flex;
+ if (wasShown != m.Exhausted.Length > 0) SetCompact(bar.layout.width); // the plate's raised layout follows the line (PadPlate)
Set("treasury", m.Treasury); Set("immigration", m.Immigration); Set("security", m.Security);
Set("support", m.Support); Set("standing", m.Standing); Set("fx", m.Fx);
// Social cohesion: the GDD loop only (#380), as the score; a hidden meter takes no room in the bar.
diff --git a/unity/Assets/Tests/EditMode/HudTests.cs b/unity/Assets/Tests/EditMode/HudTests.cs
index 5b38e585c..8b1749fde 100644
--- a/unity/Assets/Tests/EditMode/HudTests.cs
+++ b/unity/Assets/Tests/EditMode/HudTests.cs
@@ -189,6 +189,28 @@ public class HudTests
Assert.AreEqual("Score 150", label.text);
}
+ // ---- The exhausted-turn count (#812, R-END-002): "1 of 3" under the date while Money and Food are both out ----
+
+ [Test]
+ public void TheBarCountsTheExhaustedTurnsAgainstTheDefeatLimit()
+ {
+ using var ui = new UiTestKit();
+ var bridge = GddBridge();
+ using var hud = new HudPresenter(ui.Root, bridge, Text);
+ var label = ui.Q<Label>("exhausted");
+ // Nothing is shown at 0: one exhausted resource alone ends nothing, so there is no count to warn about.
+ Assert.AreEqual("", HudModel.From(bridge, Text).Exhausted);
+ Assert.AreEqual(DisplayStyle.None, label.style.display.value);
+ var limit = bridge.Content.RulesAt(bridge.State.Date).Mvp!.DefeatTurns!.Value;
+ bridge.State.ExhaustedTurns = 1;
+ hud.Render();
+ Assert.AreEqual($"Money and Food ran out: turn 1 of {limit}", label.text);
+ Assert.AreEqual(DisplayStyle.Flex, label.style.display.value);
+ // The value carries left-to-right marks in a Hebrew line (U+200E, #543), as every Hebrew value does.
+ var he = HudModel.From(bridge, He).Exhausted;
+ Assert.AreEqual($"הכסף והמזון אזלו: תור 1 מתוך {limit}", he.Replace("\u200E", ""));
+ }
+
// ---- Social cohesion (#380): a resource meter, only in the GDD loop, from the morale indicator ----
/// <summary>The owner's ruling of 15 October 2026 (#380): Social cohesion on the top bar as a resource meter, in the GDD
diff --git a/unity/Assets/Tests/EditMode/TopBarScoreLayoutTests.cs b/unity/Assets/Tests/EditMode/TopBarScoreLayoutTests.cs
index d367b6496..59de899a2 100644
--- a/unity/Assets/Tests/EditMode/TopBarScoreLayoutTests.cs
+++ b/unity/Assets/Tests/EditMode/TopBarScoreLayoutTests.cs
@@ -13,7 +13,8 @@ using UnityEngine.UIElements;
/// <summary>The score in the top bar's date box (#380, 7b): a worst-case score stays inside the box's frame, on no other
/// text, and whole, at every window size the HUD's tests use, in English and Hebrew. At the widest date the year, turn
-/// and date labels stay inside that frame too (#625).</summary>
+/// and date labels stay inside that frame too (#625). Each runs with no exhausted turns (the line hidden, the plate as
+/// before #812) and with two (the line shown under the date).</summary>
public class TopBarScoreLayoutTests
{
static readonly Content Gdd = ContentLoader.Load(Paths.Content); // the real game: GDD since the cutover
@@ -56,7 +57,7 @@ public class TopBarScoreLayoutTests
public IEnumerator AWorstCaseScoreStaysInsideTheDateBox()
{
var problems = new List<string>();
- foreach (var (language, text, hebrew) in new[] { ("en", En, false), ("he", He, true) })
+ foreach (var (language, text, hebrew, turns) in new[] { ("en", En, false, 0), ("en", En, false, 2), ("he", He, true, 0), ("he", He, true, 2) })
foreach (var (w, h) in InfoPanelLayoutTests.Windows)
{
var rt = new RenderTexture(w, h, 0);
@@ -75,13 +76,14 @@ public class TopBarScoreLayoutTests
bridge.State.Score = WorstScore;
bridge.State.Date = WorstDate(hebrew);
bridge.State.Turn = WorstTurn;
+ bridge.State.ExhaustedTurns = turns; // #812: above 0 the count shows under the date and must fit the plate too
var hud = new HudPresenter(root, bridge, text);
try
{
var score = root.Q<Label>("score");
for (int i = 0; i < 20 && float.IsNaN(score.worldBound.width); i++) yield return null;
for (int i = 0; i < 3; i++) yield return null; // the bar's tier classes settle after the first layout
- var at = $"{language} {w}x{h}";
+ var at = $"{language} {w}x{h} exhausted {turns}";
Assert.AreEqual(text.Format("hud.score", WorstScore), score.text, $"{at}: precondition: the worst score shows");
Assert.AreEqual(text.Format("hud.date", Statecraft.Game.Map.Control1948.DateText(WorstDate(hebrew), k => text[k])), root.Q<Label>("date").text, $"{at}: precondition: the widest date shows");
var box = root.Q(className: "date-box");
@@ -95,6 +97,26 @@ public class TopBarScoreLayoutTests
// #625: the year, turn and date labels lie inside the frame too, at the widest date.
if (!Inside(o.worldBound, ContentBox(box))) problems.Add($"{at}: {other} '{o.text}' {o.worldBound} leaves the date box's frame {ContentBox(box)}");
}
+ var exhausted = root.Q<Label>("exhausted");
+ if (turns == 0)
+ {
+ if (exhausted.resolvedStyle.display != DisplayStyle.None) problems.Add($"{at}: the exhausted label '{exhausted.text}' shows with no exhausted turns");
+ }
+ else
+ {
+ // The label must really be shown before its geometry means anything: a hidden label has no box to overlap.
+ if (exhausted.resolvedStyle.display == DisplayStyle.None || exhausted.resolvedStyle.visibility == Visibility.Hidden
+ || exhausted.worldBound.width <= 0f || exhausted.worldBound.height <= 0f)
+ problems.Add($"{at}: the exhausted label is not shown ({exhausted.resolvedStyle.display}, {exhausted.resolvedStyle.visibility}, {exhausted.worldBound})");
+ if (!Inside(exhausted.worldBound, ContentBox(box))) problems.Add($"{at}: '{exhausted.text}' {exhausted.worldBound} leaves the date box's frame {ContentBox(box)}");
+ if (!Whole(exhausted)) problems.Add($"{at}: '{exhausted.text}' is clipped in {exhausted.contentRect}");
+ // The owner's text floor (#624) covers this line like the date's: on screen it is at least TextFloorPx.
+ var onScreen = exhausted.resolvedStyle.fontSize * root.panel.scaledPixelsPerPoint;
+ if (onScreen < HudPresenter.TextFloorPx - 0.01f)
+ problems.Add($"{at}: the exhausted line is {onScreen:0.##} px on screen ({exhausted.resolvedStyle.fontSize} px at {root.panel.scaledPixelsPerPoint:0.###}; under the {HudPresenter.TextFloorPx} px floor)");
+ foreach (var other in new[] { "year", "score", "turn", "date" })
+ if (!Apart(exhausted.worldBound, root.Q<Label>(other).worldBound)) problems.Add($"{at}: '{exhausted.text}' {exhausted.worldBound} overlaps {other}");
+ }
}
finally
{
@@ -104,4 +126,144 @@ public class TopBarScoreLayoutTests
}
Assert.IsEmpty(problems, string.Join("\n", problems));
}
+
+ /// <summary>#812 review: where only the 13 px exhausted line is raised (scale 0.8 to 0.92: 13 px is under the 12 px floor on
+ /// screen, 15 px is not), the plate still takes its frame clearance (PlateSidePx, PlateEdgePx). Inside(ContentBox) alone
+ /// would not show it: it reads the plate's current padding, whatever that is. Run in English and Hebrew, at the normal tier
+ /// (1600x900) and in the compact one (1400x1100, under CompactBelowPx), where the stylesheet's date box is 226 px: the plate
+ /// must still keep the turn and the date on one row and clear of the meters.</summary>
+ [UnityTest]
+ public IEnumerator TheExhaustedLineRaisedAloneKeepsThePlatesFrameClearance()
+ {
+ var problems = new List<string>();
+ foreach (var (language, text, hebrew) in new[] { ("en", En, false), ("he", He, true) })
+ foreach (var (w, h, compact) in new[] { (1600, 900, false), (1400, 1100, true) })
+ {
+ var at = $"{language} {w}x{h}";
+ var rt = new RenderTexture(w, h, 0);
+ var ps = Object.Instantiate(AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel));
+ ps.targetTexture = rt;
+ var go = new GameObject("ExhaustedClearanceTest");
+ 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;
+ root.Q("root").RemoveFromClassList("loading");
+ root.Q("root").EnableInClassList(UiLanguage.HebrewClass, hebrew);
+ var bridge = new SimBridge(GameSession.New(Gdd, GoldenRun.Seed, Mode.Historical), text);
+ bridge.State.Score = WorstScore;
+ bridge.State.Date = WorstDate(hebrew);
+ bridge.State.Turn = WorstTurn;
+ bridge.State.ExhaustedTurns = 2;
+ var hud = new HudPresenter(root, bridge, text);
+ try
+ {
+ var exhausted = root.Q<Label>("exhausted");
+ for (int i = 0; i < 20 && float.IsNaN(exhausted.worldBound.width); i++) yield return null;
+ for (int i = 0; i < 3; i++) yield return null;
+ var scale = root.panel.scaledPixelsPerPoint;
+ Assert.Greater(exhausted.resolvedStyle.fontSize, HudPresenter.ExhaustedPx, $"{at}: precondition: the exhausted line is raised (scale {scale:0.###})");
+ Assert.AreEqual(HudPresenter.SmallTextPx, root.Q<Label>("date").resolvedStyle.fontSize, 0.01f, $"{at}: precondition: the 15 px text is not raised (scale {scale:0.###})");
+ Assert.AreEqual(compact, root.Q(className: HudPresenter.CompactClass) != null, $"{at}: precondition: the compact tier is {(compact ? "on" : "off")}");
+ var plate = root.Q(className: "date-box");
+ var s = plate.resolvedStyle;
+ // Layout snaps to whole screen pixels (9 px at 0.833 resolves to 9.6), so compare within a screen pixel.
+ var tol = 1f / scale;
+ if (Mathf.Abs(s.paddingTop - HudPresenter.PlateEdgePx) > tol) problems.Add($"{at}: plate paddingTop {s.paddingTop} is not the clearance {HudPresenter.PlateEdgePx}");
+ if (Mathf.Abs(s.paddingBottom - HudPresenter.PlateEdgePx) > tol) problems.Add($"{at}: plate paddingBottom {s.paddingBottom} is not the clearance {HudPresenter.PlateEdgePx}");
+ if (Mathf.Abs(s.paddingLeft - HudPresenter.PlateSidePx) > tol) problems.Add($"{at}: plate paddingLeft {s.paddingLeft} is not the clearance {HudPresenter.PlateSidePx}");
+ if (Mathf.Abs(s.paddingRight - HudPresenter.PlateSidePx) > tol) problems.Add($"{at}: plate paddingRight {s.paddingRight} is not the clearance {HudPresenter.PlateSidePx}");
+ // Inside the window, and clear of every meter beside it.
+ if (!Inside(plate.worldBound, root.worldBound)) problems.Add($"{at}: the plate {plate.worldBound} leaves the window {root.worldBound}");
+ foreach (var meter in root.Query(className: "meter").ToList())
+ if (meter.resolvedStyle.display != DisplayStyle.None && !Apart(plate.worldBound, meter.worldBound))
+ problems.Add($"{at}: the plate {plate.worldBound} overlaps a meter {meter.worldBound}");
+ // Every line inside the plate's frame, whole, and on no other line.
+ var lines = new[] { "year", "score", "turn", "date", "exhausted" }.Select(n => root.Q<Label>(n)).ToList();
+ foreach (var l in lines)
+ {
+ if (!Inside(l.worldBound, ContentBox(plate))) problems.Add($"{at}: {l.name} '{l.text}' {l.worldBound} leaves the plate's frame {ContentBox(plate)}");
+ if (!Whole(l)) problems.Add($"{at}: {l.name} '{l.text}' is clipped in {l.contentRect}");
+ }
+ for (int a = 0; a < lines.Count; a++)
+ for (int b = a + 1; b < lines.Count; b++)
+ if (!Apart(lines[a].worldBound, lines[b].worldBound)) problems.Add($"{at}: {lines[a].name} {lines[a].worldBound} overlaps {lines[b].name} {lines[b].worldBound}");
+ // The turn and the date keep their one row: side by side, the same line, not stacked.
+ var turn = root.Q<Label>("turn").worldBound; var date = root.Q<Label>("date").worldBound;
+ if (Mathf.Abs(turn.center.y - date.center.y) > tol + 1f) problems.Add($"{at}: the turn {turn} and the date {date} are not on one row");
+ }
+ finally
+ {
+ hud.Dispose();
+ Object.DestroyImmediate(go); Object.DestroyImmediate(ps); rt.Release(); Object.DestroyImmediate(rt);
+ }
+ }
+ Assert.IsEmpty(problems, string.Join("\n", problems));
+ }
+
+ /// <summary>Review of #1961: at the scale where only the 13 px exhausted line is raised (1600x900, as above), a hidden line
+ /// (no exhausted turns) leaves the plate as the stylesheet has it: no inline width, minimum width or padding. Showing the
+ /// line then gives the plate its clearance, and hiding it again takes the clearance back.</summary>
+ [UnityTest]
+ public IEnumerator AHiddenExhaustedLineLeavesThePlateAsItWas()
+ {
+ var problems = new List<string>();
+ foreach (var (language, text, hebrew) in new[] { ("en", En, false), ("he", He, true) })
+ {
+ var rt = new RenderTexture(1600, 900, 0);
+ var ps = Object.Instantiate(AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel));
+ ps.targetTexture = rt;
+ var go = new GameObject("HiddenExhaustedTest");
+ 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;
+ root.Q("root").RemoveFromClassList("loading");
+ root.Q("root").EnableInClassList(UiLanguage.HebrewClass, hebrew);
+ var bridge = new SimBridge(GameSession.New(Gdd, GoldenRun.Seed, Mode.Historical), text);
+ bridge.State.ExhaustedTurns = 0;
+ var hud = new HudPresenter(root, bridge, text);
+ try
+ {
+ var date = root.Q<Label>("date");
+ for (int i = 0; i < 20 && float.IsNaN(date.worldBound.width); i++) yield return null;
+ for (int i = 0; i < 3; i++) yield return null;
+ var exhausted = root.Q<Label>("exhausted");
+ var plate = root.Q(className: "date-box");
+ Assert.Greater(exhausted.style.fontSize.value.value, HudPresenter.ExhaustedPx, $"{language}: precondition: the scale raises the exhausted line");
+ Assert.AreEqual(HudPresenter.SmallTextPx, date.resolvedStyle.fontSize, 0.01f, $"{language}: precondition: the 15 px text is not raised");
+ void Expect(string state, bool clearance)
+ {
+ var st = plate.style;
+ var inline = new[] { ("width", st.width.keyword), ("minWidth", st.minWidth.keyword), ("paddingTop", st.paddingTop.keyword),
+ ("paddingBottom", st.paddingBottom.keyword), ("paddingLeft", st.paddingLeft.keyword), ("paddingRight", st.paddingRight.keyword) };
+ foreach (var (prop, keyword) in inline)
+ if ((keyword == StyleKeyword.Null) == clearance)
+ problems.Add($"{language} {state}: the plate's {prop} is {(clearance ? "the stylesheet's" : "set inline")}");
+ if (clearance && st.paddingLeft.value.value != HudPresenter.PlateSidePx)
+ problems.Add($"{language} {state}: the plate's paddingLeft {st.paddingLeft.value.value} is not the clearance {HudPresenter.PlateSidePx}");
+ }
+ Expect("hidden", false);
+ bridge.State.ExhaustedTurns = 2;
+ hud.Render();
+ yield return null;
+ Assert.AreEqual(DisplayStyle.Flex, exhausted.resolvedStyle.display, $"{language}: precondition: two exhausted turns show the line");
+ Expect("shown", true);
+ bridge.State.ExhaustedTurns = 0;
+ hud.Render();
+ yield return null;
+ Expect("hidden again", false);
+ }
+ finally
+ {
+ hud.Dispose();
+ Object.DestroyImmediate(go); Object.DestroyImmediate(ps); rt.Release(); Object.DestroyImmediate(rt);
+ }
+ }
+ Assert.IsEmpty(problems, string.Join("\n", problems));
+ }
}
diff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxml
index 4a99c0cd0..00b442eda 100644
--- a/unity/Assets/UI/Game.uxml
+++ b/unity/Assets/UI/Game.uxml
@@ -33,6 +33,7 @@
<ui:Label name="turn" class="muted" />
<ui:Label name="date" class="muted" />
</ui:VisualElement>
+ <ui:Label name="exhausted" class="muted" />
<Statecraft.Game.UI.UiFrame shadow="false" filigree="true" />
</ui:VisualElement>
<!-- Meter captions are the content display names as written, in sentence case (#622) (Money and
diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.uss
index 72afc4622..2c71f3660 100644
--- a/unity/Assets/UI/Statecraft.uss
+++ b/unity/Assets/UI/Statecraft.uss
@@ -93,6 +93,8 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
/* 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; }
+/* The exhausted-turn count (R-END-002) takes a line of its own under the date, only while it is above 0. */
+#exhausted { font-size: 13px; } /* "turn" widens the line to fit the 196 px plate only at 13 px; wrapping runs it into the frame */
.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; }
diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yaml
index 152825008..0b46a375b 100644
--- a/unity/Assets/UI/strings.en.yaml
+++ b/unity/Assets/UI/strings.en.yaml
@@ -11,6 +11,7 @@ hud.attention: "Attention {0:0.0} of {1:0.0}"
hud.people: "{0:N0}"
hud.level: "Level {0} of 5"
hud.score: "Score {0:N0}"
+hud.exhausted: "Money and Food ran out: turn {0} of {1}"
hud.delta_people: "{0:+#,##0;-#,##0}"
# A top-bar meter in words, kept as its tooltip for a later accessibility layer (HudModel.Spoken): {0} the caption, {1}
# the value, {2} the change without its sign. Money: {0} the sign and the currency prefix from content ("IL ", "-IL ",
diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yaml
index 4636914c0..05492e5bb 100644
--- a/unity/Assets/UI/strings.he.yaml
+++ b/unity/Assets/UI/strings.he.yaml
@@ -9,6 +9,7 @@ hud.attention: "תשומת לב {0:0.0} מתוך {1:0.0}"
hud.people: "{0:N0}"
hud.level: "דרגה {0} מתוך 5"
hud.score: "ניקוד {0:N0}"
+hud.exhausted: "הכסף והמזון אזלו: תור {0} מתוך {1}"
hud.delta_people: "{0:+#,##0;-#,##0}"
hud.say: "{0}: {1}"
hud.say_up: "{0}: {1}, גידול של {2} מאז התור הקודם"