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: Tiberias' info panel says the town lies in the neighbouring water hex (refs #204) (#699)

Beri870bca67d5ac
diff --git a/CHANGELOG.md b/CHANGELOG.md
index b6e5f913b..026806db3 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -56,6 +56,9 @@ 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
+- The info panel of Tiberias' hex adds "Tiberias lies in the neighbouring water hex" (Hebrew too), so the hillside hex's
+ 70 m does not read as the town's (refs #204). It is worked out in Unity from the town's own lon/lat and the hex grid
+ (`InfoPanelPresenter.TownHex`), with no new `content/map/` field; an ordinary hex shows no such line.
- Tal's (@pixelrenderai-hash) 23 single-building Tripo models from #507, imported for the strategic map (refs #659, step
1): `unity/Assets/Art/Settlements/Prototype/Models/b*`, outside every `Resources/` folder, meshes compressed with no
animation, rig, tangents or Read/Write, colour maps committed and crunched at 512 px; `BuildingModelImportTests` pins
diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.cs
index fa25a0dae..6d3a394e3 100644
--- a/unity/Assets/Scripts/UI/GameRoot.cs
+++ b/unity/Assets/Scripts/UI/GameRoot.cs
@@ -270,7 +270,8 @@ namespace Statecraft.Game.UI
var localitiesAt = LocalitiesAt(map);
var 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));
+ regions: regions, localitiesAt: localitiesAt,
+ townHex: InfoPanelPresenter.TownHex(map.SettlementsFor(inputs.Map.SettlementsYaml), map.Hexes)));
// A smoke session never touches the player's save: no autosave, and no New Game (which deletes the autosave).
// Leaving New Game out is safer than handing it a throwaway store: no file is ever deleted, no path has to be
// right on every platform, and the scripted run never presses it.
diff --git a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
index 5db6b40cc..24e66d353 100644
--- a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
+++ b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
@@ -30,6 +30,7 @@ namespace Statecraft.Game.UI
readonly UiIcon thumb;
readonly IReadOnlyDictionary<string, string> settlementNames;
readonly MapRegions? regions;
+ readonly System.Func<string, (int q, int r)>? townHex;
/// <param name="localitiesAt">The 1948 localities that lie in a hex (null: the panel lists none); they are listed under the
/// settlements with today's name where the shared rule (Localities.TodayName) allows (#245).</param>
@@ -39,12 +40,15 @@ namespace Statecraft.Game.UI
/// <param name="regions">What the map outlines (the 1948 sub-districts and the 1949 armistice lines in force); the
/// panel names the selected hex's sub-district or armistice zone, and any armistice line through it, with its
/// agreement (null: no region line).</param>
+ /// <param name="townHex">The hex each settlement's own point lies in, by id (<see cref="TownHex"/>; null: no note on
+ /// a town drawn from the water hex next door, #204).</param>
public InfoPanelPresenter(VisualElement root, SimBridge bridge, UiText text, IReadOnlyDictionary<string, string> settlementNames,
ScreenNav? nav = null, System.Func<PlacedToken?>? selectedUnit = null, MapRegions? regions = null,
- System.Func<int, int, IReadOnlyList<Statecraft.Game.Map.Kits.Localities.Place>>? localitiesAt = null)
+ System.Func<int, int, IReadOnlyList<Statecraft.Game.Map.Kits.Localities.Place>>? localitiesAt = null,
+ System.Func<string, (int q, int r)>? townHex = null)
{
panel = root.Q<VisualElement>("info-panel"); this.bridge = bridge; this.text = text;
- this.settlementNames = settlementNames; this.regions = regions; this.localitiesAt = localitiesAt;
+ this.settlementNames = settlementNames; this.regions = regions; this.localitiesAt = localitiesAt; this.townHex = townHex;
title = panel.Q<Label>("info-title"); subtitle = panel.Q<Label>("info-subtitle"); region = panel.Q<Label>("info-region"); settlements = panel.Q<Label>("info-settlements");
localitiesLabel = panel.Q<Label>("info-localities");
placement = panel.Q<Label>("info-placement"); reason = panel.Q<Label>("info-reason");
@@ -171,6 +175,15 @@ namespace Statecraft.Game.UI
return text.Format("info.localities", string.Join(", ", names));
}
+ /// <summary>The hex each settlement's own point lies in, by id, picked as the map picks hexes (HexPicker, the rule of
+ /// tools/hexgrid.py). It differs from the settlement's hex in settlement_hexes.yaml only where hexgrid.settlement_hex
+ /// moved a town in a water hex to its nearest land neighbour (Tiberias, #204), so no content/map field is needed.</summary>
+ public static System.Func<string, (int q, int r)> TownHex(IEnumerable<Settlement> settlements, HexFile hexes)
+ {
+ var at = settlements.ToDictionary(s => s.Id, s => HexPicker.FromLonLat(s.Lon, s.Lat, hexes.bounds, hexes.hex_size_km));
+ return id => at[id];
+ }
+
void ShowLocalities(string line)
{
localitiesLabel.text = line;
@@ -224,6 +237,11 @@ namespace Statecraft.Game.UI
// hex, each with its agreement (true lines drawn to the nearest hex edge: the owner's ruling).
region.text = regions == null ? "" : RegionText(regions, text, q, r, s.Date);
settlements.text = owned.Count > 0 ? text.Format("info.owned", string.Join(", ", owned)) : "";
+ // A town in a water hex is drawn on its nearest land hex (Tiberias, in the lake, on the 70 m hex): one line says
+ // so, so this hex's elevation does not read as the town's (#204).
+ if (townHex != null)
+ foreach (var town in c.SettlementHexes.Where(x => x.Q == q && x.R == r && townHex(x.Id) != (q, r)))
+ settlements.text += "\n" + text.Format("info.town_in_water", settlementNames[town.Id]);
ShowLocalities(localitiesAt == null ? "" : LocalitiesText(text, localitiesAt(q, r)));
var here = MapActions.At(s, q, r);
var queued = bridge.QueuedLike(new MapAction(MapActions.Housing, q, r)) as MapAction;
diff --git a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
index ebaa51fb5..5fb621815 100644
--- a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
+++ b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs
@@ -205,6 +205,51 @@ public class InfoPanelLayoutTests
info.Dispose();
}
+ /// <summary>#204: Tiberias lies in the lake hex and is drawn on the land hex next to it (hexgrid.settlement_hex), so that
+ /// hex's 70 m is not the town's: its panel says so in one line, in English and in Hebrew. An ordinary hex (Lydda's,
+ /// whose towns lie in it) has no such line.</summary>
+ [Test]
+ public void ATownDrawnFromTheWaterHexNextDoorSaysSo()
+ {
+ var townHex = InfoPanelPresenter.TownHex(SettlementPlacer.Parse(MapFile(SettlementPlacer.DefaultFileName)),
+ JsonUtility.FromJson<HexFile>(MapFile("hexes.json")));
+ var tiberias = C.SettlementHexes.Single(s => s.Id == "tiberias");
+ var lod = C.SettlementHexes.Single(s => s.Id == "lod");
+ var he = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");
+ foreach (var (text, words) in new[] { (Text, "neighbouring water hex"), (he, "במשושה המים הסמוך") })
+ {
+ using var ui = new UiTestKit();
+ var info = new InfoPanelPresenter(ui.Root, new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), text), text, Names(),
+ townHex: townHex);
+ info.Show(tiberias.Q, tiberias.R);
+ var lines = ui.Q<Label>("info-settlements").text.Split('\n');
+ Assert.AreEqual(text.Format("info.town_in_water", "Tiberias"), lines.Last(), $"{text["ui.lang"]}: Tiberias' hex names the water hex");
+ StringAssert.Contains(words, lines.Last());
+ info.Show(lod.Q, lod.R);
+ StringAssert.DoesNotContain(words, ui.Q<Label>("info-settlements").text, $"{text["ui.lang"]}: Lydda's hex has no note");
+ info.Dispose();
+ }
+ }
+
+ /// <summary>#204 drift guard: the note says "water hex" because a town's own hex (TownHex) differs from its drawn hex
+ /// only where hexgrid.settlement_hex moved it off a water hex. Every such town's own hex is on the map and not land, and
+ /// there is at least one (Tiberias), so the guard cannot pass on an empty list.</summary>
+ [Test]
+ public void EveryTownDrawnOffItsOwnHexLiesInWater()
+ {
+ var townHex = InfoPanelPresenter.TownHex(SettlementPlacer.Parse(MapFile(SettlementPlacer.DefaultFileName)),
+ JsonUtility.FromJson<HexFile>(MapFile("hexes.json")));
+ var moved = C.SettlementHexes.Where(s => townHex(s.Id) != (s.Q, s.R)).ToList();
+ CollectionAssert.Contains(moved.Select(s => s.Id).ToList(), "tiberias", "Tiberias is drawn off its own (lake) hex");
+ foreach (var s in moved)
+ {
+ var (q, r) = townHex(s.Id);
+ var own = C.HexAt(q, r);
+ Assert.IsNotNull(own, $"{s.Id}: its own hex ({q}, {r}) is on the map");
+ Assert.IsFalse(own!.Land, $"{s.Id}: drawn on ({s.Q}, {s.R}) but its own hex ({q}, {r}) is land, so the water-hex note would be wrong");
+ }
+ }
+
/// <summary>#401's DPR-2 p95 rise was the filigree drawn as Painter2D curves. It is now one small code-made texture per
/// variant, made once and shared by every frame and every corner: the same instance on every call, with the scroll
/// and leaf in it (some pixels covered, most clear), and the side scroll only in the tall variant.</summary>
diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yaml
index 6c6d3f877..172d5c097 100644
--- a/unity/Assets/UI/strings.en.yaml
+++ b/unity/Assets/UI/strings.en.yaml
@@ -212,6 +212,7 @@ date.month_12: "December"
info.owned: "Settlements: {0}"
info.localities: "1948 localities: {0}"
info.locality_today: "{0} (today: {1})"
+info.town_in_water: "{0} lies in the neighbouring water hex"
map.today: "Today: {0}"
map.mixed: "Mixed locality"
minimap.overview: "Zoom all the way out"
diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yaml
index f0a763771..4e1f1adfb 100644
--- a/unity/Assets/UI/strings.he.yaml
+++ b/unity/Assets/UI/strings.he.yaml
@@ -203,6 +203,10 @@ date.month_12: "דצמבר"
info.owned: "יישובים: {0}"
info.localities: "יישובים ב-1948: {0}"
info.locality_today: "{0} (היום: {1})"
+# info.town_in_water: a town in a lake or sea hex drawn on the land hex next to it (#204); "מיקום {0}" has no verb or
+# adjective on the town, so the line agrees whatever its gender, and it fits one line of the panel. For the native
+# reviewer (#564).
+info.town_in_water: "מיקום {0}: במשושה המים הסמוך"
map.today: "היום: {0}"
map.mixed: "יישוב מעורב"
minimap.overview: "התרחקות מרבית"