A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
UI: Share to X, Facebook, Instagram, WhatsApp and Telegram, with a preview of the picture (Fixes #1237) (#1262)
Eyal Golanf1a5238f07ba
diff --git a/changelog.d/1237.md b/changelog.d/1237.mdnew file mode 100644index 000000000..bfc27c641--- /dev/null+++ b/changelog.d/1237.md@@ -0,0 +1,7 @@+### Changed++- The Share panel shows a preview of the picture it shares, and its site buttons are the owner's list in order: X,+ Facebook, Instagram, WhatsApp, Telegram and LinkedIn, shown from the start (#1237). Telegram opens its share link+ (`t.me/share/url`, with the itch URL and the post). Instagram has no share link: its button opens the share sheet+ where the browser can share files, and elsewhere downloads the picture and says, in English and Hebrew, to post it+ from the Instagram app. New Hebrew string queued for a native read (#564).diff --git a/unity/Assets/Scripts/UI/SharePresenter.cs b/unity/Assets/Scripts/UI/SharePresenter.csindex 807a64ef3..2ac90ecd1 100644--- a/unity/Assets/Scripts/UI/SharePresenter.cs+++ b/unity/Assets/Scripts/UI/SharePresenter.cs@@ -7,11 +7,13 @@ using UnityEngine.UIElements;namespace Statecraft.Game.UI{/// <summary>"Share" (#1170): the button in the Settings screen's Community row and the one on the turn report capture the- /// frame, then open a small panel over everything with the post (ShareShot.Text) and one Share button. The capture runs- /// before the panel shows, so the panel is never in the picture. Where the browser can share files, Share opens its share- /// sheet with the picture, the post and the itch URL; elsewhere the same button downloads the picture, and the panel then- /// shows the X, Facebook, WhatsApp and LinkedIn share links and says to attach the picture, which a link cannot carry.+ /// frame, then open a small panel over everything with a preview of the picture, the post (ShareShot.Text), one Share+ /// button, Copy and the site buttons (#1237). The capture runs before the panel shows, so the panel is never in the picture.+ /// Where the browser can share files, Share opens its share sheet with the picture, the post and the itch URL; elsewhere+ /// the same button downloads the picture, and the panel then says to attach it to a post, which a link cannot carry./// Copy (#1238) puts the picture on the clipboard, or the post text where the browser refuses the picture, and says which.+ /// X, Facebook, WhatsApp, Telegram and LinkedIn open their share links; Instagram has none, so its button does what Share does+ /// and, where the picture downloaded, says to post it from the Instagram app./// <para>While it shows, the root has <see cref="OpenClass"/> and every other part of the UI is disabled, so Tab stays in/// the panel; Close, Esc or Cancel give each part its own state back and the focus back to the button that opened it./// <see cref="Escape"/> is what GameRoot's Escape poll and ScreenNav (TakesEscape) ask first.</para></summary>@@ -21,21 +23,26 @@ namespace Statecraft.Game.UIpublic const string OpenClass = "share-open";/// <summary>The share links' names: brands, the same in every language.</summary>static readonly Dictionary<string, string> SiteNames = new Dictionary<string, string>- { ["x"] = "X", ["facebook"] = "Facebook", ["whatsapp"] = "WhatsApp", ["linkedin"] = "LinkedIn" };+ { ["x"] = "X", ["facebook"] = "Facebook", ["instagram"] = "Instagram", ["whatsapp"] = "WhatsApp", ["telegram"] = "Telegram",+ ["linkedin"] = "LinkedIn" };+ const string Instagram = "instagram";- readonly VisualElement hudRoot, layer, fallback;- readonly Button go, copy, close, settingsOpen, reportOpen;- readonly Label post, copied;+ readonly VisualElement hudRoot, layer, fallback, preview;+ readonly Button go, copy, close, settingsOpen, reportOpen, instagram;+ readonly Label post, copied, instagramNote;readonly SimBridge bridge; readonly UiText text;readonly Action<Action<byte[]?>> capture;readonly EventCallback<PointerDownEvent> onGoPointer;readonly EventCallback<NavigationSubmitEvent> onGoSubmit;+ readonly EventCallback<PointerDownEvent> onInstagramPointer;+ readonly EventCallback<NavigationSubmitEvent> onInstagramSubmit;readonly EventCallback<PointerDownEvent> onCopyPointer;readonly EventCallback<NavigationSubmitEvent> onCopySubmit;readonly EventCallback<NavigationCancelEvent> onCancel;readonly List<Action> unbindSites = new List<Action>();readonly List<(VisualElement part, bool enabled)> covered = new List<(VisualElement, bool)>();Button? opener;+ UnityEngine.Texture2D? picture; // the preview's, released on CloseIVisualElementScheduledItem? copyPoll;bool capturing, canShareFiles, disposed;int closedAt = -1;@@ -48,6 +55,7 @@ namespace Statecraft.Game.UIhudRoot = root.Q("root") ?? root;layer = root.Q("share-layer");fallback = layer.Q("share-fallback");+ preview = layer.Q("share-preview");go = layer.Q<Button>("share-go"); close = layer.Q<Button>("share-close");post = layer.Q<Label>("share-post");copy = layer.Q<Button>("share-copy"); copied = layer.Q<Label>("share-copied");@@ -58,12 +66,19 @@ namespace Statecraft.Game.UIlayer.Q<Label>("share-attach").text = text["share.attach"];close.text = text["report.close"];foreach (var site in ShareShot.Sites) layer.Q<Button>("share-" + site).text = SiteNames[site];- fallback.style.display = DisplayStyle.None;+ instagram = layer.Q<Button>("share-" + Instagram);+ instagramNote = layer.Q<Label>("share-instagram-note");+ instagramNote.text = text["share.instagram"];+ fallback.style.display = instagramNote.style.display = preview.style.display = DisplayStyle.None;// On the press, not on `clicked` (the release): the web build arms its release listener then (ExternalLink.Bind).onGoPointer = e => { if (e.button == 0) Go(); };onGoSubmit = _ => Go();go.RegisterCallback(onGoPointer, TrickleDown.TrickleDown);go.RegisterCallback(onGoSubmit, TrickleDown.TrickleDown);+ onInstagramPointer = e => { if (e.button == 0) Send(instagramNote); };+ onInstagramSubmit = _ => Send(instagramNote);+ instagram.RegisterCallback(onInstagramPointer, TrickleDown.TrickleDown);+ instagram.RegisterCallback(onInstagramSubmit, TrickleDown.TrickleDown);onCopyPointer = e => { if (e.button == 0) Copy(); };onCopySubmit = _ => Copy();copy.RegisterCallback(onCopyPointer, TrickleDown.TrickleDown);@@ -95,12 +110,13 @@ namespace Statecraft.Game.UIcanShareFiles = ShareShot.CanShareFiles();post.text = ShareShot.Text(text, shown.Date, bridge.State.Turn);go.text = text[canShareFiles ? "share.native" : "share.download"];- fallback.style.display = DisplayStyle.None;+ fallback.style.display = instagramNote.style.display = DisplayStyle.None;copyPoll?.Pause();copied.style.display = DisplayStyle.None;+ ShowPreview(png);foreach (var unbind in unbindSites) unbind();unbindSites.Clear();- foreach (var site in ShareShot.Sites) 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, post.text)));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.@@ -113,15 +129,43 @@ namespace Statecraft.Game.UI});}- /// <summary>Share: the browser's share sheet, or the download and then the share links.</summary>- void Go()+ /// <summary>Share: the browser's share sheet, or the download and then the note to attach the picture.</summary>+ void Go() => Send(fallback);++ /// <summary>Share and Instagram: the share sheet where the browser can share files, else the download, and then+ /// <paramref name="note"/> says what to do with the downloaded picture.</summary>+ void Send(VisualElement note){if (!IsOpen) return;ShareShot.Share(post.text, ShareShot.Itch);- if (!canShareFiles) { fallback.style.display = DisplayStyle.Flex; return; }+ 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- // share links show, as where files cannot be shared. A refusal comes at once; a few seconds is enough to wait.- go.schedule.Execute(() => { if (IsOpen && ShareShot.Failed()) fallback.style.display = DisplayStyle.Flex; }).Every(250).ForDuration(3000);+ // note shows, as where files cannot be shared. A refusal comes at once; a few seconds is enough to wait.+ go.schedule.Execute(() => { if (IsOpen && ShareShot.Failed()) note.style.display = DisplayStyle.Flex; }).Every(250).ForDuration(3000);+ }++ /// <summary>The preview: the PNG that is shared, decoded into a texture of its own (none if it does not decode).</summary>+ void ShowPreview(byte[] png)+ {+ ReleasePreview();+ var decoded = new UnityEngine.Texture2D(2, 2, UnityEngine.TextureFormat.RGBA32, false);+ if (!UnityEngine.ImageConversion.LoadImage(decoded, png, markNonReadable: true)) { Release(decoded); return; }+ picture = decoded;+ preview.style.backgroundImage = new StyleBackground(decoded);+ preview.style.display = DisplayStyle.Flex;+ }++ void ReleasePreview()+ {+ preview.style.backgroundImage = StyleKeyword.Null;+ preview.style.display = DisplayStyle.None;+ if (picture != null) Release(picture);+ picture = null;+ }++ static void Release(UnityEngine.Texture2D t)+ {+ if (UnityEngine.Application.isPlaying) UnityEngine.Object.Destroy(t); else UnityEngine.Object.DestroyImmediate(t); // edit-mode tests}/// <summary>Copy: the browser copies on the release and answers after a promise (ShareShot.jslib), so the panel looks@@ -158,6 +202,7 @@ namespace Statecraft.Game.UIhudRoot.RemoveFromClassList(OpenClass);foreach (var (part, enabled) in covered) part.SetEnabled(enabled);covered.Clear();+ ReleasePreview();opener?.Focus();opener = null;}@@ -178,6 +223,8 @@ namespace Statecraft.Game.UIforeach (var unbind in unbindSites) unbind();go.UnregisterCallback(onGoPointer, TrickleDown.TrickleDown);go.UnregisterCallback(onGoSubmit, TrickleDown.TrickleDown);+ instagram.UnregisterCallback(onInstagramPointer, TrickleDown.TrickleDown);+ instagram.UnregisterCallback(onInstagramSubmit, TrickleDown.TrickleDown);copyPoll?.Pause();copy.UnregisterCallback(onCopyPointer, TrickleDown.TrickleDown);copy.UnregisterCallback(onCopySubmit, TrickleDown.TrickleDown);diff --git a/unity/Assets/Scripts/UI/ShareShot.cs b/unity/Assets/Scripts/UI/ShareShot.csindex 2692062a9..3c7078368 100644--- a/unity/Assets/Scripts/UI/ShareShot.cs+++ b/unity/Assets/Scripts/UI/ShareShot.cs@@ -8,7 +8,7 @@ using UnityEngine;namespace Statecraft.Game.UI{/// <summary>Sharing a post with a screenshot of the game (#1170, SharePresenter): the capture, the PNG, the post text and- /// the four share links. Nothing is uploaded by the game and nothing is counted: the picture stays in the page until the+ /// the sites' share links. Nothing is uploaded by the game and nothing is counted: the picture stays in the page until the/// player shares or downloads it. On the web ShareShot.jslib keeps the PNG as a File; the Share press arms a one-shot/// release listener (as ExternalLink does, #1168), and inside that real gesture the browser's share sheet gets the file,/// the text and the itch URL (navigator.share), or, where it cannot share files (Firefox on the desktop, some others),@@ -21,8 +21,9 @@ namespace Statecraft.Game.UIpublic const string Itch = "https://eyalgolan.itch.io/statecraft-israel";/// <summary>The picture's long side at most: a DPR-3 phone frame encoded at full size can exhaust the WebGL heap.</summary>public const int MaxSide = 1920;- /// <summary>The share links offered where the browser cannot share files, in the panel's order.</summary>- public static readonly string[] Sites = { "x", "facebook", "whatsapp", "linkedin" };+ /// <summary>The site buttons, in the panel's order: the owner's list (#1237; LinkedIn kept, at the end, owner 21 Oct+ /// 2026). Instagram has no share link: its button shares or downloads the picture, as Share does (SharePresenter).</summary>+ public static readonly string[] Sites = { "x", "facebook", "instagram", "whatsapp", "telegram", "linkedin" };public static Action<byte[], string> Keep = DefaultKeep;public static Func<bool> CanShareFiles = DefaultCanShareFiles;@@ -38,13 +39,14 @@ namespace Statecraft.Game.UI/// <summary>The post, in the UI's language, with the in-game date and turn and the itch URL.</summary>public static string Text(UiText text, string date, int turn) => text.Format("share.post", date, turn, Itch);- /// <summary>A site's share link. X and WhatsApp take the text, which ends with the URL; Facebook and LinkedIn take- /// only a URL.</summary>+ /// <summary>A site's share link. X and WhatsApp take the text, which ends with the URL; Telegram takes the URL and the+ /// text, both encoded (core.telegram.org/widgets/share); Facebook and LinkedIn take only the URL.</summary>public static string IntentUrl(string site, string text) => site switch{"x" => "https://x.com/intent/post?text=" + Uri.EscapeDataString(text),"facebook" => "https://www.facebook.com/sharer/sharer.php?u=" + Uri.EscapeDataString(Itch),"whatsapp" => "https://wa.me/?text=" + Uri.EscapeDataString(text),+ "telegram" => "https://t.me/share/url?url=" + Uri.EscapeDataString(Itch) + "&text=" + Uri.EscapeDataString(text),"linkedin" => "https://www.linkedin.com/sharing/share-offsite/?url=" + Uri.EscapeDataString(Itch),_ => throw new ArgumentException("no share link for " + site, nameof(site)),};diff --git a/unity/Assets/Tests/EditMode/ShareShotTests.cs b/unity/Assets/Tests/EditMode/ShareShotTests.csindex d542ea0b8..43a6372a4 100644--- a/unity/Assets/Tests/EditMode/ShareShotTests.cs+++ b/unity/Assets/Tests/EditMode/ShareShotTests.cs@@ -1,6 +1,7 @@#nullable enableusing System;using System.Collections.Generic;+using System.Linq;using NUnit.Framework;using Statecraft.Game;using Statecraft.Game.UI;@@ -11,9 +12,10 @@ using UnityEngine.UIElements;using Object = UnityEngine.Object;/// <summary>#1170: sharing a post with a screenshot. The post text in both languages with the in-game date and turn, the-/// share links' encoding, the 1920 px cap on the picture, and the panel: it captures before it shows, offers the browser's-/// share sheet where files can be shared and otherwise the download with the four share links. Through ShareShot's-/// injectable hooks, so nothing is captured, saved or opened for real.</summary>+/// share links' encoding, the 1920 px cap on the picture, and the panel: it captures before it shows, previews the picture,+/// offers the browser's share sheet where files can be shared and otherwise the download, and the site buttons (#1237):+/// share links, and Instagram, which has none. Through ShareShot's injectable hooks, so nothing is captured, saved or+/// opened for real.</summary>public class ShareShotTests{static readonly Content C = ContentLoader.Load(Paths.Content);@@ -40,10 +42,24 @@ public class ShareShotTestsAssert.AreEqual("https://x.com/intent/post?text=" + enc, ShareShot.IntentUrl("x", text));Assert.AreEqual("https://www.facebook.com/sharer/sharer.php?u=" + url, ShareShot.IntentUrl("facebook", text));Assert.AreEqual("https://wa.me/?text=" + enc, ShareShot.IntentUrl("whatsapp", text));+ Assert.AreEqual("https://t.me/share/url?url=" + url + "&text=" + enc, ShareShot.IntentUrl("telegram", text));Assert.AreEqual("https://www.linkedin.com/sharing/share-offsite/?url=" + url, ShareShot.IntentUrl("linkedin", text));StringAssert.Contains("a%20%26%20b%20%231", enc, "'&' and '#' never end the query early");}+ /// <summary>#1237: the owner's list, in the owner's order; LinkedIn stays, at the end (owner, 21 Oct 2026). Instagram has+ /// no web share link.</summary>+ [Test]+ public void TheSitesAreTheOwnersListInOrder()+ {+ CollectionAssert.AreEqual(new[] { "x", "facebook", "instagram", "whatsapp", "telegram", "linkedin" }, ShareShot.Sites);+ Assert.Throws<ArgumentException>(() => ShareShot.IntentUrl("instagram", "a"), "Instagram has no share link");+ using var ui = new UiTestKit();+ var row = ui.Q<VisualElement>("share-x").parent;+ CollectionAssert.AreEqual(Array.ConvertAll(ShareShot.Sites, s => "share-" + s), row.Children().Select(c => c.name).ToArray(),+ "the panel shows the buttons in the list's order");+ }+[Test]public void ThePictureIsCappedAt1920OnTheLongSide(){@@ -70,7 +86,7 @@ public class ShareShotTests/// <summary>The Settings Share button: the frame is captured before the panel shows, then kept for the browser; where it/// can share files the panel offers Share (the share sheet gets the post text and the itch URL), elsewhere the same- /// button downloads the picture and the four share links and the "attach" note show. Esc closes it.</summary>+ /// button downloads the picture and the "attach" note shows. The site buttons show either way. Esc closes it.</summary>[Test]public void SharingCapturesFirstAndOffersTheSheetOrTheFallback([Values(false, true)] bool canShareFiles, [Values(false, true)] bool hebrew){@@ -101,18 +117,18 @@ public class ShareShotTestsAssert.AreEqual(post, 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 share links before the press");+ Assert.AreEqual(DisplayStyle.None, fallback.style.display.value, "no attach note before the press");+ for (VisualElement? e = ui.Q<Button>("share-x"); e != null && e.name != "share-panel"; e = e.parent)+ Assert.AreNotEqual(DisplayStyle.None, e.style.display.value, $"the site buttons show from the start ({e.name})");Assert.AreEqual(canShareFiles ? text["share.native"] : text["share.download"], ui.Q<Button>("share-go").text);SettingsScreenTests.PressWithPointer(ui.Q<Button>("share-go"));CollectionAssert.AreEqual(new[] { post + " | " + ShareShot.Itch }, shared, "the press asks the browser once");Assert.AreEqual(canShareFiles ? DisplayStyle.None : DisplayStyle.Flex, fallback.style.display.value,- "the share links and the attach note only where files cannot be shared");- if (!canShareFiles)- {- foreach (var site in ShareShot.Sites) UiTestKit.Press(ui.Q<Button>("share-" + site));- CollectionAssert.AreEqual(Array.ConvertAll(ShareShot.Sites, s => ShareShot.IntentUrl(s, post)), opened);- Assert.AreEqual(text["share.attach"], ui.Q<Label>("share-attach").text);- }+ "the attach note only where files cannot be shared");+ var links = ShareShot.Sites.Where(s => s != "instagram").ToArray();+ foreach (var site in links) UiTestKit.Press(ui.Q<Button>("share-" + site));+ CollectionAssert.AreEqual(links.Select(s => ShareShot.IntentUrl(s, post)), opened);+ Assert.AreEqual(text["share.attach"], ui.Q<Label>("share-attach").text);var go = ui.Q<Button>("share-go");using (var esc = NavigationCancelEvent.GetPooled()) { esc.target = go; go.SendEvent(esc); }Assert.IsFalse(share.IsOpen, "Esc closes it");@@ -125,6 +141,85 @@ public class ShareShotTests}}+ /// <summary>#1237: Instagram has no share link. Where the browser can share files its button opens the share sheet with+ /// the picture, as Share does; elsewhere the same press downloads the picture and a note says to post it from the+ /// Instagram app. On the press, as Share (the web build arms its one-shot release listener then); nothing opens before.</summary>+ [Test]+ public void InstagramOpensTheSheetOrDownloadsWithANote([Values(false, true)] bool canShareFiles, [Values(false, true)] bool hebrew,+ [Values(false, true)] bool keyboard)+ {+ var text = hebrew ? He : En;+ var opened = new List<string>(); var shared = new List<string>();+ ExternalLink.Opener = opened.Add;+ ShareShot.Keep = (png, name) => { };+ ShareShot.CanShareFiles = () => canShareFiles;+ ShareShot.Share = (post, url) => shared.Add(post + " | " + url);+ try+ {+ using var ui = new UiTestKit();+ var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), text);+ using var share = new SharePresenter(ui.Root, bridge, text, done => done(new byte[] { 1 }));+ UiTestKit.Press(ui.Q<Button>("settings-share"));+ var button = ui.Q<Button>("share-instagram");+ var note = ui.Q<Label>("share-instagram-note");+ Assert.AreEqual("Instagram", button.text, "a brand, the same in every language");+ Assert.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;+ 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,+ "the note only where the picture downloaded");+ Assert.AreEqual(text["share.instagram"], note.text);+ Assert.AreEqual(DisplayStyle.None, ui.Q<VisualElement>("share-fallback").style.display.value, "not the other sites' note");+ }+ finally+ {+ ExternalLink.Opener = ExternalLink.Default;+ ShareShot.Keep = ShareShot.DefaultKeep; ShareShot.CanShareFiles = ShareShot.DefaultCanShareFiles; ShareShot.Share = ShareShot.DefaultShare;+ }+ }++ /// <summary>#1237: the panel previews the picture it shares, from the captured PNG. The texture is released when the+ /// panel closes, so none is left over between opens; a PNG that does not decode shows no preview.</summary>+ [Test]+ public void ThePanelPreviewsThePictureAndReleasesItOnClose()+ {+ ShareShot.Keep = (png, name) => { };+ var frame = new Texture2D(64, 36, TextureFormat.RGB24, false);+ var real = frame.EncodeToPNG();+ Object.DestroyImmediate(frame);+ byte[] png = real;+ try+ {+ using var ui = new UiTestKit();+ var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), En);+ var share = new SharePresenter(ui.Root, bridge, En, done => done(png));+ var preview = ui.Q<VisualElement>("share-preview");+ UiTestKit.Press(ui.Q<Button>("settings-share"));+ var first = preview.style.backgroundImage.value.texture;+ Assert.IsNotNull(first, "the preview shows the picture");+ Assert.AreEqual(64, first.width); Assert.AreEqual(36, first.height);+ Assert.AreEqual(DisplayStyle.Flex, preview.style.display.value);+ UiTestKit.Press(ui.Q<Button>("share-close"));+ Assert.IsTrue(first == null, "released on Close");+ Assert.IsNull(preview.style.backgroundImage.value.texture);+ UiTestKit.Press(ui.Q<Button>("settings-share"));+ var second = preview.style.backgroundImage.value.texture;+ Assert.IsNotNull(second, "a new picture on the next open");+ share.Dispose();+ Assert.IsTrue(second == null, "released when the UI is rebuilt with the panel open");+ png = new byte[] { 1, 2, 3 };+ using var again = new SharePresenter(ui.Root, bridge, En, done => done(png));+ UiTestKit.Press(ui.Q<Button>("settings-share"));+ Assert.IsTrue(again.IsOpen, "the panel still opens");+ Assert.AreEqual(DisplayStyle.None, preview.style.display.value, "no preview for a picture that does not decode");+ Assert.IsNull(preview.style.backgroundImage.value.texture);+ }+ finally { ShareShot.Keep = ShareShot.DefaultKeep; }+ }+/// <summary>With the screens' navigation wired as GameRoot wires it, Esc in the share panel closes the panel only:/// ScreenNav's Cancel handler trickles down from the root before the panel's own and asks the panel first.</summary>[Test]@@ -150,7 +245,7 @@ public class ShareShotTests}/// <summary>A share sheet the browser refused on the release (not a cancel): the picture downloaded instead, and the- /// share links show (ShareShot.Failed, polled by the panel's scheduler). A failed capture opens nothing and leaves+ /// note to attach it shows (ShareShot.Failed, polled by the panel's scheduler). A failed capture opens nothing and leaves/// Share working.</summary>[UnityEngine.TestTools.UnityTest]public System.Collections.IEnumerator ARefusedShareSheetShowsTheShareLinks()@@ -170,11 +265,11 @@ public class ShareShotTestsAssert.IsTrue(share.IsOpen, "the next press works");SettingsScreenTests.PressWithPointer(ui.Q<Button>("share-go"));var fallback = ui.Q<VisualElement>("share-fallback");- Assert.AreEqual(DisplayStyle.None, fallback.style.display.value, "the sheet is open: no links yet");+ Assert.AreEqual(DisplayStyle.None, fallback.style.display.value, "the sheet is open: no note yet");failed = true;var until = Time.realtimeSinceStartup + 5f; // the panel looks every 250 mswhile (fallback.style.display.value != DisplayStyle.Flex && Time.realtimeSinceStartup < until) yield return null;- Assert.AreEqual(DisplayStyle.Flex, fallback.style.display.value, "refused: the share links show");+ Assert.AreEqual(DisplayStyle.Flex, fallback.style.display.value, "refused: the attach note shows");}finally{diff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxmlindex 53f63ceda..95acc21d2 100644--- a/unity/Assets/UI/Game.uxml+++ b/unity/Assets/UI/Game.uxml@@ -508,23 +508,28 @@</ui:VisualElement></ui:VisualElement><!-- "Share" (#1170, SharePresenter): over everything, the turn report too, after the frame was captured without it.- The share links show only where the browser cannot share the picture itself. Copy (#1238) puts the picture, or the- post text, on the clipboard, and the line under it says which. Before the toast. -->+ A preview of that picture, the Share/Download button, then Copy (#1238), which puts the picture, or the post+ text, on the clipboard, with a line under it that says which. Then the site buttons in the owner's order (#1237);+ the notes show once the picture downloaded, where the browser cannot share it itself. Before the toast. --><ui:VisualElement name="share-layer" class="share-layer"><ui:VisualElement name="share-panel" class="panel share-panel"><ui:VisualElement class="screen-header"><ui:Label name="share-title" text="Share a picture of the game" class="title" /></ui:VisualElement>+ <ui:VisualElement name="share-preview" class="share-preview" /><ui:Label name="share-post" class="share-post" /><ui:Button name="share-go" class="share-go" /><ui:Button name="share-copy" class="share-go" /><ui:Label name="share-copied" class="muted share-copied" />+ <ui:VisualElement class="row share-sites">+ <ui:Button name="share-x" />+ <ui:Button name="share-facebook" />+ <ui:Button name="share-instagram" />+ <ui:Button name="share-whatsapp" />+ <ui:Button name="share-telegram" />+ <ui:Button name="share-linkedin" />+ </ui:VisualElement>+ <ui:Label name="share-instagram-note" class="muted share-instagram-note" /><ui:VisualElement name="share-fallback" class="share-fallback"><ui:Label name="share-attach" text="These sites can't take a picture through a link: attach the downloaded picture to your post." class="muted share-attach" />- <ui:VisualElement class="row share-sites">- <ui:Button name="share-x" />- <ui:Button name="share-facebook" />- <ui:Button name="share-whatsapp" />- <ui:Button name="share-linkedin" />- </ui:VisualElement></ui:VisualElement><ui:VisualElement class="row share-actions"><ui:Button name="share-close" text="Close" /></ui:VisualElement><Statecraft.Game.UI.UiFrame />diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.ussindex b8c75cc48..5e4de8541 100644--- a/unity/Assets/UI/Statecraft.uss+++ b/unity/Assets/UI/Statecraft.uss@@ -555,15 +555,16 @@ Button.settings-choice-selected { -unity-font-definition: url("project://databas.feedback-choice { margin-top: 10px; }.feedback-preview { font-size: 15px; margin: 2px 4px 0 4px; }.feedback-actions { justify-content: flex-end; margin-top: 12px; flex-shrink: 0; }-/* "Share" (#1170, SharePresenter): the turn report's kind of backdrop, drawn over everything, the report too; the post, the Share button, and the share- links, which show only where the browser cannot share the picture itself. */+/* "Share" (#1170, SharePresenter): the turn report's kind of backdrop, drawn over everything, the report too; a preview of the picture (#1237), which+ gives way first in a short window, the post, the Share button, the site buttons, and the notes once the picture downloaded. */.share-layer { display: none; position: absolute; left: 0; top: 0; right: 0; bottom: 0; justify-content: center; align-items: center; background-color: rgba(5, 9, 18, 0.6); padding: 16px; }.share-open .share-layer { display: flex; }.share-panel { width: 560px; max-width: 100%; max-height: 100%; padding: 18px; background-color: rgb(11, 18, 32); }-.share-post, .share-attach { white-space: normal; }+.share-preview { height: 160px; min-height: 48px; flex-shrink: 1; margin-bottom: 12px; background-size: contain; background-repeat: no-repeat; background-position-x: center; background-position-y: center; }+.share-post, .share-attach, .share-instagram-note { white-space: normal; }.share-go { margin-top: 12px; }.share-copied { white-space: normal; margin-top: 6px; }-.share-attach { margin-top: 12px; }+.share-attach, .share-instagram-note { margin-top: 12px; }.share-sites { flex-wrap: wrap; margin-top: 6px; }.share-sites > Button { margin: 4px 8px 0 0; }.share-actions { justify-content: flex-end; margin-top: 12px; flex-shrink: 0; }diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlindex ed06b77c1..0acddbbfa 100644--- a/unity/Assets/UI/strings.en.yaml+++ b/unity/Assets/UI/strings.en.yaml@@ -123,6 +123,7 @@ share.post: "I'm running Israel in 1948 in Statecraft: Israel, a free open-sourcshare.native: "Share"share.download: "Download the picture"share.attach: "These sites can't take a picture through a link: attach the downloaded picture to your post."+share.instagram: "Instagram has no share link: the picture downloaded, so post it from the Instagram app."share.copy: "Copy"share.copied_picture: "Picture copied"share.copied_text: "Text copied"diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yamlindex 01e5e4f70..bc26e9007 100644--- a/unity/Assets/UI/strings.he.yaml+++ b/unity/Assets/UI/strings.he.yaml@@ -129,6 +129,7 @@ share.post: "ניהול מדינת ישראל ב־1948 במשחק Statecraft: Isshare.native: "שיתוף"share.download: "הורדת התמונה"share.attach: "האתרים האלה לא מקבלים תמונה דרך קישור: יש לצרף לפוסט את התמונה שהורדה."+share.instagram: "לאינסטגרם אין קישור לשיתוף: התמונה הורדה, ויש לפרסם אותה מאפליקציית אינסטגרם."# Copy (#1238): the button ("copying"), "the picture was copied", "the text was copied", and the failure ("copying is# not possible here; the picture can still be shared or downloaded with the button above"). Agent-drafted.# Approved by Beri, a native speaker, on #1253 (21 Oct 2026).