Skip to content

A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.

UI: share a post with a screenshot of the game, Web Share with a download and share-link fallback (Fixes #1170) (#1182)

Berib670e5adcb8c
diff --git a/changelog.d/1170.md b/changelog.d/1170.md
new file mode 100644
index 000000000..f33beea46
--- /dev/null
+++ b/changelog.d/1170.md
@@ -0,0 +1,7 @@
+- A "Share" button, beside Star in Settings and on the turn report, captures the frame (at its end, never inside the
+ click, capped at 1920 px on the long side) and opens a small panel with the post: the in-game date and turn and the
+ itch page, in English or Hebrew. Where the browser can share files, Share opens its share sheet with the picture
+ (`navigator.share`, inside the player's own gesture, `ShareShot.jslib`); elsewhere it downloads
+ `statecraft-<date>.png` and offers X, Facebook, WhatsApp and LinkedIn share links with a note to attach the picture.
+ Nothing is uploaded by the game and nothing is counted. Beri approved the Hebrew as a native speaker (refs #564;
+ fixes #1170).
diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.cs
index 6445ab039..097715996 100644
--- a/unity/Assets/Scripts/UI/GameRoot.cs
+++ b/unity/Assets/Scripts/UI/GameRoot.cs
@@ -68,6 +68,7 @@ namespace Statecraft.Game.UI
/// <summary>Tests: the first-turn guide of the last Begin.</summary>
internal FirstTurnGuidePresenter? Guide => guide;
FeedbackPresenter? feedback;
+ SharePresenter? share;
CameraRig? rig;
List<(string, int, int, DateTime)>? drawn;
/// <summary>The designated sites on the map (#381), made on first use beside the placements; and their states as drawn.</summary>
@@ -270,10 +271,13 @@ namespace Statecraft.Game.UI
// "Report a bug or idea" (#1169), from Settings and the start screen: the version line names the content GameBoot logged.
feedback = Own(new FeedbackPresenter(root, text, ReportLinks.Version(Application.version, inputs.Content.Hash)));
var feedbackPanel = feedback;
- nav!.TakesEscape = () => feedbackPanel.Escape(); // the same Escape never closes the screen under the panel too
Own(new CabinetPresenter(root, bridge, text, portraits));
// After End Turn, what changed in the top bar and the sim's causes (#1037); under an outcome clip, which plays first.
report = Own(new TurnReportPresenter(root, bridge, text, nav!));
+ // "Share" (#1170), from Settings and the turn report: the frame is captured at its end, before the panel shows.
+ var sharePanel = share = Own(new SharePresenter(root, bridge, text, done => StartCoroutine(ShareShot.Capture(done))));
+ // Both panels in one hook: the same Escape never closes the screen under the panel too.
+ nav!.TakesEscape = () => feedbackPanel.Escape() || sharePanel.Escape();
var names = map.SettlementsFor(inputs.Map.SettlementsYaml).ToDictionary(s => s.Id, s => s.Name); // the map's parse (issue #321)
// The 1948 sub-districts, outlined on the map, and each front's 1949 armistice line from its agreement's date
// where the line exists (display only: the sim never reads them; docs/visual-v1.md, owner rulings 2026-10-11).
@@ -557,7 +561,7 @@ namespace Statecraft.Game.UI
for (int i = owned.Count - 1; i >= 0; i--) owned[i].Dispose();
owned.Clear();
if (hoveredCity != null) { hoveredCity = null; HandCursor(false); } // the next Begin's pills start unlit
- minimap = null; labels = null; nav = null; start = null; card = null; outcomes = null; report = null; end = null; guide = null; feedback = null; rig = null; drawn = null; drawnSites = null; units = null; Regions = null; logCamera = false;
+ minimap = null; labels = null; nav = null; start = null; card = null; outcomes = null; report = null; end = null; guide = null; feedback = null; share = null; rig = null; drawn = null; drawnSites = null; units = null; Regions = null; logCamera = false;
// A ?profile run cut short (a stopped coroutine never reaches its restore line) must not leave the terrain at the
// profile's pixel error (Task 24 review M1). Nothing else changes it, so restoring is always right.
if (map != null && map.Terrain != null) map.Terrain.heightmapPixelError = MapBuilder.TerrainPixelError;
@@ -690,8 +694,8 @@ namespace Statecraft.Game.UI
// With no screen to close, Escape skips the first-turn guide (FirstTurnGuidePresenter.Escape).
// With nothing else to close, Escape on the open decision card is Hide (EventCardPresenter.Escape; the card itself
// takes the Cancel event when it has the focus).
- // The report panel (#1169) is over everything: its Escape goes no further.
- if (UnityEngine.InputSystem.Keyboard.current?.escapeKey.wasPressedThisFrame == true && feedback?.Escape() != true) { bool done = outcomes?.SkipAll() == true || outcomes?.ClosedThisFrame == true; if (!done) done = end?.Close() == true || end?.ClosedThisFrame == true; if (!done) done = report?.Close() == true || report?.ClosedThisFrame == true; done |= start?.Escape() == true; done |= nav?.Close() == true; if (!done) done = guide?.Escape() == true; if (!done && document.rootVisualElement.focusController?.focusedElement == null) card?.Escape(); }
+ // The report panel (#1169) and the share panel (#1170) are over everything: their Escape goes no further.
+ if (UnityEngine.InputSystem.Keyboard.current?.escapeKey.wasPressedThisFrame == true && feedback?.Escape() != true && share?.Escape() != true) { bool done = outcomes?.SkipAll() == true || outcomes?.ClosedThisFrame == true; if (!done) done = end?.Close() == true || end?.ClosedThisFrame == true; if (!done) done = report?.Close() == true || report?.ClosedThisFrame == true; done |= start?.Escape() == true; done |= nav?.Close() == true; if (!done) done = guide?.Escape() == true; if (!done && document.rootVisualElement.focusController?.focusedElement == null) card?.Escape(); }
// PageUp, PageDown, Home and End, with no modifier, scroll the open screen or the open card's text, with or without
// focus (KeyScroll; accessibility audit H3), but not under an End Turn outcome clip, which covers them. The arrows
// stay with the camera (NavigationGuard, B6).
diff --git a/unity/Assets/Scripts/UI/ScreenNav.cs b/unity/Assets/Scripts/UI/ScreenNav.cs
index d6ab74738..ee758f65c 100644
--- a/unity/Assets/Scripts/UI/ScreenNav.cs
+++ b/unity/Assets/Scripts/UI/ScreenNav.cs
@@ -163,7 +163,7 @@ namespace Statecraft.Game.UI
readonly EventCallback<NavigationCancelEvent> onCancel;
readonly EventCallback<GeometryChangedEvent> onGeometry;
- /// <summary>A layer over the screens that takes Escape first (GameRoot: the report panel, #1169): true when it used the
+ /// <summary>A layer over the screens that takes Escape first (GameRoot: the report panel, #1169, and the share panel, #1170): true when it used the
/// key, and the open screen under it stays open. This handler trickles down from the root, so it runs before the layer's own.</summary>
public System.Func<bool>? TakesEscape;
diff --git a/unity/Assets/Scripts/UI/SharePresenter.cs b/unity/Assets/Scripts/UI/SharePresenter.cs
new file mode 100644
index 000000000..7fd5d074f
--- /dev/null
+++ b/unity/Assets/Scripts/UI/SharePresenter.cs
@@ -0,0 +1,148 @@
+#nullable enable
+using System;
+using System.Collections.Generic;
+using System.Linq;
+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.
+ /// <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>
+ public sealed class SharePresenter : IDisposable
+ {
+ /// <summary>On the "root" element while the panel shows.</summary>
+ public 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" };
+
+ readonly VisualElement hudRoot, layer, fallback;
+ readonly Button go, close, settingsOpen, reportOpen;
+ readonly Label post;
+ readonly SimBridge bridge; readonly UiText text;
+ readonly Action<Action<byte[]?>> capture;
+ readonly EventCallback<PointerDownEvent> onGoPointer;
+ readonly EventCallback<NavigationSubmitEvent> onGoSubmit;
+ readonly EventCallback<NavigationCancelEvent> onCancel;
+ readonly List<Action> unbindSites = new List<Action>();
+ readonly List<(VisualElement part, bool enabled)> covered = new List<(VisualElement, bool)>();
+ Button? opener;
+ bool capturing, canShareFiles, disposed;
+ int closedAt = -1;
+
+ /// <param name="capture">Captures the frame at its end and hands over its PNG (GameRoot: ShareShot.Capture as a
+ /// coroutine; a test hands over bytes at once).</param>
+ public SharePresenter(VisualElement root, SimBridge bridge, UiText text, Action<Action<byte[]?>> capture)
+ {
+ this.bridge = bridge; this.text = text; this.capture = capture;
+ hudRoot = root.Q("root") ?? root;
+ layer = root.Q("share-layer");
+ fallback = layer.Q("share-fallback");
+ go = layer.Q<Button>("share-go"); close = layer.Q<Button>("share-close");
+ post = layer.Q<Label>("share-post");
+ settingsOpen = root.Q<Button>("settings-share"); reportOpen = root.Q<Button>("turn-report-share");
+ settingsOpen.text = reportOpen.text = text["share.open"];
+ layer.Q<Label>("share-title").text = text["share.title"];
+ layer.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;
+ // 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);
+ settingsOpen.clicked += OpenFromSettings;
+ reportOpen.clicked += OpenFromReport;
+ close.clicked += Close;
+ onCancel = e => { Close(); e.StopPropagation(); };
+ layer.RegisterCallback(onCancel);
+ }
+
+ public bool IsOpen => hudRoot.ClassListContains(OpenClass);
+
+ void OpenFromSettings() => Open(settingsOpen);
+ void OpenFromReport() => Open(reportOpen);
+
+ /// <summary>Captures the frame, keeps its PNG for the browser, then shows the panel; <paramref name="from"/> gets the
+ /// focus back on Close.</summary>
+ public void Open(Button? from = null)
+ {
+ if (IsOpen || capturing) return;
+ capturing = true;
+ capture(png =>
+ {
+ capturing = false;
+ if (png == null || disposed) return; // no picture (ShareShot.Capture logged why), or the UI was rebuilt meanwhile
+ var 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);
+ go.text = text[canShareFiles ? "share.native" : "share.download"];
+ fallback.style.display = DisplayStyle.None;
+ 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)));
+ 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.
+ covered.Clear();
+ foreach (var part in hudRoot.Children().Where(c => c != layer)) { covered.Add((part, part.enabledSelf)); part.SetEnabled(false); }
+ hudRoot.AddToClassList(OpenClass);
+ go.Focus();
+ // An element shown this frame may not take the focus yet (TurnReportPresenter does the same).
+ go.schedule.Execute(() => { if (IsOpen && layer.focusController?.focusedElement != go) go.Focus(); });
+ });
+ }
+
+ /// <summary>Share: the browser's share sheet, or the download and then the share links.</summary>
+ void Go()
+ {
+ if (!IsOpen) return;
+ ShareShot.Share(post.text, ShareShot.Itch);
+ if (!canShareFiles) { fallback.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);
+ }
+
+ public void Close()
+ {
+ if (!IsOpen) return;
+ closedAt = UnityEngine.Time.frameCount;
+ hudRoot.RemoveFromClassList(OpenClass);
+ foreach (var (part, enabled) in covered) part.SetEnabled(enabled);
+ covered.Clear();
+ opener?.Focus();
+ opener = null;
+ }
+
+ /// <summary>GameRoot's Escape poll and ScreenNav ask this first: it closes the panel and says the key is used, also in
+ /// the frame the panel was already closed, so the same Escape does not go on to close the screen or the turn report
+ /// under it.</summary>
+ public bool Escape()
+ {
+ if (IsOpen) { Close(); return true; }
+ return closedAt == UnityEngine.Time.frameCount;
+ }
+
+ public void Dispose()
+ {
+ disposed = true;
+ Close();
+ foreach (var unbind in unbindSites) unbind();
+ go.UnregisterCallback(onGoPointer, TrickleDown.TrickleDown);
+ go.UnregisterCallback(onGoSubmit, TrickleDown.TrickleDown);
+ settingsOpen.clicked -= OpenFromSettings;
+ reportOpen.clicked -= OpenFromReport;
+ close.clicked -= Close;
+ layer.UnregisterCallback(onCancel);
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/UI/SharePresenter.cs.meta b/unity/Assets/Scripts/UI/SharePresenter.cs.meta
new file mode 100644
index 000000000..4300f026f
--- /dev/null
+++ b/unity/Assets/Scripts/UI/SharePresenter.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 3f790164aa5be4556867349cb7deb6fb
\ No newline at end of file
diff --git a/unity/Assets/Scripts/UI/ShareShot.cs b/unity/Assets/Scripts/UI/ShareShot.cs
new file mode 100644
index 000000000..4eb98859e
--- /dev/null
+++ b/unity/Assets/Scripts/UI/ShareShot.cs
@@ -0,0 +1,122 @@
+#nullable enable
+using System;
+using System.Collections;
+using System.Globalization;
+using System.IO;
+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
+ /// 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),
+ /// the picture downloads instead and the panel offers the share links, which cannot carry an image.
+ /// <para><see cref="Keep"/>, <see cref="CanShareFiles"/> and <see cref="Share"/> are what the panel calls; tests put
+ /// recorders there (and put the defaults back), so nothing is saved or shared.</para></summary>
+ public static class ShareShot
+ {
+ /// <summary>The game's itch page, the link the post carries (owner's decision, 20 Oct 2026).</summary>
+ public 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" };
+
+ public static Action<byte[], string> Keep = DefaultKeep;
+ public static Func<bool> CanShareFiles = DefaultCanShareFiles;
+ public static Action<string, string> Share = DefaultShare;
+ /// <summary>True when the browser refused the share sheet (not a cancel) and the picture downloaded instead.</summary>
+ public static Func<bool> Failed = DefaultFailed;
+
+ /// <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>
+ 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),
+ "linkedin" => "https://www.linkedin.com/sharing/share-offsite/?url=" + Uri.EscapeDataString(Itch),
+ _ => throw new ArgumentException("no share link for " + site, nameof(site)),
+ };
+
+ /// <summary>The download's name: the in-game date the picture shows.</summary>
+ public static string FileName(DateTime date) => "statecraft-" + date.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture) + ".png";
+
+ /// <summary>A frame's size scaled down to <see cref="MaxSide"/> on its long side (never up).</summary>
+ public static Vector2Int Fit(int width, int height)
+ {
+ int longSide = Math.Max(width, height);
+ if (longSide <= MaxSide) return new Vector2Int(width, height);
+ double scale = (double)MaxSide / longSide;
+ return new Vector2Int(Math.Max(1, (int)Math.Round(width * scale)), Math.Max(1, (int)Math.Round(height * scale)));
+ }
+
+ /// <summary>The frame as a PNG, scaled down on the GPU first when it is larger than the cap.</summary>
+ public static byte[] Encode(Texture2D frame)
+ {
+ var size = Fit(frame.width, frame.height);
+ if (size.x == frame.width && size.y == frame.height) return frame.EncodeToPNG();
+ var rt = RenderTexture.GetTemporary(size.x, size.y, 0);
+ var active = RenderTexture.active;
+ var small = new Texture2D(size.x, size.y, TextureFormat.RGB24, false);
+ try
+ {
+ Graphics.Blit(frame, rt);
+ RenderTexture.active = rt;
+ small.ReadPixels(new Rect(0, 0, size.x, size.y), 0, 0);
+ small.Apply();
+ return small.EncodeToPNG();
+ }
+ finally
+ {
+ RenderTexture.active = active;
+ RenderTexture.ReleaseTemporary(rt);
+ if (Application.isPlaying) UnityEngine.Object.Destroy(small); else UnityEngine.Object.DestroyImmediate(small); // edit-mode tests
+ }
+ }
+
+ /// <summary>Captures the frame at its end, after the click that asked for it was handled (never inside it), as
+ /// VisualShots does, and hands over its PNG. GameRoot runs it as a coroutine.</summary>
+ public static IEnumerator Capture(Action<byte[]?> done)
+ {
+ yield return new WaitForEndOfFrame();
+ byte[]? png = null;
+ Texture2D? frame = null;
+ // A failed capture is logged and hands over null: the panel stays shut and the Share buttons keep working.
+ try { frame = ScreenCapture.CaptureScreenshotAsTexture(); png = Encode(frame); }
+ catch (Exception e) { Debug.LogException(e); }
+ finally { if (frame != null) UnityEngine.Object.Destroy(frame); }
+ done(png);
+ }
+
+#if UNITY_WEBGL && !UNITY_EDITOR
+ [System.Runtime.InteropServices.DllImport("__Internal")] static extern void StatecraftShareKeep(byte[] png, int length, string name);
+ [System.Runtime.InteropServices.DllImport("__Internal")] static extern int StatecraftShareCanShareFiles();
+ [System.Runtime.InteropServices.DllImport("__Internal")] static extern void StatecraftShareOnRelease(string text, string url);
+ public static void DefaultKeep(byte[] png, string name) => StatecraftShareKeep(png, png.Length, name);
+ public static bool DefaultCanShareFiles() => StatecraftShareCanShareFiles() == 1;
+ public static void DefaultShare(string text, string url) => StatecraftShareOnRelease(text, url);
+ [System.Runtime.InteropServices.DllImport("__Internal")] static extern int StatecraftShareFailed();
+ public static bool DefaultFailed() => StatecraftShareFailed() == 1;
+#else
+ static byte[]? kept; static string keptName = "";
+ public static void DefaultKeep(byte[] png, string name) { kept = png; keptName = name; }
+ /// <summary>The editor and desktop builds have no share sheet: the fallback, as in Firefox.</summary>
+ public static bool DefaultCanShareFiles() => false;
+ public static bool DefaultFailed() => false;
+ /// <summary>The download, outside the browser: the picture goes into the temporary cache, and the log says where.</summary>
+ public static void DefaultShare(string text, string url)
+ {
+ if (kept == null) return;
+ var path = Path.Combine(Application.temporaryCachePath, keptName);
+ File.WriteAllBytes(path, kept);
+ Debug.Log("SHARE picture saved to " + path);
+ }
+#endif
+ }
+}
diff --git a/unity/Assets/Scripts/UI/ShareShot.cs.meta b/unity/Assets/Scripts/UI/ShareShot.cs.meta
new file mode 100644
index 000000000..ace0d2c04
--- /dev/null
+++ b/unity/Assets/Scripts/UI/ShareShot.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: a6a560d758355cd5db9e0ef8f4dc00f6
\ No newline at end of file
diff --git a/unity/Assets/Scripts/UI/ShareShot.jslib b/unity/Assets/Scripts/UI/ShareShot.jslib
new file mode 100644
index 000000000..07b00565f
--- /dev/null
+++ b/unity/Assets/Scripts/UI/ShareShot.jslib
@@ -0,0 +1,65 @@
+// Sharing a post with a screenshot (#1170, ShareShot.cs). The game hands over the PNG when the share panel opens, and it
+// is kept here as a File, so it already exists when the player's Share press lands: navigator.share needs the real
+// gesture. Unity handles a press on the next frame, outside the browser's event, so the press arms a one-shot listener
+// for its release (pointerup on the canvas, or keyup), as ExternalLink.jslib does (#1168), and the release shares. Where
+// the browser cannot share files, the same release downloads the picture instead, and the panel shows the share links.
+// An unused arm disarms itself after 1.5 s, and a new press on the canvas (pointerdown) disarms it at once: a tap shorter
+// than a frame is released before Unity arms the listener, and a stray click would otherwise share or download (#1182
+// review, as on #1178). Nothing leaves the page unless the player shares or downloads it.
+mergeInto(LibraryManager.library, {
+ StatecraftShareKeep: function (pngPtr, length, namePtr) {
+ var bytes = HEAPU8.slice(pngPtr, pngPtr + length);
+ window.statecraftShareFile = new File([bytes], UTF8ToString(namePtr), { type: "image/png" });
+ },
+ StatecraftShareCanShareFiles: function () {
+ var file = window.statecraftShareFile;
+ try { return file && navigator.canShare && navigator.canShare({ files: [file] }) ? 1 : 0; } catch (e) { return 0; }
+ },
+ StatecraftShareFailed: function () { return window.statecraftShareFailed ? 1 : 0; },
+ StatecraftShareOnRelease: function (textPtr, urlPtr) {
+ var text = UTF8ToString(textPtr), url = UTF8ToString(urlPtr);
+ if (typeof window === "undefined") return;
+ if (window.statecraftShareDisarm) window.statecraftShareDisarm();
+ var canvas = document.querySelector("#unity-canvas") || document;
+ var timer;
+ var disarm = function () {
+ clearTimeout(timer);
+ canvas.removeEventListener("pointerup", go);
+ canvas.removeEventListener("pointerdown", disarm);
+ document.removeEventListener("keyup", go);
+ window.statecraftShareDisarm = null;
+ };
+ var download = function (file) {
+ var link = document.createElement("a");
+ link.href = URL.createObjectURL(file);
+ link.download = file.name;
+ document.body.appendChild(link);
+ link.click();
+ link.remove();
+ setTimeout(function () { URL.revokeObjectURL(link.href); }, 10000);
+ };
+ var go = function () {
+ disarm();
+ var file = window.statecraftShareFile;
+ if (!file) return;
+ var canShare = false;
+ try { canShare = !!(navigator.canShare && navigator.canShare({ files: [file] })); } catch (e) {}
+ if (!canShare) { download(file); return; }
+ // A cancelled sheet (AbortError) is not a failure. Any other refusal (an iframe without web-share, a share target
+ // that fails) downloads the picture instead, and StatecraftShareFailed tells the panel to show the share links.
+ navigator.share({ files: [file], text: text, url: url }).catch(function (e) {
+ if (e && e.name === "AbortError") return;
+ window.statecraftShareFailed = true;
+ download(file);
+ });
+ };
+ // Reset here, not on the release: the panel asks StatecraftShareFailed after this press, and after an earlier
+ // refused sheet it would read that old refusal and show the links before this share has run.
+ window.statecraftShareFailed = false;
+ canvas.addEventListener("pointerup", go);
+ canvas.addEventListener("pointerdown", disarm);
+ document.addEventListener("keyup", go);
+ window.statecraftShareDisarm = disarm;
+ timer = setTimeout(disarm, 1500);
+ },
+});
diff --git a/unity/Assets/Scripts/UI/ShareShot.jslib.meta b/unity/Assets/Scripts/UI/ShareShot.jslib.meta
new file mode 100644
index 000000000..8a0abbbd9
--- /dev/null
+++ b/unity/Assets/Scripts/UI/ShareShot.jslib.meta
@@ -0,0 +1,32 @@
+fileFormatVersion: 2
+guid: eec9aa2044744c0781501b69edbfd6b7
+PluginImporter:
+ externalObjects: {}
+ serializedVersion: 2
+ iconMap: {}
+ executionOrder: {}
+ defineConstraints: []
+ isPreloaded: 0
+ isOverridable: 0
+ isExplicitlyReferenced: 0
+ validateReferences: 1
+ platformData:
+ - first:
+ Any:
+ second:
+ enabled: 0
+ settings: {}
+ - first:
+ Editor: Editor
+ second:
+ enabled: 0
+ settings:
+ DefaultValueInitialized: true
+ - first:
+ WebGL: WebGL
+ second:
+ enabled: 1
+ settings: {}
+ userData:
+ assetBundleName:
+ assetBundleVariant:
diff --git a/unity/Assets/Tests/EditMode/HebrewUiTests.cs b/unity/Assets/Tests/EditMode/HebrewUiTests.cs
index d386c1810..c8a86c17b 100644
--- a/unity/Assets/Tests/EditMode/HebrewUiTests.cs
+++ b/unity/Assets/Tests/EditMode/HebrewUiTests.cs
@@ -298,6 +298,8 @@ public class HebrewUiTests
("settings-report", "feedback.open"), ("start-report", "feedback.open"), ("feedback-title", "feedback.open"), // #1169
("feedback-intro", "feedback.intro"), ("feedback-bug", "feedback.bug"), ("feedback-feature", "feedback.feature"),
("feedback-itch", "feedback.itch"), ("feedback-close", "report.close"),
+ ("settings-share", "share.open"), ("turn-report-share", "share.open"), ("share-title", "share.title"), // #1170
+ ("share-attach", "share.attach"), ("share-close", "report.close"),
("start-source", "start.source"), ("start-recording-credit", "start.recording_credit"),
("start-continue", "start.continue"), ("start-new-game", "start.new_game"),
};
diff --git a/unity/Assets/Tests/EditMode/SettingsScreenTests.cs b/unity/Assets/Tests/EditMode/SettingsScreenTests.cs
index 1ed4f9ce1..575d12ac3 100644
--- a/unity/Assets/Tests/EditMode/SettingsScreenTests.cs
+++ b/unity/Assets/Tests/EditMode/SettingsScreenTests.cs
@@ -596,8 +596,8 @@ public class SettingsScreenTests
}
/// <summary>The open screen at 1280x720 (the issue's size), in English and Hebrew, at each UI scale: the title, the option's name and its
- /// button inside the screen, below the top bar and inside the window, each text whole (on one line or wrapped). 125% and
- /// 150% run as if verified (VerifyOnEveryShape): the screen itself must hold them once the rest of the UI does.</summary>
+ /// button (the Community row's three: Star, Report and Share) inside the screen, below the top bar and inside the window,
+ /// each text whole (on one line or wrapped). 125% and 150% run as if verified (VerifyOnEveryShape): the screen itself must hold them once the rest of the UI does.</summary>
[UnityTest]
public IEnumerator TheOpenScreenFitsAt1280x720InBothLanguages([Values(100, 125, 150)] int uiScale)
{
@@ -637,16 +637,21 @@ public class SettingsScreenTests
"settings-quality-label", "settings-quality-auto", "settings-quality-high", "settings-quality-low",
"settings-language-label", "settings-language-en", "settings-language-he", "settings-language-note",
"settings-uiscale-label", "settings-uiscale-100", "settings-uiscale-125", "settings-uiscale-150",
- "settings-community-label", "settings-star", "settings-report" })
+ "settings-community-label", "settings-star", "settings-report", "settings-share" })
{
var e = root.Q<TextElement>(name);
Assert.IsFalse(string.IsNullOrWhiteSpace(e.text), $"{at}: {name} has its text");
Assert.IsTrue(Inside(e.worldBound, screen), $"{at}: {name} {e.worldBound} leaves the screen {screen}");
Assert.IsTrue(UiLayoutTests.TextFits(e), $"{at}: {name} '{e.text}' is cut ({e.contentRect})");
}
- // The Community row (#1168) runs right to left in Hebrew, like the language row: the button left of its name.
- var starAt = root.Q("settings-star").worldBound; var communityAt = root.Q("settings-community-label").worldBound;
- Assert.AreEqual(hebrew, starAt.xMax <= communityAt.xMin + 0.5f, $"{at}: the Star button {starAt} beside its name {communityAt}");
+ // The Community row (#1168) runs right to left in Hebrew, like the language row: its buttons (Star, #1169's
+ // Report and #1170's Share) left of its name.
+ var communityAt = root.Q("settings-community-label").worldBound;
+ foreach (var button in new[] { "settings-star", "settings-report", "settings-share" })
+ {
+ var buttonAt = root.Q(button).worldBound;
+ Assert.AreEqual(hebrew, buttonAt.xMax <= communityAt.xMin + 0.5f, $"{at}: {button} {buttonAt} beside its name {communityAt}");
+ }
// The set choice reads as set while it has the focus a press leaves on it: dark text on the gold fill.
var low = root.Q<Button>("settings-quality-low");
using (var e = NavigationSubmitEvent.GetPooled()) { e.target = low; low.SendEvent(e); }
diff --git a/unity/Assets/Tests/EditMode/ShareShotTests.cs b/unity/Assets/Tests/EditMode/ShareShotTests.cs
new file mode 100644
index 000000000..8a0f66d0d
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/ShareShotTests.cs
@@ -0,0 +1,205 @@
+#nullable enable
+using System;
+using System.Collections.Generic;
+using NUnit.Framework;
+using Statecraft.Game;
+using Statecraft.Game.UI;
+using Statecraft.Sim;
+using UnityEditor;
+using UnityEngine;
+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>
+public class ShareShotTests
+{
+ static readonly Content C = ContentLoader.Load(Paths.Content);
+ static UiText En => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);
+ static UiText He => UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.StringsHebrew).text, "strings.he.yaml");
+
+ [Test]
+ public void ThePostNamesTheGameTheDateTheTurnAndTheItchPage()
+ {
+ Assert.AreEqual("I'm running Israel in 1948 in Statecraft: Israel, a free open-source strategy game. 15 May 1948, turn 0. "
+ + "Play: https://eyalgolan.itch.io/statecraft-israel", ShareShot.Text(En, "15 May 1948", 0));
+ var he = ShareShot.Text(He, "15 במאי 1948", 3);
+ StringAssert.Contains("15 במאי 1948", he);
+ StringAssert.Contains("3", he);
+ StringAssert.EndsWith("https://eyalgolan.itch.io/statecraft-israel", he);
+ Assert.IsTrue(UiDirection.HasRightToLeft(he), "the Hebrew post is Hebrew");
+ }
+
+ [Test]
+ public void TheShareLinksCarryTheTextAndTheUrlEncoded()
+ {
+ const string text = "Play: a & b #1, 15 במאי";
+ var enc = Uri.EscapeDataString(text); var url = Uri.EscapeDataString(ShareShot.Itch);
+ Assert.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://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");
+ }
+
+ [Test]
+ public void ThePictureIsCappedAt1920OnTheLongSide()
+ {
+ Assert.AreEqual(new Vector2Int(1280, 720), ShareShot.Fit(1280, 720));
+ Assert.AreEqual(new Vector2Int(1920, 1080), ShareShot.Fit(3840, 2160));
+ Assert.AreEqual(new Vector2Int(887, 1920), ShareShot.Fit(1170, 2532), "a phone held upright, DPR 3");
+ var big = new Texture2D(3000, 1000, TextureFormat.RGB24, false);
+ try
+ {
+ var png = ShareShot.Encode(big);
+ var back = new Texture2D(2, 2);
+ Assert.IsTrue(back.LoadImage(png));
+ Assert.AreEqual(1920, back.width); Assert.AreEqual(640, back.height);
+ Object.DestroyImmediate(back);
+ }
+ finally { Object.DestroyImmediate(big); }
+ }
+
+ [Test]
+ public void TheDownloadIsNamedForTheInGameDate()
+ {
+ Assert.AreEqual("statecraft-1948-05-15.png", ShareShot.FileName(new DateTime(1948, 5, 15)));
+ }
+
+ /// <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>
+ [Test]
+ public void SharingCapturesFirstAndOffersTheSheetOrTheFallback([Values(false, true)] bool canShareFiles, [Values(false, true)] bool hebrew)
+ {
+ var text = hebrew ? He : En;
+ var opened = new List<string>(); var kept = new List<string>(); var shared = new List<string>();
+ bool shownAtCapture = true;
+ ExternalLink.Opener = opened.Add;
+ ShareShot.Keep = (png, name) => kept.Add(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);
+ SharePresenter? made = null;
+ using var share = made = new SharePresenter(ui.Root, bridge, text, done =>
+ {
+ shownAtCapture = made!.IsOpen;
+ done(new byte[] { 1, 2, 3 });
+ });
+ var button = ui.Q<Button>("settings-share");
+ Assert.AreEqual(text["share.open"], button.text);
+ UiTestKit.Press(button);
+ Assert.IsFalse(shownAtCapture, "the panel is not in the picture");
+ Assert.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.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(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);
+ }
+ 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");
+ Assert.IsTrue(ui.Q<VisualElement>("screen-settings").enabledSelf);
+ }
+ finally
+ {
+ ExternalLink.Opener = ExternalLink.Default;
+ ShareShot.Keep = ShareShot.DefaultKeep; ShareShot.CanShareFiles = ShareShot.DefaultCanShareFiles; ShareShot.Share = ShareShot.DefaultShare;
+ }
+ }
+
+ /// <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]
+ public void EscapeInTheSharePanelLeavesTheSettingsScreenOpen()
+ {
+ ShareShot.Keep = (png, name) => { };
+ try
+ {
+ using var ui = new UiTestKit();
+ var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), En);
+ using var nav = new ScreenNav(ui.Root);
+ using var share = new SharePresenter(ui.Root, bridge, En, done => done(new byte[] { 1 }));
+ nav.TakesEscape = share.Escape;
+ nav.Open("settings");
+ UiTestKit.Press(ui.Q<Button>("settings-share"));
+ Assert.IsTrue(share.IsOpen);
+ var go = ui.Q<Button>("share-go");
+ using (var esc = NavigationCancelEvent.GetPooled()) { esc.target = go; go.SendEvent(esc); }
+ Assert.IsFalse(share.IsOpen, "Esc closes the panel");
+ Assert.AreEqual("settings", nav.Current, "and only the panel");
+ }
+ finally { ShareShot.Keep = ShareShot.DefaultKeep; }
+ }
+
+ /// <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
+ /// Share working.</summary>
+ [UnityEngine.TestTools.UnityTest]
+ public System.Collections.IEnumerator ARefusedShareSheetShowsTheShareLinks()
+ {
+ bool failed = false, broken = true;
+ ShareShot.Keep = (png, name) => { }; ShareShot.CanShareFiles = () => true; ShareShot.Share = (a, b) => { };
+ ShareShot.Failed = () => failed;
+ var ui = new UiTestKit();
+ try
+ {
+ var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), En);
+ using var share = new SharePresenter(ui.Root, bridge, En, done => done(broken ? null : new byte[] { 1 }));
+ UiTestKit.Press(ui.Q<Button>("settings-share"));
+ Assert.IsFalse(share.IsOpen, "no picture, no panel");
+ broken = false;
+ UiTestKit.Press(ui.Q<Button>("settings-share"));
+ Assert.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");
+ failed = true;
+ var until = Time.realtimeSinceStartup + 5f; // the panel looks every 250 ms
+ while (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");
+ }
+ finally
+ {
+ ui.Dispose();
+ ShareShot.Keep = ShareShot.DefaultKeep; ShareShot.CanShareFiles = ShareShot.DefaultCanShareFiles;
+ ShareShot.Share = ShareShot.DefaultShare; ShareShot.Failed = ShareShot.DefaultFailed;
+ }
+ }
+
+ /// <summary>The turn report's Share opens the same panel over the report.</summary>
+ [Test]
+ public void TheTurnReportHasAShareButton()
+ {
+ ShareShot.Keep = (png, name) => { };
+ try
+ {
+ using var ui = new UiTestKit();
+ var bridge = new SimBridge(GameSession.New(C, GoldenRun.Seed, Mode.Historical), En);
+ using var share = new SharePresenter(ui.Root, bridge, En, done => done(new byte[] { 1 }));
+ Assert.AreEqual(En["share.open"], ui.Q<Button>("turn-report-share").text);
+ UiTestKit.Press(ui.Q<Button>("turn-report-share"));
+ Assert.IsTrue(share.IsOpen);
+ UiTestKit.Press(ui.Q<Button>("share-close"));
+ Assert.IsFalse(share.IsOpen);
+ }
+ finally { ShareShot.Keep = ShareShot.DefaultKeep; }
+ }
+}
diff --git a/unity/Assets/Tests/EditMode/ShareShotTests.cs.meta b/unity/Assets/Tests/EditMode/ShareShotTests.cs.meta
new file mode 100644
index 000000000..3f4e3abce
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/ShareShotTests.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 53aabc5a52b02022587cbd0102d236e8
\ No newline at end of file
diff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxml
index aa56d4a83..5173db410 100644
--- a/unity/Assets/UI/Game.uxml
+++ b/unity/Assets/UI/Game.uxml
@@ -379,12 +379,14 @@
</ui:VisualElement>
</ui:VisualElement>
<!-- Community (#1168): "Star on GitHub" opens the repository in a new tab (ExternalLink); "Report a bug or idea"
- opens the report panel (#1169, FeedbackPresenter). -->
+ opens the report panel (#1169, FeedbackPresenter); "Share" opens the share panel with a picture of the game
+ (#1170, SharePresenter). -->
<ui:VisualElement class="row settings-row">
<ui:Label name="settings-community-label" text="Community" class="settings-name" />
- <ui:VisualElement class="row settings-choices">
+ <ui:VisualElement class="row settings-choices settings-community-choices">
<ui:Button name="settings-star" text="Star on GitHub" class="settings-switch" />
<ui:Button name="settings-report" text="Report a bug or idea" class="settings-switch" />
+ <ui:Button name="settings-share" text="Share" class="settings-switch" />
</ui:VisualElement>
</ui:VisualElement>
<Statecraft.Game.UI.UiFrame />
@@ -414,6 +416,7 @@
<ui:VisualElement class="screen-header"><ui:Label name="turn-report-title" class="title" /><ui:Label name="turn-report-intro" class="muted" /></ui:VisualElement>
<ui:ScrollView name="turn-report-rows" class="turn-report-rows" />
<ui:VisualElement class="row turn-report-actions">
+ <ui:Button name="turn-report-share" text="Share" />
<ui:Button name="turn-report-all" />
<ui:Button name="turn-report-close" />
</ui:VisualElement>
@@ -503,6 +506,26 @@
<Statecraft.Game.UI.UiFrame />
</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. 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:Label name="share-post" class="share-post" />
+ <ui:Button name="share-go" class="share-go" />
+ <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 />
+ </ui:VisualElement>
+ </ui:VisualElement>
<ui:Label name="toast" class="panel toast" />
<!-- The name of an icon-only button, beside it on hover and on keyboard focus (HoverTip; UI Toolkit draws `tooltip`
only in Editor UI). Last, so it draws over the panels; it takes no clicks. -->
diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.uss
index 13e5e7149..bf2fcebc6 100644
--- a/unity/Assets/UI/Statecraft.uss
+++ b/unity/Assets/UI/Statecraft.uss
@@ -462,6 +462,10 @@ Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4);
/* The quality choice's buttons sit side by side; the one that is set is marked by a gold fill and dark text, not only a
border colour, and keeps it while hovered or focused (Button:hover and :focus would otherwise win). */
.settings-choices { flex-shrink: 0; }
+/* The Community row's three buttons (Star, Report, Share) are wider than the screen leaves them in Hebrew at 125%: they
+ wrap onto a second line instead, and the row's name keeps its width (SettingsScreenTests, 1280x720). */
+.settings-community-choices { flex-shrink: 1; flex-wrap: wrap; }
+#settings-community-label { flex-shrink: 0; }
.settings-choice-selected, .settings-choice-selected:hover, .settings-choice-selected:focus { background-color: var(--gold); color: var(--navy-solid); }
/* The regular cut's thin strokes fade on the gold. Only as specific as ".lang-he Button", which comes later and keeps
the Hebrew face in Hebrew. */
@@ -533,6 +537,17 @@ 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-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-go { margin-top: 12px; }
+.share-attach { 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; }
/* A top-bar number's explanation (MeterTip, #1037): under the bar, wrapped, kept inside the window by MeterTip. */
.meter-tip {
display: none; position: absolute; max-width: 420px; padding: 6px 10px;
diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yaml
index 688ca5996..cc45273b9 100644
--- a/unity/Assets/UI/strings.en.yaml
+++ b/unity/Assets/UI/strings.en.yaml
@@ -118,6 +118,14 @@ feedback.intro: "The form opens with these lines filled in. Nothing is sent unti
feedback.bug: "Report a bug"
feedback.feature: "Suggest a feature"
feedback.itch: "No GitHub account? Comment on itch"
+# "Share" (#1170, SharePresenter): the button beside Star and on the turn report, the panel, and the post, which gets the
+# in-game date ({0}), the turn ({1}) and the itch URL ({2}).
+share.open: "Share"
+share.title: "Share a picture of the game"
+share.post: "I'm running Israel in 1948 in Statecraft: Israel, a free open-source strategy game. {0}, turn {1}. Play: {2}"
+share.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."
event.draft: "DRAFT"
start.source: "From the Declaration of the Establishment of the State of Israel (Official Gazette No. 1, 14 May 1948) and its official English translation. Painting: AI-generated."
start.recording_credit: "Recording: Ralph Hellinger, Israel State Archives"
diff --git a/unity/Assets/UI/strings.he.yaml b/unity/Assets/UI/strings.he.yaml
index 7664c3127..8c3901033 100644
--- a/unity/Assets/UI/strings.he.yaml
+++ b/unity/Assets/UI/strings.he.yaml
@@ -120,6 +120,18 @@ feedback.intro: "הטופס נפתח עם השורות האלה כבר ממול
feedback.bug: "דיווח על באג"
feedback.feature: "הצעה לתכונה חדשה"
feedback.itch: "אין חשבון בגיטהאב? תגובה בדף המשחק באיץ׳"
+# "Share" (#1170, SharePresenter): the button and the panel's title ("sharing a picture from the game"), the post, Share,
+# "downloading the picture", and the note ("these sites do not take a picture through a link: the downloaded picture is
+# to be attached to the post"). The post opens with a noun phrase ("running the State of Israel in 1948 in the game
+# Statecraft: Israel, ...") instead of the English "I'm running", which in Hebrew would agree with the player's gender;
+# it keeps the game's name and the URL in Latin letters, as README.he.md does. Approved by Beri, a native speaker,
+# on #1182 (20 Oct 2026). For the native reviewer (#564).
+share.open: "שיתוף"
+share.title: "שיתוף תמונה מהמשחק"
+share.post: "ניהול מדינת ישראל ב־1948 במשחק Statecraft: Israel, משחק אסטרטגיה חינמי בקוד פתוח. {0}, תור {1}. לשחק: {2}"
+share.native: "שיתוף"
+share.download: "הורדת התמונה"
+share.attach: "האתרים האלה לא מקבלים תמונה דרך קישור: יש לצרף לפוסט את התמונה שהורדה."
event.draft: "טיוטה"
start.source: "מתוך ההכרזה על הקמת מדינת ישראל (עיתון רשמי מס׳ 1, 14 במאי 1948) ותרגומה הרשמי לאנגלית. הציור נוצר בבינה מלאכותית."
# The recordist's name as the Israel State Archives spells it in its own description of item