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: city and town pills start with their static 1948 population tier, with a tooltip (refs #710) (#848)

Beri5093524c2c54
diff --git a/CHANGELOG.md b/CHANGELOG.md
index aa1f9bb0d..7b0ace27b 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -145,6 +145,13 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
(Q-CUT-8). Every golden moves; the cutover re-pins them once.
### Added
+- City and town pills start with their population tier, a gold disc with a number from 1 to 9 (refs #710). The tier is
+ static: it comes from the city's 1948 people in `content/cities.yaml` (#821), not from the sim's live count (owner,
+ 15 October 2026). The scale is the design value proposed on #710 and not yet ruled: tiers double from 1,000, so under
+ 1,000 is tier 1 and 128,000 or more is tier 9, which gives eight distinct tiers across the twelve cities. Pills with no
+ 1948 figure (Arab towns, kibbutzim, moshavim, the 1948 localities) have no badge. Hovering or tapping a badged pill
+ shows a tooltip such as "Population tier 8 of 9: 98,618 people in 1948", in English and Hebrew.
+ `MapLabelTests.CitiesWearTheirStatic1948PopulationTier` checks the tier edges, the badges and the tooltip.
- Map: Revivim, the one Negev outpost on the map, is drawn as the walled lookout it was in 1943-48 (refs #32), not as a
moshava's red-roofed houses round a water tower. The three lookouts were built to one plan (he.wiki "שלושת המצפים"):
a square yard closed by a wall, a lookout tower in its corner, the living quarters along one side and the service
diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.cs
index 7fe0c51b1..91a8d557b 100644
--- a/unity/Assets/Scripts/UI/GameRoot.cs
+++ b/unity/Assets/Scripts/UI/GameRoot.cs
@@ -313,7 +313,10 @@ namespace Statecraft.Game.UI
if (unitLayer == null) return null;
unitLayer.FaceCamera(labelCamera);
return unitLayer.KeepClear;
- }));
+ },
+ // 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))));
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/MapLabelsPresenter.cs b/unity/Assets/Scripts/UI/MapLabelsPresenter.cs
index 3cebf3b70..e358b10d5 100644
--- a/unity/Assets/Scripts/UI/MapLabelsPresenter.cs
+++ b/unity/Assets/Scripts/UI/MapLabelsPresenter.cs
@@ -1,6 +1,7 @@
#nullable enable
using System;
using System.Collections.Generic;
+using System.Globalization;
using Statecraft.Game.Map;
using UnityEngine;
using UnityEngine.UIElements;
@@ -74,6 +75,13 @@ namespace Statecraft.Game.UI
/// <summary>The most of a kit's screen rectangle a pill may cover (issue #214): its own kit's, and any other
/// visible kit's.</summary>
public 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>DESIGN VALUES (proposed on #710, not yet owner-ruled): 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), eight distinct tiers across the twelve cities.</summary>
+ public const int TierBase = 1000, TierCount = 9;
+ /// <summary>The badge's left edge inside its pill (Statecraft.uss ".map-label-with-tier" leaves the room).</summary>
+ const float TierInsetPx = 7f;
/// <summary>The panels a pill never sits under (Game.uxml names).</summary>
public static readonly string[] OccluderNames = { "top-bar", "date-plate", "left-column", "info-panel", "minimap", "map-layer", "event-card" };
@@ -131,6 +139,19 @@ namespace Statecraft.Game.UI
public Label Tooltip { get; }
Item? tapped, shownFor; // the pill a tap opened; the pill the tooltip shows now
+ /// <summary>The static 1948 population tier of a city of <paramref name="people"/> (owner, 15 October 2026, on #398:
+ /// it does not follow the sim's live population).</summary>
+ public static int Tier(decimal people)
+ {
+ int tier = 1;
+ for (decimal bar = TierBase; tier < TierCount && people >= bar; bar *= 2) tier++;
+ return tier;
+ }
+
+ /// <summary>The default tier tooltip (tests; GameRoot passes the UI strings). Keep it equal to strings.en.yaml's map.tier.</summary>
+ public static string DefaultTierTip(int tier, decimal people) =>
+ string.Format(CultureInfo.InvariantCulture, "Population tier {0} of {1}: {2:N0} people in 1948", tier, TierCount, people);
+
/// <summary>The default tooltip text (tests; GameRoot passes the UI strings): null when there is nothing to say.</summary>
public static string? DefaultTip(Statecraft.Game.Map.Kits.Localities.Place p) =>
TipOf(p, n => "Today: " + n, "Mixed locality");
@@ -147,7 +168,8 @@ namespace Statecraft.Game.UI
}
public 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)
+ Func<IReadOnlyList<Bounds[]>?>? keepClear = null, IReadOnlyDictionary<string, decimal>? population = null,
+ Func<int, decimal, string>? tierTip = null)
{
var tip = tipText ?? DefaultTip;
this.keepClear = keepClear;
@@ -168,12 +190,31 @@ namespace Statecraft.Game.UI
label.AddToClassList("map-label-" + s.Type);
label.AddToClassList(anchorClass);
slot.Add(label);
+ // Issue #710: a pill with a 1948 figure (cities.yaml's people) starts with its tier; the rest have no badge.
+ // The badge is the pill's sibling, drawn over its left padding: a child would stop the Label sizing to its text.
+ string? tierText = null;
+ if (population != null && population.TryGetValue(s.Id, out var people))
+ {
+ int tier = Tier(people);
+ var badge = new Label(tier.ToString(CultureInfo.InvariantCulture)) { name = "tier-" + s.Id, pickingMode = PickingMode.Ignore };
+ badge.AddToClassList(TierClass);
+ label.AddToClassList(WithTierClass);
+ slot.Add(badge);
+ // The pill's USS anchor translates it by a share of its own size, so the badge follows its laid-out size.
+ float anchorShare = anchorClass == Left ? 0f : anchorClass == Right ? 1f : 0.5f;
+ label.RegisterCallback<GeometryChangedEvent>(e =>
+ {
+ badge.style.left = -anchorShare * e.newRect.width + TierInsetPx;
+ badge.style.top = -0.5f * e.newRect.height;
+ });
+ tierText = (tierTip ?? DefaultTierTip)(tier, people);
+ }
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",
+ Settlement = s, MarkerTop = top, Kit = KitBounds(map, s, top), Marker = MarkerBox(s, top), Slot = slot, Label = label, IsCity = s.Type == "city", Tip = tierText,
First = anchorClass == Left ? Spot.AboveLeft : anchorClass == Right ? Spot.AboveRight : Spot.AboveCentre,
});
}
@@ -479,7 +520,7 @@ namespace Statecraft.Game.UI
}
static Rect Grow(Rect r, float by) => new Rect(r.x - by, r.y - by, r.width + 2f * by, r.height + 2f * by);
- static bool Hittable(Item it) => it.IsLocality && it.Tip != null && it.ShownLast;
+ static bool Hittable(Item it) => it.Tip != null && it.ShownLast; // a locality with something to say, or a pill with a tier (#710)
/// <summary>The hit test under Hover, at a point in the labels layer's coordinates: the shown locality pill (with
/// something to say) that contains it, or none.</summary>
diff --git a/unity/Assets/Tests/EditMode/MapLabelTests.cs b/unity/Assets/Tests/EditMode/MapLabelTests.cs
index b4826de9d..a7196661a 100644
--- a/unity/Assets/Tests/EditMode/MapLabelTests.cs
+++ b/unity/Assets/Tests/EditMode/MapLabelTests.cs
@@ -340,6 +340,57 @@ public class MapLabelTests
finally { labels.Dispose(); hd.Dispose(); }
}
+ /// <summary>Issue #710 (owner, 15 October 2026): a city's or town's pill starts with its static 1948 population tier, from
+ /// cities.yaml's people; a pill with no 1948 figure (an Arab town, a kibbutz, a locality) has no badge. The tiers double
+ /// from 1,000 (the proposed design values): 999 is tier 1, 1,000 tier 2, 128,000 and up tier 9, which gives eight distinct
+ /// tiers across the twelve rows. The badge sits inside its pill, at the left, before the name; with the pointer over
+ /// Haifa's pill the tooltip explains the number.</summary>
+ [UnityTest]
+ public IEnumerator CitiesWearTheirStatic1948PopulationTier()
+ {
+ Assert.AreEqual(1, MapLabelsPresenter.Tier(999)); Assert.AreEqual(2, MapLabelsPresenter.Tier(1000));
+ Assert.AreEqual(2, MapLabelsPresenter.Tier(1999)); Assert.AreEqual(3, MapLabelsPresenter.Tier(2000));
+ Assert.AreEqual(8, MapLabelsPresenter.Tier(127999)); Assert.AreEqual(9, MapLabelsPresenter.Tier(128000));
+ Assert.AreEqual(9, MapLabelsPresenter.Tier(248459));
+ // The game's tooltip comes from map.tier (GameRoot); both languages format it with the tier, the count and the people.
+ var en = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);
+ var he = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");
+ Assert.AreEqual(MapLabelsPresenter.DefaultTierTip(8, 98618m), en.Format("map.tier", 8, MapLabelsPresenter.TierCount, "98,618"));
+ var heTip = he.Format("map.tier", 8, MapLabelsPresenter.TierCount, "98,618");
+ StringAssert.Contains("98,618", heTip); StringAssert.Contains("8", heTip); StringAssert.Contains("9", heTip);
+ Assert.IsTrue(UiDirection.RightToLeft(heTip), heTip + " reads right to left");
+ var cities = Statecraft.Sim.ContentLoader.Load(Statecraft.Game.Paths.Content).Cities;
+ var people = cities.Where(c => c.People != null).ToDictionary(c => c.Id, c => c.People!.Value);
+ Assert.AreEqual(12, people.Count, "the twelve city and town rows of cities.yaml");
+ Assert.AreEqual(8, people.Values.Select(MapLabelsPresenter.Tier).Distinct().Count(), "eight distinct tiers (#710)");
+ var hd = new HdPanel(cam);
+ var labels = new MapLabelsPresenter(hd.Root, map, cam, population: people);
+ try
+ {
+ Label? BadgeOf(string id) => labels.Slots.Single(x => x.name == "slot-" + id).Q<Label>(className: MapLabelsPresenter.TierClass);
+ string? Badge(string id) => BadgeOf(id)?.text;
+ Assert.AreEqual("9", Badge("tel_aviv")); Assert.AreEqual("8", Badge("haifa")); Assert.AreEqual("8", Badge("jerusalem"));
+ Assert.AreEqual("6", Badge("petah_tikva")); Assert.AreEqual("4", Badge("tiberias")); Assert.AreEqual("1", Badge("rosh_pinna"));
+ foreach (var s in map.Settlements.Where(s => !people.ContainsKey(s.Id))) Assert.IsNull(Badge(s.Id), s.Id + " has no 1948 figure: no badge");
+ foreach (var x in labels.LocalitySlots) Assert.IsNull(x.Q<Label>(className: MapLabelsPresenter.TierClass), x.name);
+ Assert.AreEqual("Haifa", labels.Labels.Single(l => l.name == "label-haifa").text, "the name itself is unchanged");
+
+ Pose(34.99, 32.80, 40000f);
+ yield return Settle(labels);
+ var haifa = labels.Labels.Single(l => l.name == "label-haifa");
+ Assert.IsTrue(Shown(labels.Slots.Single(x => x.name == "slot-haifa")), "Haifa is named at 40 km");
+ var pill = haifa.worldBound; var badge = BadgeOf("haifa")!.worldBound;
+ Assert.IsTrue(pill.Contains(badge.min) && pill.Contains(badge.max - Vector2.one * 0.01f), $"the badge {badge} lies inside its pill {pill}");
+ Assert.Less(badge.center.x, pill.center.x, "at the start of the name");
+ Assert.LessOrEqual(badge.xMax, pill.xMin + haifa.resolvedStyle.paddingLeft, "clear of the name's text");
+ var container = hd.Root.Q<VisualElement>(MapLabelsPresenter.ContainerName).worldBound.position;
+ labels.HoverAt(pill.center - container); yield return null;
+ Assert.AreEqual(Visibility.Visible, labels.Tooltip.style.visibility.value, "the pointer over Haifa's pill shows its tooltip");
+ Assert.AreEqual("Population tier 8 of 9: 98,618 people in 1948", labels.Tooltip.text);
+ }
+ finally { labels.Dispose(); hd.Dispose(); }
+ }
+
/// <summary>Owner rulings 2026-10-11 and 2026-10-12: the 1948 localities are named by their 1948 names only at close zoom,
/// with today's name in a tooltip only where a living place carries on. At 30 km over Beisan its pill reads "Beisan"
/// and, with the pointer over it (the hit test Hover runs, in the layer's coordinates), the tooltip "Today: Beit She'an"
diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.uss
index ded1c03e5..847aa99bc 100644
--- a/unity/Assets/UI/Statecraft.uss
+++ b/unity/Assets/UI/Statecraft.uss
@@ -580,6 +580,22 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
}
.map-label-city { font-size: 23px; color: rgb(250, 242, 224); }
.map-label-town, .map-label-arab_town { font-size: 19px; }
+/* The population tier (#710): the city's static 1948 tier as a gold disc at the start of its name, over the pill's left
+ padding. The disc is the pill's sibling in its slot; MapLabelsPresenter sets its left and top from the pill's size. */
+.map-label-with-tier { padding-left: 36px; }
+.map-label-tier {
+ position: absolute;
+ translate: 0 -50%;
+ width: 23px;
+ height: 23px;
+ margin: 0;
+ padding: 0;
+ border-radius: 12px;
+ background-color: var(--gold);
+ color: rgb(14, 22, 38);
+ font-size: 17px;
+ -unity-text-align: middle-center;
+}
/* The 1948 localities (named only at close zoom): the same pill, smaller and quieter; today's name in a tooltip under it. */
.map-label-locality { font-size: 15px; padding: 0 9px 1px 9px; color: rgb(232, 222, 200); background-color: rgba(14, 22, 38, 0.72); }
.map-label-tooltip {
diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yaml
index c82f23c74..67e22dd02 100644
--- a/unity/Assets/UI/strings.en.yaml
+++ b/unity/Assets/UI/strings.en.yaml
@@ -238,6 +238,8 @@ info.locality_today: "{0} (today: {1})"
info.town_in_water: "{0} is shown here because its own hex is water."
map.today: "Today: {0}"
map.mixed: "Mixed locality"
+# map.tier: the tooltip of the population-tier badge on a city's pill (#710): {0} its tier, {1} the number of tiers, {2} its 1948 people.
+map.tier: "Population tier {0} of {1}: {2} people in 1948"
minimap.overview: "Zoom all the way out"
minimap.labels: "Show or hide the settlement names"
minimap.borders: "Show or hide the region borders"
diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yaml
index 21fd84562..bc46784cd 100644
--- a/unity/Assets/UI/strings.he.yaml
+++ b/unity/Assets/UI/strings.he.yaml
@@ -233,6 +233,9 @@ info.locality_today: "{0} (היום: {1})"
info.town_in_water: "{0} מוצגת כאן, כי המשושה שלה מכוסה במים."
map.today: "היום: {0}"
map.mixed: "יישוב מעורב"
+# map.tier: the tooltip of the population-tier badge on a city's pill (#710): {0} its tier, {1} the number of tiers, {2} its
+# 1948 people. For the native reviewer (#564).
+map.tier: "דרגת אוכלוסייה {0} מתוך {1}: {2} תושבים ב-1948"
minimap.overview: "התרחקות מרבית"
minimap.labels: "הצגה או הסתרה של שמות היישובים"
minimap.borders: "הצגה או הסתרה של גבולות האזורים"