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: report a bug or suggest a feature from the game, prefilled GitHub forms with an itch fallback (Fixes #1169) (#1179)

Beri5ec914f28341
diff --git a/changelog.d/1169.md b/changelog.d/1169.md
new file mode 100644
index 000000000..c17e1f1fa
--- /dev/null
+++ b/changelog.d/1169.md
@@ -0,0 +1,6 @@
+- A "Report a bug or idea" button, beside Star in Settings and in a quiet row under the start screen's buttons, opens a
+ small panel with three choices: GitHub's bug form prefilled with a title, the game's version and content hash, and the
+ browser's user agent and screen size; the feature form with its title; and the itch page's comments for a player with
+ no GitHub account. The panel shows every prefilled line before anything opens, the game sends nothing itself, and each
+ value is URL-encoded with the whole link kept under GitHub's 8000 characters (`ReportLinks`). English and Hebrew
+ labels; Beri approved the Hebrew as a native speaker (refs #564; fixes #1169).
diff --git a/unity/Assets/Scripts/UI/ExternalLink.jslib b/unity/Assets/Scripts/UI/ExternalLink.jslib
index 8f2168163..b906f356d 100644
--- a/unity/Assets/Scripts/UI/ExternalLink.jslib
+++ b/unity/Assets/Scripts/UI/ExternalLink.jslib
@@ -30,4 +30,12 @@ mergeInto(LibraryManager.library, {
document.addEventListener("keyup", open);
timer = setTimeout(disarm, 1500);
},
+ // The bug form's platform line (#1169, ReportLinks.Environment): the browser's user agent and screen size, nothing else.
+ StatecraftBrowserEnv: function () {
+ var env = navigator.userAgent + ", screen " + screen.width + "x" + screen.height;
+ var size = lengthBytesUTF8(env) + 1;
+ var buffer = _malloc(size);
+ stringToUTF8(env, buffer, size);
+ return buffer;
+ },
});
diff --git a/unity/Assets/Scripts/UI/FeedbackPresenter.cs b/unity/Assets/Scripts/UI/FeedbackPresenter.cs
new file mode 100644
index 000000000..59c8bd6e5
--- /dev/null
+++ b/unity/Assets/Scripts/UI/FeedbackPresenter.cs
@@ -0,0 +1,116 @@
+#nullable enable
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using UnityEngine.UIElements;
+
+namespace Statecraft.Game.UI
+{
+ /// <summary>"Report a bug or idea" (#1169): the button in the Settings screen's Community row and the one under the start
+ /// screen's buttons open a small panel over everything, with three choices: GitHub's bug form, its feature form (both
+ /// prefilled, ReportLinks) and the itch page's comments for a player with no GitHub account. The panel shows, under each
+ /// GitHub choice, the exact lines that form opens with, so nothing goes anywhere the player has not seen; the game sends
+ /// nothing itself, the player submits on GitHub. Each choice opens through ExternalLink, inside the real press.
+ /// <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.
+ /// The platform line is read on each opening (a resized window changes the screen size).</para></summary>
+ public sealed class FeedbackPresenter : IDisposable
+ {
+ /// <summary>On the "root" element while the panel shows.</summary>
+ public const string OpenClass = "feedback-open";
+
+ readonly VisualElement hudRoot, layer;
+ readonly Button bug, feature, itch, close, settingsOpen, startOpen;
+ readonly Label bugPreview, featurePreview;
+ readonly string version;
+ readonly Action unbindFeature, unbindItch;
+ readonly EventCallback<NavigationCancelEvent> onCancel;
+ Action unbindBug = () => { };
+ Button? opener;
+ int closedAt = -1;
+ readonly List<(VisualElement part, bool enabled)> covered = new List<(VisualElement, bool)>();
+
+ /// <param name="version">ReportLinks.Version: the app's version and the content hash.</param>
+ public FeedbackPresenter(VisualElement root, UiText? text, string version)
+ {
+ this.version = version;
+ hudRoot = root.Q("root") ?? root;
+ layer = root.Q("feedback-layer");
+ bug = layer.Q<Button>("feedback-bug"); feature = layer.Q<Button>("feedback-feature");
+ itch = layer.Q<Button>("feedback-itch"); close = layer.Q<Button>("feedback-close");
+ bugPreview = layer.Q<Label>("feedback-bug-preview"); featurePreview = layer.Q<Label>("feedback-feature-preview");
+ settingsOpen = root.Q<Button>("settings-report"); startOpen = root.Q<Button>("start-report");
+ if (text != null)
+ {
+ settingsOpen.text = startOpen.text = layer.Q<Label>("feedback-title").text = text["feedback.open"];
+ layer.Q<Label>("feedback-intro").text = text["feedback.intro"];
+ bug.text = text["feedback.bug"]; feature.text = text["feedback.feature"];
+ itch.text = text["feedback.itch"]; close.text = text["report.close"];
+ }
+ featurePreview.text = Preview(ReportLinks.FeatureFields());
+ unbindFeature = ExternalLink.Bind(feature, ReportLinks.Feature());
+ unbindItch = ExternalLink.Bind(itch, ReportLinks.Itch);
+ settingsOpen.clicked += OpenFromSettings;
+ startOpen.clicked += OpenFromStart;
+ close.clicked += Close;
+ onCancel = e => { Close(); e.StopPropagation(); };
+ layer.RegisterCallback(onCancel);
+ }
+
+ public bool IsOpen => hudRoot.ClassListContains(OpenClass);
+
+ void OpenFromSettings() => Open(settingsOpen);
+ void OpenFromStart() => Open(startOpen);
+
+ /// <summary>Shows the panel with the platform line read now; <paramref name="from"/> gets the focus back on Close.</summary>
+ public void Open(Button? from = null)
+ {
+ if (IsOpen) return;
+ opener = from;
+ var env = ReportLinks.Environment();
+ bugPreview.text = Preview(ReportLinks.BugFields(version, env));
+ unbindBug();
+ unbindBug = ExternalLink.Bind(bug, ReportLinks.Bug(version, env));
+ // 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);
+ bug.Focus();
+ // An element shown this frame may not take the focus yet (TurnReportPresenter does the same).
+ bug.schedule.Execute(() => { if (IsOpen && layer.focusController?.focusedElement != bug) bug.Focus(); });
+ }
+
+ 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: closes the panel and says the key is used, also in the frame the panel's own
+ /// Cancel already closed it, 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;
+ }
+
+ /// <summary>The lines a form opens with, one per field, by the template's field id ("title: Bug: ").</summary>
+ static string Preview((string id, string value)[] fields) => string.Join("\n", fields.Select(f => $"{f.id}: {f.value}"));
+
+ public void Dispose()
+ {
+ Close();
+ unbindBug(); unbindFeature(); unbindItch();
+ settingsOpen.clicked -= OpenFromSettings;
+ startOpen.clicked -= OpenFromStart;
+ close.clicked -= Close;
+ layer.UnregisterCallback(onCancel);
+ }
+ }
+}
diff --git a/unity/Assets/Scripts/UI/FeedbackPresenter.cs.meta b/unity/Assets/Scripts/UI/FeedbackPresenter.cs.meta
new file mode 100644
index 000000000..3eda95413
--- /dev/null
+++ b/unity/Assets/Scripts/UI/FeedbackPresenter.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: 96c22a6646e6c3aed95522972f6d32f1
\ No newline at end of file
diff --git a/unity/Assets/Scripts/UI/GameRoot.cs b/unity/Assets/Scripts/UI/GameRoot.cs
index f81935e73..6445ab039 100644
--- a/unity/Assets/Scripts/UI/GameRoot.cs
+++ b/unity/Assets/Scripts/UI/GameRoot.cs
@@ -67,6 +67,7 @@ namespace Statecraft.Game.UI
FirstTurnGuidePresenter? guide;
/// <summary>Tests: the first-turn guide of the last Begin.</summary>
internal FirstTurnGuidePresenter? Guide => guide;
+ FeedbackPresenter? feedback;
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>
@@ -266,6 +267,10 @@ namespace Statecraft.Game.UI
// own settings must not leak into a test. Each Begin (New Game too) reads the file again.
// The language switch (#1036) builds every screen again in the new language over this game (SwitchLanguage).
Own(new SettingsPresenter(root, text, SettingsFile(), language => SwitchLanguage(inputs, language), panel: document.panelSettings, audio: audio));
+ // "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!));
@@ -552,7 +557,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; 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; 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;
@@ -685,7 +690,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).
- if (UnityEngine.InputSystem.Keyboard.current?.escapeKey.wasPressedThisFrame == 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) 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(); }
// 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/ReportLinks.cs b/unity/Assets/Scripts/UI/ReportLinks.cs
new file mode 100644
index 000000000..a78fe4f21
--- /dev/null
+++ b/unity/Assets/Scripts/UI/ReportLinks.cs
@@ -0,0 +1,58 @@
+#nullable enable
+using System;
+using System.Linq;
+using UnityEngine;
+
+namespace Statecraft.Game.UI
+{
+ /// <summary>The links the "Report a bug or idea" panel opens (#1169, FeedbackPresenter). Both issue templates are YAML
+ /// forms, which GitHub prefills by field id from the query and where it ignores `body=` and `labels=`: the bug form
+ /// gets its title, `version` and `env`, and leaves `what` and `repro` for the player; the feature form gets its title
+ /// only. Nothing personal goes in: the version is the app's version and the content hash, the platform the browser's
+ /// user agent and screen size, and the panel shows every value before anything opens. Each value is clipped to
+ /// <see cref="MaxValue"/> characters, so the whole URL stays under GitHub's <see cref="MaxUrl"/>.</summary>
+ public static class ReportLinks
+ {
+ public const string BugTitle = "Bug: ", FeatureTitle = "Idea: ";
+ /// <summary>The game's itch page; its comments are at the bottom, for a player with no GitHub account.</summary>
+ public const string Itch = "https://eyalgolan.itch.io/statecraft-israel";
+ /// <summary>GitHub refuses a longer issue URL.</summary>
+ public const int MaxUrl = 8000;
+ /// <summary>A character encodes to at most 9 (three %XX), so two such values and the rest stay under MaxUrl.</summary>
+ public const int MaxValue = 400;
+
+ /// <summary>The version line: GameBoot logs the same hash as `BOOT OK content ...`. The build carries no commit SHA.</summary>
+ public static string Version(string appVersion, string contentHash) => $"{appVersion} / content {contentHash}";
+
+ /// <summary>The bug form's prefilled fields, as the panel shows them and the URL carries them.</summary>
+ public static (string id, string value)[] BugFields(string version, string env) =>
+ new[] { ("title", BugTitle), ("version", Clip(version)), ("env", Clip(env)) };
+
+ public static (string id, string value)[] FeatureFields() => new[] { ("title", FeatureTitle) };
+
+ public static string Bug(string version, string env) => Url("bug_report.yml", BugFields(version, env));
+
+ public static string Feature() => Url("feature_request.yml", FeatureFields());
+
+ static string Url(string template, (string id, string value)[] fields) =>
+ ExternalLink.Repository + "/issues/new?template=" + template
+ + string.Concat(fields.Select(f => "&" + f.id + "=" + Uri.EscapeDataString(f.value)));
+
+ static string Clip(string value)
+ {
+ if (value.Length <= MaxValue) return value;
+ int n = char.IsHighSurrogate(value[MaxValue - 1]) ? MaxValue - 1 : MaxValue; // never half a pair
+ return value.Substring(0, n);
+ }
+
+ /// <summary>The platform line: in the browser its user agent and screen size (ExternalLink.jslib); elsewhere the
+ /// operating system, the Unity version and the screen size.</summary>
+#if UNITY_WEBGL && !UNITY_EDITOR
+ [System.Runtime.InteropServices.DllImport("__Internal")] static extern string StatecraftBrowserEnv();
+ public static string Environment() => StatecraftBrowserEnv() ?? "";
+#else
+ public static string Environment() =>
+ $"{SystemInfo.operatingSystem} / Unity {Application.unityVersion}, screen {Screen.width}x{Screen.height}";
+#endif
+ }
+}
diff --git a/unity/Assets/Scripts/UI/ReportLinks.cs.meta b/unity/Assets/Scripts/UI/ReportLinks.cs.meta
new file mode 100644
index 000000000..fd00258ec
--- /dev/null
+++ b/unity/Assets/Scripts/UI/ReportLinks.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: b107598632c73d169b1443a0b8291ab0
\ No newline at end of file
diff --git a/unity/Assets/Scripts/UI/ScreenNav.cs b/unity/Assets/Scripts/UI/ScreenNav.cs
index 179be958e..d6ab74738 100644
--- a/unity/Assets/Scripts/UI/ScreenNav.cs
+++ b/unity/Assets/Scripts/UI/ScreenNav.cs
@@ -163,13 +163,17 @@ 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
+ /// 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;
+
public ScreenNav(VisualElement root)
{
this.root = root;
// Escape (the UI map's Cancel, from any focused element or the panel) closes the open screen. NavigationGuard
// handles only NavigationMoveEvent, so the two never meet. GameRoot also polls the Escape key for the case where
// no element has the focus (CloseOnEscape).
- onCancel = e => { if (Close()) e.StopPropagation(); };
+ onCancel = e => { if (TakesEscape?.Invoke() == true || Close()) e.StopPropagation(); };
root.RegisterCallback(onCancel, TrickleDown.TrickleDown);
onGeometry = e => FitCloseButtons();
root.RegisterCallback(onGeometry);
diff --git a/unity/Assets/Tests/EditMode/HebrewUiTests.cs b/unity/Assets/Tests/EditMode/HebrewUiTests.cs
index 7cbd89ebf..d386c1810 100644
--- a/unity/Assets/Tests/EditMode/HebrewUiTests.cs
+++ b/unity/Assets/Tests/EditMode/HebrewUiTests.cs
@@ -295,6 +295,9 @@ public class HebrewUiTests
("settings-language-label", "settings.language"), ("settings-language-note", "settings.language.note"),
("settings-uiscale-label", "settings.uiscale"),
("settings-community-label", "settings.community"), ("settings-star", "community.star"), ("start-star", "community.star"),
+ ("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"),
("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/ReportLinksTests.cs b/unity/Assets/Tests/EditMode/ReportLinksTests.cs
new file mode 100644
index 000000000..afd3478da
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/ReportLinksTests.cs
@@ -0,0 +1,78 @@
+#nullable enable
+using System;
+using System.IO;
+using System.Linq;
+using System.Text.RegularExpressions;
+using NUnit.Framework;
+using Statecraft.Game;
+using Statecraft.Game.UI;
+
+/// <summary>#1169: the two prefilled GitHub links ReportLinks builds. GitHub fills a YAML issue form by field id and ignores
+/// `body=` and `labels=` there, so every key after the template must be a field id of that template file; the values are
+/// URL-encoded and the whole URL stays under GitHub's 8000-character limit, however long the browser's user agent.</summary>
+public class ReportLinksTests
+{
+ const string Issues = "https://github.com/eyalgolan/statecraft-israel/issues/new?";
+
+ static string[] FieldIds(string template) =>
+ Regex.Matches(File.ReadAllText(Path.Combine(Paths.RepoRoot, ".github", "ISSUE_TEMPLATE", template)), @"^\s+id:\s*(\S+)\s*$", RegexOptions.Multiline)
+ .Cast<Match>().Select(m => m.Groups[1].Value).ToArray();
+
+ static string[] Keys(string url) =>
+ url.Substring(url.IndexOf('?') + 1).Split('&').Select(p => p.Split('=')[0]).ToArray();
+
+ static string Value(string url, string key) =>
+ Uri.UnescapeDataString(url.Substring(url.IndexOf('?') + 1).Split('&').Single(p => p.StartsWith(key + "=")).Substring(key.Length + 1));
+
+ [Test]
+ public void TheBugLinkFillsTheBugFormByItsFieldIds()
+ {
+ var url = ReportLinks.Bug("0.1.0 / content ab12", "Mozilla/5.0 (X11; Linux x86_64) Chrome/141 & co, screen 1920x1080");
+ StringAssert.StartsWith(Issues + "template=bug_report.yml&", url);
+ CollectionAssert.AreEqual(new[] { "template", "title", "version", "env" }, Keys(url));
+ var ids = FieldIds("bug_report.yml");
+ foreach (var key in Keys(url).Skip(2)) CollectionAssert.Contains(ids, key, $"{key} is a field id of bug_report.yml");
+ // What the player writes stays empty: the form's own fields, never prefilled.
+ CollectionAssert.IsSubsetOf(new[] { "what", "repro" }, ids);
+ Assert.AreEqual(ReportLinks.BugTitle, Value(url, "title"));
+ Assert.AreEqual("0.1.0 / content ab12", Value(url, "version"));
+ Assert.AreEqual("Mozilla/5.0 (X11; Linux x86_64) Chrome/141 & co, screen 1920x1080", Value(url, "env"));
+ // Each value encoded: a space, '/', '&', ';' and ':' never reach the query raw.
+ StringAssert.Contains("&version=0.1.0%20%2F%20content%20ab12&", url);
+ StringAssert.Contains("&env=Mozilla%2F5.0%20%28X11%3B%20Linux%20x86_64%29%20Chrome%2F141%20%26%20co%2C%20screen%201920x1080", url);
+ StringAssert.DoesNotContain("body=", url);
+ StringAssert.DoesNotContain("labels=", url);
+ }
+
+ [Test]
+ public void TheFeatureLinkCarriesOnlyItsTitle()
+ {
+ var url = ReportLinks.Feature();
+ Assert.AreEqual(Issues + "template=feature_request.yml&title=" + Uri.EscapeDataString(ReportLinks.FeatureTitle), url);
+ Assert.IsTrue(File.Exists(Path.Combine(Paths.RepoRoot, ".github", "ISSUE_TEMPLATE", "feature_request.yml")));
+ StringAssert.DoesNotContain("body=", url);
+ StringAssert.DoesNotContain("labels=", url);
+ }
+
+ /// <summary>The version line is the app's version and the content hash GameBoot logs (`BOOT OK content ...`); the
+ /// build has no commit SHA, so none is made up.</summary>
+ [Test]
+ public void TheVersionIsTheAppVersionAndTheContentHash()
+ {
+ Assert.AreEqual("0.1.0 / content 9f3a", ReportLinks.Version("0.1.0", "9f3a"));
+ }
+
+ /// <summary>A user agent of any length, even of characters that encode to nine each, keeps the URL under 8000
+ /// characters; the clipped value is the one the panel shows (BugFields), so the player sees what is sent.</summary>
+ [Test]
+ public void TheUrlStaysUnderTheCapAndShowsWhatItCarries([Values("a", "ש", "😀")] string unit)
+ {
+ var huge = string.Concat(Enumerable.Repeat(unit, 10000));
+ var url = ReportLinks.Bug(huge, huge);
+ Assert.Less(url.Length, ReportLinks.MaxUrl, "the whole URL");
+ var fields = ReportLinks.BugFields(huge, huge);
+ Assert.AreEqual(fields.Single(f => f.id == "env").value, Value(url, "env"), "the panel shows the clipped value");
+ Assert.AreEqual(fields.Single(f => f.id == "version").value, Value(url, "version"));
+ Assert.IsFalse(char.IsHighSurrogate(fields.Single(f => f.id == "env").value.Last()), "a pair is never cut in half");
+ }
+}
diff --git a/unity/Assets/Tests/EditMode/ReportLinksTests.cs.meta b/unity/Assets/Tests/EditMode/ReportLinksTests.cs.meta
new file mode 100644
index 000000000..6daed42de
--- /dev/null
+++ b/unity/Assets/Tests/EditMode/ReportLinksTests.cs.meta
@@ -0,0 +1,2 @@
+fileFormatVersion: 2
+guid: fdc17382d37f5d9a9a8600fc787542f0
\ No newline at end of file
diff --git a/unity/Assets/Tests/EditMode/SettingsScreenTests.cs b/unity/Assets/Tests/EditMode/SettingsScreenTests.cs
index 49c3554e2..1ed4f9ce1 100644
--- a/unity/Assets/Tests/EditMode/SettingsScreenTests.cs
+++ b/unity/Assets/Tests/EditMode/SettingsScreenTests.cs
@@ -481,6 +481,73 @@ public class SettingsScreenTests
Assert.AreEqual("סימון בכוכב בגיטהאב", He["community.star"]);
}
+ /// <summary>#1169: the Community row's "Report a bug or idea" opens the report panel over the screen. The panel shows
+ /// each GitHub form's prefilled lines before anything opens, and each choice opens its link (through the injectable
+ /// opener, so no browser opens): the bug form with the version and this platform, the feature form, the itch page.
+ /// While it shows the rest of the UI is disabled; Esc closes it and gives the focus back to the button.</summary>
+ [Test]
+ public void TheReportButtonShowsWhatEachFormGetsAndOpensIt([Values(false, true)] bool hebrew)
+ {
+ var text = hebrew ? He : En;
+ var opened = new List<string>();
+ ExternalLink.Opener = opened.Add;
+ try
+ {
+ using var ui = new UiTestKit();
+ using var settings = new SettingsPresenter(ui.Root, text, new SettingsStore(dir));
+ using var feedback = new FeedbackPresenter(ui.Root, text, "0.1.0 / content ab12");
+ var report = ui.Q<Button>("settings-report");
+ Assert.AreEqual(text["feedback.open"], report.text);
+ Assert.AreEqual(text["feedback.bug"], ui.Q<Button>("feedback-bug").text);
+ Assert.IsFalse(feedback.IsOpen);
+ UiTestKit.Press(report);
+ Assert.IsTrue(feedback.IsOpen, "the panel opens");
+ Assert.IsEmpty(opened, "nothing opens before a choice");
+ Assert.IsFalse(ui.Q<VisualElement>("screen-settings").enabledSelf, "the screen under the panel is out of Tab's reach");
+ var env = ReportLinks.Environment();
+ Assert.AreEqual($"title: {ReportLinks.BugTitle}\nversion: 0.1.0 / content ab12\nenv: {env}", ui.Q<Label>("feedback-bug-preview").text);
+ Assert.AreEqual($"title: {ReportLinks.FeatureTitle}", ui.Q<Label>("feedback-feature-preview").text);
+ PressWithPointer(ui.Q<Button>("feedback-bug"));
+ UiTestKit.Press(ui.Q<Button>("feedback-feature"));
+ UiTestKit.Press(ui.Q<Button>("feedback-itch"));
+ CollectionAssert.AreEqual(new[] { ReportLinks.Bug("0.1.0 / content ab12", env), ReportLinks.Feature(), ReportLinks.Itch }, opened);
+ using (var esc = NavigationCancelEvent.GetPooled()) { esc.target = ui.Q<Button>("feedback-bug"); ui.Q<Button>("feedback-bug").SendEvent(esc); }
+ Assert.IsFalse(feedback.IsOpen, "Esc closes it");
+ Assert.IsTrue(ui.Q<VisualElement>("screen-settings").enabledSelf, "the screen is usable again");
+ Assert.AreSame(report, report.focusController?.focusedElement, "the focus is back on the button that opened it");
+ UiTestKit.Press(report);
+ UiTestKit.Press(ui.Q<Button>("feedback-close"));
+ Assert.IsFalse(feedback.IsOpen, "Close closes it");
+ // GameRoot's Escape poll asks the panel first, in the frame its own Cancel closed it too, so the same key does
+ // not also close the Settings screen under it.
+ Assert.IsTrue(feedback.Escape(), "closed this frame: the key is used");
+ UiTestKit.Press(report);
+ Assert.IsTrue(feedback.Escape());
+ Assert.IsFalse(feedback.IsOpen, "the poll's Escape closes it");
+ }
+ finally { ExternalLink.Opener = ExternalLink.Default; }
+ }
+
+ /// <summary>#1169: with the screens' navigation wired as GameRoot wires it, Esc in the report panel closes the panel
+ /// only; ScreenNav's Cancel handler trickles down from the root before the panel's own and asks the panel first.
+ /// (Time.frameCount does not move in an edit-mode test, so after this the panel keeps saying "used this frame".)</summary>
+ [Test]
+ public void EscapeInTheReportPanelLeavesTheSettingsScreenOpen()
+ {
+ using var ui = new UiTestKit();
+ using var nav = new ScreenNav(ui.Root);
+ using var settings = new SettingsPresenter(ui.Root, En, new SettingsStore(dir));
+ using var feedback = new FeedbackPresenter(ui.Root, En, "0.1.0 / content ab12");
+ nav.TakesEscape = feedback.Escape;
+ nav.Open("settings");
+ UiTestKit.Press(ui.Q<Button>("settings-report"));
+ Assert.IsTrue(feedback.IsOpen);
+ var bug = ui.Q<Button>("feedback-bug");
+ using (var esc = NavigationCancelEvent.GetPooled()) { esc.target = bug; bug.SendEvent(esc); }
+ Assert.IsFalse(feedback.IsOpen, "Esc closes the panel");
+ Assert.AreEqual("settings", nav.Current, "and only the panel");
+ }
+
/// <summary>A mouse press as the player makes it (StartScreenTests.PressWithPointer): a primary-button pointer down
/// (GetPooled leaves the button at -1), then the button's Clickable fires on the release.</summary>
internal static void PressWithPointer(Button b)
@@ -570,7 +637,7 @@ 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-community-label", "settings-star", "settings-report" })
{
var e = root.Q<TextElement>(name);
Assert.IsFalse(string.IsNullOrWhiteSpace(e.text), $"{at}: {name} has its text");
diff --git a/unity/Assets/Tests/EditMode/StartScreenTests.cs b/unity/Assets/Tests/EditMode/StartScreenTests.cs
index 048921737..61806e716 100644
--- a/unity/Assets/Tests/EditMode/StartScreenTests.cs
+++ b/unity/Assets/Tests/EditMode/StartScreenTests.cs
@@ -273,6 +273,23 @@ public class StartScreenTests
finally { ExternalLink.Opener = ExternalLink.Default; }
}
+ /// <summary>#1169: the start screen's "Report a bug or idea" opens the report panel over the start screen, which stays
+ /// open under it and is out of Tab's reach until the panel closes.</summary>
+ [Test]
+ public void TheReportButtonOpensThePanelOverTheScreen()
+ {
+ using var rig = new Rig(TempStore());
+ using var feedback = new FeedbackPresenter(rig.Ui.Root, null, "0.1.0 / content ab12");
+ Assert.AreEqual("Report a bug or idea", rig.Ui.Q<Button>("start-report").text);
+ rig.Ui.Press("start-report");
+ Assert.IsTrue(feedback.IsOpen);
+ Assert.IsTrue(rig.Start.IsOpen, "the start screen stays under it");
+ Assert.IsFalse(rig.Ui.Q<VisualElement>("start-screen").enabledSelf, "out of Tab's reach");
+ rig.Ui.Press("feedback-close");
+ Assert.IsTrue(rig.Ui.Q<VisualElement>("start-screen").enabledSelf);
+ Assert.IsTrue(rig.Start.IsOpen);
+ }
+
[Test]
public void ContinueShowsOnlyWithASaveAndLoadsIt()
{
@@ -360,7 +377,7 @@ public class StartScreenTests
var cont = rig.Ui.Q<Button>("start-continue");
cont.Focus();
Assert.AreSame(cont, rig.Ui.Root.focusController?.focusedElement, "Continue has the focus");
- // Tab walks the screen's buttons only: Continue, New Game, the recording's button and Star on GitHub (#1168).
+ // Tab walks the screen's buttons only: Continue, New Game, the recording's button, Star on GitHub (#1168) and Report a bug or idea (#1169).
var seen = new List<string>();
for (int i = 0; i < 4; i++)
{
@@ -370,7 +387,7 @@ public class StartScreenTests
seen.Add((rig.Ui.Root.focusController.focusedElement as VisualElement)?.name ?? "none");
}
Assert.AreEqual("start-new-game", seen[0], "Tab moves from Continue to New Game: " + string.Join(", ", seen));
- Assert.IsTrue(seen.All(n => n == "start-continue" || n == "start-new-game" || n == "start-listen" || n == "start-star"), "Tab stays on the screen's buttons: " + string.Join(", ", seen));
+ Assert.IsTrue(seen.All(n => n == "start-continue" || n == "start-new-game" || n == "start-listen" || n == "start-star" || n == "start-report"), "Tab stays on the screen's buttons: " + string.Join(", ", seen));
CollectionAssert.Contains(seen, "start-listen", "Tab reaches the recording's button: " + string.Join(", ", seen));
rig.Ui.Press("start-continue");
yield return null; yield return null;
@@ -561,7 +578,7 @@ public class StartScreenTests
Assert.GreaterOrEqual(panel.yMin, window.yMin + painted * 0.5f - 0.5f, $"{at}: the panel {panel} covers the painting's upper half");
}
if (h > w) Assert.IsTrue(root.Q("start-screen").ClassListContains(StartScreenPresenter.BandClass), $"{at}: a phone held upright stacks the painting over the panel");
- var lines = new[] { "start-title", "start-he-proclamation", "start-en-proclamation", "start-he-date", "start-en-date", "start-source", "start-actions" };
+ var lines = new[] { "start-title", "start-he-proclamation", "start-en-proclamation", "start-he-date", "start-en-date", "start-source", "start-actions", "start-community" };
foreach (var name in lines)
{
var r = R(name);
@@ -590,6 +607,8 @@ public class StartScreenTests
Assert.AreEqual(newGameStyle.fontSize, starStyle.fontSize, $"{at}: the Star button's text is New game's size");
Assert.Less(starStyle.backgroundColor.a, 0.01f, $"{at}: the Star button has no fill (secondary to New game)");
Assert.AreNotEqual(newGameStyle.borderTopColor, starStyle.borderTopColor, $"{at}: the Star button's edge is not New game's gold");
+ Assert.IsTrue(Inside(R("start-report"), R("start-community")), $"{at}: the Report button {R("start-report")} is in its row"); // #1169
+ Assert.IsFalse(R("start-report").Overlaps(star), at);
}
finally
{
diff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxml
index 1cc7b8408..aa56d4a83 100644
--- a/unity/Assets/UI/Game.uxml
+++ b/unity/Assets/UI/Game.uxml
@@ -378,10 +378,14 @@
<ui:Button name="settings-uiscale-150" text="150%" class="settings-switch" />
</ui:VisualElement>
</ui:VisualElement>
- <!-- Community (#1168): "Star on GitHub" opens the repository in a new tab (ExternalLink). -->
+ <!-- Community (#1168): "Star on GitHub" opens the repository in a new tab (ExternalLink); "Report a bug or idea"
+ opens the report panel (#1169, FeedbackPresenter). -->
<ui:VisualElement class="row settings-row">
<ui:Label name="settings-community-label" text="Community" class="settings-name" />
- <ui:Button name="settings-star" text="Star on GitHub" class="settings-switch" />
+ <ui:VisualElement class="row settings-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:VisualElement>
</ui:VisualElement>
<Statecraft.Game.UI.UiFrame />
</ui:VisualElement>
@@ -472,6 +476,11 @@
(ExternalLink); its star and GitHub mark are painted in by StartScreenPresenter. -->
<ui:Button name="start-star" text="Star on GitHub" class="start-button start-star" />
</ui:VisualElement>
+ <!-- "Report a bug or idea" (#1169, FeedbackPresenter): a quiet button under the actions that opens the
+ report panel. -->
+ <ui:VisualElement name="start-community" class="start-community">
+ <ui:Button name="start-report" text="Report a bug or idea" class="start-report" />
+ </ui:VisualElement>
<ui:VisualElement name="start-caption" class="start-caption" picking-mode="Ignore">
<ui:Label name="start-caption-he" text="…אנו מכריזים בזאת על הקמת מדינה יהודית בארץ־ישראל, היא מדינת ישראל." class="start-he start-caption-he" language-direction="RTL" picking-mode="Ignore" />
<ui:Label name="start-caption-en" text="…HEREBY DECLARE THE ESTABLISHMENT OF A JEWISH STATE IN ERETZ-ISRAEL, TO BE KNOWN AS THE STATE OF ISRAEL." class="start-caption-en" picking-mode="Ignore" />
@@ -480,6 +489,20 @@
</ui:VisualElement>
</ui:VisualElement>
</ui:VisualElement>
+ <!-- "Report a bug or idea" (#1169, FeedbackPresenter): over everything, the start screen too, with what each GitHub
+ form opens with under its button; the game sends nothing itself. Before the toast, which stays readable. -->
+ <ui:VisualElement name="feedback-layer" class="feedback-layer">
+ <ui:VisualElement name="feedback-panel" class="panel feedback-panel">
+ <ui:VisualElement class="screen-header"><ui:Label name="feedback-title" text="Report a bug or idea" class="title" /><ui:Label name="feedback-intro" text="The form opens with these lines filled in. Nothing is sent until you submit it on GitHub." class="muted feedback-intro" /></ui:VisualElement>
+ <ui:Button name="feedback-bug" text="Report a bug" class="feedback-choice" />
+ <ui:Label name="feedback-bug-preview" class="muted feedback-preview" />
+ <ui:Button name="feedback-feature" text="Suggest a feature" class="feedback-choice" />
+ <ui:Label name="feedback-feature-preview" class="muted feedback-preview" />
+ <ui:Button name="feedback-itch" text="No GitHub account? Comment on itch" class="feedback-choice" />
+ <ui:VisualElement class="row feedback-actions"><ui:Button name="feedback-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 307122c7e..13e5e7149 100644
--- a/unity/Assets/UI/Statecraft.uss
+++ b/unity/Assets/UI/Statecraft.uss
@@ -524,6 +524,15 @@ Button.settings-choice-selected { -unity-font-definition: url("project://databas
/* How to play's button that opens the guide again: under the lines, never squeezed by them. */
.how-to-play-guide { flex-shrink: 0; align-self: flex-start; min-height: 44px; margin-top: 8px; }
.lang-he .how-to-play-guide { align-self: flex-end; }
+/* "Report a bug or idea" (#1169, FeedbackPresenter): the same backdrop over everything, the start screen too; each GitHub
+ choice with the lines its form opens with under it, wrapped (a user agent is long). */
+.feedback-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; }
+.feedback-open .feedback-layer { display: flex; }
+.feedback-panel { width: 560px; max-width: 100%; max-height: 100%; padding: 18px; background-color: rgb(11, 18, 32); }
+.feedback-intro, .feedback-preview { white-space: normal; }
+.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; }
/* 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;
@@ -832,7 +841,11 @@ Button.settings-choice-selected { -unity-font-definition: url("project://databas
captions in a dark strip just above the panel, over the painting (the panel is the strip's positioned parent, so the
strip follows it in every layout). */
.start-recording { display: none; flex-direction: row; flex-wrap: wrap; justify-content: center; align-items: center; margin-top: 8px; }
-.start-listen { font-size: 18px; padding: 4px 16px; margin: 2px 10px; -unity-text-align: middle-center; }
+.start-listen, .start-report { font-size: 18px; padding: 4px 16px; margin: 2px 10px; -unity-text-align: middle-center; }
+/* "Report a bug or idea" (#1169) in its own centred row under the actions, as quiet as the recording's button. A
+ whole-pixel height: a fractional one shifts the panel's lines off whole pixels, and on a phone held upright the band
+ layout (StartScreenPresenter.Fit) then rounds the panel's top back and forth, a layout that never settles. */
+.start-community { flex-direction: row; justify-content: center; align-items: center; height: 40px; margin-top: 8px; }
/* Star on GitHub (#1168): a .start-button, New game's size, beside it (the row wraps it under New game in a narrow
window). Its star and GitHub mark are painted into the left padding (the right in Hebrew; StartScreenPresenter
PaintStarSigns). Secondary to New game in colour: no fill and a grey edge instead of the gold one; hover and keyboard
@@ -869,7 +882,7 @@ Button.settings-choice-selected { -unity-font-definition: url("project://databas
.lang-he .button, .lang-he Button, .lang-he #event-options Button { -unity-text-align: middle-right; }
/* The buttons and cards whose text is centred stay centred (the rule above is the more specific one). */
.lang-he .nav-button, .lang-he .seat { -unity-text-align: upper-center; }
-.lang-he .event-reopen, .lang-he .event-hide, .lang-he .event-illustration, .lang-he .start-button, .lang-he .start-listen { -unity-text-align: middle-center; }
+.lang-he .event-reopen, .lang-he .event-hide, .lang-he .event-illustration, .lang-he .start-button, .lang-he .start-listen, .lang-he .start-report { -unity-text-align: middle-center; }
.lang-he .card-stat-name { -unity-text-align: middle-right; }
.lang-he .card-stat-value { -unity-text-align: middle-left; }
/* The Hebrew plate shows the first name's initial and the surname ("י. ידין", PersonCard.InitialAndSurname), not two
diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yaml
index a68246230..688ca5996 100644
--- a/unity/Assets/UI/strings.en.yaml
+++ b/unity/Assets/UI/strings.en.yaml
@@ -112,6 +112,12 @@ settings.uiscale: "UI scale"
# The Community row and the start screen's button (#1168): it opens the repository in a new tab (ExternalLink).
settings.community: "Community"
community.star: "Star on GitHub"
+# "Report a bug or idea" (#1169, FeedbackPresenter): the button beside Star, the panel's title, and its three choices.
+feedback.open: "Report a bug or idea"
+feedback.intro: "The form opens with these lines filled in. Nothing is sent until you submit it on GitHub."
+feedback.bug: "Report a bug"
+feedback.feature: "Suggest a feature"
+feedback.itch: "No GitHub account? Comment on itch"
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 8b0e0df39..7664c3127 100644
--- a/unity/Assets/UI/strings.he.yaml
+++ b/unity/Assets/UI/strings.he.yaml
@@ -110,6 +110,16 @@ settings.uiscale: "גודל הממשק"
# the native reviewer (#564).
settings.community: "קהילה"
community.star: "סימון בכוכב בגיטהאב"
+# "Report a bug or idea" (#1169, FeedbackPresenter): the button and the panel's title ("a report of a bug or an idea"),
+# its note ("the form opens with these lines already filled in; nothing is sent before the sending on GitHub"), and the
+# three choices, all noun phrases or impersonal forms, so no verb agrees with the player's gender; GitHub and itch in
+# Hebrew letters, as the static texts carry no Latin (HebrewUiTests). Approved by Beri, a native speaker, on #1179
+# (20 Oct 2026). For the native reviewer (#564).
+feedback.open: "דיווח על באג או רעיון"
+feedback.intro: "הטופס נפתח עם השורות האלה כבר ממולאות. שום דבר לא נשלח לפני השליחה בגיטהאב."
+feedback.bug: "דיווח על באג"
+feedback.feature: "הצעה לתכונה חדשה"
+feedback.itch: "אין חשבון בגיטהאב? תגובה בדף המשחק באיץ׳"
event.draft: "טיוטה"
start.source: "מתוך ההכרזה על הקמת מדינת ישראל (עיתון רשמי מס׳ 1, 14 במאי 1948) ותרגומה הרשמי לאנגלית. הציור נוצר בבינה מלאכותית."
# The recordist's name as the Israel State Archives spells it in its own description of item