A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Start screen: Report and Replay the opening stop the recording (Fixes #2710) (#2816)
Beric67e7557a296
diff --git a/changelog.d/2710.md b/changelog.d/2710.mdnew file mode 100644index 000000000..a7a307223--- /dev/null+++ b/changelog.d/2710.md@@ -0,0 +1,4 @@+### Fixed++- The start screen's recording of Ben-Gurion now stops when Report or Replay the opening covers the painting, as it+ does when the screen closes (#2710).diff --git a/docs/declaration-recording.md b/docs/declaration-recording.mdindex 285be4545..b1b673c2a 100644--- a/docs/declaration-recording.md+++ b/docs/declaration-recording.md@@ -81,10 +81,9 @@ ceremony of 14 May 1948. The owner asked for it; the rights basis and its open q- **When it plays:**- It never plays by itself, and never on Continue or New Game.- It stops when the start screen closes.- - It plays over the still painting only, except that Replay Opening does not stop it. Replay Opening shows the- opening while the start screen stays open, and hides the start screen (`.opening-open .start-screen`), so the- recording, if it was playing, keeps playing while its button and captions are out of sight until the opening is- closed. The opening does not stop it; the start screen closing, the clip's end or the button does.+ - It plays over the still painting only. Replay Opening and Report cover the painting while the start screen stays+ open under them (Replay Opening hides it with `.opening-open .start-screen`), so pressing either of them stops it+ too (`StartScreenPresenter`, #2710).- **Captions.** The sentence shows in a dark strip above the panel, as the declaration's own texts in`docs/sources/declaration-1948`. The leading ellipsis marks a sentence quoted from its middle.- In Hebrew, in Frank Ruhl Libre, right to left: «…אנו מכריזים בזאת על הקמת מדינה יהודית בארץ־ישראל, היא מדינתdiff --git a/unity/Assets/Scripts/UI/DeclarationRecording.cs b/unity/Assets/Scripts/UI/DeclarationRecording.csindex 050853338..c31efce97 100644--- a/unity/Assets/Scripts/UI/DeclarationRecording.cs+++ b/unity/Assets/Scripts/UI/DeclarationRecording.cs@@ -12,7 +12,8 @@ namespace Statecraft.Game.UI/// The file is the archive's own Opus upload, cut by stream copy (no re-encode) and then decoded to 16-bit PCM WAV,/// which every browser and Unity's own reader play (the Web player could not load the Ogg Opus cut); it sits in StreamingAssets (its SHA-256 is pinned in a test), is fetched only when the player presses the button,/// and the browser decodes it. It plays only from that press, never by itself, never on Continue or New Game; it stops- /// when the start screen closes. While the file loads the button reads "Loading…" (pressing it again cancels); the+ /// when the start screen closes or Report or Replay the opening covers it.+ /// While the file loads the button reads "Loading…" (pressing it again cancels); the/// captions and "Stop" show only once the audio is actually playing; a failed or slow load ends with a message./// GameRoot builds it only when the start screen is shown, which automated runs skip (StartScreenPresenter.Skipped),/// and the button's row is hidden by the stylesheet until this class shows it.</summary>@@ -172,8 +173,8 @@ namespace Statecraft.Game.UIsay(text["start.recording_failed"]);}- /// <summary>Stops it (the start screen closing, the button, the end of the clip) and releases the clip. Safe to- /// call when it is not playing.</summary>+ /// <summary>Stops it (the start screen closing, Report or Replay the opening covering it, the button,+ /// the end of the clip) and releases the clip. Safe to call when it is not playing.</summary>public void Stop(){generation++;diff --git a/unity/Assets/Scripts/UI/StartScreenPresenter.cs b/unity/Assets/Scripts/UI/StartScreenPresenter.csindex e125b51f4..4aaf26f06 100644--- a/unity/Assets/Scripts/UI/StartScreenPresenter.cs+++ b/unity/Assets/Scripts/UI/StartScreenPresenter.cs@@ -72,9 +72,11 @@ namespace Statecraft.Game.UIpublic event Action? FreshGameOpened;readonly DeclarationRecording? recording;+ readonly Button reportButton, replayButton;+ readonly Action onCovered;/// <param name="recording">The "Play the recording" button's player (null in tests that do not need it); the screen- /// stops it when it closes.</param>+ /// stops it when it closes, and when Report or Replay the opening covers it.</param>/// <param name="text">The UI's strings for the source line and the two buttons (#193); null keeps Game.uxml's English/// (tests). The title is the game's name and the English lines are the Declaration's official translation: neither/// is translated.</param>@@ -106,6 +108,11 @@ namespace Statecraft.Game.UIvar quit = screen.Q<Button>("start-quit"); // #2153: desktop players onlyif (text != null) quit.text = text["ui.quit"];unbindQuit = QuitButton.BindInGame(quit);+ // #2710: the recording plays over the still painting only (docs/declaration-recording.md). The report panel and+ // the replayed opening cover the painting while the screen stays open under them, so their presses stop it too.+ onCovered = () => recording?.Stop();+ reportButton = screen.Q<Button>("start-report"); replayButton = screen.Q<Button>("start-opening-replay");+ reportButton.clicked += onCovered; replayButton.clicked += onCovered;onContinue = Continue; onNewGame = NewGame; onStarted = Started;continueButton.clicked += onContinue;newGameButton.clicked += onNewGame;@@ -283,6 +290,7 @@ namespace Statecraft.Game.UInewGame.Started -= onStarted;unbindStar();unbindQuit();+ reportButton.clicked -= onCovered; replayButton.clicked -= onCovered;starButton.generateVisualContent -= PaintStarSigns;languages.Dispose();screen.UnregisterCallback(onCancel);diff --git a/unity/Assets/Tests/EditMode/OpeningRoutingTests.cs b/unity/Assets/Tests/EditMode/OpeningRoutingTests.csindex e0a2ae19d..7effa2a84 100644--- a/unity/Assets/Tests/EditMode/OpeningRoutingTests.cs+++ b/unity/Assets/Tests/EditMode/OpeningRoutingTests.cs@@ -135,6 +135,23 @@ public class OpeningRoutingTestsAssert.AreEqual(oldHash, restarted.Bridge.State.Hash(), "a second real GameRoot resumes the untouched old autosave");}+ /// <summary>#2710: the recording plays over the still painting only (docs/declaration-recording.md), so pressing+ /// "Replay the opening", whose pictures hide the start screen, stops it although the start screen stays open.</summary>+ [UnityTest]+ public IEnumerator ReplayingTheOpeningStopsTheRecording()+ {+ var root = Open(saved: true, out _);+ for (int frame = 0; frame < 6; frame++) yield return null;+ var start = (StartScreenPresenter)typeof(GameRoot).GetField("start", BindingFlags.Instance | BindingFlags.NonPublic)!.GetValue(root)!;+ var recording = (DeclarationRecording)typeof(StartScreenPresenter).GetField("recording", BindingFlags.Instance | BindingFlags.NonPublic)!.GetValue(start)!;+ UiTestKit.Press(Ui.Q<Button>("start-listen"));+ Assert.IsTrue(recording.Playing, "precondition: its button plays it");+ UiTestKit.Press(Ui.Q<Button>("start-opening-replay"));+ Assert.IsTrue(Ui.Q("root").ClassListContains(OpeningPresenter.OpenClass), "the opening replays");+ Assert.IsTrue(StartOpen, "the start screen stays open under it");+ Assert.IsFalse(recording.Playing, "the opening's pictures cover the painting: the recording stops");+ }+[UnityTest]public IEnumerator FullGameRootOffersReplayToStartScreenNavigation(){diff --git a/unity/Assets/Tests/EditMode/StartScreenTests.cs b/unity/Assets/Tests/EditMode/StartScreenTests.csindex fec8fdca8..f84ed7e7d 100644--- a/unity/Assets/Tests/EditMode/StartScreenTests.cs+++ b/unity/Assets/Tests/EditMode/StartScreenTests.cs@@ -290,6 +290,21 @@ public class StartScreenTestsAssert.IsTrue(rig.Start.IsOpen);}+ /// <summary>#2710: the recording plays over the still painting only (docs/declaration-recording.md), so the report+ /// panel opening over the screen stops it, although the start screen stays open under the panel.</summary>+ [Test]+ public void TheReportButtonStopsTheRecording()+ {+ using var rig = new Rig(TempStore());+ using var feedback = new FeedbackPresenter(rig.Ui.Root, null, "0.1.0 / content ab12");+ rig.Ui.Press("start-listen");+ Assert.IsTrue(rig.Recording.Playing, "precondition: its button plays it");+ rig.Ui.Press("start-report");+ Assert.IsTrue(feedback.IsOpen);+ Assert.IsTrue(rig.Start.IsOpen, "the start screen stays under it");+ Assert.IsFalse(rig.Recording.Playing, "the panel covers the painting: the recording stops");+ }+[Test]public void ContinueShowsOnlyWithASaveAndLoadsIt(){