A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
HUD round 2: the minimap as promo 03's painted relief, with its three side buttons (refs #398) (#584)
Eyal Golanb1d6232b821f
diff --git a/ASSETS.yaml b/ASSETS.yamlindex cb160926b..25332073f 100644--- a/ASSETS.yaml+++ b/ASSETS.yaml@@ -237,6 +237,11 @@ rules:source: "The biome ground colours (issue #321, #529), baked by Editor BiomeColourBake from the biomes and centres of content/map/hexes.json, the heightmap's bounds (unity/Assets/StreamingAssets/map/heightmap.json) and this project's MapPalette.Ground colours. The biomes are derived by tools/hexgrid.py from the Copernicus DEM GLO-30-derived heightmap (Copernicus-DEM), CHELSA V2.1 bio12 rainfall (CC0-1.0) and the IMS station normals of content/map/precip_stations.json (data.gov.il dataset 481, decision D6); no new facts; attribution in NOTICE"status: verifiednote: "Decision D13 decided (owner, 2026-10-14, docs/oss/DECISIONS.md): CC BY-SA 4.0, the most restrictive input (the map content in content/map/); the DEM, CHELSA and IMS findings accepted as recorded."+ - glob: "unity/Assets/Resources/Map/MinimapRelief.png"+ licence: CC-BY-SA-4.0+ source: "The minimap's painted relief (HUD round 2, #398), made by tools/minimap_bake.py from files already in this repository: a hill shade of the Copernicus DEM GLO-30-derived heightmap (unity/Assets/StreamingAssets/map/heightmap.*, Copernicus-DEM), the biome colour bake (Resources/Map/BiomeColours.bytes), the land-use and coast textures (Textures/Map/landuse.png, coast.png) and the sub-district hexes of content/map/subdistrict_hexes_1948.yaml (this project's own content, CC-BY-SA-4.0) for the rim of Mandatory Palestine. Procedural, not AI-generated; no new facts; attribution in NOTICE"+ status: verified+ note: "Decision D13 (owner, 2026-10-14, docs/oss/DECISIONS.md): CC BY-SA 4.0, the most restrictive input; the owner's decision (2026-10-15), relayed by the coordinator, is that this bake of the same D13 inputs follows it and is verified."- glob: "unity/Assets/Textures/*"licence: Copernicus-DEMsource: "tools/terrain_bake.py from the Copernicus DEM GLO-30-derived heightmap (unity/Assets/StreamingAssets/map/heightmap.*): AO, curvature, sky-view (Map/terrain_bake.png), coast distance (Map/coast.png) and the AO copy (Map/ao.png); the terrain water's mesh samples (Map/terrain_water.bytes, Editor TerrainWaterBake from the same heightmap); attribution in NOTICE"diff --git a/CHANGELOG.md b/CHANGELOG.mdindex 61d275e2b..53f51bd8b 100644--- a/CHANGELOG.md+++ b/CHANGELOG.md@@ -20,6 +20,12 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB- GDD v0.1 Phase 1, a dev flag and the score (refs #380): `?mvp=1` in the WebGL page's URL loads the content through`MvpSlice.Overlay` (the GDD slice) for playtests. The golden check and the smoke run ignore it, and a slice game neverreads, sets aside or writes the player's autosave (and has no New Game). In the GDD loop the top bar shows the score.+- The minimap as promo 03's (HUD round 2, part 1, refs #398): a painted relief of the country, baked once from the map's+ own heightmap, ground colours, land use and coast (`tools/minimap_bake.py`, `Resources/Map/MinimapRelief.png`, checked+ fresh in CI) in place of the 128-pixel hex strip painted at boot, and beside it promo 03's three round buttons: zoom all+ the way out, show or hide the settlement names, show or hide the region borders (and their caption), icon-only, each named in a tip beside it on hover and on keyboard+ focus (`HoverTip`; UI Toolkit draws `tooltip` only in Editor UI). The picture stays+ mouse-only (accessibility audit B1d); the buttons take Tab after End Turn. Presentation only: no golden moves.- Sourced Hebrew names in content (refs #558, #193), data only (no screen shows them yet): `title_he` for 30 of 31offices, plus `title_he_f` where a woman held the office (Labour, Foreign Affairs), `name_he` for 25 of 26 parties,the 8 governments and the 25 game settlements, `body_he` for the 4 legislatures, each with its own `*_he_sources`diff --git a/LICENSING.md b/LICENSING.mdindex 1cad3e1c6..5a5077339 100644--- a/LICENSING.md+++ b/LICENSING.md@@ -18,7 +18,7 @@ Different parts of this repository are under different licences. Where a file is| Decision-card and outcome clips | `unity/Assets/StreamingAssets/video/*.mp4` | AI-generated (Veo 3.1 through ElevenLabs; Seedance 2.0 through Dreamina), cut and re-encoded, with no burned-in caption (owner ruling of 14 October 2026); CC0 1.0 under decision D1, used under the owner's ruling D-V in `docs/oss/DECISIONS.md`. Per-file records in `ASSETS.yaml` and `docs/ai-disclosure.md`; the mapping `unity/Assets/Resources/EventVideos/event-videos.yaml` is CC BY 4.0 like the other UI assets. || Fonts | `unity/Assets/UI/Fonts/` | EB Garamond, [SIL Open Font License 1.1](unity/Assets/UI/Fonts/OFL.txt); Frank Ruhl Libre (`FrankRuhlLibre/`), [SIL Open Font License 1.1](unity/Assets/UI/Fonts/FrankRuhlLibre/OFL.txt) || Terrain heightmap | `unity/Assets/StreamingAssets/map/heightmap.*`, `content/map/hexes.json` (elevations) | Derived from Copernicus GLO-30 under the Copernicus DEM licence. Required notice: "produced using Copernicus WorldDEM-30 (c) DLR e.V. 2010-2014 and (c) Airbus Defence and Space GmbH 2014-2018 provided under COPERNICUS by the European Union and ESA; all rights reserved" |-| Derived map bakes | `unity/Assets/Resources/Map/BiomeColours.bytes` (biome colours, #529), `unity/Assets/Resources/Routes/RouteRibbons.bytes` (route ribbons, #436), `unity/Assets/Textures/Map/landuse.png` (land-use texture, `tools/land_bake.py`, #33) | Made by the bakes from the map content (`content/map/`, CC BY-SA 4.0) and the Copernicus-derived heightmap. The hexes' biomes come from the Copernicus DEM, CHELSA V2.1 and the IMS station normals. [CC BY-SA 4.0](LICENSES/CC-BY-SA-4.0.txt), the most restrictive input, by the owner's decision D13 (`docs/oss/DECISIONS.md`); per-file records in `ASSETS.yaml` |+| Derived map bakes | `unity/Assets/Resources/Map/BiomeColours.bytes` (biome colours, #529), `unity/Assets/Resources/Routes/RouteRibbons.bytes` (route ribbons, #436), `unity/Assets/Textures/Map/landuse.png` (land-use texture, `tools/land_bake.py`, #33), `unity/Assets/Resources/Map/MinimapRelief.png` (the minimap's painted relief, `tools/minimap_bake.py`, #398) | Made by the bakes from the map content (`content/map/`, CC BY-SA 4.0) and the Copernicus-derived heightmap. The hexes' biomes come from the Copernicus DEM, CHELSA V2.1 and the IMS station normals. [CC BY-SA 4.0](LICENSES/CC-BY-SA-4.0.txt), the most restrictive input, by the owner's decision D13 (`docs/oss/DECISIONS.md`); per-file records in `ASSETS.yaml` || Precipitation grid | `content/map/precip_bio12.*` | CHELSA V2.1, CC0 1.0 (Karger et al. 2017, 2021; see `tools/README.md`) || Rain-gauge data | `content/map/precip_stations.json` | Israel Meteorological Service, data.gov.il dataset 481, under the licence stated on the dataset ("Other (Open)") || Unity engine and packages | `unity/Packages/`, `unity/ProjectSettings/` | Configuration only. The Unity engine and its packages are under Unity's own terms and are not included. Two editor-only packages come from OpenUPM under their own licences and are not included either: `com.ivanmurzak.unity.mcp` (Unity-MCP, Apache-2.0) and its dependency `extensions.unity.playerprefsex` (MIT); see [THIRD-PARTY-NOTICES.md](THIRD-PARTY-NOTICES.md). No Asset Store content is in this repository. |diff --git a/docs/accessibility-audit-2026-10-14.md b/docs/accessibility-audit-2026-10-14.mdindex 6ef6d19ca..a9740fb5a 100644--- a/docs/accessibility-audit-2026-10-14.md+++ b/docs/accessibility-audit-2026-10-14.md@@ -311,6 +311,9 @@ The bars are always labelled ("Competence", "Loyalty"), so their colours carry n- **Start screen (no save):** New Game only, focused on open; Tab stays on it. Enter starts the game.- **Top bar:** Cabinet, Budget, Defence, Why?, New Game, End Turn, then round again (the info panel and the minimapcolumn take no focus until a hex is chosen by mouse).+ - Since HUD round 2 (#584, after this audit): End Turn is followed by the minimap's three buttons (whole map, settlement+ names, region borders), then round again; the minimap's picture still takes no focus (B1d). Under the open decision+ card the minimap column is disabled with the info panel, so its buttons leave the order then.- **Cabinet:** the top bar first, then the Prime Minister's card, his other office ("Minister of Defense"), the candidatelist when a seat is selected, then the cards row by row (H1, M2).- **Budget:** the top bar, then each line's - and +, then Reset and Submit (Submit is disabled until the draft changes).diff --git a/docs/visual-v1.md b/docs/visual-v1.mdindex 3d3b60498..898dbdc83 100644--- a/docs/visual-v1.md+++ b/docs/visual-v1.md@@ -2698,6 +2698,66 @@ The fix's diorama02 `all` p95 (33, 34) is back at or under main's (35, 36). In rfor both branch builds in the same stretch: spreads 1.36 and 1.68 against main's 0.01, and the old branch's `none` wasup too. Round 2 is clean, with all three at p95 18. `golden&smoke=5` is unchanged on the fix build.+## HUD round 2, part 1: the minimap (#398)++The owner chose all three round-2 pieces (2026-10-14), one PR each: the minimap, the left icon column, the top bar. This is+the minimap, against promo 03's (T54: "the minimap is a pixelated hex strip").+- The picture is a bake, `tools/minimap_bake.py` -> `unity/Assets/Resources/Map/MinimapRelief.png` (256 x 1024, powers of two so it is block-compressed on the GPU,+ mipmapped, trilinear): a hill shade of the heightmap (heights averaged over 3 x 3 samples, x12, lit from the north-west)+ over the biome colour bake and the land use (softened, a third parchment), the sea from `coast.png` (dark navy, a lighter+ band within 6 km of the shore, a thin pale line at the edge), and land outside Mandatory Palestine greyed with a gold rim.+ It replaces the 128-pixel point-filtered strip that `MinimapPresenter.Paint` drew at boot, so boot loses that loop and+ nothing is drawn per frame. `tools/tests/test_minimap_bake.py` re-bakes it in CI and compares the pixels.+- Promo 03's three round buttons, beside the picture: zoom all the way out (the camera's `MaxDistance`, over the middle+ of the map), show or hide the settlement names (the `labels` switch), show or hide the borders and their caption (the+ `borders` switch). A switched-off layer dims its button. The picture stays mouse-only (accessibility audit B1d); the+ buttons take Tab after End Turn.+- The panel is 222 x 380 (was 160 x 340): the picture 133 x 356, the buttons 50 px.++Measured on the WebGL `?shot` frames at 1920x1080 against promo 03's minimap (T54's definitions; the picture resized to+300 px tall first; land is every pixel that is not blue-dominant):++| | promo 03 | main gameplay03 | branch gameplay03 | branch diorama02 |+|---|---|---|---|---|+| panel, share of the frame | 4.97% | 2.62% | 4.07% | 4.07% |+| picture, share of the frame | 3.11% | 1.80% | 2.30% | 2.30% |+| land luma, contrast (std) | 0.467, 0.109 | 0.609, 0.078 | 0.492, 0.098 | 0.497, 0.106 |+| land p10-p90 | 0.260 | 0.163 | 0.259 | 0.271 |+| land relief (mean abs Laplacian) | 0.063 | 0.024 | 0.069 | 0.074 |+| land saturation | 0.327 | 0.353 | 0.277 | 0.275 |+| dE to promo: land, sea | 0, 0 | 17.2, 27.4 | 3.3, 2.4 | 3.7, 2.6 |++The picture is still taller and narrower than promo 03's, which crops the country; the minimap shows all of it. The+promo's region tints (orange and blue by side) are not in the bake: the two-colour borders (#555) change by date.++Frame time, `?vprofile` headless 1920x1080 DPR 1, and boot (`headed.py boot --runs 3`), one `machine_lock.py+--exclusive` slot, main df17ac6f first, then the branch (median avg ms, spread):++| | main | branch |+|---|---|---|+| gameplay03 all / none | 8.39 (0.09) / 7.18 (0.10) | 8.38 (0.06) / 7.11 (0.03) |+| diorama02 all / none | 15.96 (0.48) / 11.41 (0.09) | 16.52 (0.73) / 11.99 (0.10) |+| boot map_build / first_frame, cpu 1 | 565 / 3924 ms | 563 / 3917 ms |++That first pair was not interleaved. The re-run (one `--exclusive` slot, 10 minutes; both builds with a temporary,+uncommitted FrameProfile patch that measures only `all` and `none`, in the order base, branch, branch, base; two+diagnostic branch builds; a headed DPR 2 pair) shows no cost:++| run (order) | diorama02 all | diorama02 none | gameplay03 all | gameplay03 none |+|---|---|---|---|---|+| 1 main | 16.64 (0.48) | 11.83 (0.29) | 8.60 (0.61) | 7.12 (0.28) |+| 2 branch | 16.46 (2.90) | 11.81 (1.21) | 9.92 (0.08) | 8.19 (0.09) |+| 3 branch | 15.59 (0.44) | 11.24 (0.07) | 8.37 (0.09) | 7.08 (0.05) |+| 4 main | 15.45 (0.33) | 11.23 (0.06) | 8.25 (0.07) | 7.07 (0.09) |+| 5 branch, picture without mipmaps | 15.39 (0.42) | 11.20 (0.06) | 8.30 (0.03) | 7.01 (0.03) |+| 6 branch, main's 160 x 340 panel, no buttons | 15.42 (0.37) | 11.19 (0.15) | 8.30 (0.07) | 7.07 (0.02) |+| DPR 2 headed, main | 33.73 (0.15) | 27.90 (0.15) | 19.71 (0.94) | 18.33 (0.56) |+| DPR 2 headed, branch | 33.49 (0.05) | 27.86 (0.10) | 19.34 (0.29) | 17.81 (0.02) |++Runs in the same position agree within 0.1 ms (1 and 2; 3 and 4), and the 0.6 ms step follows the position in the slot,+not the build: the machine was slower early in the slot (run 2's gameplay03 is the same drift). The variants that remove+the mipmaps or the larger panel and its buttons cost the same as the branch. The first pair's +0.56 ms was this drift.+## Issue #391: the terrain shader's frame-time cliff (warm land shade, not shipped)#391 asked for the shaded hill ground to read warm brown, as promo 03's does (about (67, 53, 46)), rather than olive-grey.The look was solved; the cost was not, so nothing shipped. What was measured is a constraint on any future addition todiff --git a/tools/minimap_bake.py b/tools/minimap_bake.pynew file mode 100644index 000000000..b0ced664a--- /dev/null+++ b/tools/minimap_bake.py@@ -0,0 +1,179 @@+# /// script+# requires-python = ">=3.11"+# dependencies = ["numpy==2.5.3", "pillow==12.3.0", "pyyaml==6.0.3"]+# ///+"""The minimap's painted relief picture (HUD round 2, #398), in the look of promo/final/03-gameplay-1936.png's minimap.++Usage: uv run tools/minimap_bake.py (a few seconds; no network)+Reads only files already in the repository, all of them the map's own bakes or data:+ unity/Assets/StreamingAssets/map/heightmap.* the relief (hill shade, lit from the north-west)+ unity/Assets/Resources/Map/BiomeColours.bytes the ground colour the map draws (MapBuilder.BiomePixels, row 0 south)+ unity/Assets/Textures/Map/landuse.png the fields, orchards and terraces over it (tools/land_bake.py)+ unity/Assets/Textures/Map/coast.png the signed distance to the shore (tools/terrain_bake.py): the sea and lakes+ content/map/subdistrict_hexes_1948.yaml which land hexes lie outside Mandatory Palestine (dimmed, with a rim)+Writes unity/Assets/Resources/Map/MinimapRelief.png, RGB8, WIDTH x HEIGHT (powers of two), row 0 = north, over the heightmap's bounds+(the hex grid's bounds, so MinimapPresenter maps a click exactly as before). It is drawn once by the GPU as a UI+background: no runtime painting, no per-frame cost. Deterministic; tools/tests/test_minimap_bake.py re-bakes it in CI and+compares the pixels."""+import json+import math+import sys+from pathlib import Path++import numpy as np+from PIL import Image++sys.path.insert(0, str(Path(__file__).resolve().parent))+import heightmap_codec # noqa: E402+import hexgrid # noqa: E402+import yaml12 # noqa: E402++ROOT = Path(__file__).resolve().parents[1]+MAP_DIR = ROOT / "unity" / "Assets" / "StreamingAssets" / "map"+BIOME = ROOT / "unity" / "Assets" / "Resources" / "Map" / "BiomeColours.bytes"+LANDUSE = ROOT / "unity" / "Assets" / "Textures" / "Map" / "landuse.png"+COAST = ROOT / "unity" / "Assets" / "Textures" / "Map" / "coast.png"+REGIONS = ROOT / "content" / "map" / "subdistrict_hexes_1948.yaml"+HEXES = ROOT / "content" / "map" / "hexes.json"+OUT = ROOT / "unity" / "Assets" / "Resources" / "Map" / "MinimapRelief.png"++WIDTH, HEIGHT = 256, 1024 # powers of two, so Unity block-compresses it with its mipmaps (an NPOT texture stays+ # uncompressed RGB: review of #584). The frame is 161.5 x 431.2 km, so a pixel is about+ # 0.63 x 0.42 km; MinimapPresenter sizes the picture to the frame's aspect, not the texture's.+SUPER = 2 # samples per pixel per axis, box-filtered+COAST_RANGE_M = 12000.0 # coast.png: 0.5 + d / (2 COAST_RANGE_M), d < 0 in water+EXAGGERATION = 12.0 # relief for a 0.5 km pixel: the hills must read at minimap size+RELIEF_SMOOTH = 3 # heights averaged over 3 x 3 samples first: promo 03's broad ridges, not every gully+SUN_AZIMUTH, SUN_ALTITUDE = 315.0, 38.0 # the cartographer's light, from the north-west+LANDUSE_WEIGHT = 0.55 # the fields and orchards, softened: a painting, not the ground texture+PARCHMENT = np.array([196, 178, 142], np.float32) / 255 # the promo's dry land between the tinted areas+PARCHMENT_MIX = 0.30+BRUSH = 6 # the land colour is averaged over BRUSH x BRUSH samples (3 x 3 pixels, about 1.5 km)+SATURATION = 1.10+LAND_TONE = 0.86 # the land a little darker, toward promo 03 minimap's mean (luma about 0.47)+SHADOW = np.array([0.66, 0.60, 0.62], np.float32) # warm-cool split: shadows a little violet,+LIGHT = np.array([1.10, 1.06, 0.96], np.float32) # lit slopes a little warm+SEA_DEEP = np.array([17, 41, 66], np.float32) / 255 # promo 03 minimap's open sea+SEA_SHALLOW = np.array([47, 92, 118], np.float32) / 255 # its lighter water along the shore+SEA_SHALLOW_M = 6000.0+SURF = np.array([196, 206, 204], np.float32) / 255 # the thin pale line at the water's edge+OUTSIDE_DIM = 0.72 # land outside Mandatory Palestine: paler and greyer, as the promo's land beyond the play area+RIM = np.array([214, 178, 104], np.float32) / 255 # the gold rim of Mandatory Palestine+RIM_ALPHA = 0.45+OUTSIDE_ID = 17+++def resize(a: np.ndarray, w: int, h: int) -> np.ndarray:+ """Float resample of a 2-D array (row 0 north) to h x w: box-filtered down, bilinear up."""+ up = w > a.shape[1]+ f = Image.Resampling.BILINEAR if up else Image.Resampling.BOX+ return np.asarray(Image.fromarray(a.astype(np.float32), mode="F").resize((w, h), f), np.float32)+++def resize_rgb(a: np.ndarray, w: int, h: int) -> np.ndarray:+ return np.stack([resize(a[..., c], w, h) for c in range(a.shape[-1])], axis=-1)+++def heights(w: int, h: int) -> tuple[np.ndarray, float, float]:+ meta = json.loads((MAP_DIR / "heightmap.json").read_text())+ raw = heightmap_codec.read(MAP_DIR, meta)+ elev = meta["elev_min_m"] + raw.astype(np.float64) / 65535.0 * (meta["elev_max_m"] - meta["elev_min_m"])+ return resize(elev, w, h), meta["width_km"] * 1000 / w, meta["length_km"] * 1000 / h+++def hillshade(z: np.ndarray, dx: float, dy: float) -> np.ndarray:+ """Lambert shade of the exaggerated surface, 0..1 (row 0 north, so +y is south)."""+ zz = z * EXAGGERATION+ gy, gx = np.gradient(zz, dy, dx)+ nx, ny, nz = -gx, gy, np.ones_like(zz) # gy is d/d(south); north-up normal+ n = np.sqrt(nx * nx + ny * ny + nz * nz)+ az, alt = math.radians(SUN_AZIMUTH), math.radians(SUN_ALTITUDE)+ lx, ly, lz = math.sin(az) * math.cos(alt), math.cos(az) * math.cos(alt), math.sin(alt)+ return np.clip((nx * lx + ny * ly + nz * lz) / n, 0, 1)+++def biome_rgb(w: int, h: int) -> np.ndarray:+ data = BIOME.read_bytes()+ res = int.from_bytes(data[8:12], "little")+ px = np.frombuffer(data, np.uint8, offset=16).reshape(res, res, 3)[::-1].astype(np.float32) / 255 # row 0 north+ return resize_rgb(px, w, h)+++def landuse(w: int, h: int) -> tuple[np.ndarray, np.ndarray]:+ im = np.asarray(Image.open(LANDUSE).convert("RGBA"), np.float32) / 255+ a = im[..., 3]+ rgb = resize_rgb(im[..., :3] * a[..., None], w, h)+ alpha = resize(a, w, h)+ return rgb / np.maximum(alpha, 1e-4)[..., None], alpha+++def coast_m(w: int, h: int) -> np.ndarray:+ c = np.asarray(Image.open(COAST).convert("L"), np.float32) / 255+ return resize((c - 0.5) * 2 * COAST_RANGE_M, w, h)+++def outside(w: int, h: int) -> np.ndarray:+ """1 where the pixel's hex is land outside Mandatory Palestine (hexgrid's projection and rounding)."""+ doc = yaml12.load_path(REGIONS)+ out = {(q, r) for q, r, rid in doc["hexes"] if rid == OUTSIDE_ID}+ grid = json.loads(HEXES.read_text())+ b, size = grid["bounds"], grid["hex_size_km"]+ xs = (np.arange(w) + 0.5) / w * (b["lon1"] - b["lon0"]) * hexgrid.km_per_deg_lon(b)+ ys = (np.arange(h) + 0.5) / h * (b["lat1"] - b["lat0"]) * hexgrid.KM_PER_DEG_LAT+ X, Y = np.meshgrid(xs, ys)+ qs, rs = hexgrid.point_to_hex(X.ravel(), Y.ravel(), size)+ return np.array([(q, r) in out for q, r in zip(qs, rs)], np.float32).reshape(h, w)+++def smooth(t: np.ndarray, a: float, b: float) -> np.ndarray:+ x = np.clip((t - a) / (b - a), 0, 1)+ return x * x * (3 - 2 * x)+++def bake() -> np.ndarray:+ w, h = WIDTH * SUPER, HEIGHT * SUPER+ z, dx, dy = heights(w, h)+ z = resize(resize(z, w // RELIEF_SMOOTH, h // RELIEF_SMOOTH), w, h)+ shade = hillshade(z, dx, dy)+ flat = math.sin(math.radians(SUN_ALTITUDE)) # the shade of level ground+ ground = biome_rgb(w, h)+ land_rgb, land_a = landuse(w, h)+ k = (land_a * LANDUSE_WEIGHT)[..., None]+ land = ground * (1 - k) + land_rgb * k+ land = resize_rgb(resize_rgb(land, w // BRUSH, h // BRUSH), w, h) # broad strokes: no field speckle at minimap size+ grey = land.mean(axis=-1, keepdims=True)+ land = grey + (land - grey) * SATURATION+ land = (land * (1 - PARCHMENT_MIX) + PARCHMENT * PARCHMENT_MIX) * LAND_TONE+ rel = np.clip((shade - flat) / (1 - flat), -1, 1)[..., None] # < 0 turned away, > 0 towards the light+ land = np.where(rel < 0, land * (1 + (SHADOW - 1) * -rel), land * (1 + (LIGHT - 1) * rel))+ out = outside(w, h)[..., None]+ grey = land.mean(axis=-1, keepdims=True)+ land = land * (1 - out) + (land * 0.5 + grey * 0.5) * OUTSIDE_DIM * out + 0.06 * out++ d = coast_m(w, h)[..., None] # metres, < 0 in water+ sea = SEA_DEEP + (SEA_SHALLOW - SEA_DEEP) * (1 - smooth(-d, 0, SEA_SHALLOW_M))+ surf = (1 - smooth(-d, 0, 900)) * (d < 0)+ sea = sea + (SURF - sea) * surf * 0.55+ water = smooth(-d, -150, 150) # a soft shore line+ rgb = land * (1 - water) + sea * water++ # the rim of Mandatory Palestine: where a land pixel inside meets land outside+ o = out[..., 0]+ edge = np.zeros_like(o)+ for sy, sx in ((0, 1), (1, 0), (0, -1), (-1, 0)):+ edge = np.maximum(edge, np.abs(o - np.roll(o, (sy, sx), axis=(0, 1))))+ edge *= (1 - water[..., 0])+ rgb = rgb + (RIM - rgb) * (edge * RIM_ALPHA)[..., None]++ rgb = resize_rgb(np.clip(rgb, 0, 1), WIDTH, HEIGHT)+ return np.clip(np.round(rgb * 255), 0, 255).astype(np.uint8)+++def main() -> None:+ OUT.parent.mkdir(parents=True, exist_ok=True)+ Image.fromarray(bake(), "RGB").save(OUT, optimize=True)+ print(f"wrote {OUT.relative_to(ROOT)} {WIDTH}x{HEIGHT}")+++if __name__ == "__main__":+ main()diff --git a/tools/tests/test_minimap_bake.py b/tools/tests/test_minimap_bake.pynew file mode 100644index 000000000..aeff7e96f--- /dev/null+++ b/tools/tests/test_minimap_bake.py@@ -0,0 +1,34 @@+"""The minimap's painted relief (unity/Assets/Resources/Map/MinimapRelief.png, HUD round 2, #398) is the bake of today's+inputs and code.++tools/minimap_bake.py makes it from the heightmap, the biome colour bake, the land-use and coast textures and the+sub-district hexes, all committed. CI runs no Unity, so this re-bakes it here and compares the pixels with the committed+PNG: a change to any input or to the bake's code without a re-bake (uv run tools/minimap_bake.py) fails. The bake is+float arithmetic in numpy and Pillow, so a different toolchain may round a channel the other way: one step is allowed."""+import sys+from pathlib import Path++import numpy as np+from PIL import Image++TOOLS = Path(__file__).resolve().parents[1]+sys.path.insert(0, str(TOOLS))+import minimap_bake # noqa: E402++REBAKE = "re-bake it: uv run tools/minimap_bake.py"+++def test_the_committed_minimap_is_the_bake_of_its_inputs():+ committed = np.asarray(Image.open(minimap_bake.OUT).convert("RGB"), np.int16)+ fresh = minimap_bake.bake().astype(np.int16)+ assert committed.shape == fresh.shape, f"{minimap_bake.OUT.name} is {committed.shape}, the bake makes {fresh.shape}: {REBAKE}"+ diff = np.abs(committed - fresh)+ off = int((diff > 1).any(axis=-1).sum())+ assert off == 0, f"{off} pixels differ by more than one step (max {int(diff.max())}): {REBAKE}"+++def test_the_minimap_sides_are_powers_of_two():+ """Unity block-compresses a mipmapped texture only with power-of-two sides (review of #584: an NPOT relief stayed+ uncompressed RGB, about 2.5 MB in the editor); the presenter sizes the picture to the frame's own aspect."""+ for side in (minimap_bake.WIDTH, minimap_bake.HEIGHT):+ assert side > 0 and side & (side - 1) == 0, sidediff --git a/unity/Assets/Resources/Map/MinimapRelief.png b/unity/Assets/Resources/Map/MinimapRelief.pngnew file mode 100644index 000000000..87a458b1bBinary files /dev/null and b/unity/Assets/Resources/Map/MinimapRelief.png differdiff --git a/unity/Assets/Resources/Map/MinimapRelief.png.meta b/unity/Assets/Resources/Map/MinimapRelief.png.metanew file mode 100644index 000000000..57b3f1531--- /dev/null+++ b/unity/Assets/Resources/Map/MinimapRelief.png.meta@@ -0,0 +1,130 @@+fileFormatVersion: 2+guid: cce36c79c7f34733a67134ad7d75b2f0+TextureImporter:+ internalIDToNameTable: []+ externalObjects: {}+ serializedVersion: 13+ mipmaps:+ mipMapMode: 0+ enableMipMap: 1+ sRGBTexture: 1+ linearTexture: 0+ fadeOut: 0+ borderMipMap: 0+ mipMapsPreserveCoverage: 0+ alphaTestReferenceValue: 0.5+ mipMapFadeDistanceStart: 1+ mipMapFadeDistanceEnd: 3+ bumpmap:+ convertToNormalMap: 0+ externalNormalMap: 0+ heightScale: 0.25+ normalMapFilter: 0+ flipGreenChannel: 0+ isReadable: 0+ streamingMipmaps: 0+ streamingMipmapsPriority: 0+ vTOnly: 0+ ignoreMipmapLimit: 0+ grayScaleToAlpha: 0+ generateCubemap: 6+ cubemapConvolution: 0+ seamlessCubemap: 0+ textureFormat: 1+ maxTextureSize: 1024+ textureSettings:+ serializedVersion: 2+ filterMode: 2+ aniso: 1+ mipBias: 0+ wrapU: 1+ wrapV: 1+ wrapW: 1+ nPOTScale: 0+ lightmap: 0+ compressionQuality: 50+ spriteMode: 0+ spriteExtrude: 1+ spriteMeshType: 1+ alignment: 0+ spritePivot: {x: 0.5, y: 0.5}+ spritePixelsToUnits: 100+ spriteBorder: {x: 0, y: 0, z: 0, w: 0}+ spriteGenerateFallbackPhysicsShape: 1+ alphaUsage: 0+ alphaIsTransparency: 0+ spriteTessellationDetail: -1+ textureType: 0+ textureShape: 1+ singleChannelComponent: 1+ flipbookRows: 1+ flipbookColumns: 1+ maxTextureSizeSet: 0+ compressionQualitySet: 0+ textureFormatSet: 0+ ignorePngGamma: 0+ applyGammaDecoding: 0+ swizzle: 50462976+ cookieLightType: 0+ platformSettings:+ - serializedVersion: 4+ buildTarget: DefaultTexturePlatform+ maxTextureSize: 1024+ resizeAlgorithm: 0+ textureFormat: -1+ textureCompression: 1+ compressionQuality: 50+ crunchedCompression: 0+ allowsAlphaSplitting: 0+ overridden: 0+ ignorePlatformSupport: 0+ androidETC2FallbackOverride: 0+ forceMaximumCompressionQuality_BC6H_BC7: 0+ - serializedVersion: 4+ buildTarget: Standalone+ maxTextureSize: 1024+ resizeAlgorithm: 0+ textureFormat: -1+ textureCompression: 1+ compressionQuality: 50+ crunchedCompression: 0+ allowsAlphaSplitting: 0+ overridden: 0+ ignorePlatformSupport: 0+ androidETC2FallbackOverride: 0+ forceMaximumCompressionQuality_BC6H_BC7: 0+ - serializedVersion: 4+ buildTarget: WebGL+ maxTextureSize: 1024+ resizeAlgorithm: 0+ textureFormat: -1+ textureCompression: 1+ compressionQuality: 50+ crunchedCompression: 0+ allowsAlphaSplitting: 0+ overridden: 0+ ignorePlatformSupport: 0+ androidETC2FallbackOverride: 0+ forceMaximumCompressionQuality_BC6H_BC7: 0+ spriteSheet:+ serializedVersion: 2+ sprites: []+ outline: []+ customData:+ physicsShape: []+ bones: []+ spriteID:+ internalID: 0+ vertices: []+ indices:+ edges: []+ weights: []+ secondaryTextures: []+ spriteCustomMetadata:+ entries: []+ nameFileIdTable: {}+ mipmapLimitGroupName:+ pSDRemoveMatte: 0+ userData:+ assetBundleName:+ assetBundleVariant:diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.csindex 25c267b70..874ba7a05 100644--- a/unity/Assets/Scripts/UI/GameRoot.cs+++ b/unity/Assets/Scripts/UI/GameRoot.cs@@ -230,8 +230,10 @@ namespace Statecraft.Game.UIregions.Apply(bridge.State.Date);layerLabel.text = regions.ControlLabel(bridge.State.Date, k => text[k])?? regions.Label(bridge.State.Date, text.Format);- layerLabel.style.display = regions.Shown ? DisplayStyle.Flex : DisplayStyle.None;+ ShowLayerLabel();};+ // The caption names the borders while they are drawn: by date, and not while the minimap's button hides them.+ void ShowLayerLabel() => layerLabel.style.display = regions.Shown && minimap?.BordersShown != false ? DisplayStyle.Flex : DisplayStyle.None;onDate();bridge.Changed += onDate;owned.Add(new Undo(() => bridge.Changed -= onDate));@@ -289,11 +291,19 @@ namespace Statecraft.Game.UIpointer.HexClicked += onHex;var camRig = rig = cameraController.GetComponent<CameraRig>();Own(new TopBarInset(root, camRig)); // the map is framed below the top bar- var mini = minimap = Own(new MinimapPresenter(root, map.Hexes));+ var mini = minimap = Own(new MinimapPresenter(root, map.Hexes, text));labels = Own(new MapLabelsPresenter(root, map, cameraController.GetComponent<Camera>(), null,p => MapLabelsPresenter.TipOf(p, n => text.Format("map.today", n), text["map.mixed"], hebrew),() => unitLayer != null ? unitLayer.KeepClear : null)); // the names keep clear of the unit tokens (issue #197)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 += () =>+ {+ var (lon, lat) = mini.Centre;+ camRig.LookAt = map.Frame.ToWorld(lon, lat, 0); camRig.Distance = CameraController.MaxDistance;+ cameraController.Settle(); SyncMinimap(); labels?.Refresh();+ };+ mini.BordersChanged += ShowLayerLabel;Action onChanged = RenderPlacementsIfChanged;bridge.Changed += onChanged;// One console line per turn, so a browser run (reload, Continue) can be checked against the hash.diff --git a/unity/Assets/Scripts/UI/HoverTip.cs b/unity/Assets/Scripts/UI/HoverTip.csnew file mode 100644index 000000000..1cac51098--- /dev/null+++ b/unity/Assets/Scripts/UI/HoverTip.cs@@ -0,0 +1,85 @@+#nullable enable+using System;+using System.Collections.Generic;+using UnityEngine.UIElements;++namespace Statecraft.Game.UI+{+ /// <summary>A visible tip for icon-only buttons (owner ruling on #584: "icon-only, with tooltips"). Each button keeps its+ /// name in <c>tooltip</c>, as the top bar's meters do (#523), but UI Toolkit draws <c>tooltip</c> only in Editor UI, not+ /// in a runtime panel, so this shows the same text in Game.uxml's <c>hud-tip</c> label beside the button.+ /// Hover and keyboard focus are tracked apart (review of #584): the tip names the hovered button, else the focused one, so+ /// a pointer leaving does not hide the name the keyboard focus still holds, and a blur (PointerBlur after a click) does+ /// not hide the one under the pointer. Pressing a button hides its tip (the screen or layer it opens may lie under it)+ /// until the pointer or the focus comes to it again. On touch the pointer enters on finger down and leaves on lift, so+ /// the tip shows only while the finger is down, and the lift presses the button. The label takes no clicks; nothing runs+ /// per frame.</summary>+ public sealed class HoverTip : IDisposable+ {+ public const string TipName = "hud-tip";+ /// <summary>Which side of its button the tip sits on.</summary>+ public enum Side { Left, Right }++ readonly VisualElement layer; readonly Label tip; readonly Func<Side> side;+ readonly List<VisualElement> targets = new List<VisualElement>();+ readonly EventCallback<PointerEnterEvent> onEnter; readonly EventCallback<PointerLeaveEvent> onLeave;+ readonly EventCallback<FocusInEvent> onFocus; readonly EventCallback<FocusOutEvent> onBlur;+ readonly EventCallback<ClickEvent> onClick; readonly EventCallback<NavigationSubmitEvent> onSubmit;+ VisualElement? hovered, focused, pressed, shownFor;++ /// <param name="root">The UI root holding the <c>hud-tip</c> label.</param>+ /// <param name="side">Where the tip goes, asked each time it shows (a mirrored layout may move the buttons).</param>+ public HoverTip(VisualElement root, IEnumerable<VisualElement> buttons, Func<Side> side)+ {+ tip = root.Q<Label>(TipName); layer = tip.parent; this.side = side;+ onEnter = e => { hovered = (VisualElement)e.currentTarget; pressed = null; Refresh(); };+ onLeave = e => { if (hovered == e.currentTarget) hovered = null; Refresh(); };+ onFocus = e => { focused = (VisualElement)e.currentTarget; if (pressed == focused && hovered != focused) pressed = null; Refresh(); };+ onBlur = e => { if (focused == e.currentTarget) focused = null; Refresh(); };+ onClick = e => { pressed = (VisualElement)e.currentTarget; Refresh(); };+ onSubmit = e => { pressed = (VisualElement)e.currentTarget; Refresh(); };+ foreach (var b in buttons)+ {+ targets.Add(b);+ b.RegisterCallback(onEnter); b.RegisterCallback(onLeave); b.RegisterCallback(onFocus); b.RegisterCallback(onBlur);+ b.RegisterCallback(onClick); b.RegisterCallback(onSubmit);+ }+ }++ /// <summary>The button the tip shows for now, or null.</summary>+ public VisualElement? ShownFor => shownFor;++ void Refresh()+ {+ var target = hovered ?? focused;+ if (target != null && target == pressed) target = null;+ if (target == null || string.IsNullOrEmpty(target.tooltip) || !(target.worldBound.width > 0)) { Hide(); return; }+ var r = layer.WorldToLocal(target.worldBound);+ tip.text = target.tooltip;+ if (side() == Side.Left) { tip.style.left = StyleKeyword.Auto; tip.style.right = layer.layout.width - r.xMin + 8; }+ else { tip.style.right = StyleKeyword.Auto; tip.style.left = r.xMax + 8; }+ tip.style.top = r.center.y;+ tip.style.display = DisplayStyle.Flex;+ shownFor = target;+ }++ void Hide()+ {+ if (shownFor == null) return;+ tip.style.display = DisplayStyle.None;+ shownFor = null;+ }++ public void Dispose()+ {+ foreach (var b in targets)+ {+ b.UnregisterCallback(onEnter); b.UnregisterCallback(onLeave); b.UnregisterCallback(onFocus); b.UnregisterCallback(onBlur);+ b.UnregisterCallback(onClick); b.UnregisterCallback(onSubmit);+ }+ hovered = focused = pressed = null;+ Hide();+ targets.Clear();+ }+ }+}diff --git a/unity/Assets/Scripts/UI/HoverTip.cs.meta b/unity/Assets/Scripts/UI/HoverTip.cs.metanew file mode 100644index 000000000..dd35b628e--- /dev/null+++ b/unity/Assets/Scripts/UI/HoverTip.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: 6bc16178903af42ffae1d223776c135f\ No newline at end of filediff --git a/unity/Assets/Scripts/UI/MinimapPresenter.cs b/unity/Assets/Scripts/UI/MinimapPresenter.csindex 8ae8c3c66..94396bfe7 100644--- a/unity/Assets/Scripts/UI/MinimapPresenter.cs+++ b/unity/Assets/Scripts/UI/MinimapPresenter.cs@@ -1,38 +1,66 @@#nullable enableusing System;+using System.Linq;using Statecraft.Game.Map;using UnityEngine;using UnityEngine.UIElements;-using Object = UnityEngine.Object;namespace Statecraft.Game.UI{- /// <summary>The minimap (bottom-right): every hex in its biome colour, north up, the camera's view as a frame, and a- /// click to move the camera there. The texture is made at runtime and destroyed by Dispose.</summary>+ /// <summary>The minimap (bottom-right, promo/final/03's): the painted relief picture, north up, the camera's view as a+ /// frame, and a click to move the camera there; beside it three round buttons: the whole map, the settlement names and+ /// the region borders. The picture is a bake (tools/minimap_bake.py, Resources/Map/MinimapRelief.png), drawn by the GPU+ /// as the element's background: nothing is painted at boot or per frame. It is a shared asset, so Dispose lets go of it+ /// and does not destroy it. The picture takes no focus (accessibility audit B1d); the buttons do.</summary>public sealed class MinimapPresenter : IDisposable{- public const int Width = 128;- public static readonly Color Sea = MapBuilder.BiomeColours["sea"];- readonly VisualElement box, image, view; readonly HexFile hexes;+ /// <summary>The bake, as Resources.Load finds it, and as the editor and the tests find the file.</summary>+ public const string Resource = "Map/MinimapRelief", AssetPath = "Assets/Resources/Map/MinimapRelief.png";+ /// <summary>On a switch button while its layer is off: the disc dims.</summary>+ public const string OffClass = "minimap-off";+ /// <summary>The switches the two layer buttons work (MapLabelsPresenter's names, MapBorders' borders).</summary>+ public const string LabelsToggle = "labels";++ readonly VisualElement box, frame, image, view; readonly HexFile hexes;+ readonly Button overview, labels, borders;readonly double widthKm, lengthKm;+ readonly HoverTip? tips;public Texture2D Texture { get; }+ /// <summary>The picture's width over its height: the map frame's, in km. The bake's sides are powers of two (so it is+ /// block-compressed), so its pixels are not square and its own width over height is not the map's.</summary>+ public float Aspect => (float)(widthKm / lengthKm);/// <summary>Raised with the lon/lat the player clicked.</summary>public event Action<double, double>? Clicked;+ /// <summary>Raised by the whole-map button: GameRoot zooms the camera all the way out.</summary>+ public event Action? Overview;+ /// <summary>Raised when the borders button switches the borders (the border layer's caption follows them).</summary>+ public event Action? BordersChanged;+ public bool LabelsShown { get; private set; } = true;+ public bool BordersShown { get; private set; } = true;- public MinimapPresenter(VisualElement root, HexFile hexes)+ public MinimapPresenter(VisualElement root, HexFile hexes, UiText? text = null){this.hexes = hexes;var b = hexes.bounds;widthKm = (b.lon1 - b.lon0) * HexPicker.KmPerDegLon(b.lat0, b.lat1);lengthKm = (b.lat1 - b.lat0) * HexPicker.KmPerDegLat;- Texture = Paint(hexes, Width, (int)Math.Round(Width * lengthKm / widthKm));+ Texture = Resources.Load<Texture2D>(Resource) ?? throw new InvalidOperationException($"Resources/{Resource} is missing (uv run tools/minimap_bake.py)");box = root.Q<VisualElement>("minimap");+ frame = box.Q<VisualElement>("minimap-map");image = box.Q<VisualElement>("minimap-image");view = box.Q<VisualElement>("minimap-view");image.style.backgroundImage = new StyleBackground(Texture);image.RegisterCallback<PointerDownEvent>(OnPointerDown);- box.RegisterCallback<GeometryChangedEvent>(OnBoxGeometry);+ frame.RegisterCallback<GeometryChangedEvent>(OnBoxGeometry);+ overview = box.Q<Button>("minimap-overview"); labels = box.Q<Button>("minimap-labels"); borders = box.Q<Button>("minimap-borders");+ overview.clicked += OnOverview; labels.clicked += OnLabels; borders.clicked += OnBorders;+ if (text != null)+ {+ overview.tooltip = text["minimap.overview"]; labels.tooltip = text["minimap.labels"]; borders.tooltip = text["minimap.borders"];+ }+ // The buttons are icon-only (owner ruling on #584); their names show beside them, on the picture's side.+ if (root.Q<Label>(HoverTip.TipName) != null) tips = new HoverTip(root, new VisualElement[] { overview, labels, borders }, () => HoverTip.Side.Left);FitImage();}@@ -49,7 +77,7 @@ namespace Statecraft.Game.UI// The picture's element is exactly as big as the picture, so (0..1, 0..1) in the element is the whole map.void FitImage(){- var size = Fit(box.contentRect.width, box.contentRect.height, (float)Texture.width / Texture.height);+ var size = Fit(frame.contentRect.width, frame.contentRect.height, Aspect);if (size == Vector2.zero) return;image.style.width = size.x; image.style.height = size.y;}@@ -62,24 +90,26 @@ namespace Statecraft.Game.UIClicked?.Invoke(lon, lat);}- /// <summary>One pixel per ~1.3 km: each pixel takes the biome of the hex its centre falls in (sea off the grid).- /// Row 0 of a Texture2D is the bottom, so it is the south edge.</summary>- public static Texture2D Paint(HexFile hexes, int width, int height)+ void OnOverview() => Overview?.Invoke();++ void OnLabels(){- var biome = new System.Collections.Generic.Dictionary<(int, int), string>();- foreach (var h in hexes.hexes) biome[(h.q, h.r)] = h.biome;- var b = hexes.bounds;- var tex = new Texture2D(width, height, TextureFormat.RGB24, false) { name = "Minimap", filterMode = FilterMode.Point, wrapMode = TextureWrapMode.Clamp };- var pixels = new Color[width * height];- for (int y = 0; y < height; y++)- for (int x = 0; x < width; x++)- {- double lon = b.lon0 + (x + 0.5) / width * (b.lon1 - b.lon0), lat = b.lat0 + (y + 0.5) / height * (b.lat1 - b.lat0);- var hex = HexPicker.FromLonLat(lon, lat, b, hexes.hex_size_km);- pixels[y * width + x] = biome.TryGetValue(hex, out var name) ? MapBuilder.BiomeColours[name] : Sea;- }- tex.SetPixels(pixels); tex.Apply();- return tex;+ LabelsShown = !LabelsShown;+ Switch(LabelsToggle, LabelsShown, labels);+ }++ void OnBorders()+ {+ BordersShown = !BordersShown;+ Switch(MapBorders.ToggleName, BordersShown, borders);+ BordersChanged?.Invoke();+ }++ // The map registers its switches when it is built; with no map (a test, or before the map) the button keeps its state.+ static void Switch(string name, bool on, Button button)+ {+ if (VisualToggles.Names.Contains(name)) VisualToggles.Set(name, on);+ button.EnableInClassList(OffClass, !on);}/// <summary>(u, v) in the image, top-left origin, 0..1 -> lon/lat.</summary>@@ -89,6 +119,9 @@ namespace Statecraft.Game.UIreturn (b.lon0 + Mathf.Clamp01(u) * (b.lon1 - b.lon0), b.lat1 - Mathf.Clamp01(v) * (b.lat1 - b.lat0));}+ /// <summary>The middle of the map's bounds (the whole-map view looks at it).</summary>+ public (double lon, double lat) Centre => ToLonLat(0.5f, 0.5f);+/// <summary>Frames the area the camera looks at: about one and a half view distances wide, centred on lookAt.</summary>public void SetView(GeoFrame frame, Vector3 lookAt, float distanceM){@@ -105,9 +138,10 @@ namespace Statecraft.Game.UIpublic void Dispose(){image.UnregisterCallback<PointerDownEvent>(OnPointerDown);- box.UnregisterCallback<GeometryChangedEvent>(OnBoxGeometry);- image.style.backgroundImage = StyleKeyword.Null; // nothing may keep drawing a destroyed texture- if (Texture != null) Object.DestroyImmediate(Texture);+ frame.UnregisterCallback<GeometryChangedEvent>(OnBoxGeometry);+ overview.clicked -= OnOverview; labels.clicked -= OnLabels; borders.clicked -= OnBorders;+ tips?.Dispose();+ image.style.backgroundImage = StyleKeyword.Null; // the shared picture stays loaded; this element lets go of it}}}diff --git a/unity/Assets/Scripts/UI/UiIcon.cs b/unity/Assets/Scripts/UI/UiIcon.csindex 7bac925d5..82b8775d6 100644--- a/unity/Assets/Scripts/UI/UiIcon.cs+++ b/unity/Assets/Scripts/UI/UiIcon.cs@@ -44,6 +44,7 @@ namespace Statecraft.Game.UI["columns"] = Columns, ["scales"] = Scales, ["helmet"] = Helmet, ["question"] = Question, ["restart"] = Restart,["chevron"] = Chevron, ["chevron-back"] = ChevronBack, ["hourglass"] = Hourglass,["region"] = Region, ["house"] = House, ["village"] = Village, ["flag"] = Flag,+ ["peaks"] = Peaks, ["skyline"] = Skyline,["biome-sea"] = Waves, ["biome-lake"] = Waves, ["biome-coastal_plain"] = Plain, ["biome-hills"] = Hills,["biome-mountains"] = Mountains, ["biome-valley"] = Valley, ["biome-lowland"] = Plain, ["biome-desert"] = Dunes,};@@ -279,6 +280,31 @@ namespace Statecraft.Game.UIp.BeginPath(); p.MoveTo(at(15, 6)); p.LineTo(at(15, 20.8f)); p.Stroke();}+ /// <summary>The minimap's whole-map button (promo 03): two peaks in outline, the far one behind, with a snow line.</summary>+ static void Peaks(Painter2D p, Func<float, float, Vector2> at, float s, Color gold)+ {+ p.strokeColor = gold; p.lineWidth = 1.4f * s;+ p.BeginPath(); p.MoveTo(at(1.8f, 20)); p.LineTo(at(9, 5.2f)); p.LineTo(at(16.2f, 20)); p.Stroke();+ p.BeginPath(); p.MoveTo(at(12.6f, 12.6f)); p.LineTo(at(15.4f, 8.2f)); p.LineTo(at(22.2f, 20)); p.Stroke();+ p.BeginPath(); p.MoveTo(at(1.8f, 20)); p.LineTo(at(22.2f, 20)); p.Stroke();+ p.lineWidth = 1f * s;+ p.BeginPath(); p.MoveTo(at(6.6f, 10.2f)); p.LineTo(at(8.2f, 11.4f)); p.LineTo(at(9.6f, 9.8f)); p.LineTo(at(11.4f, 10.2f)); p.Stroke();+ }++ /// <summary>The minimap's settlement-names button (promo 03): a town's skyline, three towers of different heights.</summary>+ static void Skyline(Painter2D p, Func<float, float, Vector2> at, float s, Color gold)+ {+ p.strokeColor = gold; p.lineWidth = 1.4f * s;+ p.BeginPath(); p.MoveTo(at(3, 20.6f)); p.LineTo(at(3, 9)); p.LineTo(at(8.4f, 9)); p.LineTo(at(8.4f, 20.6f)); p.Stroke();+ p.BeginPath(); p.MoveTo(at(8.4f, 20.6f)); p.LineTo(at(8.4f, 4.4f)); p.LineTo(at(14.6f, 4.4f)); p.LineTo(at(14.6f, 20.6f)); p.Stroke();+ p.BeginPath(); p.MoveTo(at(14.6f, 20.6f)); p.LineTo(at(14.6f, 12)); p.LineTo(at(21, 12)); p.LineTo(at(21, 20.6f)); p.Stroke();+ p.BeginPath(); p.MoveTo(at(1.6f, 20.6f)); p.LineTo(at(22.4f, 20.6f)); p.Stroke();+ p.fillColor = gold;+ foreach (var y in new[] { 7.4f, 11f, 14.6f }) { Rect(p, at, 10.4f, y, 2.2f, 1.8f); p.Fill(); }+ Rect(p, at, 4.6f, 12f, 2.2f, 1.8f); p.Fill();+ Rect(p, at, 16.6f, 15f, 2.2f, 1.8f); p.Fill();+ }+/// <summary>The settlements row: a house.</summary>static void House(Painter2D p, Func<float, float, Vector2> at, float s, Color gold){diff --git a/unity/Assets/Tests/EditMode/GameSceneTests.cs b/unity/Assets/Tests/EditMode/GameSceneTests.csindex fba89c307..4b6cf1cdc 100644--- a/unity/Assets/Tests/EditMode/GameSceneTests.cs+++ b/unity/Assets/Tests/EditMode/GameSceneTests.cs@@ -293,8 +293,8 @@ public class GameSceneTestsAssert.IsNull(camera.IsOverUi);Assert.IsNull(pointer.Map, "the pointer no longer picks on this map");Assert.AreEqual(float.MaxValue, camera.Bounds.width, "the camera bounds are restored");- Assert.IsTrue(texture == null, "the minimap texture is destroyed");- Assert.AreEqual(StyleKeyword.Null, image.style.backgroundImage.keyword, "nothing draws the destroyed texture");+ Assert.IsTrue(texture != null, "the minimap's picture is the shared baked asset: let go of, not destroyed");+ Assert.AreEqual(StyleKeyword.Null, image.style.backgroundImage.keyword, "nothing draws the minimap's picture");foreach (var label in Watched)Ui.Q<Label>(label).text = "untouched";var turn = bridge.State.Turn;diff --git a/unity/Assets/Tests/EditMode/MapActionUiTests.cs b/unity/Assets/Tests/EditMode/MapActionUiTests.csindex 909d06c77..8ec158763 100644--- a/unity/Assets/Tests/EditMode/MapActionUiTests.cs+++ b/unity/Assets/Tests/EditMode/MapActionUiTests.cs@@ -84,21 +84,26 @@ public class MapActionUiTestsAssert.AreEqual("A transit camp built here in August 1950", ui.Q<Label>("info-placement").text);}+ /// <summary>The minimap's painted relief (tools/minimap_bake.py) is north up over the hex grid's bounds: sea off Tel Aviv+ /// and in the Gulf of Aqaba, land in the hills and the Negev. Read from the PNG itself (the imported texture is not+ /// readable on the CPU).</summary>[Test]- public void TheMinimapPaintsLandAndSeaNorthUp()+ public void TheMinimapReliefHasLandAndSeaNorthUp(){- var tex = MinimapPresenter.Paint(Hexes, 128, 342);+ var tex = new Texture2D(2, 2);try{- // RGB24 stores 8 bits per channel, so compare within one step.- void Is(Color expected, double lon, double lat)- {- var c = tex.GetPixel((int)((lon - 34.2) / 1.7 * 128), (int)((lat - 29.45) / 3.9 * 342));- Assert.AreEqual(expected.r, c.r, 1f / 255); Assert.AreEqual(expected.g, c.g, 1f / 255); Assert.AreEqual(expected.b, c.b, 1f / 255);- }- Is(MapBuilder.BiomeColours["coastal_plain"], 34.80, 32.10); // just inland of Tel Aviv- Is(MinimapPresenter.Sea, 34.30, 32.60); // the Mediterranean- Is(MapBuilder.BiomeColours["desert"], 34.90, 30.50); // the Negev+ Assert.IsTrue(tex.LoadImage(File.ReadAllBytes(Path.Combine(Paths.RepoRoot, "unity", MinimapPresenter.AssetPath))), MinimapPresenter.AssetPath);+ var b = Hexes.bounds;+ Color At(double lon, double lat) =>+ tex.GetPixel((int)((lon - b.lon0) / (b.lon1 - b.lon0) * tex.width), (int)((lat - b.lat0) / (b.lat1 - b.lat0) * tex.height));+ void Sea(double lon, double lat, string where) { var c = At(lon, lat); Assert.Greater(c.b, c.r + 0.1f, $"{where} is sea: {c}"); }+ void Land(double lon, double lat, string where) { var c = At(lon, lat); Assert.Greater(c.r, c.b, $"{where} is land: {c}"); }+ Sea(34.30, 32.60, "the Mediterranean off Tel Aviv");+ Sea(34.92, 29.47, "the Gulf of Aqaba (its middle: about 34.88-34.96 E at 29.47 N)");+ Land(35.21, 31.77, "Jerusalem");+ Land(34.90, 30.50, "the Negev");+ Land(35.10, 32.95, "the Galilee");}finally { UnityEngine.Object.DestroyImmediate(tex); }}@@ -179,10 +184,10 @@ public class MapActionUiTestsusing var ui = new UiTestKit();using var mini = new MinimapPresenter(ui.Root, Hexes);var image = ui.Q<VisualElement>("minimap-image");- for (int i = 0; i < 30 && !(image.layout.width > 0 && Mathf.Abs(image.layout.width / image.layout.height - (float)mini.Texture.width / mini.Texture.height) < 0.01f); i++) yield return null;+ for (int i = 0; i < 30 && !(image.layout.width > 0 && Mathf.Abs(image.layout.width / image.layout.height - mini.Aspect) < 0.01f); i++) yield return null;Assert.Greater(image.layout.width, 0f);// the element is exactly as big as the picture (aspect of the texture), so there is no unused strip inside it- Assert.AreEqual((float)mini.Texture.width / mini.Texture.height, image.layout.width / image.layout.height, 0.01f);+ Assert.AreEqual(mini.Aspect, image.layout.width / image.layout.height, 0.01f);(double lon, double lat)? clicked = null;mini.Clicked += (lon, lat) => clicked = (lon, lat);var b = Hexes.bounds;@@ -347,7 +352,7 @@ public class MapActionUiTests}[Test]- public void ADisposedMinimapDestroysItsTextureAndADisposedPanelHearsNothing()+ public void ADisposedMinimapLetsGoOfItsPictureAndADisposedPanelHearsNothing(){using var ui = new UiTestKit();var bridge = At(new DateTime(1950, 8, 1));@@ -361,7 +366,9 @@ public class MapActionUiTestsvar mini = new MinimapPresenter(ui.Root, Hexes);var tex = mini.Texture;mini.Dispose();- Assert.IsTrue(tex == null, "the texture is destroyed");+ // The picture is the shared baked asset: the presenter lets go of it and does not destroy it.+ Assert.IsTrue(ui.Q<VisualElement>("minimap-image").style.backgroundImage.keyword == StyleKeyword.Null, "nothing draws the picture after Dispose");+ Assert.IsTrue(tex != null, "the baked picture is an asset and stays loaded");}[Test]diff --git a/unity/Assets/Tests/EditMode/MinimapReliefTests.cs b/unity/Assets/Tests/EditMode/MinimapReliefTests.csnew file mode 100644index 000000000..e9f33642d--- /dev/null+++ b/unity/Assets/Tests/EditMode/MinimapReliefTests.cs@@ -0,0 +1,344 @@+#nullable enable+using System.Collections;+using System.Collections.Generic;+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;+using UnityEngine;+using UnityEngine.TestTools;+using UnityEngine.UIElements;++/// <summary>HUD round 2, part 1 (#398): promo/final/03's minimap. The painted relief picture is a bake+/// (tools/minimap_bake.py; tools/tests/test_minimap_bake.py checks it is fresh), and beside it are the promo's three round+/// buttons: the whole map, the settlement names, the region borders. The picture stays mouse-only (accessibility audit+/// B1d); the buttons take Tab after End Turn.</summary>+public class MinimapReliefTests+{+ static readonly Content C = ContentLoader.Load(Paths.Content);+ static readonly HexFile Hexes = MapBuilder.LoadHexes(Path.Combine(Paths.Content, "map", "hexes.json"));+ static UiText En => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);+ static UiText He => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");+ static string MapFile(string name) => File.ReadAllText(Path.Combine(Paths.Content, "map", name));+ static MapRegions Regions() => new MapRegions(Subdistricts1948.Parse(MapFile(Subdistricts1948.FileName)), Armistice1949.Parse(MapFile(Armistice1949.FileName)));+ static Dictionary<string, string> Names() => SettlementPlacer.Parse(MapFile(SettlementPlacer.DefaultFileName)).ToDictionary(t => t.Id, t => t.Name);++ static readonly string[] ButtonNames = { "minimap-overview", "minimap-labels", "minimap-borders" };++ /// <summary>InfoPanelLayoutTests' 19 window sizes.</summary>+ static readonly (int w, int h)[] Windows =+ {+ (1920, 1080), (1280, 720), (1366, 768), (1760, 1000), (1920, 1200), (1440, 900), (1680, 1050), (1024, 768), (1280, 1024),+ (1024, 1024), (960, 1080), (800, 1000), (1531, 784), (2560, 1080), (1920, 900), (1600, 757), (1366, 657), (960, 600), (390, 844),+ };++ /// <summary>The real Game.uxml on the real PanelSettings at w x h, out of its loading state, in English or Hebrew, with the+ /// top bar, the info panel on Lydda's hex (its longest region line), the border layer's caption and the minimap.</summary>+ static IEnumerator Rendered(int w, int h, bool hebrew, System.Action<VisualElement, MinimapPresenter> check, System.Action<VisualElement>? act = null)+ {+ var text = hebrew ? He : En;+ var rt = new RenderTexture(w, h, 0);+ var ps = Object.Instantiate(AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel));+ ps.targetTexture = rt;+ var go = new GameObject("MinimapTest");+ 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;+ root.Q("root").RemoveFromClassList("loading");+ if (hebrew) root.Q("root").AddToClassList(UiLanguage.HebrewClass);+ var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), text);+ var hud = new HudPresenter(root, bridge, text);+ var info = new InfoPanelPresenter(root, bridge, text, Names(), regions: Regions());+ var mini = new MinimapPresenter(root, Hexes, text);+ var layer = root.Q<Label>("map-layer");+ layer.text = text["map.layer_front_no_data"].Replace("{0}", "Mandate sub-districts, 1947 · Egypt");+ layer.style.display = DisplayStyle.Flex;+ try+ {+ var lod = C.SettlementHexes.Single(s => s.Id == "lod");+ info.Show(lod.Q, lod.R);+ act?.Invoke(root);+ for (int i = 0; i < 30 && !(root.Q("minimap-image").layout.width > 0); i++) yield return null;+ for (int i = 0; i < 3; i++) yield return null; // the picture is fitted after the box's first layout+ check(root, mini);+ }+ finally+ {+ mini.Dispose(); info.Dispose(); hud.Dispose();+ Object.DestroyImmediate(go); Object.DestroyImmediate(ps); rt.Release(); Object.DestroyImmediate(rt);+ }+ }++ 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;++ /// <summary>The picture is the baked relief (Resources), drawn smooth, not the 128-pixel hex strip painted at boot.</summary>+ [Test]+ public void TheMinimapShowsTheBakedReliefPicture()+ {+ using var ui = new UiTestKit();+ using var mini = new MinimapPresenter(ui.Root, Hexes);+ var baked = Resources.Load<Texture2D>(MinimapPresenter.Resource);+ Assert.IsNotNull(baked, $"Resources/{MinimapPresenter.Resource} (tools/minimap_bake.py)");+ Assert.AreSame(baked, mini.Texture, "the presenter shows the baked picture");+ Assert.AreSame(baked, ui.Q<VisualElement>("minimap-image").style.backgroundImage.value.texture);+ Assert.AreEqual((256, 1024), (baked.width, baked.height), "the bake's size (tools/minimap_bake.py WIDTH, HEIGHT), powers of two");+ Assert.AreNotEqual(FilterMode.Point, baked.filterMode, "a painting, not pixels");+ var b = Hexes.bounds;+ double widthKm = (b.lon1 - b.lon0) * HexPicker.KmPerDegLon(b.lat0, b.lat1), lengthKm = (b.lat1 - b.lat0) * HexPicker.KmPerDegLat;+ Assert.AreEqual(widthKm / lengthKm, mini.Aspect, 0.0005, "the picture is drawn at the map's aspect, not the texture's");+ }++ /// <summary>Review of #584: the relief is block-compressed on the GPU (it was uncompressed RGB, about 1.1-1.5 MB with its+ /// mipmaps; compressed it is about a tenth of that), with its mipmaps.</summary>+ [Test]+ public void TheReliefIsCompressedOnTheGpu()+ {+ var tex = Resources.Load<Texture2D>(MinimapPresenter.Resource);+ long bytes = UnityEngine.Profiling.Profiler.GetRuntimeMemorySizeLong(tex);+ TestContext.WriteLine($"MinimapRelief: {tex.graphicsFormat}, {tex.mipmapCount} mips, {bytes} bytes");+ Assert.IsTrue(UnityEngine.Experimental.Rendering.GraphicsFormatUtility.IsCompressedFormat(tex.graphicsFormat), $"{tex.graphicsFormat} is compressed");+ Assert.Greater(tex.mipmapCount, 1, "mipmapped");+ Assert.Less(bytes, 400_000, "about a tenth of the uncompressed size");+ }++ /// <summary>At every window size, in English and in Hebrew: the minimap lies in the window at its bottom right (the+ /// Hebrew UI mirrors rows, not the screen's corners), under the bar; the picture and the three buttons lie inside its frame+ /// and do not overlap; each button is at least 24 px square (WCAG 2.5.8); and the minimap is clear of the info panel and+ /// the border layer's caption.</summary>+ [UnityTest]+ public IEnumerator TheMinimapAndItsButtonsFitEveryWindowInEnglishAndHebrew()+ {+ var problems = new List<string>();+ foreach (var hebrew in new[] { false, true })+ foreach (var (w, h) in Windows)+ yield return Rendered(w, h, hebrew, (root, mini) =>+ {+ string at = $"{(hebrew ? "he" : "en")} {w}x{h}";+ var window = root.worldBound;+ var box = root.Q("minimap").worldBound;+ var picture = root.Q("minimap-image").worldBound;+ if (!Inside(box, window)) problems.Add($"{at}: the minimap {box} leaves the window {window}");+ if (window.xMax - box.xMax > 0.05f * window.width) problems.Add($"{at}: the minimap {box} is not at the right edge");+ if (box.yMin < root.Q("top-bar").worldBound.yMax) problems.Add($"{at}: the minimap {box} rises into the top bar");+ if (!Inside(picture, box)) problems.Add($"{at}: the picture {picture} leaves the minimap {box}");+ if (!(picture.width > 0)) problems.Add($"{at}: the picture has no size");+ var buttons = ButtonNames.Select(n => root.Q<Button>(n)).ToList();+ foreach (var bt in buttons)+ {+ var r = bt.worldBound;+ if (!Inside(r, box)) problems.Add($"{at}: {bt.name} {r} leaves the minimap {box}");+ if (r.Overlaps(picture)) problems.Add($"{at}: {bt.name} {r} covers the picture {picture}");+ float scale = rtScale(root, w);+ if (r.width * scale < 24f || r.height * scale < 24f) problems.Add($"{at}: {bt.name} is {r.width * scale:0}x{r.height * scale:0} screen px, under 24");+ }+ for (int i = 0; i < buttons.Count; i++)+ for (int j = i + 1; j < buttons.Count; j++)+ if (buttons[i].worldBound.Overlaps(buttons[j].worldBound)) problems.Add($"{at}: {buttons[i].name} overlaps {buttons[j].name}");+ var panel = root.Q("info-panel").worldBound;+ if (panel.Overlaps(box)) problems.Add($"{at}: the info panel {panel} overlaps the minimap {box}");+ var layer = root.Q("map-layer").worldBound;+ if (layer.Overlaps(box)) problems.Add($"{at}: the border caption {layer} overlaps the minimap {box}");+ if (!Inside(layer, window)) problems.Add($"{at}: the border caption {layer} leaves the window");+ });+ Assert.IsEmpty(problems, string.Join("\n", problems));+ }++ // Panel units to screen pixels: the panel scales with the screen (PanelSettings: scale with screen size).+ static float rtScale(VisualElement root, int w) => w / root.worldBound.width;++ /// <summary>The audit's rules (docs/accessibility-audit-2026-10-14.md): the picture stays mouse-only (B1d: pan covers it)+ /// and takes no focus; the three buttons are buttons, so Tab reaches them, after End Turn and before anything else, and+ /// each has its name in its tooltip (for a later accessibility layer, as the meters' are).</summary>+ [UnityTest]+ public IEnumerator ThePictureTakesNoFocusAndTheButtonsComeAfterEndTurn()+ {+ foreach (var hebrew in new[] { false, true })+ yield return Rendered(1920, 1080, hebrew, (root, mini) =>+ {+ string at = hebrew ? "he" : "en";+ var text = hebrew ? He : En;+ Assert.IsFalse(root.Q("minimap-image").focusable, at + ": the picture takes no focus (B1d)");+ Assert.IsFalse(root.Q("minimap").focusable, at + ": the frame takes no focus");+ var keys = new[] { "minimap.overview", "minimap.labels", "minimap.borders" };+ for (int i = 0; i < ButtonNames.Length; i++)+ {+ var bt = root.Q<Button>(ButtonNames[i]);+ Assert.IsTrue(bt.focusable && bt.canGrabFocus, $"{at}: {bt.name} takes focus");+ Assert.GreaterOrEqual(bt.tabIndex, 0, $"{at}: {bt.name} is in the Tab order");+ Assert.AreEqual(text[keys[i]], bt.tooltip, $"{at}: {bt.name} has its name");+ }+ // Tree order is Tab order: End Turn, then the three buttons, then nothing else of the minimap.+ var order = root.Query<VisualElement>().Where(e => e.focusable && e.canGrabFocus && e.tabIndex >= 0).ToList().Select(e => e.name).ToList();+ int end = order.IndexOf("end-turn");+ Assert.GreaterOrEqual(end, 0, at + ": End Turn takes focus");+ CollectionAssert.AreEqual(ButtonNames, order.Skip(end + 1).Take(3).ToArray(), $"{at}: the Tab order after End Turn: {string.Join(", ", order)}");+ });+ }++ /// <summary>Owner ruling on #584: icon-only buttons with tooltips. Each button has a non-empty name in English and Hebrew+ /// in its <c>tooltip</c> (the meters' mechanism, #523), and since UI Toolkit draws <c>tooltip</c> only in Editor UI, the+ /// name shows in the visible tip beside the button on hover and on keyboard focus, inside the window, and goes on leave.</summary>+ [UnityTest]+ public IEnumerator EachButtonShowsItsNameOnHoverAndOnFocusInEnglishAndHebrew()+ {+ var problems = new List<string>();+ foreach (var hebrew in new[] { false, true })+ foreach (var (w, h) in new[] { (1920, 1080), (960, 600), (390, 844) })+ yield return Rendered(w, h, hebrew, (root, mini) =>+ {+ string at = $"{(hebrew ? "he" : "en")} {w}x{h}";+ var text = hebrew ? He : En;+ var tip = root.Q<Label>(HoverTip.TipName);+ var keys = new[] { "minimap.overview", "minimap.labels", "minimap.borders" };+ for (int i = 0; i < ButtonNames.Length; i++)+ {+ var bt = root.Q<Button>(ButtonNames[i]);+ if (string.IsNullOrWhiteSpace(bt.tooltip)) problems.Add($"{at}: {bt.name} has no tooltip");+ if (bt.tooltip != text[keys[i]]) problems.Add($"{at}: {bt.name} tooltip '{bt.tooltip}' is not {keys[i]}");+ using (var e = PointerEnterEvent.GetPooled(new Event { type = EventType.MouseMove, mousePosition = bt.worldBound.center }))+ { e.target = bt; bt.SendEvent(e); }+ if (tip.style.display.value != DisplayStyle.Flex || tip.text != bt.tooltip) problems.Add($"{at}: hovering {bt.name} shows no tip ('{tip.text}')");+ // left of the button, as wide as its text: it stays in the window+ float width = tip.MeasureTextSize(tip.text, 0, VisualElement.MeasureMode.Undefined, 0, VisualElement.MeasureMode.Undefined).x + 22;+ float right = root.Q("root").layout.width - tip.style.right.value.value;+ if (right > bt.worldBound.xMin + 0.5f) problems.Add($"{at}: the tip of {bt.name} covers its button");+ if (right - width < 0) problems.Add($"{at}: the tip of {bt.name} ({width:0} wide, right edge {right:0}) leaves the window");+ using (var e = PointerLeaveEvent.GetPooled(new Event { type = EventType.MouseMove, mousePosition = Vector2.zero }))+ { e.target = bt; bt.SendEvent(e); }+ if (tip.style.display.value != DisplayStyle.None) problems.Add($"{at}: the tip of {bt.name} stays after the pointer leaves");+ bt.Focus();+ if (tip.style.display.value != DisplayStyle.Flex || tip.text != bt.tooltip) problems.Add($"{at}: focusing {bt.name} shows no tip");+ bt.Blur();+ if (tip.style.display.value != DisplayStyle.None) problems.Add($"{at}: the tip of {bt.name} stays after blur");+ }+ Assert.AreEqual(PickingMode.Ignore, tip.pickingMode, "the tip takes no clicks");+ });+ Assert.IsEmpty(problems, string.Join("\n", problems));+ }++ /// <summary>Review of #584: hover and keyboard focus are tracked apart, and a press hides the tip. The tip names the+ /// hovered button, else the focused one; a pointer leaving gives the tip back to the focused button, a blur keeps the+ /// hovered one, and a press hides it until the pointer or the focus comes back.</summary>+ [UnityTest]+ public IEnumerator HoverAndFocusAreTrackedApartAndAPressHidesTheTip()+ {+ yield return Rendered(1920, 1080, false, (root, mini) =>+ {+ var tip = root.Q<Label>(HoverTip.TipName);+ var b = ButtonNames.Select(n => root.Q<Button>(n)).ToArray();+ void Enter(Button x) { using var e = PointerEnterEvent.GetPooled(new Event { type = EventType.MouseMove, mousePosition = x.worldBound.center }); e.target = x; x.SendEvent(e); }+ void Leave(Button x) { using var e = PointerLeaveEvent.GetPooled(new Event { type = EventType.MouseMove, mousePosition = Vector2.zero }); e.target = x; x.SendEvent(e); }+ void Click(Button x) { using var e = ClickEvent.GetPooled(new Event { type = EventType.MouseUp, mousePosition = x.worldBound.center }); e.target = x; x.SendEvent(e); }+ string Shown() => tip.style.display.value == DisplayStyle.Flex ? tip.text : "";+ b[1].Focus();+ Assert.AreEqual(b[1].tooltip, Shown(), "focus shows its name");+ Enter(b[2]);+ Assert.AreEqual(b[2].tooltip, Shown(), "hover wins while the pointer is there");+ Leave(b[2]);+ Assert.AreEqual(b[1].tooltip, Shown(), "the pointer leaving gives the tip back to the focused button");+ Enter(b[2]); b[1].Blur();+ Assert.AreEqual(b[2].tooltip, Shown(), "a blur does not hide the hovered button's name");+ Click(b[2]);+ Assert.AreEqual("", Shown(), "a press hides the tip");+ Leave(b[2]); Enter(b[2]);+ Assert.AreEqual(b[2].tooltip, Shown(), "and the pointer coming back shows it again");+ Leave(b[2]);+ Assert.AreEqual("", Shown(), "nothing hovered or focused: no tip");+ });+ }++ /// <summary>Review of #584: a switched-off layer's button dims, but its glyph keeps at least 3:1 against its disc+ /// (WCAG 1.4.11): the disc's opacity blends the gold line toward the navy behind it.</summary>+ [UnityTest]+ public IEnumerator ASwitchedOffButtonsGlyphKeepsThreeToOne()+ {+ yield return Rendered(1920, 1080, false, (root, mini) =>+ {+ var disc = root.Q<Button>("minimap-labels").Q(className: "minimap-disc");+ float a = disc.resolvedStyle.opacity;+ Assert.Less(a, 1f, "precondition: the off button is dimmed");+ Color gold = UiIcon.LineColour(false), navy = new Color32(9, 14, 26, 255);+ var g = Color.Lerp(navy, gold, a);+ double L(Color c) { double f(float v) => v <= 0.04045f ? v / 12.92 : System.Math.Pow((v + 0.055) / 1.055, 2.4); return 0.2126 * f(c.r) + 0.7152 * f(c.g) + 0.0722 * f(c.b); }+ double ratio = (L(g) + 0.05) / (L(navy) + 0.05);+ TestContext.WriteLine($"off opacity {a:0.00}: glyph {ratio:0.00}:1 against the disc");+ Assert.GreaterOrEqual(ratio, 3.0, $"the off glyph at opacity {a} is {ratio:0.00}:1");+ }, root => root.Q<Button>("minimap-labels").AddToClassList(MinimapPresenter.OffClass));+ }++ /// <summary>The buttons do only what the game already does: the first zooms all the way out (the camera's own limit),+ /// the second switches the settlement names, the third the region borders (the map's "labels" and "borders" switches).+ /// A switched-off layer dims its button, and pressing it again switches the layer back on.</summary>+ [Test]+ public void TheButtonsZoomOutAndSwitchTheNamesAndTheBorders()+ {+ using var ui = new UiTestKit();+ using var mini = new MinimapPresenter(ui.Root, Hexes, En);+ var labels = new List<bool>(); var borders = new List<bool>();+ var removeLabels = VisualToggles.Register("labels", on => labels.Add(on));+ var removeBorders = VisualToggles.Register(MapBorders.ToggleName, on => borders.Add(on));+ try+ {+ int overviews = 0, bordersChanged = 0;+ mini.Overview += () => overviews++;+ mini.BordersChanged += () => bordersChanged++;+ ui.Press("minimap-overview");+ Assert.AreEqual(1, overviews, "the whole-map button asks for the overview");+ CollectionAssert.IsEmpty(labels); CollectionAssert.IsEmpty(borders);++ ui.Press("minimap-labels");+ CollectionAssert.AreEqual(new[] { false }, labels, "the names go off");+ Assert.IsFalse(mini.LabelsShown);+ Assert.IsTrue(ui.Q<Button>("minimap-labels").ClassListContains(MinimapPresenter.OffClass), "its button dims");+ ui.Press("minimap-labels");+ CollectionAssert.AreEqual(new[] { false, true }, labels, "and back on");+ Assert.IsFalse(ui.Q<Button>("minimap-labels").ClassListContains(MinimapPresenter.OffClass));++ ui.Press("minimap-borders");+ CollectionAssert.AreEqual(new[] { false }, borders, "the borders go off");+ Assert.IsFalse(mini.BordersShown);+ Assert.AreEqual(1, bordersChanged, "the border caption hears of it");+ Assert.IsTrue(ui.Q<Button>("minimap-borders").ClassListContains(MinimapPresenter.OffClass));+ ui.Press("minimap-borders");+ CollectionAssert.AreEqual(new[] { false, true }, borders);+ Assert.IsTrue(mini.BordersShown);+ Assert.AreEqual(1, overviews, "no other button asks for the overview");+ }+ finally { removeLabels(); removeBorders(); }+ }++ /// <summary>With no map built (no switch registered) the buttons still keep their own state and throw nothing.</summary>+ [Test]+ public void TheSwitchButtonsWorkWithNoMap()+ {+ using var ui = new UiTestKit();+ using var mini = new MinimapPresenter(ui.Root, Hexes, En);+ Assert.IsFalse(VisualToggles.Names.Contains("labels") && VisualToggles.Names.Contains(MapBorders.ToggleName), "precondition: no map");+ Assert.DoesNotThrow(() => ui.Press("minimap-labels"));+ Assert.DoesNotThrow(() => ui.Press("minimap-borders"));+ Assert.IsFalse(mini.LabelsShown); Assert.IsFalse(mini.BordersShown);+ }++ /// <summary>A disposed presenter hears no button.</summary>+ [Test]+ public void ADisposedMinimapHearsNoButton()+ {+ using var ui = new UiTestKit();+ var mini = new MinimapPresenter(ui.Root, Hexes, En);+ int overviews = 0;+ mini.Overview += () => overviews++;+ mini.Dispose();+ ui.Press("minimap-overview");+ ui.Press("minimap-labels");+ Assert.AreEqual(0, overviews);+ Assert.IsTrue(mini.LabelsShown, "the names' state did not change");+ }+}diff --git a/unity/Assets/Tests/EditMode/MinimapReliefTests.cs.meta b/unity/Assets/Tests/EditMode/MinimapReliefTests.cs.metanew file mode 100644index 000000000..1af68be9b--- /dev/null+++ b/unity/Assets/Tests/EditMode/MinimapReliefTests.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: 6ea5bc03dc0a74ac893944ecf31a6c70\ No newline at end of filediff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxmlindex fc808ecf0..6c1269579 100644--- a/unity/Assets/UI/Game.uxml+++ b/unity/Assets/UI/Game.uxml@@ -83,9 +83,19 @@<ui:VisualElement class="right-gap" picking-mode="Ignore" /><!-- What the map's region borders show while they are drawn (owner ruling 2026-10-11: "Mandate sub-districts, 1947"). --><ui:Label name="map-layer" class="map-layer" picking-mode="Ignore" />+ <!-- The painted relief picture (a bake: tools/minimap_bake.py) and, beside it, promo 03's three round buttons:+ the whole map, the settlement names, the region borders (MinimapPresenter). The picture takes no focus (the+ accessibility audit's B1d); the buttons do, after End Turn. --><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 name="minimap-map" class="minimap-map" picking-mode="Ignore">+ <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="minimap-buttons" class="minimap-buttons" picking-mode="Ignore">+ <ui:Button name="minimap-overview" class="minimap-button"><Statecraft.Game.UI.UiIcon glyph="peaks" class="minimap-disc" picking-mode="Ignore" /></ui:Button>+ <ui:Button name="minimap-labels" class="minimap-button"><Statecraft.Game.UI.UiIcon glyph="skyline" class="minimap-disc" picking-mode="Ignore" /></ui:Button>+ <ui:Button name="minimap-borders" class="minimap-button"><Statecraft.Game.UI.UiIcon glyph="region" class="minimap-disc" picking-mode="Ignore" /></ui:Button></ui:VisualElement><Statecraft.Game.UI.UiFrame filigree="true" /></ui:VisualElement>@@ -308,5 +318,8 @@</ui:VisualElement></ui:VisualElement><ui:Label name="toast" class="panel toast" />+ <!-- The name of an icon-only button, beside it on hover and on keyboard focus (HoverTip; UI Toolkit draws `tooltip`+ only in Editor UI). Last, so it draws over the panels; it takes no clicks. -->+ <ui:Label name="hud-tip" class="hud-tip" picking-mode="Ignore" /></ui:VisualElement></ui:UXML>diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.ussindex 8f02ae247..33c3c2776 100644--- a/unity/Assets/UI/Statecraft.uss+++ b/unity/Assets/UI/Statecraft.uss@@ -266,16 +266,35 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);.info-row-sign { width: 22px; height: 22px; flex-shrink: 0; margin: 3px 10px 0 0; }.info-row-text { flex-grow: 1; flex-shrink: 1; min-width: 0; }.info-unit .info-row-sign { display: none; }-/* Narrow, as the country is: the frame hugs the tall map picture (MinimapPresenter fits it to the content box). *//* The border layer's label, beside the minimap's lower left: what the outlines are (MapRegions.Label). Out of the column'sflex flow (absolute), so it takes no height from the event card at any HUD tier (armistice review I-4). */-.map-layer { display: none; position: absolute; right: 168px; bottom: 0; max-width: 312px; padding: 5px 8px; font-size: 15px; white-space: normal; -unity-text-align: middle-center; color: var(--ink); background-color: rgba(9, 14, 26, 0.9); border-radius: 3px; }+.map-layer { display: none; position: absolute; right: 230px; bottom: 0; max-width: 250px; padding: 5px 8px; font-size: 15px; white-space: normal; -unity-text-align: middle-center; color: var(--ink); background-color: rgba(9, 14, 26, 0.9); border-radius: 3px; }/* A phone upright (three-row bar): the info panel spans the bottom left, beside the minimap, but the column is tall, so thelabel goes back above the minimap, in the column's flow. */.hud-three-row .map-layer { position: relative; right: auto; bottom: auto; align-self: flex-end; max-width: 480px; margin-bottom: 6px; }-.minimap { align-self: flex-end; flex-shrink: 0; width: 160px; height: 340px; padding: 12px; background-color: rgba(9, 14, 26, 0.97); }-.minimap-image { align-self: center; -unity-background-scale-mode: stretch-to-fill; } /* the element is sized to the picture's aspect by MinimapPresenter */+/* HUD round 2 (#398): promo 03's minimap, the painted relief picture with three round buttons beside it, in one frame. The+ picture's box is as wide as the tall picture needs at this height (MinimapPresenter fits the picture to it). */+.minimap { align-self: flex-end; flex-shrink: 0; flex-direction: row; width: 222px; height: 380px; padding: 12px; background-color: rgba(9, 14, 26, 0.97); }+.minimap-map { width: 134px; flex-shrink: 0; justify-content: center; }+.minimap-image { align-self: center; -unity-background-scale-mode: stretch-to-fill; } /* sized to the picture's aspect by MinimapPresenter */.minimap-view { position: absolute; border-color: var(--ink); border-width: 1.5px; }+.minimap-buttons { flex-grow: 1; margin-left: 10px; justify-content: space-around; align-items: center; }+.minimap-button { width: 50px; height: 50px; margin: 0; padding: 0; border-width: 0; border-radius: 25px; background-color: rgba(0, 0, 0, 0); }+.minimap-disc {+ position: absolute; left: 0; top: 0; width: 50px; height: 50px; padding: 11px;+ border-radius: 25px; border-width: 1.5px; border-color: var(--gold-dim); background-color: var(--navy-deep);+}+.minimap-button:hover { background-color: rgba(0, 0, 0, 0); }+.minimap-button:hover .minimap-disc { border-color: var(--gold); background-color: var(--navy-raised); }+.minimap-button:focus { background-color: rgba(0, 0, 0, 0); border-width: 0; }+.minimap-button:focus .minimap-disc { border-color: var(--ink); background-color: var(--focus); }+/* A layer switched off (the names or the borders): the disc goes dim, as a lamp turned off. */+.minimap-off .minimap-disc { opacity: 0.6; } /* the glyph keeps about 4:1 on its disc (MinimapReliefTests) */+/* An icon-only button's name, beside it while hovered or focused (HoverTip): one line, centred on the button's middle. */+.hud-tip {+ display: none; position: absolute; translate: 0 -50%; padding: 4px 10px; font-size: 16px; white-space: nowrap;+ color: var(--ink); background-color: var(--navy-solid); border-color: var(--gold); border-width: 1px; border-radius: 3px;+}/* Full screens (Cabinet, Budget, Defence, Why) open in the centre, one at a time. *//* Hidden until ScreenNav opens one (never visible while loading; playtest 2, P2-1). Right edge clear of the 480px column. */diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlindex 0d21ed3e6..1f4ce6e87 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -199,6 +199,9 @@ info.localities: "1948 localities: {0}"info.locality_today: "{0} (today: {1})"map.today: "Today: {0}"map.mixed: "Mixed locality"+minimap.overview: "Zoom all the way out"+minimap.labels: "Show or hide the settlement names"+minimap.borders: "Show or hide the region borders"ui.lang: "en"info.built: "{0} built here in {1}"info.queued: "Ordered: {0}, at End Turn"diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yamlindex fad644b44..249b19e0e 100644--- a/unity/Assets/UI/strings.he.yaml+++ b/unity/Assets/UI/strings.he.yaml@@ -186,6 +186,9 @@ info.localities: "יישובים ב-1948: {0}"info.locality_today: "{0} (היום: {1})"map.today: "היום: {0}"map.mixed: "יישוב מעורב"+minimap.overview: "התרחקות מרבית"+minimap.labels: "הצגה או הסתרה של שמות היישובים"+minimap.borders: "הצגה או הסתרה של גבולות האזורים"ui.lang: "he"info.built: "{0} נבנה כאן בשנת {1}"info.queued: "ניתנה פקודה: {0}, בסיום התור"