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: a short How to play screen in the side menu, in English and Hebrew (refs #1041) (#1059)

Eyal Golanaec4bc48db76
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 70288587e..550c3930a 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -8,6 +8,8 @@ adds a line under **Unreleased**; CI's `Changelog` job checks this (see `CONTRIB
## [Unreleased]
### Added
+- A short How to play screen in the side menu explains the monthly loop, Attention, cities, training, event decisions,
+ the top bar, End turn and delegation, and the Why screen in English and Hebrew (refs #1041, #42).
- The military unit record (GDD Phase 5 PR 2): a unit can hold a side, a strength and a standing order with its target,
each written into the state hash only when set, so a halutz hashes as before and no golden moves. `unit_types.yaml`
gains Israel's `veteran_soldier` (infantry), `artillery` and `armoured_car` (armour) with a `side` and a `class`; the
diff --git a/tools/headed.py b/tools/headed.py
index 2408999d1..63c23cf34 100644
--- a/tools/headed.py
+++ b/tools/headed.py
@@ -48,12 +48,13 @@ END_TURN, OPTION, MAP_UNDER_WHY = (1516, 42), (608, 520), (1180, 300)
def left_column_button(index: int, window: tuple[int, int] = WINDOW) -> tuple[int, int]:
"""The centre of the left icon column's button `index` (0 Cabinet, 1 Budget, 2 Defence, 3 Why?) in CSS pixels, from
- Statecraft.uss (HUD round 2, #398): the column at left 16 px and top 112 px (the one-row bar), 56 px discs 68 px apart,
+ Statecraft.uss (HUD round 2, #398): the column at left 16 px and top 112 px (the one-row bar), 50 px discs 56 px apart
+ (six since How to play, #1041),
in panel units the PanelSettings scale to the window (1920x1080 reference, match 0.5: the geometric mean of the two
ratios). Derived, so a moved column is one change in the USS and here, not a re-measured capture."""
w, h = window
scale = ((w / 1920) * (h / 1080)) ** 0.5
- return round((16 + 28) * scale), round((112 + 68 * index + 28) * scale)
+ return round((16 + 28) * scale), round((112 + 56 * index + 25) * scale) # the discs are centred in the 56 px column
WHY = left_column_button(3) # Why? moved from the top bar to the left icon column (#602)
diff --git a/tools/tests/test_headed_column.py b/tools/tests/test_headed_column.py
index 767a261f7..4c0bb735e 100644
--- a/tools/tests/test_headed_column.py
+++ b/tools/tests/test_headed_column.py
@@ -29,11 +29,12 @@ def px(body: str, prop: str) -> float:
def test_the_column_click_points_follow_the_uss():
col, button = rule(".left-column"), rule(".left-column .rail-button")
- left, top, size = px(col, "left"), px(col, "top"), px(button, "height")
+ left, top, width, size = px(col, "left"), px(col, "top"), px(col, "width"), px(button, "height")
gap = float(re.search(r"margin:\s*0 0 ([0-9.]+)px 0", button).group(1))
h = headed()
w, hh = h.WINDOW
scale = ((w / 1920) * (hh / 1080)) ** 0.5
for i in range(4):
- assert h.left_column_button(i) == (round((left + size / 2) * scale), round((top + (size + gap) * i + size / 2) * scale))
+ # The column centres its discs (align-items: center), so a disc's middle is the column's.
+ assert h.left_column_button(i) == (round((left + width / 2) * scale), round((top + (size + gap) * i + size / 2) * scale))
assert h.WHY == h.left_column_button(3)
diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.cs
index fd49a2c7f..223d686fe 100644
--- a/unity/Assets/Scripts/UI/GameRoot.cs
+++ b/unity/Assets/Scripts/UI/GameRoot.cs
@@ -229,6 +229,7 @@ namespace Statecraft.Game.UI
Own(new DefencePresenter(root, bridge, text, portraits));
Own(new BudgetPresenter(root, bridge, text));
Own(new WhyPresenter(root, bridge, text));
+ Own(new HowToPlayPresenter(root, text));
// Presentation only (#40): never the sim or the save. Outside Play mode (EditMode tests) no file: the developer's
// own settings must not leak into a test. Each Begin (New Game too) reads the file again.
Own(new SettingsPresenter(root, text, Application.isPlaying ? SettingsStore.ForPlatform() : null));
diff --git a/unity/Assets/Scripts/UI/HowToPlayPresenter.cs b/unity/Assets/Scripts/UI/HowToPlayPresenter.cs
new file mode 100644
index 000000000..295010d3c
--- /dev/null
+++ b/unity/Assets/Scripts/UI/HowToPlayPresenter.cs
@@ -0,0 +1,21 @@
+#nullable enable
+using UnityEngine.UIElements;
+
+namespace Statecraft.Game.UI
+{
+ /// <summary>Fills the short, presentation-only guide to the simulation's existing turn loop (#1041).</summary>
+ public sealed class HowToPlayPresenter : System.IDisposable
+ {
+ readonly VisualElement screen;
+
+ public HowToPlayPresenter(VisualElement root, UiText text)
+ {
+ screen = root.Q<VisualElement>("screen-how-to-play");
+ screen.Q<Label>("how-to-play-title").text = text["how_to_play.title"];
+ foreach (var key in new[] { "turn", "attention", "city", "training", "events", "top_bar", "end_turn", "why" })
+ screen.Q<Label>("how-to-play-" + key.Replace('_', '-')).text = text["how_to_play." + key];
+ }
+
+ public void Dispose() { }
+ }
+}
diff --git a/unity/Assets/Scripts/UI/HowToPlayPresenter.cs.meta b/unity/Assets/Scripts/UI/HowToPlayPresenter.cs.meta
new file mode 100644
index 000000000..0a3dade2f
--- /dev/null
+++ b/unity/Assets/Scripts/UI/HowToPlayPresenter.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 8490c32a58cb44d58ea92496991d54d4
diff --git a/unity/Assets/Scripts/UI/HudPresenter.cs b/unity/Assets/Scripts/UI/HudPresenter.cs
index ef6a59ae6..316fa4759 100644
--- a/unity/Assets/Scripts/UI/HudPresenter.cs
+++ b/unity/Assets/Scripts/UI/HudPresenter.cs
@@ -69,7 +69,8 @@ namespace Statecraft.Game.UI
static readonly (string name, string key)[] Texts =
{
("nav-cabinet", "hud.nav.cabinet"), ("nav-budget", "hud.nav.budget"), ("nav-defence", "hud.nav.defence"),
- ("nav-why", "hud.nav.why"), ("nav-settings", "hud.nav.settings"), ("new-game", "hud.new_game"), ("end-turn", "hud.end_turn"),
+ ("nav-why", "hud.nav.why"), ("nav-how-to-play", "hud.nav.how_to_play"), ("nav-settings", "hud.nav.settings"),
+ ("new-game", "hud.new_game"), ("end-turn", "hud.end_turn"),
};
/// <summary>The owner's text floor (#624, 15 October 2026): the bar's small text (the seven captions, Security's level
diff --git a/unity/Assets/Scripts/UI/KeyScroll.cs b/unity/Assets/Scripts/UI/KeyScroll.cs
index e341ac460..7e19c1d6a 100644
--- a/unity/Assets/Scripts/UI/KeyScroll.cs
+++ b/unity/Assets/Scripts/UI/KeyScroll.cs
@@ -18,6 +18,7 @@ namespace Statecraft.Game.UI
static readonly Dictionary<string, string> MainViews = new Dictionary<string, string>
{
["cabinet"] = "cabinet-seats", ["budget"] = "budget-rows", ["defence"] = "defence-body", ["why"] = "why-rows",
+ ["how-to-play"] = "how-to-play-body",
};
/// <summary>A page is the view's height less about one line of text, so the line at the edge stays in sight.</summary>
diff --git a/unity/Assets/Scripts/UI/ScreenNav.cs b/unity/Assets/Scripts/UI/ScreenNav.cs
index fed80092c..87e692a14 100644
--- a/unity/Assets/Scripts/UI/ScreenNav.cs
+++ b/unity/Assets/Scripts/UI/ScreenNav.cs
@@ -4,13 +4,13 @@ using UnityEngine.UIElements;
namespace Statecraft.Game.UI
{
- /// <summary>The top-bar buttons open the Cabinet, Budget, Defence, Why and Settings screens, one at a time; pressing the open
+ /// <summary>The side-menu buttons open the Cabinet, Budget, Defence, Why, How to play and Settings screens, one at a time; pressing the open
/// screen's button again closes it. Every press toggles, synchronously, with no debounce: two presses in one frame (a
/// double click, or a click plus Enter) open and close again, so the result depends only on the number of presses
/// (HudTests.TwoPressesInOneFrameToggleTwice; playtest 1, item 11).</summary>
public sealed class ScreenNav : System.IDisposable
{
- public static readonly string[] Screens = { "cabinet", "budget", "defence", "why", "settings" };
+ public static readonly string[] Screens = { "cabinet", "budget", "defence", "why", "how-to-play", "settings" };
/// <summary>The class on the open screen's button (Statecraft.uss lights its ring).</summary>
public const string OpenClass = "nav-open";
/// <summary>The class on the "root" element while a wide screen (class <see cref="WideClass"/>: Cabinet, Defence) is
diff --git a/unity/Assets/Scripts/UI/UiIcon.cs b/unity/Assets/Scripts/UI/UiIcon.cs
index f4f17428d..46b917e9e 100644
--- a/unity/Assets/Scripts/UI/UiIcon.cs
+++ b/unity/Assets/Scripts/UI/UiIcon.cs
@@ -41,7 +41,7 @@ namespace Statecraft.Game.UI
static readonly Dictionary<string, Painter> Painters = new Dictionary<string, Painter>
{
["coin"] = Coin, ["people"] = People, ["crowd"] = Crowd, ["shield"] = Shield, ["globe"] = Globe, ["banknote"] = Banknote, ["rings"] = Rings,
- ["columns"] = Columns, ["scales"] = Scales, ["helmet"] = Helmet, ["question"] = Question, ["restart"] = Restart, ["gear"] = Gear,
+ ["columns"] = Columns, ["scales"] = Scales, ["helmet"] = Helmet, ["question"] = Question, ["book"] = Book, ["restart"] = Restart, ["gear"] = Gear,
["chevron"] = Chevron, ["chevron-back"] = ChevronBack, ["hourglass"] = Hourglass,
["region"] = Region, ["house"] = House, ["village"] = Village, ["flag"] = Flag,
["peaks"] = Peaks, ["skyline"] = Skyline, ["ledger"] = Ledger,
@@ -247,6 +247,24 @@ namespace Statecraft.Game.UI
p.fillColor = gold; Circle(p, at(12, 20), 1.6f * s); p.Fill();
}
+ /// <summary>An open book (How to play, #1041): two pages from a middle spine, two text lines on each, in gold line, so
+ /// its disc is not Why?'s question mark.</summary>
+ static void Book(Painter2D p, Func<float, float, Vector2> at, float s, Color gold)
+ {
+ p.strokeColor = gold; p.lineWidth = 1.6f * s;
+ p.BeginPath(); p.MoveTo(at(12, 6.4f)); p.LineTo(at(12, 19.6f)); p.Stroke();
+ p.BeginPath(); p.MoveTo(at(12, 6.4f)); p.BezierCurveTo(at(9.4f, 4.8f), at(6, 4.6f), at(3, 5.6f)); p.LineTo(at(3, 18.8f));
+ p.BezierCurveTo(at(6, 17.8f), at(9.4f, 18f), at(12, 19.6f)); p.Stroke();
+ p.BeginPath(); p.MoveTo(at(12, 6.4f)); p.BezierCurveTo(at(14.6f, 4.8f), at(18, 4.6f), at(21, 5.6f)); p.LineTo(at(21, 18.8f));
+ p.BezierCurveTo(at(18, 17.8f), at(14.6f, 18f), at(12, 19.6f)); p.Stroke();
+ p.lineWidth = 1f * s;
+ foreach (var y in new[] { 10f, 13.6f })
+ {
+ p.BeginPath(); p.MoveTo(at(5.4f, y)); p.LineTo(at(9.8f, y + 0.6f)); p.Stroke();
+ p.BeginPath(); p.MoveTo(at(14.2f, y + 0.6f)); p.LineTo(at(18.6f, y)); p.Stroke();
+ }
+ }
+
static void Restart(Painter2D p, Func<float, float, Vector2> at, float s, Color gold)
{
p.strokeColor = gold; p.lineWidth = 2f * s;
diff --git a/unity/Assets/Tests/EditMode/GameSceneTests.cs b/unity/Assets/Tests/EditMode/GameSceneTests.cs
index 3ed0deacd..e1d4052f3 100644
--- a/unity/Assets/Tests/EditMode/GameSceneTests.cs
+++ b/unity/Assets/Tests/EditMode/GameSceneTests.cs
@@ -147,7 +147,7 @@ public class GameSceneTests
float h = Screen.height;
Vector2 o = UiPointer.ToPanel(panel, Vector2.zero, h), ex = UiPointer.ToPanel(panel, Vector2.right * 100, h) - o, ey = UiPointer.ToPanel(panel, Vector2.up * 100, h) - o;
Vector2 ScreenFor(Vector2 p) => new Vector2((p - o).x / ex.x * 100, (p - o).y / ey.y * 100);
- Rect a = ui.Q("nav-cabinet").worldBound, b = ui.Q("nav-budget").worldBound, last = ui.Q("nav-why").worldBound;
+ Rect a = ui.Q("nav-cabinet").worldBound, b = ui.Q("nav-budget").worldBound, last = ui.Q("nav-settings").worldBound;
var probes = new (string where, Vector2 p)[]
{
("left of a disc", new Vector2(a.xMin - 6f, a.center.y)),
diff --git a/unity/Assets/Tests/EditMode/HebrewUiTests.cs b/unity/Assets/Tests/EditMode/HebrewUiTests.cs
index 55a30853e..1121d0748 100644
--- a/unity/Assets/Tests/EditMode/HebrewUiTests.cs
+++ b/unity/Assets/Tests/EditMode/HebrewUiTests.cs
@@ -217,11 +217,13 @@ public class HebrewUiTests
("meter-security/meter-name", "hud.caption.security"), ("meter-support/meter-name", "hud.caption.support"),
("meter-cohesion/meter-name", "hud.caption.cohesion"), ("meter-standing/meter-name", "hud.caption.standing"), ("meter-fx/meter-name", "hud.caption.fx"),
("nav-cabinet", "hud.nav.cabinet"), ("nav-budget", "hud.nav.budget"), ("nav-defence", "hud.nav.defence"),
- ("nav-why", "hud.nav.why"), ("new-game", "hud.new_game"), ("end-turn", "hud.end_turn"),
+ ("nav-why", "hud.nav.why"), ("nav-how-to-play", "hud.nav.how_to_play"),
+ ("new-game", "hud.new_game"), ("end-turn", "hud.end_turn"),
("event-draft", "event.draft"),
("budget-screen-title", "budget.title"), ("budget-reset", "budget.reset"), ("budget-submit", "budget.submit"),
("defence-screen-title", "defence.title"), ("de-escalate", "defence.lower"), ("escalate", "defence.raise"),
("why-screen-title", "why.title"),
+ ("how-to-play-title", "how_to_play.title"),
("nav-settings", "hud.nav.settings"), ("settings-screen-title", "settings.title"), ("settings-tiltshift-label", "settings.tiltshift"),
("settings-quality-label", "settings.quality"), ("settings-quality-auto", "settings.quality.auto"),
("settings-quality-high", "settings.quality.high"), ("settings-quality-low", "settings.quality.low"),
diff --git a/unity/Assets/Tests/EditMode/HowToPlayScreenTests.cs b/unity/Assets/Tests/EditMode/HowToPlayScreenTests.cs
new file mode 100644
index 000000000..14e22f9e2
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/HowToPlayScreenTests.cs
@@ -0,0 +1,98 @@
+#nullable enable
+using System.Collections;
+using System.Collections.Generic;
+using System.Linq;
+using NUnit.Framework;
+using Statecraft.Game;
+using Statecraft.Game.UI;
+using Statecraft.Sim;
+using UnityEditor;
+using UnityEngine;
+using UnityEngine.TestTools;
+using UnityEngine.UIElements;
+using Object = UnityEngine.Object;
+
+/// <summary>The short How to play screen (#1041): side-menu navigation, both languages, and its two required layouts.</summary>
+public class HowToPlayScreenTests
+{
+ static readonly Content C = ContentLoader.Load(Paths.Content);
+ 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");
+
+ [Test]
+ public void TheSideMenuOpensAndClosesTheScreenInBothLanguages([Values(false, true)] bool hebrew)
+ {
+ var text = hebrew ? He : En;
+ using var ui = new UiTestKit();
+ using var nav = new ScreenNav(ui.Root);
+ using var guide = new HowToPlayPresenter(ui.Root, text);
+ var screen = ui.Q<VisualElement>("screen-how-to-play");
+
+ Assert.IsFalse(ScreenNav.IsOpen(screen), "hidden at start");
+ ui.Press("nav-how-to-play");
+ Assert.IsTrue(ScreenNav.IsOpen(screen), "the side-menu button opens it");
+ Assert.AreEqual("how-to-play", nav.Current);
+ Assert.AreEqual(text["how_to_play.title"], ui.Q<Label>("how-to-play-title").text);
+ ui.Press("nav-how-to-play");
+ Assert.IsFalse(ScreenNav.IsOpen(screen), "pressing the same button closes it");
+ Assert.IsNull(nav.Current);
+ }
+
+ [UnityTest]
+ public IEnumerator TheGuideFitsLaptopAndPhoneInBothLanguages()
+ {
+ var problems = new List<string>();
+ foreach (var hebrew in new[] { false, true })
+ foreach (var size in new[] { new Vector2Int(1280, 720), new Vector2Int(390, 844) })
+ yield return Rendered(size.x, size.y, hebrew, root =>
+ {
+ string at = $"{(hebrew ? "he" : "en")} {size.x}x{size.y}";
+ var screen = root.Q("screen-how-to-play").worldBound;
+ var window = root.worldBound;
+ if (!(screen.width > 0 && screen.height > 0)) problems.Add($"{at}: screen is not visible");
+ if (screen.xMin < window.xMin || screen.yMin < window.yMin || screen.xMax > window.xMax || screen.yMax > window.yMax)
+ problems.Add($"{at}: screen {screen} leaves window {window}");
+ var body = root.Q<ScrollView>("how-to-play-body").worldBound;
+ foreach (var line in root.Q<ScrollView>("how-to-play-body").Query<Label>().ToList())
+ {
+ if (string.IsNullOrWhiteSpace(line.text)) problems.Add($"{at}: {line.name} is empty");
+ if (line.worldBound.xMin < body.xMin - 1 || line.worldBound.xMax > body.xMax + 1)
+ problems.Add($"{at}: {line.name} {line.worldBound} overflows body {body}");
+ }
+ });
+ Assert.IsEmpty(problems, string.Join("\n", problems));
+ }
+
+ static IEnumerator Rendered(int width, int height, bool hebrew, System.Action<VisualElement> check)
+ {
+ var rt = new RenderTexture(width, height, 0);
+ var ps = Object.Instantiate(AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel));
+ ps.targetTexture = rt;
+ var go = new GameObject("HowToPlayLayoutTest");
+ 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 text = hebrew ? He : En;
+ var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), text);
+ var hud = new HudPresenter(root, bridge, text);
+ var guide = new HowToPlayPresenter(root, text);
+ var nav = new ScreenNav(root);
+ nav.Open("how-to-play");
+ try
+ {
+ for (int i = 0; i < 30 && !(root.Q("screen-how-to-play").layout.width > 0); i++) yield return null;
+ for (int i = 0; i < 3; i++) yield return null;
+ check(root);
+ }
+ finally
+ {
+ nav.Dispose(); guide.Dispose(); hud.Dispose();
+ Object.DestroyImmediate(go); Object.DestroyImmediate(ps); rt.Release(); Object.DestroyImmediate(rt);
+ }
+ }
+}
diff --git a/unity/Assets/Tests/EditMode/HowToPlayScreenTests.cs.meta b/unity/Assets/Tests/EditMode/HowToPlayScreenTests.cs.meta
new file mode 100644
index 000000000..a33da98e4
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/HowToPlayScreenTests.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: c409872840184cce85a24bc58a241159
diff --git a/unity/Assets/Tests/EditMode/LeftColumnTests.cs b/unity/Assets/Tests/EditMode/LeftColumnTests.cs
index 90ffb074b..9a970b30c 100644
--- a/unity/Assets/Tests/EditMode/LeftColumnTests.cs
+++ b/unity/Assets/Tests/EditMode/LeftColumnTests.cs
@@ -13,10 +13,10 @@ using UnityEngine;
using UnityEngine.TestTools;
using UnityEngine.UIElements;
-/// <summary>HUD round 2, part 2 (#398): promo/final/03's left icon column. It holds the four screens' buttons, moved from
-/// the top bar (no new action): Cabinet, Budget, Defence, Why?. They are round icons with no caption; each one's name is its
+/// <summary>HUD round 2, part 2 (#398): promo/final/03's left icon column. It holds the screens' buttons, moved from
+/// the top bar. They are round icons with no caption; each one's name is its
/// text (clear) and its tooltip, which HoverTip shows beside it. The Hebrew UI mirrors rows, not the screen's corners (#550),
-/// so the column stays at the left. Tab still runs Cabinet, Budget, Defence, Why?, then Settings (#40), New Game, End Turn.</summary>
+/// so the column stays at the left. Tab runs the side-menu screens, New Game, then End Turn.</summary>
public class LeftColumnTests
{
static readonly Content C = ContentLoader.Load(Paths.Content);
@@ -33,6 +33,7 @@ public class LeftColumnTests
{
("nav-cabinet", "hud.nav.cabinet", "columns"), ("nav-budget", "hud.nav.budget", "ledger"),
("nav-defence", "hud.nav.defence", "helmet"), ("nav-why", "hud.nav.why", "question"),
+ ("nav-how-to-play", "hud.nav.how_to_play", "book"),
("nav-settings", "hud.nav.settings", "gear"),
};
@@ -100,7 +101,7 @@ public class LeftColumnTests
}
}
- /// <summary>The column holds the four screens, in the top bar's old order, then Settings (#40), each a round icon whose name is its text and
+ /// <summary>The column holds every ScreenNav screen in order, each a round icon whose name is its text and
/// its tooltip in both languages; the top bar keeps New Game and End Turn only. No new button: the screens are ScreenNav's.</summary>
[Test]
public void TheColumnHoldsTheScreensAsRoundIconsNamedInBothLanguages()
@@ -114,6 +115,8 @@ public class LeftColumnTests
var column = ui.Q<VisualElement>(Column);
CollectionAssert.AreEqual(Rail.Select(r => r.name).ToArray(), column.Query<Button>().ToList().Select(b => b.name).ToArray(), "the column's buttons, in order");
CollectionAssert.AreEquivalent(ScreenNav.Screens.Select(s => "nav-" + s).ToArray(), Rail.Select(r => r.name).ToArray(), "exactly ScreenNav's screens");
+ // The discs have no caption, so each glyph alone tells them apart (How to play is not a second Why? mark, #1041).
+ CollectionAssert.AllItemsAreUnique(column.Query<UiIcon>(className: "nav-disc").ToList().Select(i => i.Glyph).ToArray(), "each disc its own glyph");
foreach (var (name, key, glyph) in Rail)
{
var b = ui.Q<Button>(name);
@@ -238,7 +241,7 @@ public class LeftColumnTests
static Rect Hull(VisualElement root) => root.Q(Column).Query<Button>().ToList().Select(b => b.worldBound)
.Aggregate((a, b) => Rect.MinMaxRect(Mathf.Min(a.xMin, b.xMin), Mathf.Min(a.yMin, b.yMin), Mathf.Max(a.xMax, b.xMax), Mathf.Max(a.yMax, b.yMax)));
- /// <summary>The audit's focus order is kept: Cabinet, Budget, Defence, Why?, Settings, New Game, End Turn (then the minimap's
+ /// <summary>The audit's focus order is kept: the side-menu screens, New Game, End Turn (then the minimap's
/// buttons, out of reach under the open card). The column is out of Tab's reach under the start screen and an outcome clip, as the top bar is, and usable
/// under the decision card, as the top bar is.</summary>
[UnityTest]
@@ -252,7 +255,7 @@ public class LeftColumnTests
var order = root.Query<VisualElement>().Where(e => e.focusable && e.canGrabFocus && e.tabIndex >= 0 && e is Button).ToList()
.Select(e => e.name).Where(n => n.StartsWith("nav-") || n == "new-game" || n == "end-turn" || n.StartsWith("minimap-")).ToList();
// Under the open card the minimap column is out of reach (the backdrop covers it); the column and the bar are not.
- CollectionAssert.AreEqual(new[] { "nav-cabinet", "nav-budget", "nav-defence", "nav-why", "nav-settings", "new-game", "end-turn" },
+ CollectionAssert.AreEqual(new[] { "nav-cabinet", "nav-budget", "nav-defence", "nav-why", "nav-how-to-play", "nav-settings", "new-game", "end-turn" },
order, $"{at}: the Tab order under the open card");
var r = root.Q("root");
Assert.IsTrue(r.ClassListContains(EventCardPresenter.ModalClass), at + ": precondition: the card is open");
diff --git a/unity/Assets/Tests/EditMode/PromoHudTests.cs b/unity/Assets/Tests/EditMode/PromoHudTests.cs
index 8439e50eb..86a7a5f86 100644
--- a/unity/Assets/Tests/EditMode/PromoHudTests.cs
+++ b/unity/Assets/Tests/EditMode/PromoHudTests.cs
@@ -39,7 +39,8 @@ public class PromoHudTests
{
using var ui = new UiTestKit();
foreach (var (button, name, glyph) in new[] { ("nav-cabinet", "Cabinet", "columns"), ("nav-budget", "Budget", "ledger"),
- ("nav-defence", "Defence", "helmet"), ("nav-why", "Why?", "question"), ("nav-settings", "Settings", "gear"),
+ ("nav-defence", "Defence", "helmet"), ("nav-why", "Why?", "question"),
+ ("nav-how-to-play", "How to play", "book"), ("nav-settings", "Settings", "gear"),
("new-game", "New game", "restart") })
{
var b = ui.Q<Button>(button);
diff --git a/unity/Assets/Tests/EditMode/PromoScreensTests.cs b/unity/Assets/Tests/EditMode/PromoScreensTests.cs
index e1faae4ca..950a44c22 100644
--- a/unity/Assets/Tests/EditMode/PromoScreensTests.cs
+++ b/unity/Assets/Tests/EditMode/PromoScreensTests.cs
@@ -943,6 +943,7 @@ public class PromoScreensTests
owned.Add(new DefencePresenter(root, bridge, Text));
owned.Add(new BudgetPresenter(root, bridge, Text));
owned.Add(new WhyPresenter(root, bridge, Text));
+ owned.Add(new HowToPlayPresenter(root, Text));
var info = new InfoPanelPresenter(root, bridge, Text, C.SettlementHexes.ToDictionary(x => x.Id, x => x.Id)); owned.Add(info);
var nav = new ScreenNav(root); owned.Add(nav);
var toast = root.Q<Label>("toast");
diff --git a/unity/Assets/Tests/EditMode/TopBarTests.cs b/unity/Assets/Tests/EditMode/TopBarTests.cs
index ecaa0b6ba..979d3111c 100644
--- a/unity/Assets/Tests/EditMode/TopBarTests.cs
+++ b/unity/Assets/Tests/EditMode/TopBarTests.cs
@@ -465,7 +465,7 @@ public class TopBarTests
Assert.IsEmpty(problems, string.Join("\n", problems));
}
- /// <summary>The audit's Tab order is kept: Cabinet, Budget, Defence, Why?, Settings (the left column), New Game, End Turn, then the
+ /// <summary>The audit's Tab order is kept: the side-menu screens, New Game, End Turn, then the
/// minimap's buttons.</summary>
[UnityTest]
public IEnumerator TheTabOrderIsKept()
@@ -475,7 +475,7 @@ public class TopBarTests
{
var order = root.Query<Button>().ToList().Where(e => e.focusable && e.canGrabFocus && e.tabIndex >= 0)
.Select(e => e.name).Where(n => n.StartsWith("nav-") || n == "new-game" || n == "end-turn" || n.StartsWith("minimap-")).ToList();
- CollectionAssert.AreEqual(new[] { "nav-cabinet", "nav-budget", "nav-defence", "nav-why", "nav-settings", "new-game", "end-turn", "minimap-overview", "minimap-labels", "minimap-borders" },
+ CollectionAssert.AreEqual(new[] { "nav-cabinet", "nav-budget", "nav-defence", "nav-why", "nav-how-to-play", "nav-settings", "new-game", "end-turn", "minimap-overview", "minimap-labels", "minimap-borders" },
order, (hebrew ? "he" : "en") + ": the Tab order");
}, widest: false);
}
diff --git a/unity/Assets/Tests/EditMode/UiLayoutTests.cs b/unity/Assets/Tests/EditMode/UiLayoutTests.cs
index a5508b9d4..fa90ae781 100644
--- a/unity/Assets/Tests/EditMode/UiLayoutTests.cs
+++ b/unity/Assets/Tests/EditMode/UiLayoutTests.cs
@@ -390,7 +390,7 @@ public class UiLayoutTests
{
new HudPresenter(root, bridge, text), new EventCardPresenter(root, bridge, text, null),
new CabinetPresenter(root, bridge, text, null), new BudgetPresenter(root, bridge, text),
- new DefencePresenter(root, bridge, text), new WhyPresenter(root, bridge, text),
+ new DefencePresenter(root, bridge, text), new WhyPresenter(root, bridge, text), new HowToPlayPresenter(root, text),
};
var nav = new ScreenNav(root);
try
diff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxml
index 587e64194..be86bc98c 100644
--- a/unity/Assets/UI/Game.uxml
+++ b/unity/Assets/UI/Game.uxml
@@ -5,9 +5,9 @@
<ui:Label name="loading" text="Loading the map of 1948…" class="loading-line" picking-mode="Ignore" />
<!-- Settlement names, positioned by MapLabelsPresenter under every panel; clicks pass through to the map. -->
<ui:VisualElement name="map-labels" class="map-labels" picking-mode="Ignore" />
- <!-- HUD round 2, part 2 (#398): promo 03's left icon column, the four screens (ScreenNav), icon-only; each one's name
+ <!-- HUD round 2, part 2 (#398): promo 03's left icon column, the screens (ScreenNav), icon-only; each one's name
is its text (the event log records it), hidden, and its tooltip, shown beside it on hover and on focus
- (HoverTip). Before the top bar in the tree, so Tab still runs Cabinet, Budget, Defence, Why?, Settings, New Game, End Turn. -->
+ (HoverTip). Before the top bar in the tree, so Tab runs the side-menu screens, New Game, then End Turn. -->
<!-- The left column's strip of the decision card's backdrop (review of #602): dimmed and taking the pointer while the
card is open (event-modal), so the map is blocked between and below the discs as it is everywhere else; before
the column in the tree, so the column's buttons stay above it and usable. -->
@@ -17,6 +17,7 @@
<ui:Button name="nav-budget" text="Budget" class="nav-button rail-button"><Statecraft.Game.UI.UiIcon glyph="ledger" class="nav-disc" /></ui:Button>
<ui:Button name="nav-defence" text="Defence" class="nav-button rail-button"><Statecraft.Game.UI.UiIcon glyph="helmet" class="nav-disc" /></ui:Button>
<ui:Button name="nav-why" text="Why?" class="nav-button rail-button"><Statecraft.Game.UI.UiIcon glyph="question" class="nav-disc" /></ui:Button>
+ <ui:Button name="nav-how-to-play" text="How to play" class="nav-button rail-button"><Statecraft.Game.UI.UiIcon glyph="book" class="nav-disc" /></ui:Button>
<ui:Button name="nav-settings" text="Settings" class="nav-button rail-button"><Statecraft.Game.UI.UiIcon glyph="gear" class="nav-disc" /></ui:Button>
</ui:VisualElement>
<ui:VisualElement name="top-bar" class="panel top-bar">
@@ -294,6 +295,21 @@
<ui:ScrollView name="why-rows" class="grow" />
<Statecraft.Game.UI.UiFrame />
</ui:VisualElement>
+ <!-- A short guide to the existing loop (#1041). It is a normal side-menu screen, so ScreenNav owns opening and closing. -->
+ <ui:VisualElement name="screen-how-to-play" class="panel screen">
+ <ui:VisualElement class="screen-header"><ui:Label name="how-to-play-title" text="How to play" class="title" /></ui:VisualElement>
+ <ui:ScrollView name="how-to-play-body" class="grow how-to-play-body">
+ <ui:Label name="how-to-play-turn" class="how-to-play-line" />
+ <ui:Label name="how-to-play-attention" class="how-to-play-line" />
+ <ui:Label name="how-to-play-city" class="how-to-play-line" />
+ <ui:Label name="how-to-play-training" class="how-to-play-line" />
+ <ui:Label name="how-to-play-events" class="how-to-play-line" />
+ <ui:Label name="how-to-play-top-bar" class="how-to-play-line" />
+ <ui:Label name="how-to-play-end-turn" class="how-to-play-line" />
+ <ui:Label name="how-to-play-why" class="how-to-play-line" />
+ </ui:ScrollView>
+ <Statecraft.Game.UI.UiFrame />
+ </ui:VisualElement>
<!-- Settings (#40, SettingsPresenter): the player's presentation options, kept per browser (SettingsStore), never in
the sim or the save. Each option is a row: its name, and a button that says what is set. -->
<ui:VisualElement name="screen-settings" class="panel screen">
diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.uss
index 8f31f351f..232242748 100644
--- a/unity/Assets/UI/Statecraft.uss
+++ b/unity/Assets/UI/Statecraft.uss
@@ -218,14 +218,17 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
full height (the bar draws over its top), shown and taking the pointer only while the decision card is open. */
.event-gutter { display: none; position: absolute; left: 0; top: 112px; bottom: 0; width: 72px; background-color: rgba(5, 9, 18, 0.55); }
.event-modal .event-gutter { display: flex; }
-.left-column .rail-button { width: 56px; height: 56px; margin: 0 0 12px 0; padding: 0; font-size: 1px; color: rgba(0, 0, 0, 0); }
+.left-column .rail-button { width: 50px; height: 50px; margin: 0 0 6px 0; padding: 0; font-size: 1px; color: rgba(0, 0, 0, 0); }
.left-column .rail-button:hover, .left-column .rail-button:focus, .left-column .nav-open { color: rgba(0, 0, 0, 0); }
-.left-column .rail-button .nav-disc { top: 0; left: 0; width: 56px; height: 56px; padding: 13px; border-radius: 28px; }
+/* Six discs since How to play (#1041): 50 px, 6 px apart, so the column ends at 112 + 336 px (the five 56 px discs: 340),
+ above the info panel's top (456 px) in a short, wide window (InfoPanelLayoutTests); the column keeps its 56 px width,
+ so the backdrop, the screens and the toast keep their places. */
+.left-column .rail-button .nav-disc { top: 0; left: 0; width: 50px; height: 50px; padding: 11px; border-radius: 25px; }
/* On a phone held upright the panel's scale falls to about 0.41 (375x667), where a 56 px disc is 22.8 px on screen: the
column's discs are 60 px there, at least 24 on screen (LeftColumnTests), and the backdrop's strip and the backdrop
follow the wider column. */
.hud-three-row .left-column { width: 60px; }
-.hud-three-row .left-column > .rail-button { width: 60px; height: 60px; }
+.hud-three-row .left-column > .rail-button { width: 60px; height: 60px; margin: 0 0 12px 0; }
.hud-three-row .left-column > .rail-button .nav-disc { width: 60px; height: 60px; padding: 14px; border-radius: 30px; }
.hud-three-row .event-gutter { width: 76px; }
.hud-three-row .event-scrim { left: 60px; }
@@ -398,6 +401,8 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
.screen .row.grow > .grow { min-height: 0; flex-shrink: 1; }
/* Settings (#40): an option's name takes the row's width and wraps; its button keeps room for "On" / "Off". */
.settings-row { margin-top: 8px; }
+.how-to-play-body { min-height: 0; }
+.how-to-play-line { white-space: normal; margin-bottom: 12px; font-size: 18px; }
.settings-name { flex-grow: 1; flex-shrink: 1; min-width: 0; white-space: normal; }
.settings-switch { flex-shrink: 0; min-width: 96px; -unity-text-align: middle-center; }
/* The quality choice's buttons sit side by side; the one that is set is marked by a gold fill and dark text, not only a
diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yaml
index b0eaf5391..0e8acd012 100644
--- a/unity/Assets/UI/strings.en.yaml
+++ b/unity/Assets/UI/strings.en.yaml
@@ -37,6 +37,7 @@ hud.nav.cabinet: "Cabinet"
hud.nav.budget: "Budget"
hud.nav.defence: "Defence"
hud.nav.why: "Why?"
+hud.nav.how_to_play: "How to play"
hud.nav.settings: "Settings"
hud.new_game: "New game"
hud.end_turn: "End turn"
@@ -48,6 +49,16 @@ defence.title: "Defence"
defence.lower: "Lower the level"
defence.raise: "Raise the level"
why.title: "Why did this happen?"
+# The short guide (#1041). These describe the existing sim without balance values, so rule changes stay in the sim.
+how_to_play.title: "How to play"
+how_to_play.turn: "Each turn is one month. Look over the country, give your orders, then press End turn."
+how_to_play.attention: "Most orders cost Attention, shown in the top bar. It refills at the start of each turn, and Attention you leave unspent does not carry over."
+how_to_play.city: "Select a city on the map to see its housing and jobs, and set how many of its civilians are in work."
+how_to_play.training: "In a city with a military camp or a Hakhshara, you can train civilians who have no work as recruits or halutzim. The button shows what the training costs and how many turns it takes."
+how_to_play.events: "An event card asks for a decision. Answering it costs Attention, and your choice takes effect when you end the turn."
+how_to_play.top_bar: "The top bar shows the date, your Attention, Money and the country's main indicators."
+how_to_play.end_turn: "End turn carries out your orders and moves to the next month. A card you leave unanswered, or have no Attention left to answer, goes to the responsible minister, who decides it for you."
+how_to_play.why: "After a turn, open Why? to see each change and its cause."
# The Settings screen (#40): its title, the tilt-shift option and the button that says what is set.
settings.title: "Settings"
settings.tiltshift: "Blur at the top and bottom of the map"
diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yaml
index f186ecb4e..dd352a6f1 100644
--- a/unity/Assets/UI/strings.he.yaml
+++ b/unity/Assets/UI/strings.he.yaml
@@ -30,6 +30,7 @@ hud.nav.cabinet: "ממשלה"
hud.nav.budget: "תקציב"
hud.nav.defence: "ביטחון"
hud.nav.why: "למה?"
+hud.nav.how_to_play: "איך משחקים"
hud.nav.settings: "הגדרות"
hud.new_game: "משחק חדש"
hud.end_turn: "סיום התור"
@@ -40,6 +41,16 @@ defence.title: "ביטחון"
defence.lower: "הורדת הדרגה"
defence.raise: "העלאת הדרגה"
why.title: "למה זה קרה?"
+# The short How to play guide (#1041). For the native reviewer (#564).
+how_to_play.title: "איך משחקים"
+how_to_play.turn: "כל תור הוא חודש אחד. בחנו את מצב המדינה, תנו הוראות ואז לחצו על סיום התור."
+how_to_play.attention: "רוב ההוראות עולות תשומת לב, המוצגת בסרגל העליון. היא מתמלאת מחדש בתחילת כל תור, ותשומת לב שלא ניצלתם אינה עוברת לתור הבא."
+how_to_play.city: "בחרו עיר במפה כדי לראות את הדיור ואת המשרות בה, וקבעו כמה מאזרחיה עובדים."
+how_to_play.training: "בעיר שיש בה מחנה צבאי או מחנה הכשרה אפשר לאמן אזרחים ללא עבודה כמגויסים או להכשיר אותם כחלוצים. הכפתור מראה כמה עולה האימון וכמה תורות הוא נמשך."
+how_to_play.events: "כרטיס אירוע מבקש מכם החלטה. מענה עליו עולה תשומת לב, והבחירה שלכם נכנסת לתוקף בסיום התור."
+how_to_play.top_bar: "הסרגל העליון מציג את התאריך, את תשומת הלב שלכם, את הכסף ואת המדדים העיקריים של המדינה."
+how_to_play.end_turn: "סיום התור מבצע את ההוראות שלכם ומעביר לחודש הבא. כרטיס שלא עניתם עליו, או שלא נשארה לכם תשומת לב לענות עליו, עובר לשר האחראי, והוא מחליט במקומכם."
+how_to_play.why: "אחרי תור, פתחו את המסך למה? כדי לראות כל שינוי ואת הסיבה לו."
# The Settings screen (#40). "On" / "Off" as a switch's state, not a command. For the native reviewer (#564).
settings.title: "הגדרות"
settings.tiltshift: "טשטוש בחלק העליון ובחלק התחתון של המפה"