A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
Keep each link on one line in the Hebrew share panel (#1651)
Eyal Golanbeaedcf1fc74
diff --git a/changelog.d/fix-playtest-advisor-share.md b/changelog.d/fix-playtest-advisor-share.mdnew file mode 100644index 000000000..6cd4bf3b1--- /dev/null+++ b/changelog.d/fix-playtest-advisor-share.md@@ -0,0 +1,2 @@+### Fixed+- The Hebrew share panel keeps each link (the itch page, the GitHub repository) whole on one line; "https://" no longer ends one line with the rest of the link on the next. English and the text that is shared and copied are unchanged.diff --git a/unity/Assets/Scripts/UI/SharePresenter.cs b/unity/Assets/Scripts/UI/SharePresenter.csindex 2ac90ecd1..49fe1993d 100644--- a/unity/Assets/Scripts/UI/SharePresenter.cs+++ b/unity/Assets/Scripts/UI/SharePresenter.cs@@ -42,6 +42,8 @@ namespace Statecraft.Game.UIreadonly List<Action> unbindSites = new List<Action>();readonly List<(VisualElement part, bool enabled)> covered = new List<(VisualElement, bool)>();Button? opener;+ /// <summary>The post as it is shared and copied (ShareShot.Text); the label shows ShareShot.Shown's form of it.</summary>+ string postText = "";UnityEngine.Texture2D? picture; // the preview's, released on CloseIVisualElementScheduledItem? copyPoll;bool capturing, canShareFiles, disposed;@@ -108,7 +110,8 @@ namespace Statecraft.Game.UIvar shown = HudModel.From(bridge, text);ShareShot.Keep(png, ShareShot.FileName(bridge.State.Date));canShareFiles = ShareShot.CanShareFiles();- post.text = ShareShot.Text(text, shown.Date, bridge.State.Turn);+ postText = ShareShot.Text(text, shown.Date, bridge.State.Turn);+ post.text = ShareShot.Shown(postText, text["ui.lang"] == UiLanguage.Hebrew);go.text = text[canShareFiles ? "share.native" : "share.download"];fallback.style.display = instagramNote.style.display = DisplayStyle.None;copyPoll?.Pause();@@ -116,7 +119,7 @@ namespace Statecraft.Game.UIShowPreview(png);foreach (var unbind in unbindSites) unbind();unbindSites.Clear();- foreach (var site in ShareShot.Sites.Where(s => s != Instagram)) unbindSites.Add(ExternalLink.Bind(layer.Q<Button>("share-" + site), ShareShot.IntentUrl(site, post.text)));+ foreach (var site in ShareShot.Sites.Where(s => s != Instagram)) unbindSites.Add(ExternalLink.Bind(layer.Q<Button>("share-" + site), ShareShot.IntentUrl(site, postText)));opener = from;// Each part's own state comes back on Close. The panel takes every press meanwhile, so no screen opens or// closes under it; a resize may still run ScreenNav.DisableCovered, and Close then puts back the states from before.@@ -137,7 +140,7 @@ namespace Statecraft.Game.UIvoid Send(VisualElement note){if (!IsOpen) return;- ShareShot.Share(post.text, ShareShot.Itch);+ ShareShot.Share(postText, ShareShot.Itch);if (!canShareFiles) { note.style.display = DisplayStyle.Flex; return; }// The share sheet can still be refused on the release (ShareShot.jslib); then the picture downloads and the// note shows, as where files cannot be shared. A refusal comes at once; a few seconds is enough to wait.@@ -175,7 +178,7 @@ namespace Statecraft.Game.UIif (!IsOpen) return;copyPoll?.Pause();copied.style.display = DisplayStyle.None;- ShareShot.Copy(post.text);+ ShareShot.Copy(postText);// A press whose release never reached the browser (shorter than a frame, or another press first) copies// nothing and stays Pending: after a few seconds the panel says so rather than staying silent.var giveUpAt = UnityEngine.Time.realtimeSinceStartup + 4.5f;diff --git a/unity/Assets/Scripts/UI/ShareShot.cs b/unity/Assets/Scripts/UI/ShareShot.csindex 385c4903a..e9ab7c070 100644--- a/unity/Assets/Scripts/UI/ShareShot.cs+++ b/unity/Assets/Scripts/UI/ShareShot.cs@@ -41,6 +41,24 @@ namespace Statecraft.Game.UI/// <summary>The post, in the UI's language, with the in-game date and turn, the itch URL and the repository's.</summary>public static string Text(UiText text, string date, int turn) => text.Format("share.post", date, turn, Itch, Repo);+ /// <summary>The post as the panel shows it (playtest, 25 Oct 2026). In the right-to-left Hebrew paragraph a URL broke+ /// across lines, "https://" ending one line and the rest starting the next, so in Hebrew each URL is kept whole: a word+ /// joiner (U+2060) after each '/', ':', '.' and '-' takes away the line breaks the text generator allows there.+ /// UiText.Format's marks already keep the URL a left-to-right run. (Rich text's nobr and a U+2066 isolate were tried+ /// and changed nothing under the advanced text generator.) English shows the post as it is. Only the label takes+ /// this: the text shared, posted and copied stays <see cref="Text"/>'s.</summary>+ public static string Shown(string post, bool hebrew) =>+ hebrew ? post.Replace(Itch, OneLine(Itch)).Replace(Repo, OneLine(Repo)) : post;++ public const char WordJoiner = (char)0x2060;++ static string OneLine(string url)+ {+ var line = new System.Text.StringBuilder(url.Length * 2);+ foreach (var c in url) { line.Append(c); if (c == '/' || c == ':' || c == '.' || c == '-') line.Append(WordJoiner); }+ return line.ToString();+ }+/// <summary>A site's share link. X and WhatsApp take the text, which carries both URLs; Telegram takes the itch URL and/// the text, both encoded (core.telegram.org/widgets/share); Facebook and LinkedIn take only a URL, the itch one.</summary>public static string IntentUrl(string site, string text) => site switchdiff --git a/unity/Assets/Tests/EditMode/ShareShotTests.cs b/unity/Assets/Tests/EditMode/ShareShotTests.csindex 93de3521b..a7c37d4d1 100644--- a/unity/Assets/Tests/EditMode/ShareShotTests.cs+++ b/unity/Assets/Tests/EditMode/ShareShotTests.cs@@ -39,6 +39,23 @@ public class ShareShotTestsAssert.IsTrue(UiDirection.HasRightToLeft(he), "the Hebrew post is Hebrew");}+ /// <summary>Playtest, 25 Oct 2026: in the Hebrew panel "https://" ended one line and the rest of the URL began the next.+ /// The label puts a word joiner after each break point inside a URL ('/', ':', '.', '-'), so no line break falls inside+ /// it; English is shown as shared, and what is shared and copied never carries the joiners.</summary>+ [Test]+ public void TheHebrewPanelKeepsEachUrlOnOneLine()+ {+ var en = ShareShot.Text(En, "15 November 1948", 6);+ Assert.AreEqual(en, ShareShot.Shown(en, false), "English unchanged");+ var he = ShareShot.Text(He, "15 בנובמבר 1948", 6);+ var shown = ShareShot.Shown(he, true);+ var j = ShareShot.WordJoiner.ToString();+ StringAssert.Contains($"https:{j}/{j}/{j}eyalgolan.{j}itch.{j}io/{j}statecraft-{j}israel", shown);+ StringAssert.Contains($"https:{j}/{j}/{j}github.{j}com/{j}eyalgolan/{j}statecraft-{j}israel", shown);+ Assert.AreEqual(he, shown.Replace(j, ""), "nothing else changes");+ StringAssert.DoesNotContain(j, he, "the shared post carries no joiner");+ }+/// <summary>X's limit is 280 by its own count (twitter-text v3): any URL is 23, a character in its light ranges (Latin,/// Hebrew, most punctuation) is 1 and any other (the bidi marks Format puts round the URLs) is 2. The longest real post,/// the last turn's longest date (rules.yaml ends the game on 15 January 1952), fits in both languages.</summary>@@ -157,7 +174,7 @@ public class ShareShotTestsAssert.IsTrue(share.IsOpen);CollectionAssert.AreEqual(new[] { "statecraft-1948-05-15.png" }, kept);var post = ShareShot.Text(text, HudModel.From(bridge, text).Date, bridge.State.Turn);- Assert.AreEqual(post, ui.Q<Label>("share-post").text, "the panel shows the post");+ Assert.AreEqual(ShareShot.Shown(post, hebrew), ui.Q<Label>("share-post").text, "the panel shows the post");Assert.IsFalse(ui.Q<VisualElement>("screen-settings").enabledSelf, "out of Tab's reach under the panel");var fallback = ui.Q<VisualElement>("share-fallback");Assert.AreEqual(DisplayStyle.None, fallback.style.display.value, "no attach note before the press");@@ -210,7 +227,7 @@ public class ShareShotTestsAssert.AreEqual(DisplayStyle.None, note.style.display.value, "no note before the press");CollectionAssert.IsEmpty(shared, "nothing is shared before the press");if (keyboard) UiTestKit.Press(button); else SettingsScreenTests.PressWithPointer(button);- var post = ui.Q<Label>("share-post").text;+ var post = ShareShot.Text(text, HudModel.From(bridge, text).Date, bridge.State.Turn);CollectionAssert.AreEqual(new[] { post + " | " + ShareShot.Itch }, shared, "the share sheet, or the download, once");CollectionAssert.IsEmpty(opened, "no web page: Instagram has no share link");Assert.AreEqual(canShareFiles ? DisplayStyle.None : DisplayStyle.Flex, note.style.display.value,@@ -351,7 +368,8 @@ public class ShareShotTestsAssert.AreEqual(text["share.copy"], copy.text);Assert.AreEqual(DisplayStyle.None, said.style.display.value, "nothing to say before the press");SettingsScreenTests.PressWithPointer(copy);- CollectionAssert.AreEqual(new[] { ui.Q<Label>("share-post").text }, copies, "one copy, of the post, on the press");+ CollectionAssert.AreEqual(new[] { ShareShot.Text(text, HudModel.From(bridge, text).Date, bridge.State.Turn) }, copies,+ "one copy, of the post (not the label's joiners), on the press");StringAssert.Contains(ShareShot.Itch, copies[0], "the copied text links the itch page");StringAssert.Contains(ShareShot.Repo, copies[0], "and the repository");// The batch editor idles between frames unless asked for one, and the panel's scheduler runs on those frames.