A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
fix(ui): the event card sits above the minimap in one column (Task 24 review I2)
eyalgolan0fd69d97401d
diff --git a/unity/Assets/Tests/EditMode/UiLayoutTests.cs b/unity/Assets/Tests/EditMode/UiLayoutTests.csindex f0b1a2185..7600db084 100644--- a/unity/Assets/Tests/EditMode/UiLayoutTests.cs+++ b/unity/Assets/Tests/EditMode/UiLayoutTests.cs@@ -250,4 +250,59 @@ public class UiLayoutTests}Assert.IsEmpty(problems, string.Join("\n", problems));}++ /// <summary>Task 24 review I2: every real event, the tallest included, fits its card above the minimap at every window+ /// shape, wide and short ones included: the card never overlaps the minimap and its option buttons stay inside it.</summary>+ [UnityTest]+ public IEnumerator EveryEventCardStaysAboveTheMinimap()+ {+ var problems = new List<string>();+ foreach (var (w, h) in new[] { (1920, 1080), (1280, 720), (1531, 784), (2560, 1080), (1920, 900), (1366, 657), (1280, 1024) })+ {+ var rt = new RenderTexture(w, h, 0);+ var ps = Object.Instantiate(AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel));+ ps.targetTexture = rt;+ var go = new GameObject("LayoutTest");+ 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;+ var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), Text);+ // The real portraits: a minister's portrait adds the 200 px image row, so the tallest card is a portrait card.+ var portraits = AssetDatabase.LoadAssetAtPath<PortraitCatalog>("Assets/UI/Portraits/PortraitCatalog.asset");+ Assert.IsNotNull(portraits);+ var card = new EventCardPresenter(root, bridge, Text, portraits);+ float tallest = 0; string tallestId = "";+ try+ {+ for (int i = 0; i < 20 && float.IsNaN(root.Q("minimap").worldBound.width); i++) yield return null;+ foreach (var e in C.Events)+ {+ var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);+ g.State.Date = e.From; // the text names the office holders of the event's own time+ g.State.PendingEvents.Clear(); g.State.PendingEvents.Add(e.Id);+ bridge.Replace(g);+ for (int i = 0; i < 3; i++) yield return null;+ var c = root.Q("event-card").worldBound;+ var mini = root.Q("minimap").worldBound;+ if (c.height > tallest) { tallest = c.height; tallestId = e.Id; }+ if (c.yMax > mini.yMin + 0.5f && c.xMax > mini.xMin && c.xMin < mini.xMax)+ problems.Add($"{w}x{h}: {e.Id}: card {c} overlaps the minimap {mini}");+ foreach (var b in root.Q("event-options").Query<Button>().ToList())+ if (b.worldBound.yMax > c.yMax + 0.5f || b.worldBound.yMin < c.yMin - 0.5f)+ problems.Add($"{w}x{h}: {e.Id}: option '{b.text}' {b.worldBound} is cut off by the card {c}");+ }+ Debug.Log($"I2 {w}x{h}: tallest card {tallestId} {tallest:0} px");+ Assert.Greater(tallest, 400f, $"{w}x{h}: the cards were laid out (a short window shrinks the tallest to fit)");+ }+ finally+ {+ card.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.uxmlindex f81fb7615..696c5d046 100644--- a/unity/Assets/UI/Game.uxml+++ b/unity/Assets/UI/Game.uxml@@ -48,14 +48,24 @@<ui:Button name="end-turn" text="End Turn" class="end-turn" /></ui:VisualElement></ui:VisualElement>- <ui:VisualElement name="event-card" class="panel event-card">- <ui:VisualElement name="event-image" class="event-image" />- <ui:Label name="event-draft" text="DRAFT" class="draft" />- <ui:Label name="event-title" class="title event-title" />- <ui:Label name="event-office" class="muted" />- <ui:Label name="event-text" class="event-text" />- <ui:VisualElement name="event-options" />- <ui:Label name="event-count" class="muted" />+ <!-- The right-hand column (Task 24 review I2): the event card above the minimap, so the two can never overlap; a tall+ card shrinks its text, which scrolls, and keeps its option buttons. -->+ <ui:VisualElement name="right-column" class="right-column" picking-mode="Ignore">+ <ui:VisualElement name="event-card" class="panel event-card">+ <ui:VisualElement name="event-image" class="event-image" />+ <ui:Label name="event-draft" text="DRAFT" class="draft" />+ <ui:Label name="event-title" class="title event-title" />+ <ui:Label name="event-office" class="muted" />+ <ui:ScrollView name="event-scroll" class="event-scroll"><ui:Label name="event-text" class="event-text" /></ui:ScrollView>+ <ui:VisualElement name="event-options" />+ <ui:Label name="event-count" class="muted" />+ </ui:VisualElement>+ <ui:VisualElement class="right-gap" picking-mode="Ignore" />+ <ui:VisualElement name="minimap" class="panel minimap">+ <ui:VisualElement name="minimap-image" class="minimap-image">+ <ui:VisualElement name="minimap-view" class="minimap-view" picking-mode="Ignore" />+ </ui:VisualElement>+ </ui:VisualElement></ui:VisualElement><ui:VisualElement name="info-panel" class="panel info-panel"><ui:Label name="info-title" class="title" />@@ -68,11 +78,6 @@</ui:VisualElement><ui:Label name="info-reason" class="reason" /></ui:VisualElement>- <ui:VisualElement name="minimap" class="panel minimap">- <ui:VisualElement name="minimap-image" class="minimap-image">- <ui:VisualElement name="minimap-view" class="minimap-view" picking-mode="Ignore" />- </ui:VisualElement>- </ui:VisualElement><ui:VisualElement name="screen-cabinet" class="panel screen"><ui:VisualElement class="screen-header"><ui:Label name="cabinet-government" class="title" /><ui:Label name="cabinet-coalition" class="muted" /></ui:VisualElement><ui:VisualElement class="row grow">diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.ussindex a24d64b82..b8f3fe61b 100644--- a/unity/Assets/UI/Statecraft.uss+++ b/unity/Assets/UI/Statecraft.uss@@ -75,13 +75,21 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);.end-turn { -unity-font-definition: url("project://database/Assets/UI/Fonts/EBGaramond-SemiBold.ttf"); font-size: 22px; border-color: var(--gold); }/* Event card at the right, info panel at the bottom-left, minimap at the bottom-right. */-.event-card { position: absolute; right: 16px; top: 112px; width: 420px; max-height: 560px; overflow: hidden; }+/* The event card and the minimap share one column (Task 24 review I2): the card can never reach the minimap; when the+ window is short the portrait and then the text (it scrolls) give way, never the option buttons. */+.right-column { position: absolute; right: 16px; top: 112px; bottom: 16px; width: 420px; }+.right-gap { flex-grow: 1; flex-shrink: 0; min-height: 16px; }+.event-card { flex-shrink: 1; min-height: 0; max-height: 560px; overflow: hidden; }+.event-card > * { flex-shrink: 0; }+.event-card > .event-image { flex-shrink: 1; min-height: 0; }+.event-card > .event-scroll { flex-shrink: 1; min-height: 48px; }+#event-options { flex-shrink: 0; }.event-image { height: 200px; margin-bottom: 8px; -unity-background-scale-mode: scale-and-crop; background-color: var(--navy-deep); }.event-title { -unity-text-align: middle-center; margin-bottom: 6px; }.event-text { white-space: normal; margin-bottom: 8px; }.draft { color: var(--down); -unity-font-definition: url("project://database/Assets/UI/Fonts/EBGaramond-SemiBold.ttf"); -unity-text-align: middle-center; }.info-panel { position: absolute; left: 16px; bottom: 16px; width: 520px; min-height: 160px; }-.minimap { position: absolute; right: 16px; bottom: 16px; width: 300px; height: 340px; padding: 6px; }+.minimap { align-self: flex-end; flex-shrink: 0; width: 300px; height: 340px; padding: 6px; }.minimap-image { align-self: center; -unity-background-scale-mode: stretch-to-fill; } /* the element is sized to the picture's aspect by MinimapPresenter */.minimap-view { position: absolute; border-color: var(--ink); border-width: 1px; }