A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
UI: keep phone map hints clear of the minimap (#998) (#1056)
Jacob Cohene188e972708c
diff --git a/changelog.d/998.md b/changelog.d/998.mdnew file mode 100644index 000000000..2d84e429a--- /dev/null+++ b/changelog.d/998.md@@ -0,0 +1,3 @@+### Fixed+- On phones, the empty map hint wraps beside the minimap in English and Hebrew instead of overlapping it or leaving+ the window (#998, #1056).diff --git a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.csindex b3ccd266b..9b80c3c93 100644--- a/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs+++ b/unity/Assets/Tests/EditMode/InfoPanelLayoutTests.cs@@ -13,7 +13,7 @@ using UnityEngine;using UnityEngine.TestTools;using UnityEngine.UIElements;-/// <summary>HUD round 1 (#398): the info panel in the promo's shape (promo/final/03): a one-line hint before a hex is chosen,+/// <summary>HUD round 1 (#398): the info panel in the promo's shape (promo/final/03): a compact hint before a hex is chosen,/// the hex's facts as icon rows (only what the game models: no yields, no land-use name), its text inside the panel at/// every window size (#397), and the panels' filigree trim, which takes no clicks.</summary>public class InfoPanelLayoutTests@@ -171,27 +171,36 @@ public class InfoPanelLayoutTestsAssert.IsEmpty(problems, string.Join("\n", problems));}- /// <summary>Before a hex is chosen the panel is a one-line hint (the promo shows no panel until a tile is chosen): no- /// terrain sign, no rows, and no taller than the hint's line and the panel's padding.</summary>+ /// <summary>The empty hint stays inside the window and clear of the minimap in both languages: one line on desktop,+ /// at most two on the phone tier, with no terrain sign, fact rows or spare panel height.</summary>[UnityTest]- public IEnumerator TheEmptyInfoPanelIsAOneLineHint()+ public IEnumerator TheEmptyInfoPanelHintFitsBothLanguages(){var g = GameSession.New(C, GoldenRun.Seed, Mode.Historical);- foreach (var (w, h) in new[] { (1920, 1080), (1280, 720), (390, 844) })- yield return Rendered(w, h, g, (root, info) => { }, root =>- {- var panel = root.Q("info-panel");- var hint = root.Q<Label>("info-title");- Assert.AreEqual(Text["info.hint"], hint.text);- Assert.IsTrue(TextFits(hint), $"{w}x{h}: the hint fits");- Assert.AreEqual(DisplayStyle.None, root.Q("info-thumb").resolvedStyle.display, $"{w}x{h}: no terrain sign");- foreach (var row in panel.Query(className: InfoPanelPresenter.RowClass).ToList())- Assert.IsFalse(Shown(row), $"{w}x{h}: no fact row before a hex is chosen");- var s = panel.resolvedStyle;- var oneLine = hint.worldBound.height + hint.resolvedStyle.marginTop + hint.resolvedStyle.marginBottom- + s.paddingTop + s.paddingBottom + s.borderTopWidth + s.borderBottomWidth;- Assert.LessOrEqual(panel.worldBound.height, oneLine + 4f, $"{w}x{h}: the empty panel {panel.worldBound} is one line ({hint.worldBound})");- });+ var he = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");+ foreach (var hebrew in new[] { false, true })+ foreach (var (w, h) in new[] { (1920, 1080), (1280, 720), (390, 844) })+ yield return Rendered(w, h, g, (root, info) => { }, root =>+ {+ var at = $"{(hebrew ? "he" : "en")} {w}x{h}";+ var panel = root.Q("info-panel");+ var hint = root.Q<Label>("info-title");+ Assert.AreEqual((hebrew ? he : Text)["info.hint"], hint.text, at);+ Assert.IsTrue(TextFits(hint), $"{at}: the hint fits");+ Assert.IsTrue(Inside(hint.worldBound, panel.worldBound), $"{at}: the hint fits the panel");+ Assert.IsTrue(Inside(panel.worldBound, root.worldBound), $"{at}: the hint panel fits the window");+ Assert.IsFalse(panel.worldBound.Overlaps(root.Q("minimap").worldBound), $"{at}: the hint stays clear of the minimap");+ var lines = root.Q("root").ClassListContains("hud-three-row") ? 2 : 1;+ var natural = hint.MeasureTextSize(hint.text, 0, VisualElement.MeasureMode.Undefined, 0, VisualElement.MeasureMode.Undefined);+ Assert.LessOrEqual(hint.contentRect.height, natural.y * lines + 1f, $"{at}: the hint uses at most {lines} lines");+ Assert.AreEqual(DisplayStyle.None, root.Q("info-thumb").resolvedStyle.display, $"{at}: no terrain sign");+ foreach (var row in panel.Query(className: InfoPanelPresenter.RowClass).ToList())+ Assert.IsFalse(Shown(row), $"{at}: no fact row before a hex is chosen");+ var s = panel.resolvedStyle;+ var tightHeight = hint.worldBound.height + hint.resolvedStyle.marginTop + hint.resolvedStyle.marginBottom+ + s.paddingTop + s.paddingBottom + s.borderTopWidth + s.borderBottomWidth;+ Assert.LessOrEqual(panel.worldBound.height, tightHeight + 4f, $"{at}: the empty panel {panel.worldBound} hugs its hint ({hint.worldBound})");+ }, hebrew ? he : Text, hebrew);}/// <summary>The hex's facts in the promo's rhythm, as icon rows: the region and the settlements each sit in a row whosediff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.ussindex 09d698485..9810686ca 100644--- a/unity/Assets/UI/Statecraft.uss+++ b/unity/Assets/UI/Statecraft.uss@@ -371,6 +371,8 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);.info-panel.info-empty { min-height: 0; width: auto; padding: 8px 16px; }.info-empty .gold-rule, .info-empty #info-subtitle, .info-empty .reason { display: none; }.info-empty #info-title { font-size: 20px; }+.hud-three-row .info-panel.info-empty { right: 254px; }+.hud-three-row .info-empty #info-title { white-space: normal; }/* The hex's facts as the promo's icon rows: a gold sign, then the line, which wraps inside the panel (#397). A unit's cardreuses the lines without the signs (they name a hex's facts, not a unit's). */.info-row { flex-direction: row; align-items: flex-start; margin-bottom: 3px; }