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: first-turn guide follow-ups: close on turn advance, ring gap, restore selection (refs #42) (#1225)

Eyal Golan8b6334eb9130
diff --git a/changelog.d/first-turn-guide-followups-42.md b/changelog.d/first-turn-guide-followups-42.md
new file mode 100644
index 000000000..550e172a3
--- /dev/null
+++ b/changelog.d/first-turn-guide-followups-42.md
@@ -0,0 +1,4 @@
+### Fixed
+- The first-turn guide (#42) closes when End turn is pressed under it, so the next turn's decision card no longer opens
+ with its backdrop over a guide step about something else. Step 1's gold ring round Attention now sits clear of End
+ turn's border. Done, Skip or Escape puts back the hex or unit that was selected before the guide showed its city.
diff --git a/unity/Assets/Scripts/UI/FirstTurnGuidePresenter.cs b/unity/Assets/Scripts/UI/FirstTurnGuidePresenter.cs
index 47cefed88..7e493607d 100644
--- a/unity/Assets/Scripts/UI/FirstTurnGuidePresenter.cs
+++ b/unity/Assets/Scripts/UI/FirstTurnGuidePresenter.cs
@@ -16,9 +16,10 @@ namespace Statecraft.Game.UI
/// step (Skip, Escape) and opened again from the How to play screen.</para>
/// <para>Presentation only: it reads the state and changes the UI alone (the card's Hide, the hex the info panel shows,
/// the "seen" line in the settings file, SettingsStore), never the sim, the queued orders or the save. Steps 2 and 3
- /// show a city with a training facility (<see cref="CityHex"/>) in the info panel; the decision card is hidden
- /// ("Decision waiting") except on step 4 and put back as it was when the guide closes. The guide takes no pointer
- /// outside its panel, so the HUD stays usable under it (the browser checks press End Turn with it open).</para></summary>
+ /// show a city with a training facility (<see cref="CityHex"/>) in the info panel, and the selection the guide found
+ /// is put back when it closes; the decision card is hidden ("Decision waiting") except on step 4 and put back as it was
+ /// when the guide closes. The guide takes no pointer outside its panel, so the HUD stays usable under it (the browser
+ /// checks press End Turn with it open); End Turn closes it as the turn advances.</para></summary>
public sealed class FirstTurnGuidePresenter : IDisposable
{
/// <summary>On the "root" element while the guide shows (Statecraft.uss shows its layer).</summary>
@@ -31,7 +32,8 @@ namespace Statecraft.Game.UI
public static readonly string[] Steps = { "attention", "city", "training", "event", "objectives" };
/// <summary>The event card's step (the card shows on it and is hidden on the others).</summary>
public const int EventStep = 3;
- /// <summary>The ring's gap round its target, in panel px.</summary>
+ /// <summary>The ring's gap round its target, in panel px. Under Attention (step 1) End Turn's border is kept clear of
+ /// it by Statecraft.uss (.guide-open #attention), not by this gap: the two sit 3 px apart in the bar.</summary>
const float RingGap = 4f;
readonly VisualElement hudRoot, layer, ring, dock;
@@ -41,20 +43,32 @@ namespace Statecraft.Game.UI
readonly SettingsStore? store;
readonly EventCardPresenter? card;
readonly Action? showCity, closeScreens;
+ readonly Func<Action>? keepSelection;
+ readonly SimBridge? bridge;
readonly Action onNext, onSkip, onReopen;
+ readonly Action<IReadOnlyList<Rejection>> onTurn;
readonly IVisualElementScheduledItem follow;
bool disposed;
/// <summary>The card was open (not hidden) when the guide opened: it is put back so when the guide closes.</summary>
bool cardWasOpen;
+ /// <summary>The event the card showed when the guide opened (null: none), and the turn it opened on.</summary>
+ string? cardEvent;
+ int openTurn;
+ /// <summary>Puts back the selection the guide found, once it has shown its city (null: it has not).</summary>
+ Action? putBack;
/// <param name="store">The settings file, where the guide notes that it has shown (null: it never shows by itself).</param>
/// <param name="card">The decision card, hidden except on the event step (null: none).</param>
/// <param name="showCity">Shows <see cref="CityHex"/>'s city in the info panel, as a click on it would (null: nothing).</param>
/// <param name="closeScreens">Closes an open side-menu screen when the guide opens (null: nothing).</param>
+ /// <param name="bridge">The game: the guide closes when its turn advances (End Turn under the open guide; null: never).</param>
+ /// <param name="keepSelection">Notes the selection (hex or unit) just before the guide first shows its city, and
+ /// returns what puts it back when the guide closes (null: the guide's city stays shown).</param>
public FirstTurnGuidePresenter(VisualElement root, UiText text, SettingsStore? store, EventCardPresenter? card = null,
- Action? showCity = null, Action? closeScreens = null)
+ Action? showCity = null, Action? closeScreens = null, SimBridge? bridge = null, Func<Action>? keepSelection = null)
{
this.text = text; this.store = store; this.card = card; this.showCity = showCity; this.closeScreens = closeScreens;
+ this.bridge = bridge; this.keepSelection = keepSelection;
hudRoot = root.Q("root") ?? root;
layer = root.Q<VisualElement>("first-turn-guide");
ring = layer.Q<VisualElement>("guide-ring");
@@ -66,6 +80,8 @@ namespace Statecraft.Game.UI
reopenButton.text = text["how_to_play.guide"];
onNext = Next; onSkip = Close; onReopen = Open;
next.clicked += onNext; skip.clicked += onSkip; reopenButton.clicked += onReopen;
+ onTurn = _ => TurnEnded();
+ if (bridge != null) bridge.TurnEnded += onTurn;
// The targets move with the layout (a window resized, the info panel re-rendered after an order), so the ring
// follows them while the guide shows.
follow = layer.schedule.Execute(Place).Every(100);
@@ -97,7 +113,12 @@ namespace Statecraft.Game.UI
{
if (disposed) return;
closeScreens?.Invoke();
- if (!IsOpen) cardWasOpen = card?.Shown != null && !card.Collapsed;
+ if (!IsOpen)
+ {
+ cardWasOpen = card?.Shown != null && !card.Collapsed;
+ cardEvent = card?.Shown?.Id;
+ openTurn = bridge?.State.Turn ?? 0;
+ }
hudRoot.AddToClassList(OpenClass);
follow.Resume();
Show(0);
@@ -118,8 +139,21 @@ namespace Statecraft.Game.UI
return true;
}
- /// <summary>Closes the guide (Skip, Done, Escape) and puts the decision card back as it was when the guide opened.</summary>
- public void Close()
+ /// <summary>Closes the guide (Skip, Done, Escape) and puts the decision card and the selection back as they were when
+ /// the guide opened.</summary>
+ public void Close() => Close(restoreCard: true);
+
+ /// <summary>The turn has ended (End Turn, which the guide leaves in reach): when it advanced, the guide closes, as Skip
+ /// does. Only the card the guide found is put back as it was; a new turn's card is left to its own rule (a new event
+ /// opens), so it neither stays hidden nor shows its backdrop under the guide (review of #1209). A refused turn (the
+ /// state unchanged) leaves the guide open.</summary>
+ void TurnEnded()
+ {
+ if (!IsOpen || bridge!.State.Turn == openTurn) return;
+ Close(restoreCard: card?.Shown?.Id == cardEvent);
+ }
+
+ void Close(bool restoreCard)
{
if (!IsOpen) return;
Step = -1;
@@ -128,13 +162,15 @@ namespace Statecraft.Game.UI
var focused = layer.focusController?.focusedElement as VisualElement;
bool hadFocus = focused != null && layer.Contains(focused);
if (hadFocus) focused!.Blur();
- if (card?.Shown != null)
+ if (restoreCard && card?.Shown != null)
{
if (cardWasOpen && card.Collapsed) card.Reopen(); // the card takes the focus itself
else if (!cardWasOpen && !card.Collapsed) card.Collapse(takeFocus: false);
}
// From the keyboard, the next Tab carries on from End Turn (#41 M1), unless the card is open and took the focus.
if (hadFocus && (card?.Shown == null || card.Collapsed)) FocusReturn.To(hudRoot.Q<Button>("end-turn"));
+ var back = putBack; putBack = null;
+ back?.Invoke();
}
void Show(int step)
@@ -151,7 +187,11 @@ namespace Statecraft.Game.UI
if (step == EventStep && card.Collapsed) card.Reopen();
else if (step != EventStep && !card.Collapsed) card.Collapse(takeFocus: false);
}
- if (key == "city" || key == "training") showCity?.Invoke();
+ if (key == "city" || key == "training")
+ {
+ putBack ??= keepSelection?.Invoke(); // what the guide found, before it first shows its city
+ showCity?.Invoke();
+ }
Place();
FocusReturn.To(next); // Enter goes on to the next step; again once styles resolve, as the layer may only now show
}
@@ -203,9 +243,17 @@ namespace Statecraft.Game.UI
var area = TargetArea();
ring.style.display = area == null ? DisplayStyle.None : DisplayStyle.Flex;
if (area is not Rect a) { dock.RemoveFromClassList(TopClass); return; }
- var topLeft = layer.WorldToLocal(new Vector2(a.xMin, a.yMin));
- ring.style.left = topLeft.x - RingGap; ring.style.top = topLeft.y - RingGap;
- ring.style.width = a.width + 2 * RingGap; ring.style.height = a.height + 2 * RingGap;
+ var topLeft = layer.WorldToLocal(new Vector2(a.xMin, a.yMin)) - new Vector2(RingGap, RingGap);
+ var bottomRight = layer.WorldToLocal(new Vector2(a.xMax, a.yMax)) + new Vector2(RingGap, RingGap);
+ // Inside the window: a target at its edge (Attention under the top of the window) gets a narrower gap there.
+ var size = layer.layout.size;
+ if (size.x > 0 && size.y > 0)
+ {
+ topLeft = Vector2.Max(topLeft, Vector2.zero);
+ bottomRight = Vector2.Min(bottomRight, size);
+ }
+ ring.style.left = topLeft.x; ring.style.top = topLeft.y;
+ ring.style.width = bottomRight.x - topLeft.x; ring.style.height = bottomRight.y - topLeft.y;
dock.EnableInClassList(TopClass, a.center.y > layer.worldBound.center.y);
}
@@ -236,7 +284,9 @@ namespace Statecraft.Game.UI
disposed = true;
follow.Pause();
Step = -1;
+ putBack = null; // a game going away: nothing to put back
hudRoot.RemoveFromClassList(OpenClass);
+ if (bridge != null) bridge.TurnEnded -= onTurn;
next.clicked -= onNext; skip.clicked -= onSkip; reopenButton.clicked -= onReopen;
}
}
diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.cs
index 097715996..a97167516 100644
--- a/unity/Assets/Scripts/UI/GameRoot.cs
+++ b/unity/Assets/Scripts/UI/GameRoot.cs
@@ -69,6 +69,9 @@ namespace Statecraft.Game.UI
internal FirstTurnGuidePresenter? Guide => guide;
FeedbackPresenter? feedback;
SharePresenter? share;
+ InfoPanelPresenter? info;
+ /// <summary>Tests: the info panel of the last Begin.</summary>
+ internal InfoPanelPresenter? Info => info;
CameraRig? rig;
List<(string, int, int, DateTime)>? drawn;
/// <summary>The designated sites on the map (#381), made on first use beside the placements; and their states as drawn.</summary>
@@ -323,7 +326,7 @@ namespace Statecraft.Game.UI
showUnits();
DiagLog.BootPhase("units layer built");
var localitiesAt = LocalitiesAt(map);
- var info = Own(new InfoPanelPresenter(root, bridge, text, names, nav: nav,
+ var info = this.info = Own(new InfoPanelPresenter(root, bridge, text, names, nav: nav,
selectedUnit: () => unitLayer.Selected is string id ? unitLayer.Tokens.First(p => p.Token.Unit.Id == id) : (Statecraft.Game.Map.Units.PlacedToken?)null,
regions: regions, localitiesAt: localitiesAt,
townHex: InfoPanelPresenter.TownHex(map.SettlementsFor(inputs.Map.SettlementsYaml), map.Hexes),
@@ -448,8 +451,24 @@ namespace Statecraft.Game.UI
if (FirstTurnGuidePresenter.CityHex(bridge.Content, bridge.State) is not (int q, int r)) return;
unitLayer.Select(null); map.Select(q, r); info.Show(q, r);
};
+ // When it closes, the guide puts back the selection it found (a hex, a unit, or none), unless the player has
+ // picked something else meanwhile (the HUD stays usable under it).
+ Func<Action> keepSelection = () =>
+ {
+ var hex = info.ShowsUnit ? null : info.Selected;
+ var unit = info.ShowsUnit ? unitLayer.Selected : null;
+ var city = FirstTurnGuidePresenter.CityHex(bridge.Content, bridge.State);
+ return () =>
+ {
+ if (info.Covered || info.ShowsUnit || info.Selected != city) return; // under a screen, or the player picked another
+ unitLayer.Select(unit);
+ if (unitLayer.Selected != null) { map.ClearSelection(); info.ShowUnit(); }
+ else if (hex is (int q, int r)) { map.Select(q, r); info.Show(q, r); }
+ else { map.ClearSelection(); info.Clear(); }
+ };
+ };
guide = firstTurn = Own(new FirstTurnGuidePresenter(root, text, showsStart && !FirstCardCheckRequested() ? SettingsFile() : null,
- card, showCity, () => nav?.Close()));
+ card, showCity, () => nav?.Close(), bridge, keepSelection));
if (newGame != null) newGame.Started += firstTurn.NewGame; // New Game in the top bar too; both die with this Begin
if (hebrew) Own(new UiDirection(root, bridge));
root.Q("root")?.RemoveFromClassList("loading"); // ready: the bar, panels and screens may show (P2-1)
@@ -561,7 +580,7 @@ namespace Statecraft.Game.UI
for (int i = owned.Count - 1; i >= 0; i--) owned[i].Dispose();
owned.Clear();
if (hoveredCity != null) { hoveredCity = null; HandCursor(false); } // the next Begin's pills start unlit
- minimap = null; labels = null; nav = null; start = null; card = null; outcomes = null; report = null; end = null; guide = null; feedback = null; share = null; rig = null; drawn = null; drawnSites = null; units = null; Regions = null; logCamera = false;
+ minimap = null; labels = null; nav = null; start = null; card = null; outcomes = null; report = null; end = null; guide = null; feedback = null; share = null; info = null; rig = null; drawn = null; drawnSites = null; units = null; Regions = null; logCamera = false;
// A ?profile run cut short (a stopped coroutine never reaches its restore line) must not leave the terrain at the
// profile's pixel error (Task 24 review M1). Nothing else changes it, so restoring is always right.
if (map != null && map.Terrain != null) map.Terrain.heightmapPixelError = MapBuilder.TerrainPixelError;
diff --git a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
index 122fa4d10..157baca39 100644
--- a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
+++ b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
@@ -112,6 +112,13 @@ namespace Statecraft.Game.UI
unitMode = true; Selected = null; Render();
}
+ /// <summary>Shows nothing selected (the hint), as before the first click; ignored while covered.</summary>
+ public void Clear()
+ {
+ if (Covered) return;
+ unitMode = false; Selected = null; Render();
+ }
+
void Build(string action)
{
if (Selected == null) return;
diff --git a/unity/Assets/Tests/EditMode/FirstTurnGuideTests.cs b/unity/Assets/Tests/EditMode/FirstTurnGuideTests.cs
index ea32bf56d..6cbf93f0a 100644
--- a/unity/Assets/Tests/EditMode/FirstTurnGuideTests.cs
+++ b/unity/Assets/Tests/EditMode/FirstTurnGuideTests.cs
@@ -201,6 +201,89 @@ public class FirstTurnGuideTests
Assert.IsTrue(rig.Card.Collapsed, "and Skip hides it again, as the player left it");
}
+ /// <summary>End turn pressed with the guide open (it takes no pointer outside its panel, so the HUD stays usable): the
+ /// guide closes as the turn advances, at any step, and the new turn's card is left to its own rule (a new event opens),
+ /// not hidden or shown by what the guide found on the old card (review of #1209, follow-up 1).</summary>
+ [Test]
+ public void EndTurnClosesTheGuide([Values(0, 1, FirstTurnGuidePresenter.EventStep)] int step, [Values(false, true)] bool cardHidden)
+ {
+ var game = OpenScene(new SaveStore(TempDir()), new SettingsStore(TempDir()));
+ game.Begin(Inputs, 0, startScreen: true);
+ UiTestKit.Press(Ui.Q<Button>("start-new-game"));
+ Assert.IsTrue(game.Guide!.IsOpen, "precondition: the first new game opens the guide");
+ game.Guide.Close();
+ var card = game.Card!;
+ Assert.IsNotNull(card.Shown, "precondition: a new game opens on a card");
+ var first = card.Shown!.Id;
+ if (cardHidden) card.Collapse();
+ game.Guide.Open();
+ for (int i = 0; i < step; i++) UiTestKit.Press(Ui.Q<Button>("guide-next"));
+ var turn = game.Bridge!.State.Turn;
+ UiTestKit.Press(Ui.Q<Button>("end-turn"));
+ Assert.AreEqual(turn + 1, game.Bridge.State.Turn, "precondition: End turn ran the turn");
+ Assert.IsFalse(game.Guide.IsOpen, "the guide closes when the turn advances");
+ Assert.AreEqual(-1, game.Guide.Step);
+ Assert.IsFalse(Ui.Q("root").ClassListContains(FirstTurnGuidePresenter.OpenClass));
+ if (card.Shown != null && card.Shown.Id != first)
+ Assert.IsFalse(card.Collapsed, $"the new turn's card ({card.Shown.Id}) opens by its own rule");
+ else if (card.Shown != null)
+ Assert.AreEqual(cardHidden, card.Collapsed, "the same card is put back as the guide found it");
+ Assert.AreEqual(card.Shown != null && !card.Collapsed, Ui.Q("root").ClassListContains(EventCardPresenter.OpenClass),
+ "the backdrop shows with an open card only");
+ }
+
+ /// <summary>The guide shows its city on steps 2 and 3; Done, Skip or Escape puts back the selection it found (none, a
+ /// hex or a unit) with the info panel and the map's outline; a selection the player made meanwhile is kept (review of
+ /// #1209, follow-up 3).</summary>
+ [Test]
+ public void ClosingPutsBackTheSelectionItFound()
+ {
+ var game = OpenScene(new SaveStore(TempDir()), new SettingsStore(TempDir()));
+ game.Begin(Inputs, 0, startScreen: true);
+ UiTestKit.Press(Ui.Q<Button>("start-new-game"));
+ var guide = game.Guide!; var info = game.Info!; var units = game.Units!; var bridge = game.Bridge!;
+ var map = Object.FindFirstObjectByType<MapScene>();
+ var city = FirstTurnGuidePresenter.CityHex(bridge.Content, bridge.State)!.Value;
+ bool Outlined() { var t = map.Terrain.transform.Find(MapScene.SelectionName); return t != null && t.GetComponent<MeshRenderer>().enabled; }
+ void ToCity() { UiTestKit.Press(Ui.Q<Button>("guide-next")); Assert.AreEqual(city, info.Selected, "step 2 shows the guide's city"); }
+ void Click(int q, int r) => GameRoot.OnHexClicked(map, units, info, q, r);
+
+ Assert.IsTrue(guide.IsOpen && info.Selected == null && !info.ShowsUnit, "precondition: a new game, nothing selected");
+ ToCity();
+ UiTestKit.Press(Ui.Q<Button>("guide-skip"));
+ Assert.IsNull(info.Selected, "Skip: nothing selected again");
+ Assert.IsFalse(info.ShowsUnit);
+ Assert.IsNull(units.Selected);
+ Assert.IsFalse(Outlined(), "and no outline on the map");
+
+ var hex = bridge.Content.Hexes.Where(h => h.Land).Select(h => (h.Q, h.R)).First(h => h != city && units.UnitToSelectAt(h.Item1, h.Item2) == null);
+ Click(hex.Item1, hex.Item2);
+ Assert.AreEqual(hex, info.Selected, "precondition: a hex selected");
+ guide.Open(); ToCity();
+ for (int i = 1; i < FirstTurnGuidePresenter.Steps.Length; i++) UiTestKit.Press(Ui.Q<Button>("guide-next"));
+ Assert.IsFalse(guide.IsOpen, "Done");
+ Assert.AreEqual(hex, info.Selected, "Done: the hex the guide found");
+ Assert.IsTrue(Outlined(), "outlined again");
+
+ Assert.IsNotEmpty(units.Tokens, "precondition: units in play");
+ var token = units.Tokens[0];
+ Click(token.Q, token.R);
+ var unit = units.Selected;
+ Assert.IsTrue(unit != null && info.ShowsUnit, "precondition: a unit selected");
+ guide.Open(); ToCity();
+ Assert.IsTrue(guide.Escape());
+ Assert.AreEqual(unit, units.Selected, "Escape: the unit the guide found");
+ Assert.IsTrue(info.ShowsUnit, "its card in the info panel");
+ Assert.IsFalse(Outlined(), "with its ring, not a hex outline");
+
+ Click(hex.Item1, hex.Item2);
+ guide.Open(); ToCity();
+ var other = bridge.Content.Hexes.Where(h => h.Land).Select(h => (h.Q, h.R)).First(h => h != city && h != hex && units.UnitToSelectAt(h.Item1, h.Item2) == null);
+ Click(other.Item1, other.Item2); // the player picks a hex under the open guide
+ UiTestKit.Press(Ui.Q<Button>("guide-skip"));
+ Assert.AreEqual(other, info.Selected, "a selection the player made meanwhile stays");
+ }
+
// --- Presentation only ------------------------------------------------------------------------------------------
/// <summary>The whole guide, by itself, through How to play, through every step, Skip and Escape: the state hash, the
@@ -238,15 +321,16 @@ public class FirstTurnGuideTests
// --- Where each step points --------------------------------------------------------------------------------------
- /// <summary>Every step's target is on screen, in the window, with the gold ring round it and the panel inside the window
- /// and clear of it, at 1280x720 and 390x844 (the phone the three-row bar is tuned for), in English and Hebrew, on a new
- /// game's first turn (the opening card open).</summary>
+ /// <summary>Every step's target is on screen, in the window, with the gold ring round it (inside the window) and the panel
+ /// inside the window and clear of it, at 1920x1080 (the one-row bar), 1280x720 and 390x844 (the phone the three-row bar
+ /// is tuned for), in English and Hebrew, on a new game's first turn (the opening card open). Step 1's ring keeps clear of
+ /// End turn's border, so the two read as two boxes (review of #1209, follow-up 2).</summary>
[UnityTest]
public IEnumerator EveryStepPointsAtAVisibleElement()
{
var problems = new List<string>();
foreach (var hebrew in new[] { false, true })
- foreach (var (w, h) in new[] { (1280, 720), (390, 844) })
+ foreach (var (w, h) in new[] { (1920, 1080), (1280, 720), (390, 844) })
yield return EachStep(w, h, hebrew, (root, guide, step) =>
{
string at = $"{(hebrew ? "he" : "en")} {w}x{h} step {step + 1} ({FirstTurnGuidePresenter.Steps[step]})";
@@ -257,7 +341,15 @@ public class FirstTurnGuideTests
if (!Inside(area, window)) problems.Add($"{at}: the target {area} leaves the window {window}");
var ring = root.Q("guide-ring");
if (ring.resolvedStyle.display != DisplayStyle.Flex) problems.Add($"{at}: no ring");
- else if (!Inside(area, ring.worldBound)) problems.Add($"{at}: the ring {ring.worldBound} is not round the target {area}");
+ else
+ {
+ if (!Inside(area, ring.worldBound)) problems.Add($"{at}: the ring {ring.worldBound} is not round the target {area}");
+ if (!Inside(ring.worldBound, window)) problems.Add($"{at}: the ring {ring.worldBound} leaves the window {window}");
+ // Step 1's ring round Attention must read as its own box, not one with End turn's gold border under it.
+ var endTurn = root.Q("end-turn").worldBound;
+ if (step == 0 && Gap(ring.worldBound, endTurn) < RingClearPx)
+ problems.Add($"{at}: the ring {ring.worldBound} is {Gap(ring.worldBound, endTurn):0.#} px from End turn {endTurn} (under {RingClearPx})");
+ }
var panel = root.Q("guide-panel").worldBound;
if (!(panel.width > 0) || !Inside(panel, window)) problems.Add($"{at}: the panel {panel} leaves the window {window}");
if (panel.Overlaps(area)) problems.Add($"{at}: the panel {panel} covers the target {area}");
@@ -267,6 +359,13 @@ public class FirstTurnGuideTests
Assert.IsEmpty(problems, string.Join("\n", problems));
}
+ /// <summary>The least clear space between the ring and End turn for them to read as two boxes, in panel px.</summary>
+ const float RingClearPx = 4f;
+
+ /// <summary>The clear space between two rects (the larger of the horizontal and vertical gaps; negative when they overlap).</summary>
+ static float Gap(Rect a, Rect b) =>
+ Mathf.Max(Mathf.Max(a.xMin - b.xMax, b.xMin - a.xMax), Mathf.Max(a.yMin - b.yMax, b.yMin - a.yMax));
+
static 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;
diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.uss
index bf2fcebc6..09d698485 100644
--- a/unity/Assets/UI/Statecraft.uss
+++ b/unity/Assets/UI/Statecraft.uss
@@ -516,6 +516,11 @@ Button.settings-choice-selected { -unity-font-definition: url("project://databas
.guide-layer { display: none; position: absolute; left: 0; top: 0; right: 0; bottom: 0; }
.guide-open .guide-layer { display: flex; }
.guide-ring { position: absolute; border-width: 3px; border-color: var(--gold-light); border-radius: 6px; }
+/* Attention sits about 3 px over End Turn in the bar: while the guide shows, more room under it keeps step 1's ring (4 px
+ round Attention) at least 4 px clear of End Turn's gold border, so the two read as two boxes (review of #1209;
+ FirstTurnGuideTests). 5 px is what the one-row bar's 70 px holds with End Turn in it; the taller narrow bar takes 8. */
+.guide-open #attention { margin-bottom: 5px; }
+.guide-open.hud-narrow #attention { margin-bottom: 8px; }
.guide-dock { position: absolute; left: 0; right: 0; bottom: 16px; flex-direction: row; justify-content: center; padding: 0 16px; }
.guide-dock.guide-dock-top { bottom: auto; top: 16px; }
.guide-panel { flex-grow: 1; flex-shrink: 1; max-width: 560px; padding: 14px 18px; background-color: var(--navy-solid); border-color: var(--gold); }