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.

fix(ui): loading state, wrapping options, a card that fits, framed faces, sentence case (playtest 2, P2-1 P2-2 P2-3 P2-5 P2-6)

eyalgolan8978566c9699
diff --git a/content/people.yaml b/content/people.yaml
index 34b6a2d74..67717a09d 100644
--- a/content/people.yaml
+++ b/content/people.yaml
@@ -7,6 +7,8 @@
# 1948-49 cabinet, 2026-10-10 for people added in M3).
# Portraits: public-domain files fetched with license check (promo/CREDITS.md).
# Not modelled: deputy ministers (Efrati, Shari, Kahana) and Kaplan's Deputy Prime Minister title (research notes 1c, 1e).
+# portrait.focus_y: the face centre's height as a share of the picture (0 top, 1 bottom), measured on each picture;
+# the event card keeps it in view (playtest 2, P2-5).
people:
- id: ben_gurion
name: David Ben-Gurion
@@ -14,7 +16,7 @@ people:
party: mapai
competence: 9
loyalty: 10
- portrait: { file: promo/ref/people/David_Ben-Gurion.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:David_Ben-Gurion_(D597-087).jpg" }
+ portrait: { file: promo/ref/people/David_Ben-Gurion.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:David_Ben-Gurion_(D597-087).jpg", focus_y: 0.3 }
offices:
- { office: prime_minister, from: 1948-05-14, sources: &prov [{ url: "https://en.wikipedia.org/wiki/Provisional_government_of_Israel", checked: 2026-10-09 }] }
- { office: defense_minister, from: 1948-05-14, sources: *prov }
@@ -27,7 +29,7 @@ people:
party: mapam
competence: 6
loyalty: 5
- portrait: { file: promo/ref/people/Aharon_Zisling.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:Aharon_Zisling.jpg" }
+ portrait: { file: promo/ref/people/Aharon_Zisling.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:Aharon_Zisling.jpg", focus_y: 0.34 }
offices:
- { office: agriculture_minister, from: 1948-05-14, to: 1949-03-10, sources: *prov }
status: fact-checked
@@ -37,7 +39,7 @@ people:
party: mapai
competence: 8
loyalty: 9
- portrait: { file: promo/ref/people/Eliezer_Kaplan.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:Eliezer_Kaplan.jpg" }
+ portrait: { file: promo/ref/people/Eliezer_Kaplan.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:Eliezer_Kaplan.jpg", focus_y: 0.3 }
offices:
- { office: finance_minister, from: 1948-05-14, to: 1949-03-10, sources: *prov }
- { office: finance_minister, from: 1949-03-10, to: 1950-11-01, sources: &first [{ url: "https://en.wikipedia.org/wiki/First_government_of_Israel", checked: 2026-10-10 }, { url: "https://bengurionarchive.bgu.ac.il/en/node/14566", checked: 2026-10-09 }] }
@@ -51,7 +53,7 @@ people:
party: mapai
competence: 8
loyalty: 8
- portrait: { file: promo/ref/people/Moshe_Sharett.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:Moshe_Sharett_Portrait.jpg" }
+ portrait: { file: promo/ref/people/Moshe_Sharett.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:Moshe_Sharett_Portrait.jpg", focus_y: 0.22 }
offices:
- { office: foreign_minister, from: 1948-05-14, to: 1949-03-10, sources: *prov }
- { office: foreign_minister, from: 1949-03-10, to: 1950-11-01, sources: *first }
@@ -64,7 +66,7 @@ people:
party: hapoel_hamizrachi
competence: 7
loyalty: 7
- portrait: { file: promo/ref/people/Haim-Moshe_Shapira.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:Moshe_Shapira.jpg" }
+ portrait: { file: promo/ref/people/Haim-Moshe_Shapira.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:Moshe_Shapira.jpg", focus_y: 0.42 }
offices:
- { office: health_minister, from: 1948-05-14, to: 1949-03-10, sources: *prov }
- { office: immigration_minister, from: 1948-05-14, to: 1949-03-10, sources: *prov }
@@ -87,7 +89,7 @@ people:
party: independent
competence: 6
loyalty: 6
- portrait: { file: promo/ref/people/Yitzhak_Gruenbaum.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:Yitzhak_Gruenbaum_1948.jpg" }
+ portrait: { file: promo/ref/people/Yitzhak_Gruenbaum.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:Yitzhak_Gruenbaum_1948.jpg", focus_y: 0.3 }
offices:
- { office: interior_minister, from: 1948-05-14, to: 1949-03-10, sources: *prov }
status: fact-checked
@@ -97,7 +99,7 @@ people:
party: new_aliyah
competence: 8
loyalty: 7
- portrait: { file: promo/ref/people/Pinchas_Rosen.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:Pinchas_Rosen.jpg" }
+ portrait: { file: promo/ref/people/Pinchas_Rosen.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:Pinchas_Rosen.jpg", focus_y: 0.36 }
offices:
- { office: justice_minister, from: 1948-05-14, to: 1949-03-10, sources: *prov }
- { office: justice_minister, from: 1949-03-10, to: 1950-11-01, party: progressive, sources: *first }
@@ -110,7 +112,7 @@ people:
party: mapam
competence: 7
loyalty: 5
- portrait: { file: promo/ref/people/Mordechai_Bentov.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:MordechaiBentov.jpg" }
+ portrait: { file: promo/ref/people/Mordechai_Bentov.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:MordechaiBentov.jpg", focus_y: 0.28 }
offices:
- { office: labour_minister, from: 1948-05-14, to: 1949-03-10, sources: *prov }
status: fact-checked
@@ -120,7 +122,7 @@ people:
party: sephardim
competence: 7
loyalty: 7
- portrait: { file: promo/ref/people/Bechor-Shalom_Sheetrit.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:Bechor-Shalom_Shitreet.jpg" }
+ portrait: { file: promo/ref/people/Bechor-Shalom_Sheetrit.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:Bechor-Shalom_Shitreet.jpg", focus_y: 0.18 }
offices:
- { office: police_minister, from: 1948-05-14, to: 1949-03-10, sources: *prov }
- { office: minority_affairs_minister, from: 1948-05-14, to: 1949-03-10, sources: *prov }
@@ -136,7 +138,7 @@ people:
party: mizrachi
competence: 6
loyalty: 7
- portrait: { file: promo/ref/people/Yehuda_Leib_Maimon.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:Yehuda_Leib_Maimon.jpg" }
+ portrait: { file: promo/ref/people/Yehuda_Leib_Maimon.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:Yehuda_Leib_Maimon.jpg", focus_y: 0.26 }
offices:
- { office: religions_minister, from: 1948-05-14, to: 1949-03-10, sources: *prov }
- { office: war_victims_minister, from: 1948-05-14, to: 1949-03-10, sources: *prov }
@@ -156,7 +158,7 @@ people:
party: general_zionists
competence: 7
loyalty: 6
- portrait: { file: promo/ref/people/Peretz_Bernstein.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:Peretz_Bernstein.jpg" }
+ portrait: { file: promo/ref/people/Peretz_Bernstein.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:Peretz_Bernstein.jpg", focus_y: 0.28 }
offices:
- { office: trade_minister, from: 1948-05-14, to: 1949-03-10, sources: *prov }
status: fact-checked
@@ -168,7 +170,7 @@ people:
party: mapai
competence: 7
loyalty: 8
- portrait: { file: promo/ref/people/David_Remez.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:David_Remez_(cropped).jpg" }
+ portrait: { file: promo/ref/people/David_Remez.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:David_Remez_(cropped).jpg", focus_y: 0.38 }
offices:
- { office: transportation_minister, from: 1948-05-14, to: 1949-03-10, sources: *prov }
- { office: transportation_minister, from: 1949-03-10, to: 1950-11-01, sources: *first }
@@ -180,7 +182,7 @@ people:
party: agudat_yisrael
competence: 6
loyalty: 6
- portrait: { file: promo/ref/people/Yitzhak-Meir_Levin.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:Yitzhak_Meir_Levin.jpg" }
+ portrait: { file: promo/ref/people/Yitzhak-Meir_Levin.jpg, license: Public domain, source: "https://commons.wikimedia.org/wiki/File:Yitzhak_Meir_Levin.jpg", focus_y: 0.28 }
offices:
- { office: welfare_minister, from: 1948-05-14, to: 1949-03-10, sources: *prov }
- { office: welfare_minister, from: 1949-03-10, to: 1950-11-01, party: united_religious_front, sources: *first }
diff --git a/docs/m3-release.md b/docs/m3-release.md
index ccd747916..27b78a37a 100644
--- a/docs/m3-release.md
+++ b/docs/m3-release.md
@@ -23,6 +23,11 @@
- `TURN <n> <date> hash <state hash>` after every End Turn.
- `CAMERA distance=<m> yaw=<deg>` with `?camlog`.
- `PROFILE ...` with `?profile`.
+ - `BOOT phase=<name> at=<ms> ms dt=<ms> ms` for each boot phase with `?bootlog` (playtest 2, P2-1).
+ - `NAV f=<frame> ...` with `?navlog`: every raw mouse event, UI pointer and submit event, screen toggle and map click,
+ with its frame (playtest 2, P2-4).
+- **Player-facing wording:** the Budget screen gives each ministry's multiplier as "spending effect 150%" (the share's
+ effect on that ministry's effects, on the 0-100 scale the rest of the game uses), never "x1.50" (playtest 2, P2-6).
## WebGL terrain profile
Results from `?profile`: 300 frames per setting after 60 warm-up frames, from the diorama camera over central Israel. All runs were in Chrome for Testing 1228 with `--disable-frame-rate-limit --disable-gpu-vsync`.
diff --git a/sim/Statecraft.Sim.Tests/CabinetTests.cs b/sim/Statecraft.Sim.Tests/CabinetTests.cs
index c13eba8ed..5d6e2cb11 100644
--- a/sim/Statecraft.Sim.Tests/CabinetTests.cs
+++ b/sim/Statecraft.Sim.Tests/CabinetTests.cs
@@ -61,7 +61,7 @@ public class CabinetTests
Assert.Equal("def_two", Offices.Holder(C, "finance_minister", s.Date)!.Id); // history itself is unchanged
Assert.Equal(0.9, s.CoalitionStability, 9); // Def Two had no party: a seat lost
Assert.Contains(why, w => w.System == "cabinet" && w.Message == "Loy Alist appointed Minister of Finance, replacing Def Two");
- Assert.Contains(why, w => w.Target == "coalition_stability" && w.Message == "coalition stability -10.0% (Def Two lost the Minister of Finance)");
+ Assert.Contains(why, w => w.Target == "coalition_stability" && w.Message == "Coalition stability -10.0% (Def Two lost the Minister of Finance)");
}
[Fact]
@@ -72,7 +72,7 @@ public class CabinetTests
var why = new List<Cause>();
Assert.Null(Cabinet.Appoint(C, s, "finance_minister", "loyal_two", why));
Assert.Equal(0.9 - 0.03, s.CoalitionStability, 9);
- Assert.Contains(why, w => w.Message == "coalition stability -3.0% (Alpha resents the reshuffle)");
+ Assert.Contains(why, w => w.Message == "Coalition stability -3.0% (Alpha resents the reshuffle)");
}
[Theory]
diff --git a/sim/Statecraft.Sim.Tests/EventTests.cs b/sim/Statecraft.Sim.Tests/EventTests.cs
index 27876bc5a..fc884874e 100644
--- a/sim/Statecraft.Sim.Tests/EventTests.cs
+++ b/sim/Statecraft.Sim.Tests/EventTests.cs
@@ -320,7 +320,7 @@ options:
EventSystem.Trigger(c, s, why);
s.Date = new DateTime(1949, 1, 15); // still pending after To, office unheld today
Assert.Null(EventSystem.Choose(c, s, "shortage", "ration", why));
- Assert.Contains(why, w => w.Message == "chosen: Pm One rations food");
+ Assert.Contains(why, w => w.Message == "Chosen: Pm One rations food");
}
[Fact]
@@ -332,7 +332,7 @@ options:
EventSystem.Trigger(c, s, why);
s.Date = new DateTime(1949, 1, 1); // exactly To
EventSystem.Delegate(c, s, why);
- Assert.Contains(why, w => w.Message.StartsWith("delegated") && w.Message.EndsWith("Pm One rations food"));
+ Assert.Contains(why, w => w.Message.StartsWith("Delegated") && w.Message.EndsWith("Pm One rations food"));
}
[Fact]
@@ -437,7 +437,7 @@ options:
var s = State(c, new DateTime(1948, 6, 1)); s.RngState = seed; var why = new List<Cause>();
EventSystem.Trigger(c, s, why); why.Clear();
EventSystem.Delegate(c, s, why);
- return why.First(w => w.Message.StartsWith("delegated")).Message;
+ return why.First(w => w.Message.StartsWith("Delegated")).Message;
}
[Fact]
diff --git a/sim/Statecraft.Sim.Tests/MapActionTests.cs b/sim/Statecraft.Sim.Tests/MapActionTests.cs
index 80aec66df..f3fe8c202 100644
--- a/sim/Statecraft.Sim.Tests/MapActionTests.cs
+++ b/sim/Statecraft.Sim.Tests/MapActionTests.cs
@@ -44,7 +44,7 @@ public class MapActionTests
Assert.Null(MapActions.Apply(C, s, "housing", 1, 1, why));
Assert.Equal(0, s.Treasury);
Assert.Equal(5, s.Debt, 9);
- Assert.Contains(why, w => w.Message == "borrowed IL 5.0m to build a housing project");
+ Assert.Contains(why, w => w.Message == "Borrowed IL 5.0m to build a housing project");
}
[Fact]
diff --git a/sim/Statecraft.Sim.Tests/PlayerTextTests.cs b/sim/Statecraft.Sim.Tests/PlayerTextTests.cs
index f49b51471..fb1a2c348 100644
--- a/sim/Statecraft.Sim.Tests/PlayerTextTests.cs
+++ b/sim/Statecraft.Sim.Tests/PlayerTextTests.cs
@@ -179,7 +179,7 @@ public class PlayerTextTests
Assert.True(budget && camp && housing, $"the script ran every command (budget {budget}, camp {camp}, housing {housing})");
Assert.True(appointable.SetEquals(appointedOffices), $"every appointable office was filled: missing {string.Join(", ", appointable.Except(appointedOffices))}");
Assert.True(c.Policies.All(p => policiesSet.Contains(p.Id)), $"every policy was set: missing {string.Join(", ", c.Policies.Select(p => p.Id).Except(policiesSet))}");
- Assert.Contains(causes, w => w.Message.StartsWith("borrowed ", StringComparison.Ordinal));
+ Assert.Contains(causes, w => w.Message.StartsWith("Borrowed ", StringComparison.Ordinal));
Assert.Contains(causes, w => w.System == "policy");
Assert.Contains(causes, w => w.System == "politics" && w.Message.Contains(" voted down "));
return causes;
@@ -407,4 +407,28 @@ public class PlayerTextTests
Assert.Equal(shown, PlayerText.PercentChangeShown(before, now));
Assert.Equal(PlayerText.ShownPoints(now) - PlayerText.ShownPoints(before), double.Parse(shown.TrimEnd('%'), System.Globalization.CultureInfo.InvariantCulture));
}
+
+ /// <summary>Playtest 2, P2-6: every Cause line is in sentence case (a capital letter or a number first).</summary>
+ [Fact]
+ public void EveryCauseLineStartsWithACapitalOrANumber()
+ {
+ var bad = AllCauses(Real).Select(w => w.Message).Where(m => m.Length == 0 || char.IsLower(m[0])).Distinct().ToList();
+ Assert.True(bad.Count == 0, "lowercase Cause lines:\n" + string.Join("\n", bad.Take(20)));
+ }
+
+ /// <summary>Playtest 2, P2-5: a portrait carries its documented focal point (the face's height as a share of the
+ /// picture, 0..1), required, so the event card can keep the face in view.</summary>
+ [Theory]
+ [InlineData(" portrait: { file: a.jpg, license: Public domain, source: s }\n", "people[pm_one].portrait.focus_y")]
+ [InlineData(" portrait: { file: a.jpg, license: Public domain, source: s, focus_y: 1.4 }\n", "people[pm_one].portrait.focus_y")]
+ public void APortraitNeedsItsFocalPoint(string portrait, string field)
+ {
+ var ex = ValidationTests.Bad("people.yaml", " - id: pm_one\n", " - id: pm_one\n" + portrait);
+ Assert.Equal("people.yaml", ex.File);
+ Assert.Equal(field, ex.Field);
+ }
+
+ [Fact]
+ public void EveryRealPortraitHasAFocalPoint() =>
+ Assert.All(Real.People.Where(p => p.Portrait != null && p.Portrait.File != ""), p => Assert.InRange(p.Portrait!.FocusY ?? -1, 0.05, 0.95));
}
diff --git a/sim/Statecraft.Sim.Tests/SecurityTests.cs b/sim/Statecraft.Sim.Tests/SecurityTests.cs
index 0514f91ac..4f3f2022e 100644
--- a/sim/Statecraft.Sim.Tests/SecurityTests.cs
+++ b/sim/Statecraft.Sim.Tests/SecurityTests.cs
@@ -51,7 +51,7 @@ public class SecurityTests
Assert.Null(SecuritySystem.SetMobilization(C, s, 0.9, why));
var cause = Assert.Single(why, w => w.System == "security" && w.Target == "mobilization");
Assert.Equal(0.9, cause.Delta);
- Assert.Equal("reserve call-up set to 90%", cause.Message);
+ Assert.Equal("Reserve call-up set to 90%", cause.Message);
Assert.Equal(0.9, s.Mobilization);
}
diff --git a/sim/Statecraft.Sim.Tests/SimTests.cs b/sim/Statecraft.Sim.Tests/SimTests.cs
index e62ea3f78..79bdfa538 100644
--- a/sim/Statecraft.Sim.Tests/SimTests.cs
+++ b/sim/Statecraft.Sim.Tests/SimTests.cs
@@ -263,8 +263,8 @@ options:
var r = Simulation.Step(c, s0, HistoricalAI.Commands(c, s0)); // 3 attention, each choice costs 2
Assert.StartsWith("Not enough attention", r.Rejected.Single().Reason);
Assert.Empty(r.State.PendingEvents);
- Assert.Contains(r.Why, w => w.System == "events" && w.Message.StartsWith("chosen: "));
- Assert.Contains(r.Why, w => w.System == "events" && w.Message.StartsWith("delegated to Def Two"));
+ Assert.Contains(r.Why, w => w.System == "events" && w.Message.StartsWith("Chosen: "));
+ Assert.Contains(r.Why, w => w.System == "events" && w.Message.StartsWith("Delegated to Def Two"));
}
[Fact]
@@ -316,7 +316,7 @@ options:
var s0 = Simulation.NewGame(c, seed, Mode.Historical);
Assert.Equal(new[] { "partition" }, s0.PendingEvents);
var r = Simulation.Step(c, s0, None);
- Assert.Contains(r.Why, w => w.System == "events" && w.Message == "delegated to Pm One: Accept the line");
+ Assert.Contains(r.Why, w => w.System == "events" && w.Message == "Delegated to Pm One: Accept the line");
Assert.Equal(seed, r.State.RngState);
}
}
@@ -329,7 +329,7 @@ options:
s0.Mode = Mode.Open;
var r = Simulation.Step(c, s0, None);
Assert.NotEqual(5UL, r.State.RngState);
- Assert.Contains(r.Why, w => w.System == "events" && w.Message.StartsWith("delegated to Pm One: "));
+ Assert.Contains(r.Why, w => w.System == "events" && w.Message.StartsWith("Delegated to Pm One: "));
}
const string Late = @"
diff --git a/sim/Statecraft.Sim/Cause.cs b/sim/Statecraft.Sim/Cause.cs
index b7267a950..90c2f4bb5 100644
--- a/sim/Statecraft.Sim/Cause.cs
+++ b/sim/Statecraft.Sim/Cause.cs
@@ -8,7 +8,7 @@ namespace Statecraft.Sim
public double Delta { get; }
public string Message { get; }
public Cause(string system, string target, double delta, string message)
- { System = system; Target = target; Delta = delta; Message = message; }
+ { System = system; Target = target; Delta = delta; Message = PlayerText.Capitalised(message); } // sentence case (playtest 2, P2-6)
public override string ToString() => $"[{System}] {Message}";
}
}
diff --git a/sim/Statecraft.Sim/Content.cs b/sim/Statecraft.Sim/Content.cs
index c2840ab91..66abcef7a 100644
--- a/sim/Statecraft.Sim/Content.cs
+++ b/sim/Statecraft.Sim/Content.cs
@@ -28,7 +28,13 @@ namespace Statecraft.Sim
public List<Source> Sources { get; set; } = new List<Source>();
}
- public sealed class Portrait { public string File { get; set; } = ""; public string License { get; set; } = ""; public string Source { get; set; } = ""; }
+ public sealed class Portrait
+ {
+ public string File { get; set; } = ""; public string License { get; set; } = ""; public string Source { get; set; } = "";
+ /// <summary>Where the face is: its centre's height as a share of the picture (0 = top, 1 = bottom), so the event card
+ /// can keep it in view (playtest 2, P2-5). Required for a portrait with a file.</summary>
+ public double? FocusY { get; set; }
+ }
public sealed class Person
{
diff --git a/sim/Statecraft.Sim/ContentLoader.cs b/sim/Statecraft.Sim/ContentLoader.cs
index 6cb927214..fa6bf06ee 100644
--- a/sim/Statecraft.Sim/ContentLoader.cs
+++ b/sim/Statecraft.Sim/ContentLoader.cs
@@ -335,6 +335,8 @@ namespace Statecraft.Sim
foreach (var p in c.People)
{
+ if (p.Portrait != null && p.Portrait.File != "" && !(p.Portrait.FocusY >= 0 && p.Portrait.FocusY <= 1))
+ throw new ContentException("people.yaml", $"people[{p.Id}].portrait.focus_y", "required: the face's height as a share of the picture, from 0 (top) to 1 (bottom)");
if (!p.Living.HasValue) throw new ContentException("people.yaml", $"people[{p.Id}].living", "required (true or false)");
if (p.Competence < 0 || p.Competence > 10) throw new ContentException("people.yaml", $"people[{p.Id}].competence", "must be 0-10");
if (p.Loyalty < 0 || p.Loyalty > 10) throw new ContentException("people.yaml", $"people[{p.Id}].loyalty", "must be 0-10");
diff --git a/unity/Assets/Editor/PortraitImport.cs b/unity/Assets/Editor/PortraitImport.cs
index c79095917..b60e8c904 100644
--- a/unity/Assets/Editor/PortraitImport.cs
+++ b/unity/Assets/Editor/PortraitImport.cs
@@ -68,7 +68,7 @@ namespace Statecraft.Game.EditorTools
}
else AssetDatabase.ImportAsset(target);
Configure(target);
- catalog.entries.Add(new PortraitCatalog.Entry { personId = p.Id, image = AssetDatabase.LoadAssetAtPath<Texture2D>(target) });
+ catalog.entries.Add(new PortraitCatalog.Entry { personId = p.Id, image = AssetDatabase.LoadAssetAtPath<Texture2D>(target), focusY = (float)p.Portrait!.FocusY!.Value });
credits.Append(p.Id).Append(" | ").Append(p.Portrait.License).Append(" | ").Append(p.Portrait.Source).Append('\n');
}
var creditsPath = Folder + "/PORTRAITS.txt";
diff --git a/unity/Assets/Scripts/UI/BudgetPresenter.cs b/unity/Assets/Scripts/UI/BudgetPresenter.cs
index ffc2fb2b4..737bb0c85 100644
--- a/unity/Assets/Scripts/UI/BudgetPresenter.cs
+++ b/unity/Assets/Scripts/UI/BudgetPresenter.cs
@@ -117,7 +117,7 @@ namespace Statecraft.Game.UI
row.Add(new Label(text.Format("budget.share", PlayerText.Percent(share))) { name = "budget-" + office + "-share" });
row.Add(new Button(() => Change(office, +Step)) { name = "budget-" + office + "-up", text = "+" });
var factor = EffectsSystem.BudgetFactor(draft, office);
- row.Add(new Label(text.Format("budget.factor", factor)) { name = "budget-" + office + "-factor" });
+ row.Add(new Label(text.Format("budget.factor", PlayerText.Percent(factor))) { name = "budget-" + office + "-factor" });
row[4].AddToClassList("muted");
rows.Add(row);
}
diff --git a/unity/Assets/Scripts/UI/EventCardPresenter.cs b/unity/Assets/Scripts/UI/EventCardPresenter.cs
index 0d095a54e..f17710ca7 100644
--- a/unity/Assets/Scripts/UI/EventCardPresenter.cs
+++ b/unity/Assets/Scripts/UI/EventCardPresenter.cs
@@ -10,6 +10,9 @@ namespace Statecraft.Game.UI
/// A choice is an order: it takes effect at End Turn, and an unanswered event is delegated to the minister.</summary>
public sealed class EventCardPresenter : System.IDisposable
{
+ /// <summary>The portrait thumbnail's size in the card (Statecraft.uss .event-image).</summary>
+ public const float PortraitWidth = 96f, PortraitHeight = 128f;
+
readonly VisualElement card; readonly SimBridge bridge; readonly UiText text; readonly PortraitCatalog? portraits;
public EventCardPresenter(VisualElement root, SimBridge bridge, UiText text, PortraitCatalog? portraits)
@@ -37,9 +40,13 @@ namespace Statecraft.Game.UI
var date = EventSystem.FillDate(e, s.Date);
var holder = e.Office == "" ? null : Cabinet.Holder(c, s, e.Office, date);
var image = card.Q<VisualElement>("event-image");
- var portrait = portraits?.Get(holder?.Id);
+ var entry = portraits?.Find(holder?.Id);
+ var portrait = entry?.image;
image.style.backgroundImage = portrait == null ? (StyleBackground)StyleKeyword.None : new StyleBackground(portrait);
image.style.display = portrait == null ? DisplayStyle.None : DisplayStyle.Flex;
+ if (portrait != null) // keep the face in view (playtest 2, P2-5)
+ image.style.backgroundPositionY = new BackgroundPosition(BackgroundPositionKeyword.Top,
+ new Length(PortraitFraming.PositionYPercent(portrait.width, portrait.height, PortraitWidth, PortraitHeight, entry!.Value.focusY), LengthUnit.Percent));
card.Q<Label>("event-draft").style.display = e.Status == "draft" ? DisplayStyle.Flex : DisplayStyle.None;
card.Q<Label>("event-title").text = Cabinet.Fill(c, s, e.Title, date);
card.Q<Label>("event-office").text = holder == null ? "" : text.Format("event.office", c.Offices.First(o => o.Id == e.Office).Title, holder.Name);
diff --git a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
index 343773b09..1cf16f218 100644
--- a/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
+++ b/unity/Assets/Scripts/UI/InfoPanelPresenter.cs
@@ -58,7 +58,7 @@ namespace Statecraft.Game.UI
var hex = c.HexAt(q, r);
var owned = c.SettlementHexes.Where(x => x.Q == q && x.R == r).Select(x => settlementNames.TryGetValue(x.Id, out var n) ? n : x.Id).ToList();
title.text = owned.Count > 0 ? owned[0] : hex == null ? text["info.off_map"] : text["info.biome." + hex.Biome];
- subtitle.text = hex == null ? "" : text.Format("info.hex", text["info.biome." + hex.Biome], q, r, hex.ElevM);
+ subtitle.text = hex == null ? "" : text.Format("info.hex", text["info.biome." + hex.Biome], hex.ElevM); // no debug coordinates in player text (playtest 2, P2-6)
settlements.text = owned.Count > 0 ? text.Format("info.owned", string.Join(", ", owned)) : "";
var here = MapActions.At(s, q, r);
var queued = bridge.QueuedLike(new MapAction(MapActions.Housing, q, r)) as MapAction;
diff --git a/unity/Assets/Scripts/UI/PortraitCatalog.cs b/unity/Assets/Scripts/UI/PortraitCatalog.cs
index 1c91644cc..e8f486539 100644
--- a/unity/Assets/Scripts/UI/PortraitCatalog.cs
+++ b/unity/Assets/Scripts/UI/PortraitCatalog.cs
@@ -12,15 +12,23 @@ namespace Statecraft.Game.UI
public sealed class PortraitCatalog : ScriptableObject
{
[Serializable]
- public struct Entry { public string personId; public Texture2D image; }
+ public struct Entry
+ {
+ public string personId; public Texture2D image;
+ /// <summary>The face centre's height as a share of the picture (people.yaml portrait.focus_y).</summary>
+ public float focusY;
+ }
public List<Entry> entries = new List<Entry>();
/// <summary>The person's portrait, or null when there is none.</summary>
- public Texture2D? Get(string? personId)
+ public Texture2D? Get(string? personId) => Find(personId)?.image;
+
+ /// <summary>The person's entry (picture and focal point), or null.</summary>
+ public Entry? Find(string? personId)
{
if (personId == null) return null;
- foreach (var e in entries) if (e.personId == personId) return e.image;
+ foreach (var e in entries) if (e.personId == personId) return e;
return null;
}
}
diff --git a/unity/Assets/Scripts/UI/PortraitFraming.cs b/unity/Assets/Scripts/UI/PortraitFraming.cs
new file mode 100644
index 000000000..7d00eefa0
--- /dev/null
+++ b/unity/Assets/Scripts/UI/PortraitFraming.cs
@@ -0,0 +1,34 @@
+#nullable enable
+using UnityEngine;
+
+namespace Statecraft.Game.UI
+{
+ /// <summary>Frames a portrait in a box with background-size cover so its focal point (the face) is in view: the picture is
+ /// scaled to cover the box, and its vertical position puts the focal point at the box's middle where it can, clamped so
+ /// no empty edge shows (playtest 2, P2-5).</summary>
+ public static class PortraitFraming
+ {
+ /// <summary>The picture's top offset under cover scaling, in picture pixels scaled to the box, and the scaled height.</summary>
+ static (float offset, float height) Offset(float texW, float texH, float boxW, float boxH, float focusY)
+ {
+ var scale = Mathf.Max(boxW / texW, boxH / texH);
+ var h = texH * scale;
+ var offset = Mathf.Clamp(focusY * h - boxH / 2, 0f, Mathf.Max(0f, h - boxH));
+ return (offset, h);
+ }
+
+ /// <summary>background-position-y in percent: p% puts the picture's p% line on the box's p% line.</summary>
+ public static float PositionYPercent(float texW, float texH, float boxW, float boxH, float focusY)
+ {
+ var (offset, h) = Offset(texW, texH, boxW, boxH, focusY);
+ return h - boxH <= 0.5f ? 50f : offset / (h - boxH) * 100f;
+ }
+
+ /// <summary>The share of the picture's height in view, from top to bottom.</summary>
+ public static (float top, float bottom) VisibleBand(float texW, float texH, float boxW, float boxH, float focusY)
+ {
+ var (offset, h) = Offset(texW, texH, boxW, boxH, focusY);
+ return (offset / h, Mathf.Min(1f, (offset + boxH) / h));
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/UI/PortraitFraming.cs.meta b/unity/Assets/Scripts/UI/PortraitFraming.cs.meta
new file mode 100644
index 000000000..5d31ef3af
--- /dev/null
+++ b/unity/Assets/Scripts/UI/PortraitFraming.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 3e34df7a2eda5463e8a304014b9a67d5
\ No newline at end of file
diff --git a/unity/Assets/Tests/EditMode/BudgetScreenTests.cs b/unity/Assets/Tests/EditMode/BudgetScreenTests.cs
index f5eceeb1e..045d92f0b 100644
--- a/unity/Assets/Tests/EditMode/BudgetScreenTests.cs
+++ b/unity/Assets/Tests/EditMode/BudgetScreenTests.cs
@@ -34,7 +34,7 @@ public class BudgetScreenTests
var budget = new BudgetPresenter(ui.Root, bridge, Text);
Assert.AreEqual("45%", ui.Q<Label>("budget-defense_minister-share").text);
Assert.AreEqual("Minister of Defense (David Ben-Gurion)", ui.Q<Label>("budget-defense_minister-name").text);
- Assert.AreEqual("effect x1.50", ui.Q<Label>("budget-defense_minister-factor").text); // capped at 1.5
+ Assert.AreEqual("spending effect 150%", ui.Q<Label>("budget-defense_minister-factor").text); // capped at 1.5 (playtest 2, P2-6)
Assert.AreEqual("The Provisional State Council does not vote on the budget", ui.Q<Label>("budget-vote").text);
Assert.AreEqual("Treasury IL 20.0m · debt IL 0.0m · foreign currency $40.0m", ui.Q<Label>("budget-money").text);
UiTestKit.Press(ui.Q<Button>("budget-education_minister-up"));
@@ -67,11 +67,11 @@ public class BudgetScreenTests
var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), Text);
var budget = new BudgetPresenter(ui.Root, bridge, Text);
foreach (var office in C.Rules.BudgetStart.Keys)
- Assert.AreEqual(System.FormattableString.Invariant($"effect x{EffectsSystem.BudgetFactor(budget.Draft, office):0.00}"), ui.Q<Label>($"budget-{office}-factor").text, office);
+ Assert.AreEqual("spending effect " + PlayerText.Percent(EffectsSystem.BudgetFactor(budget.Draft, office)), ui.Q<Label>($"budget-{office}-factor").text, office);
var f = EconomySystem.Flows(C, bridge.State, 1.0);
Assert.AreEqual(System.FormattableString.Invariant($"Taxes IL {f.Tax:0.0}m, spending IL {f.Spending:0.0}m and reserve call-up IL {f.Mobilization:0.0}m a year"), ui.Q<Label>("budget-flow").text);
UiTestKit.Press(ui.Q<Button>("budget-education_minister-up"));
- Assert.AreEqual(System.FormattableString.Invariant($"effect x{EffectsSystem.BudgetFactor(budget.Draft, "education_minister"):0.00}"), ui.Q<Label>("budget-education_minister-factor").text);
+ Assert.AreEqual("spending effect " + PlayerText.Percent(EffectsSystem.BudgetFactor(budget.Draft, "education_minister")), ui.Q<Label>("budget-education_minister-factor").text);
}
[Test]
diff --git a/unity/Assets/Tests/EditMode/EventCardTests.cs b/unity/Assets/Tests/EditMode/EventCardTests.cs
index 5b9213875..28dbb1ed1 100644
--- a/unity/Assets/Tests/EditMode/EventCardTests.cs
+++ b/unity/Assets/Tests/EditMode/EventCardTests.cs
@@ -131,7 +131,7 @@ public class EventCardTests
Assert.AreNotEqual("armistice_egypt", card.Shown?.Id); // the card moves on
bridge.EndTurn();
Assert.AreEqual(2, bridge.State.Rung); // signing ends full war
- Assert.IsTrue(bridge.Session.Last!.Why.Any(w => w.Message == "chosen: Sign the armistice"));
+ Assert.IsTrue(bridge.Session.Last!.Why.Any(w => w.Message == "Chosen: Sign the armistice"));
}
// Fix round 1, I3: the 1949 elections are a one-option card; it renders one button, and pressing it answers the event.
diff --git a/unity/Assets/Tests/EditMode/GameSceneTests.cs b/unity/Assets/Tests/EditMode/GameSceneTests.cs
index cad0220c9..f1b6dee79 100644
--- a/unity/Assets/Tests/EditMode/GameSceneTests.cs
+++ b/unity/Assets/Tests/EditMode/GameSceneTests.cs
@@ -435,8 +435,8 @@ public class GameSceneTests
StringAssert.StartsWith("SMOKE OK 1 turns", log[log.Count - 1], string.Join("\n", log));
StringAssert.StartsWith($"SMOKE turn {turn + 1} ", log[log.Count - 2]);
Assert.AreEqual(turn + 1, bridge.State.Turn);
- Assert.IsTrue(bridge.Session.Last!.Why.Any(w => w.Message == "chosen: Sign the armistice"), "the card's option was pressed, not delegated");
- Assert.IsFalse(bridge.Session.Last.Why.Any(w => w.Target == "armistice_egypt" && w.Message.StartsWith("delegated")));
+ Assert.IsTrue(bridge.Session.Last!.Why.Any(w => w.Message == "Chosen: Sign the armistice"), "the card's option was pressed, not delegated");
+ Assert.IsFalse(bridge.Session.Last.Why.Any(w => w.Target == "armistice_egypt" && w.Message.StartsWith("Delegated")));
}
[Test]
@@ -535,4 +535,12 @@ public class GameSceneTests
root.enabled = false;
Assert.AreEqual(MapBuilder.TerrainPixelError, terrain.heightmapPixelError);
}
+
+ /// <summary>Playtest 2, P2-1: once GameRoot has started the game, the loading state is gone.</summary>
+ [Test]
+ public void TheGameLeavesTheLoadingState()
+ {
+ Boot();
+ Assert.IsFalse(Ui.Q("root").ClassListContains("loading"), "GameRoot clears the loading state");
+ }
}
diff --git a/unity/Assets/Tests/EditMode/HudTests.cs b/unity/Assets/Tests/EditMode/HudTests.cs
index bb70ee32b..a1184bb68 100644
--- a/unity/Assets/Tests/EditMode/HudTests.cs
+++ b/unity/Assets/Tests/EditMode/HudTests.cs
@@ -359,6 +359,7 @@ public class HudTests
static readonly (string file, string contains, string why)[] AllowedScale =
{
("MinimapPresenter.cs", "Length.Percent(", "the view frame's position and size in percent of the picture (layout, not text)"),
+ ("PortraitFraming.cs", "offset / (h - boxH) * 100f", "a portrait's background-position-y in percent (layout, not text)"),
};
[Test]
diff --git a/unity/Assets/Tests/EditMode/MapActionUiTests.cs b/unity/Assets/Tests/EditMode/MapActionUiTests.cs
index 9c93b46b5..ad8de958b 100644
--- a/unity/Assets/Tests/EditMode/MapActionUiTests.cs
+++ b/unity/Assets/Tests/EditMode/MapActionUiTests.cs
@@ -61,7 +61,8 @@ public class MapActionUiTests
var tlv = C.SettlementHexes.Single(s => s.Id == "tel_aviv");
info.Show(tlv.Q, tlv.R);
Assert.AreEqual("Tel Aviv", ui.Q<Label>("info-title").text);
- StringAssert.StartsWith("Coastal plain · hex (", ui.Q<Label>("info-subtitle").text);
+ StringAssert.StartsWith("Coastal plain · elevation ", ui.Q<Label>("info-subtitle").text);
+ StringAssert.DoesNotContain("hex (", ui.Q<Label>("info-subtitle").text, "no debug coordinates in player text (playtest 2, P2-6)");
Assert.IsFalse(ui.Q<Button>("build-camp").enabledSelf);
Assert.AreEqual("Transit camps and housing projects can be placed from 1 January 1950", ui.Q<Label>("info-reason").text);
}
diff --git a/unity/Assets/Tests/EditMode/PortraitFramingTests.cs b/unity/Assets/Tests/EditMode/PortraitFramingTests.cs
new file mode 100644
index 000000000..6c40197d8
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/PortraitFramingTests.cs
@@ -0,0 +1,38 @@
+#nullable enable
+using NUnit.Framework;
+using Statecraft.Game.UI;
+using UnityEditor;
+using UnityEngine;
+
+/// <summary>Playtest 2, P2-5: event portraits show the face. Each portrait carries a documented focal point (people.yaml
+/// portrait.focus_y, the face's height as a share of the picture); the card positions the picture so that point is in view.</summary>
+public class PortraitFramingTests
+{
+ const string CatalogPath = "Assets/UI/Portraits/PortraitCatalog.asset";
+
+ [Test]
+ public void EveryPortraitFramesItsFace()
+ {
+ var catalog = AssetDatabase.LoadAssetAtPath<PortraitCatalog>(CatalogPath);
+ Assert.IsNotNull(catalog);
+ Assert.IsNotEmpty(catalog.entries);
+ foreach (var e in catalog.entries)
+ {
+ Assert.That(e.focusY, Is.InRange(0.05f, 0.95f), $"{e.personId}: a focal point");
+ var (top, bottom) = PortraitFraming.VisibleBand(e.image.width, e.image.height, EventCardPresenter.PortraitWidth, EventCardPresenter.PortraitHeight, e.focusY);
+ Assert.LessOrEqual(top, Mathf.Max(0f, e.focusY - 0.12f), $"{e.personId}: the top of the face is in view ({top:0.00}-{bottom:0.00})");
+ Assert.GreaterOrEqual(bottom, Mathf.Min(1f, e.focusY + 0.12f), $"{e.personId}: the chin is in view ({top:0.00}-{bottom:0.00})");
+ }
+ }
+
+ /// <summary>The framing arithmetic: a wide box shows a band of a tall picture, centred on the focal point where it can be.</summary>
+ [Test]
+ public void TheBandIsCentredOnTheFocalPoint()
+ {
+ var (top, bottom) = PortraitFraming.VisibleBand(375, 512, 396, 200, 0.30f); // the old banner: a band of the picture
+ Assert.AreEqual(0.30f, (top + bottom) / 2, 0.01f, "centred on the face");
+ (top, bottom) = PortraitFraming.VisibleBand(375, 512, 396, 200, 0.05f);
+ Assert.AreEqual(0f, top, 1e-4f, "clamped at the picture's top");
+ Assert.AreEqual(100f, PortraitFraming.PositionYPercent(375, 512, 396, 200, 0.99f), 1e-3f, "clamped at the bottom");
+ }
+}
diff --git a/unity/Assets/Tests/EditMode/PortraitFramingTests.cs.meta b/unity/Assets/Tests/EditMode/PortraitFramingTests.cs.meta
new file mode 100644
index 000000000..9e13e5476
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/PortraitFramingTests.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 2730b9f65974d4f2f9c6753785164c7f
\ No newline at end of file
diff --git a/unity/Assets/Tests/EditMode/UiFoundationTests.cs b/unity/Assets/Tests/EditMode/UiFoundationTests.cs
index a0d2cb2af..f0b3a0a5c 100644
--- a/unity/Assets/Tests/EditMode/UiFoundationTests.cs
+++ b/unity/Assets/Tests/EditMode/UiFoundationTests.cs
@@ -69,6 +69,7 @@ public class UiFoundationTests
using var ui = new UiTestKit();
foreach (var name in new[] { "screen-cabinet", "screen-budget", "screen-defence", "screen-why", "toast" })
ui.Q<VisualElement>(name).style.display = DisplayStyle.None; // closed, as at game start
+ ui.Q<VisualElement>("root").RemoveFromClassList("loading"); // ready, as GameRoot leaves it
var button = ui.Q<Button>("end-turn");
for (int i = 0; i < 10 && float.IsNaN(button.worldBound.width); i++) yield return null;
var panel = ui.Root.panel;
@@ -112,4 +113,25 @@ public class UiFoundationTests
for (int i = 0; i < 10 && bar.resolvedStyle.backgroundColor.a < 0.5f; i++) yield return null;
Assert.AreEqual(1f, bar.resolvedStyle.backgroundColor.a, 1e-3f);
}
+
+ /// <summary>Playtest 2, P2-1: until GameRoot has started the game, the tree shows only a styled loading line: no screen,
+ /// no event card (and never its DRAFT placeholder), no empty top-bar values, info panel or minimap.</summary>
+ [UnityTest]
+ public IEnumerator BeforeTheGameIsReadyOnlyALoadingLineShows()
+ {
+ using var ui = new UiTestKit();
+ var loading = ui.Q<Label>("loading");
+ for (int i = 0; i < 10 && float.IsNaN(loading.worldBound.width); i++) yield return null;
+ Assert.IsTrue(ui.Q<VisualElement>("root").ClassListContains("loading"), "the tree starts in the loading state");
+ Assert.AreEqual(DisplayStyle.Flex, loading.resolvedStyle.display);
+ Assert.IsNotEmpty(loading.text);
+ foreach (var s in ScreenNav.Screens)
+ Assert.AreEqual(DisplayStyle.None, ui.Q<VisualElement>("screen-" + s).resolvedStyle.display, s);
+ Assert.AreEqual(DisplayStyle.None, ui.Q<VisualElement>("event-card").resolvedStyle.display, "event card");
+ Assert.AreEqual(DisplayStyle.None, ui.Q<VisualElement>("event-draft").resolvedStyle.display, "DRAFT placeholder");
+ foreach (var cls in new[] { "date-box", "meters", "nav", "turn-box" })
+ Assert.AreEqual(Visibility.Hidden, ui.Root.Q(className: cls).resolvedStyle.visibility, cls);
+ foreach (var name in new[] { "info-panel", "right-column" })
+ Assert.AreEqual(Visibility.Hidden, ui.Q<VisualElement>(name).resolvedStyle.visibility, name);
+ }
}
diff --git a/unity/Assets/Tests/EditMode/UiLayoutTests.cs b/unity/Assets/Tests/EditMode/UiLayoutTests.cs
index fcf9e01a9..77a1fd144 100644
--- a/unity/Assets/Tests/EditMode/UiLayoutTests.cs
+++ b/unity/Assets/Tests/EditMode/UiLayoutTests.cs
@@ -260,13 +260,24 @@ public class UiLayoutTests
Assert.IsEmpty(problems, string.Join("\n", problems));
}
+ /// <summary>A button's text fits its content box: on one line, or wrapped (white-space normal) within its height.</summary>
+ static bool TextFits(TextElement b)
+ {
+ var box = b.contentRect;
+ var natural = b.MeasureTextSize(b.text, 0, VisualElement.MeasureMode.Undefined, 0, VisualElement.MeasureMode.Undefined);
+ if (natural.x <= box.width + 1f) return true;
+ if (b.resolvedStyle.whiteSpace != WhiteSpace.Normal) return false;
+ var wrapped = b.MeasureTextSize(b.text, box.width, VisualElement.MeasureMode.Exactly, 0, VisualElement.MeasureMode.Undefined);
+ return wrapped.y <= box.height + 1f;
+ }
+
/// <summary>Task 24 review I2: every real event, the tallest included, fits its card above the minimap at every window
/// shape, wide and short ones included: the card never overlaps the minimap and its option buttons stay inside it.</summary>
[UnityTest]
public IEnumerator EveryEventCardStaysAboveTheMinimap()
{
var problems = new List<string>();
- foreach (var (w, h) in new[] { (1920, 1080), (1280, 720), (1531, 784), (2560, 1080), (1920, 900), (1366, 657), (1280, 1024) })
+ foreach (var (w, h) in new[] { (1920, 1080), (1280, 720), (1531, 784), (1568, 752), (2560, 1080), (1920, 900), (1366, 657), (1280, 1024) })
{
var rt = new RenderTexture(w, h, 0);
var ps = Object.Instantiate(AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel));
@@ -300,8 +311,19 @@ public class UiLayoutTests
if (c.yMax > mini.yMin + 0.5f && c.xMax > mini.xMin && c.xMin < mini.xMax)
problems.Add($"{w}x{h}: {e.Id}: card {c} overlaps the minimap {mini}");
foreach (var b in root.Q("event-options").Query<Button>().ToList())
- if (b.worldBound.yMax > c.yMax + 0.5f || b.worldBound.yMin < c.yMin - 0.5f)
+ {
+ if (b.worldBound.yMax > c.yMax + 0.5f || b.worldBound.yMin < c.yMin - 0.5f || b.worldBound.xMax > c.xMax + 0.5f || b.worldBound.xMin < c.xMin - 0.5f)
problems.Add($"{w}x{h}: {e.Id}: option '{b.text}' {b.worldBound} is cut off by the card {c}");
+ // Playtest 2, P2-2: the option's text lies inside its button (it wraps; it is never cut at the edge).
+ if (!TextFits(b))
+ problems.Add($"{w}x{h}: {e.Id}: option text '{b.text}' does not fit its button {b.contentRect}");
+ }
+ // Playtest 2, P2-3: in a window at least as tall (logically) as 1366x657, the body and the options fit
+ // without scrolling; shorter windows may scroll the body as the fallback.
+ var scroll = root.Q<ScrollView>("event-scroll");
+ var logicalHeight = root.panel.visualTree.layout.height;
+ if (logicalHeight >= 990f && scroll.contentContainer.layout.height > scroll.contentViewport.layout.height + 1f)
+ problems.Add($"{w}x{h} (logical height {logicalHeight:0}): {e.Id}: the body scrolls ({scroll.contentContainer.layout.height:0} px of text in {scroll.contentViewport.layout.height:0} px)");
}
Debug.Log($"I2 {w}x{h}: tallest card {tallestId} {tallest:0} px");
Assert.Greater(tallest, 400f, $"{w}x{h}: the cards were laid out (a short window shrinks the tallest to fit)");
diff --git a/unity/Assets/Tests/EditMode/WhyScreenTests.cs b/unity/Assets/Tests/EditMode/WhyScreenTests.cs
index c1cb25c95..13684b086 100644
--- a/unity/Assets/Tests/EditMode/WhyScreenTests.cs
+++ b/unity/Assets/Tests/EditMode/WhyScreenTests.cs
@@ -25,7 +25,7 @@ public class WhyScreenTests
var lines = ui.Q<ScrollView>("why-rows").Query<Label>(className: "why-line").ToList();
Assert.AreEqual(r.Why.Count, lines.Count);
Assert.AreEqual("Immigration and population", ui.Q<Label>("why-group-population").text);
- Assert.IsTrue(lines.Any(l => l.text == "reserve call-up set to 100%"));
+ Assert.IsTrue(lines.Any(l => l.text == "Reserve call-up set to 100%"));
var groups = ui.Q<ScrollView>("why-rows").Query<Label>(className: "why-group").ToList().Select(l => l.name).ToList();
Assert.Less(groups.IndexOf("why-group-security"), groups.IndexOf("why-group-economy"));
}
@@ -90,7 +90,7 @@ public class WhyScreenTests
Assert.AreEqual("why-group-zzz", headers.Last().name);
Assert.AreEqual("Other", headers.Last().text);
Assert.IsFalse(rows.Query<Label>().ToList().Any(l => l.text == "zzz"), "the raw id is never shown");
- Assert.AreEqual("something odd happened", rows.Query<Label>(className: "why-line").ToList().Last().text);
+ Assert.AreEqual("Something odd happened", rows.Query<Label>(className: "why-line").ToList().Last().text);
}
}
diff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxml
index ae4b53d23..cd821d6d3 100644
--- a/unity/Assets/UI/Game.uxml
+++ b/unity/Assets/UI/Game.uxml
@@ -1,6 +1,8 @@
<ui:UXML xmlns:ui="UnityEngine.UIElements">
<Style src="Statecraft.uss" />
- <ui:VisualElement name="root" class="root" picking-mode="Ignore">
+ <!-- "loading" until GameRoot has started the game: only the loading line shows (playtest 2, P2-1). -->
+ <ui:VisualElement name="root" class="root loading" picking-mode="Ignore">
+ <ui:Label name="loading" text="Loading the map of 1948…" class="loading-line" picking-mode="Ignore" />
<ui:VisualElement name="top-bar" class="panel top-bar">
<ui:VisualElement class="date-box">
<ui:Label name="year" class="year" />
@@ -55,10 +57,15 @@
card shrinks its text, which scrolls, and keeps its option buttons. -->
<ui:VisualElement name="right-column" class="right-column" picking-mode="Ignore">
<ui:VisualElement name="event-card" class="panel event-card">
- <ui:VisualElement name="event-image" class="event-image" />
- <ui:Label name="event-draft" text="DRAFT" class="draft" />
- <ui:Label name="event-title" class="title event-title" />
- <ui:Label name="event-office" class="muted" />
+ <!-- A portrait-shaped thumbnail beside the heading, framed on the face (playtest 2, P2-3 and P2-5). -->
+ <ui:VisualElement class="event-head">
+ <ui:VisualElement name="event-image" class="event-image" />
+ <ui:VisualElement class="event-heading">
+ <ui:Label name="event-draft" text="DRAFT" class="draft" />
+ <ui:Label name="event-title" class="title event-title" />
+ <ui:Label name="event-office" class="muted event-office" />
+ </ui:VisualElement>
+ </ui:VisualElement>
<ui:ScrollView name="event-scroll" class="event-scroll"><ui:Label name="event-text" class="event-text" /></ui:ScrollView>
<ui:VisualElement name="event-options" />
<ui:Label name="event-count" class="muted" />
diff --git a/unity/Assets/UI/Portraits/PortraitCatalog.asset b/unity/Assets/UI/Portraits/PortraitCatalog.asset
index edf523c8d..7961739be 100644
--- a/unity/Assets/UI/Portraits/PortraitCatalog.asset
+++ b/unity/Assets/UI/Portraits/PortraitCatalog.asset
@@ -15,27 +15,40 @@ MonoBehaviour:
entries:
- personId: ben_gurion
image: {fileID: 2800000, guid: 4cfbaea3af206434584f5d663c3f617b, type: 3}
+ focusY: 0.3
- personId: zisling
image: {fileID: 2800000, guid: 32c3dc5a870694b1db0b869b507fcf33, type: 3}
+ focusY: 0.34
- personId: kaplan
image: {fileID: 2800000, guid: acea051ba099241b5a2ec18417c6b855, type: 3}
+ focusY: 0.3
- personId: sharett
image: {fileID: 2800000, guid: f0ed7522ce11d4c0db50dafd321df604, type: 3}
+ focusY: 0.22
- personId: shapira
image: {fileID: 2800000, guid: 01b0755a76e4d4a23843d26ac45b200f, type: 3}
+ focusY: 0.42
- personId: gruenbaum
image: {fileID: 2800000, guid: d570b912751fc4c1cb3fd166a568ee10, type: 3}
+ focusY: 0.3
- personId: rosen
image: {fileID: 2800000, guid: 939a5df99ebbf4fe9927c13dea97b145, type: 3}
+ focusY: 0.36
- personId: bentov
image: {fileID: 2800000, guid: 8a07543ce92e7451c9496ba142d9ddad, type: 3}
+ focusY: 0.28
- personId: sheetrit
image: {fileID: 2800000, guid: ac4fafd5b03774d24a8771d87b31f392, type: 3}
+ focusY: 0.18
- personId: maimon
image: {fileID: 2800000, guid: 485b4273ede0249908e89cc3b2945bb7, type: 3}
+ focusY: 0.26
- personId: bernstein
image: {fileID: 2800000, guid: 0a41c67eb7f774a0f896da33c391417a, type: 3}
+ focusY: 0.28
- personId: remez
image: {fileID: 2800000, guid: 271cf2de1793546e284dad1440ae085e, type: 3}
+ focusY: 0.38
- personId: levin
image: {fileID: 2800000, guid: a90c09eb271424986af44b29de55f345, type: 3}
+ focusY: 0.28
diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.uss
index d222e0c78..08f146164 100644
--- a/unity/Assets/UI/Statecraft.uss
+++ b/unity/Assets/UI/Statecraft.uss
@@ -79,24 +79,32 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
/* Event card at the right, info panel at the bottom-left, minimap at the bottom-right. */
/* The event card and the minimap share one column (Task 24 review I2): the card can never reach the minimap; when the
window is short the portrait and then the text (it scrolls) give way, never the option buttons. */
-.right-column { position: absolute; right: 16px; top: 112px; bottom: 16px; width: 420px; }
+.right-column { position: absolute; right: 16px; top: 112px; bottom: 16px; width: 480px; }
.right-gap { flex-grow: 1; flex-shrink: 0; min-height: 16px; }
.event-card { flex-shrink: 1; min-height: 0; max-height: 560px; overflow: hidden; }
.event-card > * { flex-shrink: 0; }
-.event-card > .event-image { flex-shrink: 1; min-height: 0; }
.event-card > .event-scroll { flex-shrink: 1; min-height: 48px; }
#event-options { flex-shrink: 0; }
-.event-image { height: 200px; margin-bottom: 8px; -unity-background-scale-mode: scale-and-crop; background-color: var(--navy-deep); }
-.event-title { -unity-text-align: middle-center; margin-bottom: 6px; }
+/* Hidden until EventCardPresenter shows an event (never visible while loading). */
+.event-card { display: none; }
+.event-head { flex-direction: row; align-items: flex-start; margin-bottom: 8px; }
+.event-heading { flex-grow: 1; flex-shrink: 1; }
+/* Portrait-shaped, so the whole head shows; EventCardPresenter sets background-position-y from the portrait's focal point. */
+.event-image { width: 96px; height: 128px; flex-shrink: 0; margin-right: 12px; background-size: cover; background-color: var(--navy-deep); }
+.event-office { white-space: normal; }
+/* Options wrap inside the card (playtest 2, P2-2). */
+#event-options Button { white-space: normal; -unity-text-align: middle-left; }
+.event-title { -unity-text-align: middle-center; margin-bottom: 4px; white-space: normal; font-size: 26px; } /* centred, as before, in its column */
.event-text { white-space: normal; margin-bottom: 8px; }
-.draft { color: var(--down); -unity-font-definition: url("project://database/Assets/UI/Fonts/EBGaramond-SemiBold.ttf"); -unity-text-align: middle-center; }
+.draft { display: none; color: var(--down); -unity-font-definition: url("project://database/Assets/UI/Fonts/EBGaramond-SemiBold.ttf"); -unity-text-align: middle-center; }
.info-panel { position: absolute; left: 16px; bottom: 16px; width: 520px; min-height: 160px; }
.minimap { align-self: flex-end; flex-shrink: 0; width: 300px; height: 340px; padding: 6px; }
.minimap-image { align-self: center; -unity-background-scale-mode: stretch-to-fill; } /* the element is sized to the picture's aspect by MinimapPresenter */
.minimap-view { position: absolute; border-color: var(--ink); border-width: 1px; }
/* Full screens (Cabinet, Budget, Defence, Why) open in the centre, one at a time. */
-.screen { position: absolute; left: 552px; right: 452px; top: 112px; bottom: 16px; }
+/* Hidden until ScreenNav opens one (never visible while loading; playtest 2, P2-1). Right edge clear of the 480px column. */
+.screen { display: none; position: absolute; left: 552px; right: 512px; top: 112px; bottom: 16px; }
.screen-header { flex-direction: row; justify-content: space-between; align-items: center; border-bottom-width: 1px; border-color: var(--gold-dim); margin-bottom: 8px; }
.row { flex-direction: row; align-items: center; }
.rung { flex-direction: row; padding: 4px 8px; border-left-width: 3px; border-color: rgba(0, 0, 0, 0); }
@@ -107,7 +115,7 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
.screen .row.grow { align-items: stretch; flex-basis: 0; flex-shrink: 1; min-height: 0; }
.screen .row.grow > .grow { min-height: 0; flex-shrink: 1; }
-.toast { position: absolute; left: 30%; right: 30%; top: 112px; -unity-text-align: middle-center; white-space: normal; }
+.toast { display: none; position: absolute; left: 30%; right: 30%; top: 112px; -unity-text-align: middle-center; white-space: normal; }
.why-group { -unity-font-definition: url("project://database/Assets/UI/Fonts/EBGaramond-SemiBold.ttf"); color: var(--gold); margin-top: 8px; }
.why-line { white-space: normal; padding-left: 12px; }
@@ -118,3 +126,9 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
.appointed { color: var(--gold); }
.candidate { flex-direction: row; align-items: center; }
.reason { color: var(--ink-dim); font-size: 16px; white-space: normal; flex-shrink: 1; }
+
+/* Loading (playtest 2, P2-1): until GameRoot is ready only this line shows; the bar's values, the info panel and the
+ right-hand column are kept out of sight (visibility, so the layout does not jump when they appear). */
+.loading-line { display: none; position: absolute; left: 0; right: 0; top: 45%; -unity-text-align: middle-center; font-size: 28px; color: var(--ink); }
+.loading .loading-line { display: flex; }
+.loading .date-box, .loading .meters, .loading .nav, .loading .turn-box, .loading .info-panel, .loading .right-column { visibility: hidden; }
diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yaml
index 5698fdae4..fa9776e77 100644
--- a/unity/Assets/UI/strings.en.yaml
+++ b/unity/Assets/UI/strings.en.yaml
@@ -35,7 +35,7 @@ defence.ceasefire_starts: "UN ceasefire: {0} weeks once level 5 is reached"
budget.share: "{0}"
budget.office: "{0} ({1})"
budget.vacant: "vacant"
-budget.factor: "effect x{0:0.00}"
+budget.factor: "spending effect {0}"
budget.vote_needed: "The {0} must approve it: the coalition holds {1} of {2} seats"
budget.no_vote: "The {0} does not vote on the budget"
budget.money: "Treasury {0} · debt {1} · foreign currency {2}"
@@ -66,7 +66,7 @@ cabinet.pick: "Appoint to {0}"
cabinet.queued: "Ordered: {0} to {1}, at End Turn"
info.hint: "Click the map to inspect a hex"
info.off_map: "Off the map"
-info.hex: "{0} · hex ({1}, {2}) · {3:N0} m"
+info.hex: "{0} · elevation {1:N0} m"
info.owned: "Settlements: {0}"
info.built: "{0} built here in {1}"
info.queued: "Ordered: {0}, at End Turn"