A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Settlement states on the map: a word tag under each name, and the support tip's places line (#803 PR 11) (#2974)
Eyal Golanf232cbe89df6
diff --git a/changelog.d/803-settlement-states.md b/changelog.d/803-settlement-states.mdnew file mode 100644index 000000000..95f8f083a--- /dev/null+++ b/changelog.d/803-settlement-states.md@@ -0,0 +1,7 @@+### Added++- The map now names each settlement's control state with a short word tag under its name ("Decision pending",+ "Occupied", "Occupation period over", "Depopulated", "Annexed", "Enemy-held"), in one quiet colour for every state,+ while the name keeps its own pill; the tags follow the map at once, and the turns left stay in the side panel (owner,+ 24 October 2026, "1521: 1. a 2.a"). International support's tip always counts the places depopulated by Deport while+ there are any (Refs #803).diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.csindex dd9783827..208c2f532 100644--- a/unity/Assets/Scripts/UI/GameRoot.cs+++ b/unity/Assets/Scripts/UI/GameRoot.cs@@ -635,7 +635,15 @@ namespace Statecraft.Game.UI// Issue #710: the static 1948 tier from cities.yaml's people, not the sim's live count (owner, 15 October 2026).bridge.Content.Cities.Where(c => c.People != null).ToDictionary(c => c.Id, c => c.People!.Value),(tier, people) => text.Format("map.tier", tier, MapLabelsPresenter.TierCount, people.ToString("N0", CultureInfo.InvariantCulture)),- hebrew, bridge.Content.MapLocations)); // #1008: the GDD v0.2 map locations are named too+ hebrew, bridge.Content.MapLocations, // #1008: the GDD v0.2 map locations are named too+ r => SettlementControlView.MapText(text, r))); // #803: each place's control state as a tag under its name+ // #803 Task 5: the tags follow the state the map shows (the order preview, U1) on every change, apart from the+ // placements' own redraw (RenderPlacementsIfChanged); they never rebuild the names.+ var shownLabels = labels;+ Action showSettlementControl = () => shownLabels.SetSettlementControl(bridge.State.Settlements);+ bridge.Changed += showSettlementControl;+ owned.Add(new Undo(() => bridge.Changed -= showSettlementControl));+ showSettlementControl();mini.Clicked += (lon, lat) => { camRig.LookAt = map.Frame.ToWorld(lon, lat, 0); cameraController.Settle(); SyncMinimap(); labels?.Refresh(); }; // the click may come after LateUpdate (review M6)// The minimap's whole-map button: the camera's own farthest zoom, over the middle of the map (no new rule).mini.Overview += () =>diff --git a/unity/Assets/Scripts/UI/HudModel.cs b/unity/Assets/Scripts/UI/HudModel.csindex d4e35386b..b76080c1f 100644--- a/unity/Assets/Scripts/UI/HudModel.cs+++ b/unity/Assets/Scripts/UI/HudModel.cs@@ -53,6 +53,14 @@ namespace Statecraft.Game.UI_ => throw new ArgumentOutOfRangeException(nameof(id), id, "not a top-bar meter"),};+ /// <summary>#803 (R-CTRL-019): the lines a meter's tip always shows, whatever the turn's causes: for International+ /// support, the places the player's Deports have depopulated while there are any; none for any other meter. MeterTip+ /// puts them before the causes' heading, so MaxCauses never drops them.</summary>+ public static IReadOnlyList<string> PersistentCauses(UiText text, GameState state, string meter) =>+ meter == "standing" && state.DisplacedByPlayer > 0+ ? new[] { text.Format("hud.standing_displaced_places", state.DisplacedByPlayer) }+ : Array.Empty<string>();+/// <summary>The main causes behind a meter in <paramref name="turn"/> (#1037): the sim's own causes/// (StepResult.Why) for the quantity the meter shows. Immigration's causes are this turn's arrivals, not causes of/// the difference from the preceding turn. Each is worded by <paramref name="line"/> (CauseText.Line: the player'sdiff --git a/unity/Assets/Scripts/UI/MapLabelsPresenter.cs b/unity/Assets/Scripts/UI/MapLabelsPresenter.csindex 069139174..0a124813b 100644--- a/unity/Assets/Scripts/UI/MapLabelsPresenter.cs+++ b/unity/Assets/Scripts/UI/MapLabelsPresenter.cs@@ -89,6 +89,8 @@ namespace Statecraft.Game.UIpublic const float MaxKitCover = 0.1f;/// <summary>The population-tier badge (issue #710) inside a city's or town's pill, and the class that makes room for it.</summary>public const string TierClass = "map-label-tier", WithTierClass = "map-label-with-tier";+ /// <summary>#803: a game settlement's control tag, a short word under its name (owner, 24 October 2026, "1521: 1. a 2.a").</summary>+ public const string ControlBadgeClass = "map-label-control";/// <summary>OWNER-APPROVED DESIGN VALUES (#710, 18 October 2026, "Accept as shipped"): tiers 1 to 9, doubling/// from 1,000 people (under 1,000 is tier 1, 1,000-1,999 tier 2, ..., 128,000 and over tier 9). The badge is at/// the start of the name, mirrored in Hebrew, and remains part of the pill at every zoom where the pill is shown.</summary>@@ -117,7 +119,7 @@ namespace Statecraft.Game.UIsealed class Item{public Settlement Settlement = null!; public Vector3 MarkerTop; public Bounds[] Kit = null!, Marker = null!; public VisualElement Slot = null!;- public Label Label = null!; public Spot First; public bool IsCity, IsLocality, TopVisible, KitInFront, ShownLast = true;+ public Label Label = null!; public Label? Control; public bool ControlShown; public Spot First; public bool IsCity, IsLocality, TopVisible, KitInFront, ShownLast = true;public Vector2 TopPanel; public Rect KitPanel, Around, Placed; public string? Tip;}@@ -127,6 +129,7 @@ namespace Statecraft.Game.UIreadonly CameraRig? rig;readonly Func<float>? zoomDistance;readonly bool hebrew;+ readonly Func<Statecraft.Sim.SettlementControl, string?>? controlText; // #803: a record's map tag words, or nonereadonly List<Item> items = new List<Item>(); // in placing (priority) orderreadonly List<Item> settlementOrder = new List<Item>();readonly List<VisualElement> occluders = new List<VisualElement>();@@ -209,7 +212,8 @@ namespace Statecraft.Game.UIpublic MapLabelsPresenter(VisualElement root, MapScene map, Camera camera, Func<float>? zoomDistance = null, Func<Statecraft.Game.Map.Kits.Localities.Place, string?>? tipText = null,Func<IReadOnlyList<Bounds[]>?>? keepClear = null, IReadOnlyDictionary<string, decimal>? population = null,- Func<int, decimal, string>? tierTip = null, bool hebrew = false, IReadOnlyList<Statecraft.Sim.MapLocation>? locations = null)+ Func<int, decimal, string>? tierTip = null, bool hebrew = false, IReadOnlyList<Statecraft.Sim.MapLocation>? locations = null,+ Func<Statecraft.Sim.SettlementControl, string?>? controlText = null){var tip = tipText ?? DefaultTip;onLabelGeometry = _ => geometryDirty = true;@@ -219,6 +223,7 @@ namespace Statecraft.Game.UIthis.map = map;this.zoomDistance = zoomDistance;this.hebrew = hebrew;+ this.controlText = controlText;rig = camera.TryGetComponent(out CameraRig r) ? r : null;container.Clear(); // one layer, one owner: the newest presenter (GameRoot makes one per Begin)var labels = new List<Label>(); var slots = new List<VisualElement>();@@ -257,12 +262,25 @@ namespace Statecraft.Game.UI});tierText = (tierTip ?? DefaultTierTip)(tier, people);}+ // #803 (owner, 24 October 2026, "1521: 1. a 2.a"): the place's control state as a short word tag under its+ // name, hidden until SetSettlementControl gives it a record. It starts where the name does (its anchor's share+ // of its own width), and Refresh places the name and the tag as one block, so the name keeps its pill.+ Label? control = null;+ if (controlText != null)+ {+ control = new Label { name = "control-" + s.Id, pickingMode = PickingMode.Ignore };+ control.AddToClassList(ControlBadgeClass);+ control.AddToClassList(ControlBadgeClass + (anchorClass == Left ? "-left" : anchorClass == Right ? "-right" : "-centre"));+ control.style.display = DisplayStyle.None;+ control.RegisterCallback(onLabelGeometry);+ slot.Add(control);+ }container.Add(slot);labels.Add(label); slots.Add(slot);var top = MarkerTop(map, s);settlementOrder.Add(new Item{- Settlement = s, MarkerTop = top, Kit = KitBounds(map, s, top), Marker = MarkerBox(s, top), Slot = slot, Label = label, IsCity = s.Type == "city", Tip = tierText,+ Settlement = s, MarkerTop = top, Kit = KitBounds(map, s, top), Marker = MarkerBox(s, top), Slot = slot, Label = label, Control = control, IsCity = s.Type == "city", Tip = tierText,First = anchorClass == Left ? Spot.AboveLeft : anchorClass == Right ? Spot.AboveRight : Spot.AboveCentre,});}@@ -475,6 +493,26 @@ namespace Statecraft.Game.UIreturn mask;}+ /// <summary>#803: shows each game settlement's control tag for its record in <paramref name="control"/> (the bridge's+ /// GameState.Settlements), and hides it for a place with none. Only the tags change: the names are never rebuilt.</summary>+ public void SetSettlementControl(IReadOnlyDictionary<string, Statecraft.Sim.SettlementControl> control)+ {+ if (controlText == null) return;+ foreach (var it in settlementOrder)+ {+ if (it.Control == null) continue;+ var words = control.TryGetValue(it.Settlement.Id, out var record) ? controlText(record) : null;+ bool show = !string.IsNullOrEmpty(words);+ if (show && it.Control.text != words) { it.Control.text = words; geometryDirty = true; }+ if (show != it.ControlShown)+ {+ it.ControlShown = show;+ it.Control.style.display = show ? DisplayStyle.Flex : DisplayStyle.None;+ geometryDirty = true;+ }+ }+ }+public void Refresh(bool force = false){SyncRouteLabels();@@ -548,12 +586,19 @@ namespace Statecraft.Game.UIbool shown = it.KitInFront && it.TopVisible && (it.IsLocality || !HiddenByZoom(it.Settlement.Type, distance));var at = new Vector2(it.KitPanel.center.x, it.KitPanel.yMin - LiftPx); // the slot: the USS anchor puts the pill above the kitvar shift = Vector2.zero;+ float tag = 0f; // the shown tag's height: the slot (the name's bottom) sits that far above the block's bottomif (shown){#if UNITY_EDITORLabelSizeReadsForTests++;#endifvar size = new Vector2(it.Label.resolvedStyle.width, it.Label.resolvedStyle.height);+ if (it.ControlShown && it.Control != null) // #803: the name and its tag under it are placed as one block+ {+ float tagWidth = it.Control.resolvedStyle.width, tagHeight = it.Control.resolvedStyle.height;+ if (float.IsNaN(tagWidth) || tagWidth <= 0f || float.IsNaN(tagHeight)) size.x = float.NaN; // not laid out yet+ else { size = new Vector2(Mathf.Max(size.x, tagWidth), size.y + tagHeight); tag = tagHeight; }+ }if (!laidOut || float.IsNaN(size.x) || size.x <= 0f) sizesKnown = false; // not laid out yet: show it, place on a later refreshelse{@@ -580,7 +625,7 @@ namespace Statecraft.Game.UI}it.ShownLast = shown;it.Slot.style.visibility = shown ? Visibility.Visible : Visibility.Hidden;- if (shown && laidOut) it.Slot.style.translate = new Translate(at.x + shift.x, at.y + shift.y);+ if (shown && laidOut) it.Slot.style.translate = new Translate(at.x + shift.x, at.y + shift.y - tag);}foreach (var x in routeLabels){@@ -811,7 +856,7 @@ namespace Statecraft.Game.UIremoveToggle?.Invoke(); removeToggle = null;foreach (var e in occluders) e.UnregisterCallback(onOccluderGeometry);container.UnregisterCallback(onContainerGeometry);- foreach (var it in items) it.Label.UnregisterCallback(onLabelGeometry);+ foreach (var it in items) { it.Label.UnregisterCallback(onLabelGeometry); it.Control?.UnregisterCallback(onLabelGeometry); }occluders.Clear();foreach (var slot in Slots) slot.RemoveFromHierarchy();foreach (var slot in LocalitySlots) slot.RemoveFromHierarchy();diff --git a/unity/Assets/Scripts/UI/MeterTip.cs b/unity/Assets/Scripts/UI/MeterTip.csindex 99d47483c..7b25318b6 100644--- a/unity/Assets/Scripts/UI/MeterTip.cs+++ b/unity/Assets/Scripts/UI/MeterTip.cs@@ -87,7 +87,8 @@ namespace Statecraft.Game.UIpublic VisualElement? ShownFor => shownFor;/// <summary>The tip's lines for <paramref name="meter"/> (an element named "meter-" + a HudModel.MeterIds id): its- /// words and what the meter is (hud.tip.<id>, #2200), with the causes' heading when there are causes (for+ /// words and what the meter is (hud.tip.<id>, #2200), then its standing lines (HudModel.PersistentCauses, #803),+ /// with the causes' heading when there are causes (for/// Immigration, this turn's arrivals), and the causes, one a line (none when none).</summary>public (string words, IReadOnlyList<string> causes) Lines(VisualElement meter){@@ -95,6 +96,7 @@ namespace Statecraft.Game.UIvar causes = HudModel.Causes(bridge.Session.Last, id, bridge.Content,w => CauseText.Line(w, bridge.Content, Array.Empty<Statecraft.Game.Map.Units.UnitEntry>(), text, TownNamesHe)); // no meter counts a unit linevar words = meter.tooltip + "\n" + text["hud.tip." + id]; // the number alone does not say what moves it (#2200)+ foreach (var line in HudModel.PersistentCauses(text, bridge.State, id)) words += "\n" + line; // #803: before the causesvar causesHeading = id == "immigration" ? "hud.arrivals_this_turn" : "hud.causes";return causes.Count == 0 ? (words, causes) : (words + "\n" + text[causesHeading], causes);}diff --git a/unity/Assets/Tests/EditMode/GameSceneTests.cs b/unity/Assets/Tests/EditMode/GameSceneTests.csindex f5d56b699..a901c304b 100644--- a/unity/Assets/Tests/EditMode/GameSceneTests.cs+++ b/unity/Assets/Tests/EditMode/GameSceneTests.cs@@ -1283,6 +1283,29 @@ public class GameSceneTestsAssert.IsNull(units.Selected);}+ /// <summary>#803 Task 5: GameRoot keeps the map's settlement tags in step with bridge.State on every Changed, without a+ /// new name label: a record shows its tag, and removing it hides the tag.</summary>+ [Test]+ public void TheMapTagsFollowTheBridgeWithoutANewNameLabel()+ {+ var root = Boot(language: UiLanguage.English);+ var b = root.Bridge!; var labels = root.Labels!;+ var name = labels.Labels.Single(l => l.name == "label-nazareth");+ var tag = labels.Slots.Single(x => x.name == "slot-nazareth").Q<Label>(className: MapLabelsPresenter.ControlBadgeClass);+ Assert.IsNotNull(tag, "Nazareth has a tag");+ Assert.IsFalse(b.State.Settlements.ContainsKey("nazareth"), "precondition: no record at the start");+ Assert.AreEqual(DisplayStyle.None, tag.style.display.value, "no record, no tag");+ b.State.Settlements["nazareth"] = new SettlementControl("israel", SettlementControl.Occupied, turns: 4);+ b.Replace(b.Session); // Changed, as after a turn+ Assert.AreEqual(Text["map.control.occupied"], tag.text);+ Assert.AreEqual(DisplayStyle.Flex, tag.style.display.value, "the record shows its tag");+ Assert.AreSame(name, labels.Labels.Single(l => l.name == "label-nazareth"), "the same name label");+ Assert.AreEqual(name.text, labels.Slots.Single(x => x.name == "slot-nazareth").Q<Label>("label-nazareth").text, "the name stays");+ b.State.Settlements.Remove("nazareth");+ b.Replace(b.Session);+ Assert.AreEqual(DisplayStyle.None, tag.style.display.value, "the record is gone: the tag hides");+ Assert.AreSame(name, labels.Labels.Single(l => l.name == "label-nazareth"));+ }}/// <summary>#2340 L2 (#2521): with the start screen closed, Escape withdraws a New Game request armed from the top bar, anddiff --git a/unity/Assets/Tests/EditMode/MapLabelTests.cs b/unity/Assets/Tests/EditMode/MapLabelTests.csindex 3c37ec7f3..21a67d027 100644--- a/unity/Assets/Tests/EditMode/MapLabelTests.cs+++ b/unity/Assets/Tests/EditMode/MapLabelTests.cs@@ -1746,4 +1746,145 @@ public class MapLabelTests}finally { labels.Dispose(); hd.Dispose(); Statecraft.Game.Map.Collection.SeaAirCollection.Request = saved; }}++ // --- #803: settlement-control states on the map ----------------------------------------------------------------++ static UiText En803 => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);+ static UiText He803 => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");++ /// <summary>The map tag's words for a record, as GameRoot gives them (SettlementControlView.MapText).</summary>+ static System.Func<Statecraft.Sim.SettlementControl, string?> ControlText(UiText text) => r => SettlementControlView.MapText(text, r);++ static Label ControlBadge(MapLabelsPresenter labels, string id) =>+ labels.Slots.Single(x => x.name == "slot-" + id).Q<Label>(className: MapLabelsPresenter.ControlBadgeClass);++ /// <summary>#803 Task 3 (owner, 24 October 2026, "1521: 1. a 2.a"): each state on main shows as a short word tag under the+ /// town's name, in one quiet colour for every state; the name stays, and a place with no record has no tag.</summary>+ [UnityTest]+ public IEnumerator EachStateHasOneBadgeAndTheNameStays()+ {+ var hd = new HdPanel(cam);+ var text = En803;+ var labels = new MapLabelsPresenter(hd.Root, map, cam, controlText: ControlText(text));+ try+ {+ var names = labels.Labels.ToDictionary(x => x.name, x => x.text);+ var badges = new System.Collections.Generic.List<Label>();+ labels.SetSettlementControl(new System.Collections.Generic.Dictionary<string, Statecraft.Sim.SettlementControl>+ {+ ["acre"] = new Statecraft.Sim.SettlementControl("israel", Statecraft.Sim.SettlementControl.AwaitingChoice),+ ["nazareth"] = new Statecraft.Sim.SettlementControl("israel", Statecraft.Sim.SettlementControl.Occupied, turns: 4),+ ["lod"] = new Statecraft.Sim.SettlementControl("israel", Statecraft.Sim.SettlementControl.AwaitingEnd),+ ["ramla"] = new Statecraft.Sim.SettlementControl(depopulated: true),+ ["beersheba"] = new Statecraft.Sim.SettlementControl("israel", Statecraft.Sim.SettlementControl.Annexed),+ });+ for (int i = 0; i < 3; i++) yield return null;+ foreach (var (id, key) in new[] { ("acre", "awaiting_choice"), ("nazareth", "occupied"), ("lod", "awaiting_end"), ("ramla", "depopulated"), ("beersheba", "annexed") })+ {+ var slot = labels.Slots.Single(x => x.name == "slot-" + id);+ Assert.AreEqual(names["label-" + id], slot.Q<Label>("label-" + id).text, id + ": the name is kept");+ var badge = ControlBadge(labels, id);+ Assert.IsNotNull(badge, id + " has a badge");+ Assert.AreEqual(text["map.control." + key], badge.text, id);+ Assert.AreEqual(DisplayStyle.Flex, badge.resolvedStyle.display, id + ": shown");+ StringAssert.DoesNotMatch(@"\d", badge.text, id + ": the map tag carries no number (Question 2 (a))");+ badges.Add(badge);+ }+ Assert.AreEqual(1, badges.Select(x => x.resolvedStyle.color).Distinct().Count(), "one quiet colour for every state");+ Assert.AreEqual(1, badges.Select(x => x.resolvedStyle.backgroundColor).Distinct().Count(), "one background for every state");+ Assert.AreEqual(DisplayStyle.None, ControlBadge(labels, "jaffa").resolvedStyle.display, "no record, no badge");+ foreach (var x in labels.LocalitySlots.Concat(labels.LocationSlots))+ Assert.IsNull(x.Q<Label>(className: MapLabelsPresenter.ControlBadgeClass), x.name + ": only game settlements have a badge");+ }+ finally { labels.Dispose(); hd.Dispose(); }+ }++ /// <summary>#803 Task 3: clearing a record hides its badge and keeps the very same name label (no rebuild).</summary>+ [UnityTest]+ public IEnumerator ClearingARecordHidesItsBadgeAndKeepsTheSameNameLabel()+ {+ var hd = new HdPanel(cam);+ var text = En803;+ var labels = new MapLabelsPresenter(hd.Root, map, cam, controlText: ControlText(text));+ try+ {+ var name = labels.Labels.Single(l => l.name == "label-nazareth");+ var badge = ControlBadge(labels, "nazareth");+ var occupied = new System.Collections.Generic.Dictionary<string, Statecraft.Sim.SettlementControl>+ { ["nazareth"] = new Statecraft.Sim.SettlementControl("israel", Statecraft.Sim.SettlementControl.Occupied, turns: 4) };+ labels.SetSettlementControl(occupied);+ yield return null;+ Assert.AreEqual(DisplayStyle.Flex, badge.resolvedStyle.display);+ Assert.AreEqual(text["map.control.occupied"], badge.text);+ labels.SetSettlementControl(new System.Collections.Generic.Dictionary<string, Statecraft.Sim.SettlementControl>());+ yield return null;+ Assert.AreEqual(DisplayStyle.None, badge.resolvedStyle.display, "the record is gone: the badge hides");+ Assert.AreSame(name, labels.Labels.Single(l => l.name == "label-nazareth"), "the same name label");+ Assert.AreSame(name, labels.Slots.Single(x => x.name == "slot-nazareth").Q<Label>("label-nazareth"), "still in its slot");+ Assert.AreSame(badge, ControlBadge(labels, "nazareth"), "the same badge, hidden, not rebuilt");+ }+ finally { labels.Dispose(); hd.Dispose(); }+ }++ /// <summary>#803 Task 3: at 1920x1080, 1280x720 and 390x844, in English and Hebrew, each shown badge sits under its own+ /// name (its top at the name's bottom, across the name), stays inside the window, and overlaps no other shown name or+ /// badge: Lod and Ramla share a hex, and Jaffa sits by Tel Aviv.</summary>+ [UnityTest]+ public IEnumerator EveryShownBadgeSitsUnderItsNameAndClearOfTheOtherNames()+ {+ var problems = new System.Collections.Generic.List<string>();+ var records = new System.Collections.Generic.Dictionary<string, Statecraft.Sim.SettlementControl>+ {+ ["jaffa"] = new Statecraft.Sim.SettlementControl("israel", Statecraft.Sim.SettlementControl.AwaitingEnd),+ ["lod"] = new Statecraft.Sim.SettlementControl("israel", Statecraft.Sim.SettlementControl.Occupied, turns: 3),+ ["ramla"] = new Statecraft.Sim.SettlementControl(depopulated: true),+ };+ foreach (var hebrew in new[] { false, true })+ foreach (var (w, h) in new[] { (1920, 1080), (1280, 720), (390, 844) })+ foreach (var distance in new[] { 30000f, 90000f })+ {+ string at = $"{(hebrew ? "he" : "en")} {w}x{h} {distance / 1000f:0} km";+ var hd = new HdPanel(cam, w, h);+ if (hebrew) (hd.Root.Q("root") ?? hd.Root).AddToClassList(UiLanguage.HebrewClass);+ var labels = new MapLabelsPresenter(hd.Root, map, cam, hebrew: hebrew, controlText: ControlText(hebrew ? He803 : En803));+ try+ {+ Pose(34.85, 31.98, distance);+ labels.SetSettlementControl(records);+ for (int i = 0; i < 20 && labels.Labels.Any(l => float.IsNaN(l.resolvedStyle.width) || l.resolvedStyle.width <= 0); i++) yield return null;+ yield return null;+ labels.Refresh(force: true); yield return null;+ labels.Refresh(force: true); yield return null;+ var win = hd.Root.worldBound;+ var shown = labels.Slots.Where(Shown).ToList();+ var rects = new System.Collections.Generic.List<(string what, Rect rect)>();+ foreach (var slot in shown)+ {+ rects.Add((slot.name + " name", slot.Q<Label>().worldBound));+ var b = slot.Q<Label>(className: MapLabelsPresenter.ControlBadgeClass);+ if (b != null && b.resolvedStyle.display == DisplayStyle.Flex) rects.Add((slot.name + " badge", b.worldBound));+ }+ int seen = 0;+ foreach (var id in records.Keys)+ {+ var slot = labels.Slots.Single(x => x.name == "slot-" + id);+ if (!Shown(slot)) continue;+ seen++;+ Rect name = slot.Q<Label>("label-" + id).worldBound, badge = ControlBadge(labels, id).worldBound;+ if (Mathf.Abs(badge.yMin - name.yMax) > 1f) problems.Add($"{at} {id}: the badge {badge} is not right under its name {name}");+ if (badge.xMax < name.xMin || badge.xMin > name.xMax) problems.Add($"{at} {id}: the badge {badge} is not under its name {name}");+ if (badge.xMin < win.xMin - 0.5f || badge.xMax > win.xMax + 0.5f || badge.yMin < win.yMin - 0.5f || badge.yMax > win.yMax + 0.5f)+ problems.Add($"{at} {id}: the badge {badge} leaves the window {win}");+ }+ for (int i = 0; i < rects.Count; i++)+ for (int j = i + 1; j < rects.Count; j++)+ if (rects[i].what.Split(' ')[0] != rects[j].what.Split(' ')[0] && rects[i].rect.Overlaps(rects[j].rect))+ problems.Add($"{at}: {rects[i].what} {rects[i].rect} overlaps {rects[j].what} {rects[j].rect}");+ TestContext.WriteLine($"{at}: {seen} of {records.Count} places with a record shown");+ if (w >= 1280 && seen == 0) problems.Add($"{at}: precondition: no place with a record is shown");+ }+ finally { labels.Dispose(); hd.Dispose(); }+ }+ Assert.IsEmpty(problems, string.Join("\n", problems));+ }}diff --git a/unity/Assets/Tests/EditMode/MeterTipTests.cs b/unity/Assets/Tests/EditMode/MeterTipTests.csindex 3d617eb6d..cbf37bb1e 100644--- a/unity/Assets/Tests/EditMode/MeterTipTests.cs+++ b/unity/Assets/Tests/EditMode/MeterTipTests.cs@@ -209,6 +209,52 @@ public class MeterTipTestsObject.DestroyImmediate(go); Object.DestroyImmediate(ps); rt.Release(); Object.DestroyImmediate(rt);}}++ /// <summary>#803 Task 5 (R-CTRL-019): while the player's Deports have emptied any place, International support's tip+ /// always counts them, whatever the turn's causes; no other meter, and none at 0 places.</summary>+ [Test]+ public void PersistentCausesCountThePlacesDepopulatedByDeport()+ {+ var text = En;+ var s = GameSession.New(C, GoldenRun.Seed, Mode.Historical).State;+ s.DisplacedByPlayer = 2;+ CollectionAssert.AreEqual(new[] { text.Format("hud.standing_displaced_places", 2) }, HudModel.PersistentCauses(text, s, "standing"));+ StringAssert.Contains("2", HudModel.PersistentCauses(text, s, "standing")[0]);+ CollectionAssert.IsEmpty(HudModel.PersistentCauses(text, s, "cohesion"), "only International support");+ s.DisplacedByPlayer = 0;+ CollectionAssert.IsEmpty(HudModel.PersistentCauses(text, s, "standing"), "none at 0 places");+ }++ /// <summary>#803 Task 5: rendered in English and Hebrew, International support's tip shows the places line after its+ /// words and before the causes' heading on a turn with no Deport cause, so HudModel.MaxCauses never drops it.</summary>+ [UnityTest]+ public IEnumerator TheSupportTipCountsDepopulatedPlacesOnATurnWithNoDeport()+ {+ var problems = new List<string>();+ foreach (var hebrew in new[] { false, true })+ {+ string at = hebrew ? "he" : "en";+ yield return Rendered(1280, 720, hebrew, Check);++ IEnumerator Check(VisualElement root, SimBridge bridge, UiText text)+ {+ bridge.State.DisplacedByPlayer = 2;+ var meter = root.Q("meter-standing");+ Enter(meter);+ for (int i = 0; i < 3; i++) yield return null;+ var line = text.Format("hud.standing_displaced_places", 2);+ var causes = HudModel.Causes(bridge.Session.Last, "standing", bridge.Content, w => w.Key);+ if (causes.Any(k => k.Contains("deport") || k.Contains("depopulation"))) problems.Add($"{at}: precondition: the turn has a Deport cause");+ var words = Words(root);+ var head = meter.tooltip + "\n" + text["hud.tip.standing"] + "\n" + line;+ if (!words.StartsWith(head, System.StringComparison.Ordinal)) problems.Add($"{at}: the tip's words '{words}' do not show '{line}' after the meter's words");+ if (causes.Count > 0 && words != head + "\n" + text["hud.causes"]) problems.Add($"{at}: the line is not before the causes' heading: '{words}'");+ if (UiDirection.RightToLeft(line) != hebrew) problems.Add($"{at}: the line '{line}' is not in the UI's language");+ Leave(meter);+ }+ }+ Assert.IsEmpty(problems, string.Join("\n", problems));+ }}/// <summary>#1184: a tap on the bare map never reaches the panel (the event system sends a pointer event only to a paneldiff --git a/unity/Assets/Tests/EditMode/SettlementControlShots.cs b/unity/Assets/Tests/EditMode/SettlementControlShots.csnew file mode 100644index 000000000..fbe426747--- /dev/null+++ b/unity/Assets/Tests/EditMode/SettlementControlShots.cs@@ -0,0 +1,173 @@+#nullable enable+using System;+using System.Collections;+using System.IO;+using System.Linq;+using NUnit.Framework;+using Statecraft.Game;+using Statecraft.Game.Map;+using Statecraft.Game.UI;+using Statecraft.Sim;+using UnityEditor.SceneManagement;+using UnityEngine;+using UnityEngine.TestTools;+using UnityEngine.UIElements;+using Object = UnityEngine.Object;++/// <summary>Writes the before and after stills for #803 (each settlement's control state as a word tag under its name: owner,+/// 24 October 2026, "1521: 1. a 2.a") to `.superpowers/shots-803/<SHOTS_TAG>/` at the repository root (local, not+/// committed; SHOTS_TAG from the environment, "untagged" when unset), in English and Hebrew (GameRoot with its Hebrew+/// language, so UiDirection runs), at 1920x1080 and 390x844. Each still is the map camera's frame with the UI drawn over it,+/// as CivMovementShots draws it. The same opening game in each: four records set on the first turn's state (Acre awaiting+/// the capture choice, Nazareth occupied with 4 turns left, Lydda awaiting the end of its occupation, Ramle depopulated+/// and counted once in DisplacedByPlayer), then Changed raised, as a turn would.+/// <list type="bullet">+/// <item>`centre-<lang>-<w>x<h>.png`: the camera on Lydda's hex from 45 km (Lydda, Ramle, Jaffa).</item>+/// <item>`north-<lang>-<w>x<h>.png`: the camera on Nazareth's hex from 60 km (Nazareth, Acre).</item>+/// <item>`panel-<lang>-<w>x<h>.png`: the centre view with Lydda's hex clicked (its side panel).</item>+/// <item>`support-tip-<lang>-<w>x<h>.png`: the centre view with International support hovered.</item>+/// </list>+/// It uses only calls main has, so the same file run on main gives the "before" stills. Run (Unity, the unity/ project):+/// <code>SHOTS_TAG=after <Unity> -batchmode -projectPath unity -runTests -testPlatform EditMode -testFilter SettlementControlShots</code>+/// then with this file and its .meta copied onto main, SHOTS_TAG=before. Explicit, so it does not run with the checks.</summary>+[Explicit("writes stills for a pull request, not a check")]+public class SettlementControlShots+{+ string shotDir = "", saveDir = "";+ RenderTexture? rt; PanelSettings? ps;++ [SetUp]+ public void Prepare()+ {+ var tag = Environment.GetEnvironmentVariable("SHOTS_TAG");+ shotDir = Path.GetFullPath(Path.Combine(Application.dataPath, "..", "..", ".superpowers", "shots-803",+ string.IsNullOrEmpty(tag) ? "untagged" : tag));+ Directory.CreateDirectory(shotDir);+ saveDir = Path.Combine(Path.GetTempPath(), "statecraft-803-shots-" + Guid.NewGuid().ToString("N"));+ }++ [TearDown]+ public void DiscardScene()+ {+ EditorSceneManager.NewScene(NewSceneSetup.EmptyScene, NewSceneMode.Single);+ if (ps != null) Object.DestroyImmediate(ps);+ if (rt != null) { rt.Release(); Object.DestroyImmediate(rt); }+ rt = null; ps = null;+ if (Directory.Exists(saveDir)) Directory.Delete(saveDir, true);+ }++ static IEnumerator Frames(int n) { for (int i = 0; i < n; i++) yield return null; }++ static Color[] Read(RenderTexture from)+ {+ var prev = RenderTexture.active;+ RenderTexture.active = from;+ var tex = new Texture2D(from.width, from.height, TextureFormat.RGBA32, false);+ tex.ReadPixels(new Rect(0, 0, from.width, from.height), 0, 0);+ tex.Apply();+ RenderTexture.active = prev;+ var px = tex.GetPixels();+ Object.DestroyImmediate(tex);+ return px;+ }++ /// <summary>The map camera's frame with the UI texture over it (premultiplied by its alpha), as CivMovementShots.Shot.</summary>+ void Shot(int w, int h, string name)+ {+ var cam = Camera.main;+ ShotCamera.Require(cam, w, h);+ var frame = new RenderTexture(w, h, 24, RenderTextureFormat.ARGB32);+ var before = cam.targetTexture;+ cam.targetTexture = frame; cam.Render(); cam.targetTexture = before;+ var map = Read(frame); var over = Read(rt!);+ frame.Release(); Object.DestroyImmediate(frame);+ var outPx = new Color[map.Length];+ for (int i = 0; i < map.Length; i++)+ {+ var u = over[i]; var m = map[i];+ outPx[i] = new Color(u.r + m.r * (1f - u.a), u.g + m.g * (1f - u.a), u.b + m.b * (1f - u.a), 1f);+ }+ var tex = new Texture2D(w, h, TextureFormat.RGB24, false);+ tex.SetPixels(outPx); tex.Apply();+ File.WriteAllBytes(Path.Combine(shotDir, name + ".png"), tex.EncodeToPNG());+ Object.DestroyImmediate(tex);+ Debug.Log("SHOT " + name);+ }++ static void Aim(Content c, string settlement, float distance)+ {+ var at = c.SettlementHexes.First(x => x.Id == settlement);+ var map = Object.FindFirstObjectByType<MapScene>();+ var hex = c.HexAt(at.Q, at.R)!;+ var ground = map.Frame.ToWorld(hex.Lon, hex.Lat, 0);+ ground.y = map.Terrain.SampleHeight(ground) + map.Terrain.transform.position.y;+ var rig = Camera.main.GetComponent<CameraRig>();+ rig.LookAt = ground; rig.Distance = distance; rig.Apply();+ }++ static void Enter(VisualElement e)+ {+ using var ev = PointerEnterEvent.GetPooled(new Event { type = EventType.MouseMove, mousePosition = e.worldBound.center });+ ev.target = e; e.SendEvent(ev);+ }++ IEnumerator Shots(bool hebrew, int w, int h)+ {+ string at = $"{(hebrew ? "he" : "en")}-{w}x{h}";+ EditorSceneManager.OpenScene("Assets/Map.unity", OpenSceneMode.Single);+ ShotCamera.Configure(Camera.main, w, h);+ var doc = Object.FindFirstObjectByType<UIDocument>();+ rt = new RenderTexture(w, h, 24, RenderTextureFormat.ARGB32);+ ps = Object.Instantiate(doc.panelSettings);+ ps.targetTexture = rt; ps.clearColor = true; ps.colorClearValue = Color.clear;+ doc.panelSettings = ps;+ Object.FindFirstObjectByType<MapScene>().Build(MapFocusTests.Inputs.Map);+ var root = Object.FindFirstObjectByType<GameRoot>();+ root.Store = new SaveStore(saveDir);+ root.Language = hebrew ? UiLanguage.Hebrew : UiLanguage.English;+ root.Begin(MapFocusTests.Inputs, 0);+ var ui = doc.rootVisualElement;+ for (int i = 0; i < 30 && !(ui.Q("top-bar").worldBound.height > 0); i++) yield return null;+ yield return Frames(5);+ GameSceneTests.HideTheOpeningCard(ui);+ if (root.Advisor != null && root.Advisor.IsOpen) UiTestKit.Press(ui.Q<Button>("advisor-close"));+ yield return Frames(3);++ var bridge = root.Bridge!; var c = bridge.Content;+ var s = bridge.State.Settlements;+ s["acre"] = new SettlementControl("israel", SettlementControl.AwaitingChoice);+ s["nazareth"] = new SettlementControl("israel", SettlementControl.Occupied, turns: 4);+ s["lod"] = new SettlementControl("israel", SettlementControl.AwaitingEnd);+ s["ramla"] = new SettlementControl(depopulated: true);+ bridge.State.DisplacedByPlayer = 1;+ bridge.Replace(bridge.Session); // Changed, as after a turn+ yield return Frames(3);+ // Acre's decision dialog opens over the map; Hide puts it behind "Decision waiting", as a player would.+ var hideDecision = ui.Q<Button>("capture-hide");+ if (hideDecision != null && hideDecision.resolvedStyle.display != DisplayStyle.None) UiTestKit.Press(hideDecision);+ yield return Frames(3);++ Aim(c, "lod", 45000f); yield return Frames(6);+ Shot(w, h, "centre-" + at);+ Aim(c, "nazareth", 60000f); yield return Frames(6);+ Shot(w, h, "north-" + at);++ Aim(c, "lod", 45000f); yield return Frames(4);+ var meter = ui.Q("meter-standing");+ Enter(meter);+ yield return Frames(4);+ Shot(w, h, "support-tip-" + at);+ using (var ev = PointerLeaveEvent.GetPooled(new Event { type = EventType.MouseMove, mousePosition = Vector2.zero })) { ev.target = meter; meter.SendEvent(ev); }+ yield return Frames(2);++ var lod = c.SettlementHexes.First(x => x.Id == "lod");+ GameRoot.OnHexClicked(Object.FindFirstObjectByType<MapScene>(), root.Units!, root.Info!, lod.Q, lod.R);+ yield return Frames(6);+ Shot(w, h, "panel-" + at);+ }++ [UnityTest] public IEnumerator EnglishWide() => Shots(false, 1920, 1080);+ [UnityTest] public IEnumerator HebrewWide() => Shots(true, 1920, 1080);+ [UnityTest] public IEnumerator EnglishPhone() => Shots(false, 390, 844);+ [UnityTest] public IEnumerator HebrewPhone() => Shots(true, 390, 844);+}diff --git a/unity/Assets/Tests/EditMode/SettlementControlShots.cs.meta b/unity/Assets/Tests/EditMode/SettlementControlShots.cs.metanew file mode 100644index 000000000..b17bde497--- /dev/null+++ b/unity/Assets/Tests/EditMode/SettlementControlShots.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: 65ec2b6911bf42e49bc836df80a0b910diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.ussindex e9d325ff9..38dcc24d3 100644--- a/unity/Assets/UI/Statecraft.uss+++ b/unity/Assets/UI/Statecraft.uss@@ -917,6 +917,26 @@ Button.settings-choice-selected { -unity-font-definition: url("project://databasmargin: 0;white-space: nowrap;}+/* #803 (owner, 24 October 2026, "1521: 1. a 2.a"): a game settlement's control state as a short word tag under its name,+ in one quiet colour for every state (the localities' own), never a number. The tag is the name's sibling in its slot,+ lined up with the name by the anchor class below (the name's, without the lift); MapLabelsPresenter places the two as one. */+.map-label-control {+ position: absolute;+ left: 0;+ top: 0;+ -unity-font-definition: url("project://database/Assets/UI/Fonts/EBGaramond-SemiBold.ttf");+ font-size: 15px;+ color: rgb(232, 222, 200);+ background-color: rgba(14, 22, 38, 0.72);+ border-radius: 6px;+ padding: 0 6px 1px 6px;+ margin: 0;+ -unity-text-align: middle-center;+ white-space: nowrap;+}+.map-label-control-centre { translate: -50% 0; }+.map-label-control-left { translate: 0 0; }+.map-label-control-right { translate: -100% 0; }.anchor-lower-centre { translate: -50% -100%; }.anchor-lower-left { translate: 0 -100%; }.anchor-lower-right { translate: -100% -100%; }@@ -1011,7 +1031,7 @@ Button.settings-choice-selected { -unity-font-definition: url("project://databasclasses only presenters add (it gives a label each). */.lang-he, .lang-he .title, .lang-he .button, .lang-he Button, .lang-he .year, .lang-he .end-turn, .lang-he .draft,.lang-he .why-group, .lang-he .turn-report-heading, .lang-he .end-screen-outcome, .lang-he .party-group-heading, .lang-he .section-title, .lang-he .card-initials, .lang-he .card-name, .lang-he .house-size,-.lang-he .big-figure, .lang-he .map-label, .lang-he .map-label-tooltip, .lang-he .start-title, .lang-he .start-button {+.lang-he .big-figure, .lang-he .map-label, .lang-he .map-label-tooltip, .lang-he .map-label-control, .lang-he .start-title, .lang-he .start-button {-unity-font-definition: url("project://database/Assets/UI/Fonts/FrankRuhlLibre/FrankRuhlLibre-Medium.ttf");-unity-text-generator: advanced;}