A Civilization-style strategy game about governing Israel from 15 May 1948. Real ministers, real map, every fact sourced. Unity + deterministic C# sim.
feat(ui): theme, EB Garamond, 1080p panel settings, strings, layout skeleton, UI test harness
eyalgolanc4aca6f16c57
diff --git a/unity/Assets/Editor/UiAssets.cs b/unity/Assets/Editor/UiAssets.csnew file mode 100644index 000000000..e5159191c--- /dev/null+++ b/unity/Assets/Editor/UiAssets.cs@@ -0,0 +1,29 @@+using Statecraft.Game.UI;+using UnityEditor;+using UnityEngine;+using UnityEngine.UIElements;++namespace Statecraft.Game.EditorTools+{+ /// <summary>Creates the UI Toolkit PanelSettings asset (tech notes 1.3): scale with screen size against 1920x1080,+ /// matching width and height equally, with the default runtime theme. An asset, not a runtime instance, so its theme+ /// and shader references are included in player builds (the M0 Shader.Find lesson). Idempotent.+ /// Run headless: Unity -batchmode -quit -projectPath unity -executeMethod Statecraft.Game.EditorTools.UiAssets.Create</summary>+ public static class UiAssets+ {+ public static void Create()+ {+ var theme = AssetDatabase.LoadAssetAtPath<ThemeStyleSheet>(UiPaths.Theme);+ if (theme == null) throw new System.IO.FileNotFoundException("theme missing (commit Assets/UI/StatecraftTheme.tss)", UiPaths.Theme);+ var ps = AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel);+ if (ps == null) { ps = ScriptableObject.CreateInstance<PanelSettings>(); AssetDatabase.CreateAsset(ps, UiPaths.Panel); }+ ps.themeStyleSheet = theme;+ ps.scaleMode = PanelScaleMode.ScaleWithScreenSize;+ ps.referenceResolution = new Vector2Int(1920, 1080);+ ps.screenMatchMode = PanelScreenMatchMode.MatchWidthOrHeight;+ ps.match = 0.5f;+ EditorUtility.SetDirty(ps);+ AssetDatabase.SaveAssets();+ }+ }+}diff --git a/unity/Assets/Editor/UiAssets.cs.meta b/unity/Assets/Editor/UiAssets.cs.metanew file mode 100644index 000000000..c65d1140d--- /dev/null+++ b/unity/Assets/Editor/UiAssets.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: b8e1b7e6e26064af3aef8b858d51d868\ No newline at end of filediff --git a/unity/Assets/Scripts/UI.meta b/unity/Assets/Scripts/UI.metanew file mode 100644index 000000000..3870caadd--- /dev/null+++ b/unity/Assets/Scripts/UI.meta@@ -0,0 +1,8 @@+fileFormatVersion: 2+guid: fc0a28790d174418eb2e1ac8786e7f9b+folderAsset: yes+DefaultImporter:+ externalObjects: {}+ userData:+ assetBundleName:+ assetBundleVariant:diff --git a/unity/Assets/Scripts/UI/UiPaths.cs b/unity/Assets/Scripts/UI/UiPaths.csnew file mode 100644index 000000000..e382bc16b--- /dev/null+++ b/unity/Assets/Scripts/UI/UiPaths.cs@@ -0,0 +1,16 @@+#nullable enable+namespace Statecraft.Game.UI+{+ /// <summary>Project paths of the UI assets, shared by the editor scripts (Assets/Editor) and the edit-mode tests,+ /// which cannot reference the editor assembly.</summary>+ public static class UiPaths+ {+ public const string Folder = "Assets/UI";+ public const string Panel = Folder + "/StatecraftPanel.asset";+ public const string Theme = Folder + "/StatecraftTheme.tss";+ public const string GameUxml = Folder + "/Game.uxml";+ public const string Strings = Folder + "/strings.en.yaml";+ public const string FontRegular = Folder + "/Fonts/EBGaramond-Regular.ttf";+ public const string FontSemiBold = Folder + "/Fonts/EBGaramond-SemiBold.ttf";+ }+}diff --git a/unity/Assets/Scripts/UI/UiPaths.cs.meta b/unity/Assets/Scripts/UI/UiPaths.cs.metanew file mode 100644index 000000000..a66cf63a6--- /dev/null+++ b/unity/Assets/Scripts/UI/UiPaths.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: 245e1bd1637e64d1d880af080637404b\ No newline at end of filediff --git a/unity/Assets/Scripts/UI/UiPointer.cs b/unity/Assets/Scripts/UI/UiPointer.csnew file mode 100644index 000000000..33f1eb11a--- /dev/null+++ b/unity/Assets/Scripts/UI/UiPointer.cs@@ -0,0 +1,18 @@+#nullable enable+using UnityEngine;+using UnityEngine.UIElements;++namespace Statecraft.Game.UI+{+ /// <summary>"Is the pointer over the UI?" for camera and map clicks (tech notes section 5). Input System positions are+ /// y-up; RuntimePanelUtils.ScreenToPanel does not flip, and panel space is y-down, so y is flipped first. Elements with+ /// picking-mode Ignore (the root) let the pointer through to the map.</summary>+ public static class UiPointer+ {+ public static Vector2 ToPanel(IPanel panel, Vector2 screenYUp, float screenHeight) =>+ RuntimePanelUtils.ScreenToPanel(panel, new Vector2(screenYUp.x, screenHeight - screenYUp.y));++ public static bool IsOverUi(IPanel? panel, Vector2 screenYUp, float screenHeight) =>+ panel != null && panel.Pick(ToPanel(panel, screenYUp, screenHeight)) != null;+ }+}diff --git a/unity/Assets/Scripts/UI/UiPointer.cs.meta b/unity/Assets/Scripts/UI/UiPointer.cs.metanew file mode 100644index 000000000..172fb7f0f--- /dev/null+++ b/unity/Assets/Scripts/UI/UiPointer.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: a3984ffbe56dd4aeca0ad37b420e7b9a\ No newline at end of filediff --git a/unity/Assets/Scripts/UI/UiText.cs b/unity/Assets/Scripts/UI/UiText.csnew file mode 100644index 000000000..3cd83649b--- /dev/null+++ b/unity/Assets/Scripts/UI/UiText.cs@@ -0,0 +1,30 @@+#nullable enable+using System;+using System.Collections.Generic;+using System.Globalization;+using YamlDotNet.Serialization;++namespace Statecraft.Game.UI+{+ /// <summary>UI strings kept outside code (unity/Assets/UI/strings.en.yaml): key -> string.Format pattern.</summary>+ public sealed class UiText+ {+ readonly Dictionary<string, string> map;+ UiText(Dictionary<string, string> map) { this.map = map; }++ /// <summary>Parses the strings file. Throws InvalidOperationException naming the file when it is empty or not a map.</summary>+ public static UiText Parse(string yaml, string file = "strings.en.yaml")+ {+ Dictionary<string, string> m;+ try { m = new DeserializerBuilder().WithDuplicateKeyChecking().Build().Deserialize<Dictionary<string, string>>(yaml ?? ""); }+ catch (YamlDotNet.Core.YamlException e) { throw new InvalidOperationException($"{file}: {e.Message}", e); }+ if (m == null || m.Count == 0) throw new InvalidOperationException($"{file}: no strings");+ return new UiText(m);+ }++ public string this[string key] =>+ map.TryGetValue(key, out var v) ? v : throw new KeyNotFoundException($"strings.en.yaml has no key '{key}'");++ public string Format(string key, params object[] args) => string.Format(CultureInfo.InvariantCulture, this[key], args);+ }+}diff --git a/unity/Assets/Scripts/UI/UiText.cs.meta b/unity/Assets/Scripts/UI/UiText.cs.metanew file mode 100644index 000000000..cf29ff1c4--- /dev/null+++ b/unity/Assets/Scripts/UI/UiText.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: cb908672200da48bcbd736b663f95412\ No newline at end of filediff --git a/unity/Assets/Tests/EditMode/UiFoundationTests.cs b/unity/Assets/Tests/EditMode/UiFoundationTests.csnew file mode 100644index 000000000..3a8d2f299--- /dev/null+++ b/unity/Assets/Tests/EditMode/UiFoundationTests.cs@@ -0,0 +1,80 @@+using System.Collections;+using NUnit.Framework;+using Statecraft.Game.UI;+using UnityEditor;+using UnityEngine;+using UnityEngine.TestTools;+using UnityEngine.UIElements;++public class UiFoundationTests+{+ [Test]+ public void PanelSettingsScaleWithA1080pReference()+ {+ var ps = AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel);+ Assert.AreEqual(PanelScaleMode.ScaleWithScreenSize, ps.scaleMode);+ Assert.AreEqual(new Vector2Int(1920, 1080), ps.referenceResolution);+ Assert.AreEqual(PanelScreenMatchMode.MatchWidthOrHeight, ps.screenMatchMode);+ Assert.AreEqual(0.5f, ps.match);+ Assert.IsNotNull(ps.themeStyleSheet, "theme");+ }++ [Test]+ public void ASubmittedButtonFiresClickedSynchronously()+ {+ using var ui = new UiTestKit();+ int clicks = 0;+ ui.Q<Button>("end-turn").clicked += () => clicks++;+ ui.Press("end-turn");+ Assert.AreEqual(1, clicks);+ }++ [Test]+ public void TheLayoutHasEveryRegionOfTheTargetScreen()+ {+ using var ui = new UiTestKit();+ foreach (var name in new[] { "top-bar", "event-card", "info-panel", "minimap", "screen-cabinet", "screen-budget", "screen-defence", "screen-why", "toast" })+ ui.Q<VisualElement>(name);+ foreach (var name in new[] { "treasury", "immigration", "security", "support", "standing", "fx" })+ {+ ui.Q<Label>(name + "-value");+ ui.Q<Label>(name + "-delta");+ }+ Assert.AreEqual(PickingMode.Ignore, ui.Q<VisualElement>("root").pickingMode, "empty screen areas must let clicks reach the map");+ }++ [UnityTest]+ public IEnumerator TextUsesTheSerifFaces()+ {+ using var ui = new UiTestKit();+ for (int i = 0; i < 10 && ui.Q<Label>("year").resolvedStyle.unityFontDefinition.font == null; i++) yield return null;+ var regular = AssetDatabase.LoadAssetAtPath<Font>(UiPaths.FontRegular);+ var semibold = AssetDatabase.LoadAssetAtPath<Font>(UiPaths.FontSemiBold);+ Assert.AreSame(semibold, ui.Q<Label>("year").resolvedStyle.unityFontDefinition.font);+ Assert.AreSame(regular, ui.Q<Label>("turn").resolvedStyle.unityFontDefinition.font);+ }++ [Test]+ public void StringsLoadFromTheYamlFileAndFormatInvariantly()+ {+ var text = UiText.Parse(AssetDatabase.LoadAssetAtPath<TextAsset>(UiPaths.Strings).text);+ Assert.AreEqual("Turn 3", text.Format("hud.turn", 3));+ Assert.AreEqual("1,234,567", text.Format("hud.people", 1234567.0));+ Assert.Throws<System.Collections.Generic.KeyNotFoundException>(() => { var _ = text["no.such.key"]; });+ }++ [UnityTest]+ public IEnumerator PickingFindsButtonsButNotTheTransparentRoot()+ {+ using var ui = new UiTestKit();+ foreach (var name in new[] { "screen-cabinet", "screen-budget", "screen-defence", "screen-why", "toast" })+ ui.Q<VisualElement>(name).style.display = DisplayStyle.None; // closed, as at game start+ var button = ui.Q<Button>("end-turn");+ for (int i = 0; i < 10 && float.IsNaN(button.worldBound.width); i++) yield return null;+ var panel = ui.Root.panel;+ Assert.AreSame(button, panel.Pick(button.worldBound.center));+ Assert.IsNull(panel.Pick(ui.Root.worldBound.center), "the empty middle of the screen must reach the map");+ // Input System screen positions are y-up; ToPanel flips y before RuntimePanelUtils.ScreenToPanel (which does not).+ Assert.AreEqual(RuntimePanelUtils.ScreenToPanel(panel, new Vector2(10, 20)), UiPointer.ToPanel(panel, new Vector2(10, 1060), 1080f));+ }+}diff --git a/unity/Assets/Tests/EditMode/UiFoundationTests.cs.meta b/unity/Assets/Tests/EditMode/UiFoundationTests.cs.metanew file mode 100644index 000000000..bfee8c0b8--- /dev/null+++ b/unity/Assets/Tests/EditMode/UiFoundationTests.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: 920531be8f64d42d59b462661f4c6238\ No newline at end of filediff --git a/unity/Assets/Tests/EditMode/UiLayoutTests.cs b/unity/Assets/Tests/EditMode/UiLayoutTests.csnew file mode 100644index 000000000..683ac5625--- /dev/null+++ b/unity/Assets/Tests/EditMode/UiLayoutTests.cs@@ -0,0 +1,49 @@+using System.Collections;+using NUnit.Framework;+using Statecraft.Game.UI;+using UnityEditor;+using UnityEngine;+using UnityEngine.TestTools;+using UnityEngine.UIElements;++/// <summary>The screen layout at 1920x1080 and 1280x720 (the panel scales with the screen against a 1080p reference,+/// so both resolve to the same logical layout): no fixed region overlaps another, no centre screen covers a fixed region,+/// and the six top-bar meters fit before the screen buttons at their minimum width.</summary>+public class UiLayoutTests+{+ static readonly string[] Fixed = { "top-bar", "event-card", "info-panel", "minimap" };+ static readonly string[] Screens = { "screen-cabinet", "screen-budget", "screen-defence", "screen-why" };++ [UnityTest]+ public IEnumerator NothingOverlapsAt1080pAnd720p()+ {+ foreach (var (w, h) in new[] { (1920, 1080), (1280, 720) })+ {+ var rt = new RenderTexture(w, h, 0);+ var ps = Object.Instantiate(AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel));+ ps.targetTexture = rt;+ var go = new GameObject("LayoutTest");+ go.SetActive(false);+ var doc = go.AddComponent<UIDocument>();+ doc.panelSettings = ps;+ doc.visualTreeAsset = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(UiPaths.GameUxml);+ go.SetActive(true);+ var root = doc.rootVisualElement;+ for (int i = 0; i < 20 && float.IsNaN(root.Q("minimap").worldBound.width); i++) yield return null;+ try+ {+ Rect R(string name) => root.Q(name).worldBound;+ foreach (var a in Fixed)+ foreach (var b in Fixed)+ if (string.CompareOrdinal(a, b) < 0) Assert.IsFalse(R(a).Overlaps(R(b)), $"{w}x{h}: {a} {R(a)} overlaps {b} {R(b)}");+ foreach (var s in Screens)+ foreach (var f in Fixed)+ Assert.IsFalse(R(s).Overlaps(R(f)), $"{w}x{h}: {s} {R(s)} overlaps {f} {R(f)}");+ Assert.LessOrEqual(R("meters").xMax, R("nav").xMin + 0.5f, $"{w}x{h}: the meters run into the screen buttons");+ foreach (var m in root.Q("meters").Children())+ Assert.GreaterOrEqual(m.worldBound.width, 128.5f, $"{w}x{h}: {m.name} is squeezed below its minimum width"); // 130 less pixel rounding at 2/3 scale+ }+ finally { Object.DestroyImmediate(go); Object.DestroyImmediate(ps); rt.Release(); Object.DestroyImmediate(rt); }+ }+ }+}diff --git a/unity/Assets/Tests/EditMode/UiLayoutTests.cs.meta b/unity/Assets/Tests/EditMode/UiLayoutTests.cs.metanew file mode 100644index 000000000..4afe41e0e--- /dev/null+++ b/unity/Assets/Tests/EditMode/UiLayoutTests.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: cab4b8ee5cde24a999586bd524027777\ No newline at end of filediff --git a/unity/Assets/Tests/EditMode/UiTestKit.cs b/unity/Assets/Tests/EditMode/UiTestKit.csnew file mode 100644index 000000000..0e7155c81--- /dev/null+++ b/unity/Assets/Tests/EditMode/UiTestKit.cs@@ -0,0 +1,50 @@+using System;+using NUnit.Framework;+using Statecraft.Game.UI;+using UnityEditor;+using UnityEngine;+using UnityEngine.UIElements;+using Object = UnityEngine.Object;++/// <summary>Edit-mode UI harness (tech notes 1.6): a UIDocument on a fresh GameObject gives the tree a real runtime+/// panel, so events dispatch. Buttons are pressed with NavigationSubmitEvent, which fires Button.clicked; a synthetic+/// ClickEvent does not.</summary>+public sealed class UiTestKit : IDisposable+{+ public readonly GameObject Go;+ public readonly UIDocument Doc;+ public VisualElement Root => Doc.rootVisualElement;++ public UiTestKit(string uxmlPath = UiPaths.GameUxml)+ {+ var ps = AssetDatabase.LoadAssetAtPath<PanelSettings>(UiPaths.Panel);+ var vta = AssetDatabase.LoadAssetAtPath<VisualTreeAsset>(uxmlPath);+ Assert.IsNotNull(ps, UiPaths.Panel + " (run UiAssets.Create)");+ Assert.IsNotNull(vta, uxmlPath);+ Go = new GameObject("UITest");+ Go.SetActive(false);+ Doc = Go.AddComponent<UIDocument>();+ Doc.panelSettings = ps;+ Doc.visualTreeAsset = vta;+ Go.SetActive(true); // OnEnable -> RecreateUI+ Assert.IsNotNull(Root.panel, "the UIDocument tree has no panel");+ }++ public T Q<T>(string name) where T : VisualElement+ {+ var e = Root.Q<T>(name);+ Assert.IsNotNull(e, $"no {typeof(T).Name} named '{name}'");+ return e;+ }++ /// <summary>Presses a button the way keyboard/gamepad Submit does: Button.clicked fires synchronously.</summary>+ public static void Press(Button b)+ {+ Assert.IsNotNull(b.panel, $"button '{b.name}' is not on a panel");+ using (var e = NavigationSubmitEvent.GetPooled()) { e.target = b; b.SendEvent(e); }+ }++ public void Press(string buttonName) => Press(Q<Button>(buttonName));++ public void Dispose() => Object.DestroyImmediate(Go);+}diff --git a/unity/Assets/Tests/EditMode/UiTestKit.cs.meta b/unity/Assets/Tests/EditMode/UiTestKit.cs.metanew file mode 100644index 000000000..8c68e4f9d--- /dev/null+++ b/unity/Assets/Tests/EditMode/UiTestKit.cs.meta@@ -0,0 +1,2 @@+fileFormatVersion: 2+guid: bc0d1b76d47d5442fabe6aa10026df60\ No newline at end of filediff --git a/unity/Assets/UI.meta b/unity/Assets/UI.metanew file mode 100644index 000000000..849bd413d--- /dev/null+++ b/unity/Assets/UI.meta@@ -0,0 +1,8 @@+fileFormatVersion: 2+guid: 1e9a026bf4b2c451c8e892066e8369b2+folderAsset: yes+DefaultImporter:+ externalObjects: {}+ userData:+ assetBundleName:+ assetBundleVariant:diff --git a/unity/Assets/UI/Fonts.meta b/unity/Assets/UI/Fonts.metanew file mode 100644index 000000000..350859697--- /dev/null+++ b/unity/Assets/UI/Fonts.meta@@ -0,0 +1,8 @@+fileFormatVersion: 2+guid: f9a32269bfdfa4f789ac35ab7bc86df9+folderAsset: yes+DefaultImporter:+ externalObjects: {}+ userData:+ assetBundleName:+ assetBundleVariant:diff --git a/unity/Assets/UI/Fonts/EBGaramond-Regular.ttf b/unity/Assets/UI/Fonts/EBGaramond-Regular.ttfnew file mode 100644index 000000000..8194251d7Binary files /dev/null and b/unity/Assets/UI/Fonts/EBGaramond-Regular.ttf differdiff --git a/unity/Assets/UI/Fonts/EBGaramond-Regular.ttf.meta b/unity/Assets/UI/Fonts/EBGaramond-Regular.ttf.metanew file mode 100644index 000000000..7b92a405b--- /dev/null+++ b/unity/Assets/UI/Fonts/EBGaramond-Regular.ttf.meta@@ -0,0 +1,21 @@+fileFormatVersion: 2+guid: 0c7bc3a3f631442f599ae9513c373c6c+TrueTypeFontImporter:+ externalObjects: {}+ serializedVersion: 4+ fontSize: 16+ forceTextureCase: -2+ characterSpacing: 0+ characterPadding: 1+ includeFontData: 1+ fontNames:+ - EB Garamond+ fallbackFontReferences: []+ customCharacters:+ fontRenderingMode: 0+ ascentCalculationMode: 1+ useLegacyBoundsCalculation: 0+ shouldRoundAdvanceValue: 1+ userData:+ assetBundleName:+ assetBundleVariant:diff --git a/unity/Assets/UI/Fonts/EBGaramond-SemiBold.ttf b/unity/Assets/UI/Fonts/EBGaramond-SemiBold.ttfnew file mode 100644index 000000000..4bf4cb0b7Binary files /dev/null and b/unity/Assets/UI/Fonts/EBGaramond-SemiBold.ttf differdiff --git a/unity/Assets/UI/Fonts/EBGaramond-SemiBold.ttf.meta b/unity/Assets/UI/Fonts/EBGaramond-SemiBold.ttf.metanew file mode 100644index 000000000..880affaa8--- /dev/null+++ b/unity/Assets/UI/Fonts/EBGaramond-SemiBold.ttf.meta@@ -0,0 +1,21 @@+fileFormatVersion: 2+guid: fcd2c25bde9274b38858d38f80168b77+TrueTypeFontImporter:+ externalObjects: {}+ serializedVersion: 4+ fontSize: 16+ forceTextureCase: -2+ characterSpacing: 0+ characterPadding: 1+ includeFontData: 1+ fontNames:+ - EB Garamond+ fallbackFontReferences: []+ customCharacters:+ fontRenderingMode: 0+ ascentCalculationMode: 1+ useLegacyBoundsCalculation: 0+ shouldRoundAdvanceValue: 1+ userData:+ assetBundleName:+ assetBundleVariant:diff --git a/unity/Assets/UI/Fonts/OFL.txt b/unity/Assets/UI/Fonts/OFL.txtnew file mode 100644index 000000000..0375b8096--- /dev/null+++ b/unity/Assets/UI/Fonts/OFL.txt@@ -0,0 +1,94 @@+Copyright 2017 The EB Garamond Project Authors (https://github.com/octaviopardo/EBGaramond12)+Copyright 2025 Deborah Khodanovich (RCS citation glyphs)++This Font Software is licensed under the SIL Open Font License, Version 1.1.+This license is copied below, and is also available with a FAQ at:+http://scripts.sil.org/OFL+++-----------------------------------------------------------+SIL OPEN FONT LICENSE Version 1.1 - 26 February 2007+-----------------------------------------------------------++PREAMBLE+The goals of the Open Font License (OFL) are to stimulate worldwide+development of collaborative font projects, to support the font creation+efforts of academic and linguistic communities, and to provide a free and+open framework in which fonts may be shared and improved in partnership+with others.++The OFL allows the licensed fonts to be used, studied, modified and+redistributed freely as long as they are not sold by themselves. The+fonts, including any derivative works, can be bundled, embedded,+redistributed and/or sold with any software provided that any reserved+names are not used by derivative works. The fonts and derivatives,+however, cannot be released under any other type of license. The+requirement for fonts to remain under this license does not apply+to any document created using the fonts or their derivatives.++DEFINITIONS+"Font Software" refers to the set of files released by the Copyright+Holder(s) under this license and clearly marked as such. This may+include source files, build scripts and documentation.++"Reserved Font Name" refers to any names specified as such after the+copyright statement(s).++"Original Version" refers to the collection of Font Software components as+distributed by the Copyright Holder(s).++"Modified Version" refers to any derivative made by adding to, deleting,+or substituting -- in part or in whole -- any of the components of the+Original Version, by changing formats or by porting the Font Software to a+new environment.++"Author" refers to any designer, engineer, programmer, technical+writer or other person who contributed to the Font Software.++PERMISSION & CONDITIONS+Permission is hereby granted, free of charge, to any person obtaining+a copy of the Font Software, to use, study, copy, merge, embed, modify,+redistribute, and sell modified and unmodified copies of the Font+Software, subject to the following conditions:++1) Neither the Font Software nor any of its individual components,+in Original or Modified Versions, may be sold by itself.++2) Original or Modified Versions of the Font Software may be bundled,+redistributed and/or sold with any software, provided that each copy+contains the above copyright notice and this license. These can be+included either as stand-alone text files, human-readable headers or+in the appropriate machine-readable metadata fields within text or+binary files as long as those fields can be easily viewed by the user.++3) No Modified Version of the Font Software may use the Reserved Font+Name(s) unless explicit written permission is granted by the corresponding+Copyright Holder. This restriction only applies to the primary font name as+presented to the users.++4) The name(s) of the Copyright Holder(s) or the Author(s) of the Font+Software shall not be used to promote, endorse or advertise any+Modified Version, except to acknowledge the contribution(s) of the+Copyright Holder(s) and the Author(s) or with their explicit written+permission.++5) The Font Software, modified or unmodified, in part or in whole,+must be distributed entirely under this license, and must not be+distributed under any other license. The requirement for fonts to+remain under this license does not apply to any document created+using the Font Software.++TERMINATION+This license becomes null and void if any of the above conditions are+not met.++DISCLAIMER+THE FONT SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,+EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO ANY WARRANTIES OF+MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT+OF COPYRIGHT, PATENT, TRADEMARK, OR OTHER RIGHT. IN NO EVENT SHALL THE+COPYRIGHT HOLDER BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,+INCLUDING ANY GENERAL, SPECIAL, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL+DAMAGES, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING+FROM, OUT OF THE USE OR INABILITY TO USE THE FONT SOFTWARE OR FROM+OTHER DEALINGS IN THE FONT SOFTWARE.diff --git a/unity/Assets/UI/Fonts/OFL.txt.meta b/unity/Assets/UI/Fonts/OFL.txt.metanew file mode 100644index 000000000..3e57286c1--- /dev/null+++ b/unity/Assets/UI/Fonts/OFL.txt.meta@@ -0,0 +1,7 @@+fileFormatVersion: 2+guid: 5f99d63e47ff840ae8404e65d2d0a89d+TextScriptImporter:+ externalObjects: {}+ userData:+ assetBundleName:+ assetBundleVariant:diff --git a/unity/Assets/UI/Fonts/SOURCE.txt b/unity/Assets/UI/Fonts/SOURCE.txtnew file mode 100644index 000000000..b50271ff8--- /dev/null+++ b/unity/Assets/UI/Fonts/SOURCE.txt@@ -0,0 +1,4 @@+EB Garamond (static TTFs), SIL Open Font License 1.1 (OFL.txt in this folder).+Source: https://github.com/octaviopardo/EBGaramond12 at commit 106a4a6d377987459ae5e68673a4570f13b957fb, fonts/ttf/+sha256 2028dc06d3c130b4761693481436a32a8e35ed500bf58c25c53de004106125b8 EBGaramond-Regular.ttf+sha256 ebf827a102983972abb2a1a3964afd5a7b79ca04f2ddd9e53917ce623cefdf2c EBGaramond-SemiBold.ttfdiff --git a/unity/Assets/UI/Fonts/SOURCE.txt.meta b/unity/Assets/UI/Fonts/SOURCE.txt.metanew file mode 100644index 000000000..baaa6a626--- /dev/null+++ b/unity/Assets/UI/Fonts/SOURCE.txt.meta@@ -0,0 +1,7 @@+fileFormatVersion: 2+guid: 67fe1707d154f4975ba87a4aac77ce25+TextScriptImporter:+ externalObjects: {}+ userData:+ assetBundleName:+ assetBundleVariant:diff --git a/unity/Assets/UI/Game.uxml b/unity/Assets/UI/Game.uxmlnew file mode 100644index 000000000..621ab04cd--- /dev/null+++ b/unity/Assets/UI/Game.uxml@@ -0,0 +1,57 @@+<ui:UXML xmlns:ui="UnityEngine.UIElements">+ <Style src="Statecraft.uss" />+ <ui:VisualElement name="root" class="root" picking-mode="Ignore">+ <ui:VisualElement name="top-bar" class="panel top-bar">+ <ui:VisualElement class="date-box">+ <ui:Label name="year" class="year" />+ <ui:Label name="turn" class="muted" />+ <ui:Label name="date" class="muted" />+ </ui:VisualElement>+ <ui:VisualElement name="meters" class="meters">+ <ui:VisualElement name="meter-treasury" class="meter">+ <ui:Label text="Treasury" class="meter-name" />+ <ui:VisualElement class="meter-row"><ui:Label name="treasury-value" class="meter-value" /><ui:Label name="treasury-delta" class="meter-delta" /></ui:VisualElement>+ </ui:VisualElement>+ <ui:VisualElement name="meter-immigration" class="meter">+ <ui:Label text="Immigration" class="meter-name" />+ <ui:VisualElement class="meter-row"><ui:Label name="immigration-value" class="meter-value" /><ui:Label name="immigration-delta" class="meter-delta" /></ui:VisualElement>+ </ui:VisualElement>+ <ui:VisualElement name="meter-security" class="meter">+ <ui:Label text="Security" class="meter-name" />+ <ui:VisualElement class="meter-row"><ui:Label name="security-value" class="meter-value" /><ui:Label name="security-delta" class="meter-delta" /></ui:VisualElement>+ <ui:Label name="security-level" class="meter-name" />+ </ui:VisualElement>+ <ui:VisualElement name="meter-support" class="meter">+ <ui:Label text="Public Support" class="meter-name" />+ <ui:VisualElement class="meter-row"><ui:Label name="support-value" class="meter-value" /><ui:Label name="support-delta" class="meter-delta" /></ui:VisualElement>+ </ui:VisualElement>+ <ui:VisualElement name="meter-standing" class="meter">+ <ui:Label text="International Standing" class="meter-name" />+ <ui:VisualElement class="meter-row"><ui:Label name="standing-value" class="meter-value" /><ui:Label name="standing-delta" class="meter-delta" /></ui:VisualElement>+ </ui:VisualElement>+ <ui:VisualElement name="meter-fx" class="meter">+ <ui:Label text="Foreign Currency" class="meter-name" />+ <ui:VisualElement class="meter-row"><ui:Label name="fx-value" class="meter-value" /><ui:Label name="fx-delta" class="meter-delta" /></ui:VisualElement>+ </ui:VisualElement>+ </ui:VisualElement>+ <ui:VisualElement name="nav" class="nav">+ <ui:Button name="nav-cabinet" text="Cabinet" />+ <ui:Button name="nav-budget" text="Budget" />+ <ui:Button name="nav-defence" text="Defence" />+ <ui:Button name="nav-why" text="Why?" />+ </ui:VisualElement>+ <ui:VisualElement class="turn-box">+ <ui:Label name="attention" class="muted" />+ <ui:Button name="end-turn" text="End Turn" class="end-turn" />+ </ui:VisualElement>+ </ui:VisualElement>+ <ui:VisualElement name="event-card" class="panel event-card" />+ <ui:VisualElement name="info-panel" class="panel info-panel" />+ <ui:VisualElement name="minimap" class="panel minimap" />+ <ui:VisualElement name="screen-cabinet" class="panel screen" />+ <ui:VisualElement name="screen-budget" class="panel screen" />+ <ui:VisualElement name="screen-defence" class="panel screen" />+ <ui:VisualElement name="screen-why" class="panel screen" />+ <ui:Label name="toast" class="panel toast" />+ </ui:VisualElement>+</ui:UXML>diff --git a/unity/Assets/UI/Game.uxml.meta b/unity/Assets/UI/Game.uxml.metanew file mode 100644index 000000000..3e27fab89--- /dev/null+++ b/unity/Assets/UI/Game.uxml.meta@@ -0,0 +1,10 @@+fileFormatVersion: 2+guid: 40f0d74d627394577981d9875ae6489f+ScriptedImporter:+ internalIDToNameTable: []+ externalObjects: {}+ serializedVersion: 2+ userData:+ assetBundleName:+ assetBundleVariant:+ script: {fileID: 13804, guid: 0000000000000000e000000000000000, type: 0}diff --git a/unity/Assets/UI/Statecraft.uss b/unity/Assets/UI/Statecraft.ussnew file mode 100644index 000000000..1e4b24937--- /dev/null+++ b/unity/Assets/UI/Statecraft.uss@@ -0,0 +1,101 @@+/* Statecraft UI language (target: promo/final/03-gameplay-1936.png): dark navy panels, thin gold borders, serif type. */+:root {+ --navy: rgba(14, 22, 38, 0.94);+ --navy-deep: rgb(9, 14, 26);+ --gold: rgb(196, 160, 92);+ --gold-dim: rgba(196, 160, 92, 0.45);+ --ink: rgb(236, 228, 210);+ --ink-dim: rgb(170, 164, 150);+ --up: rgb(126, 196, 120);+ --down: rgb(222, 120, 104);+}++.root {+ flex-grow: 1;+ -unity-font-definition: url("project://database/Assets/UI/Fonts/EBGaramond-Regular.ttf");+ color: var(--ink);+ font-size: 20px;+}++.panel {+ background-color: var(--navy);+ border-color: var(--gold-dim);+ border-width: 1px;+ border-radius: 4px;+ padding: 12px;+}++.title {+ -unity-font-definition: url("project://database/Assets/UI/Fonts/EBGaramond-SemiBold.ttf");+ font-size: 30px;+ color: var(--ink);+}++.muted { color: var(--ink-dim); }+.delta-up { color: var(--up); }+.delta-down { color: var(--down); }++.button, Button {+ background-color: var(--navy-deep);+ border-color: var(--gold-dim);+ border-width: 1px;+ border-radius: 3px;+ color: var(--ink);+ -unity-font-definition: url("project://database/Assets/UI/Fonts/EBGaramond-Regular.ttf");+ font-size: 19px;+ padding: 6px 12px;+ margin: 3px 0;+ -unity-text-align: middle-left;+}+Button:hover { border-color: var(--gold); }+Button:disabled { color: var(--ink-dim); border-color: rgba(120, 120, 120, 0.4); }++/* Top bar: date box, national indicators with value and change, screen buttons, attention and End turn. */+.top-bar {+ position: absolute; left: 0; right: 0; top: 0; height: 96px;+ flex-direction: row; align-items: center;+ border-width: 0 0 1px 0; border-radius: 0; padding: 0 16px;+}+.date-box { width: 190px; border-right-width: 1px; border-color: var(--gold-dim); padding-right: 12px; }+.year { -unity-font-definition: url("project://database/Assets/UI/Fonts/EBGaramond-SemiBold.ttf"); font-size: 36px; }+.meters { flex-direction: row; flex-grow: 1; }+.meter { min-width: 130px; flex-shrink: 1; padding: 0 12px; border-right-width: 1px; border-color: var(--gold-dim); }+.meter-name { font-size: 18px; color: var(--ink-dim); }+.meter-row { flex-direction: row; align-items: flex-end; }+.meter-value { font-size: 26px; }+.meter-delta { font-size: 18px; margin-left: 8px; }+.nav { flex-direction: row; }+.nav Button { margin: 0 4px; -unity-text-align: middle-center; }+.turn-box { width: 190px; align-items: flex-end; }+.end-turn { -unity-font-definition: url("project://database/Assets/UI/Fonts/EBGaramond-SemiBold.ttf"); font-size: 22px; border-color: var(--gold); }++/* Event card at the right, info panel at the bottom-left, minimap at the bottom-right. */+.event-card { position: absolute; right: 16px; top: 112px; width: 420px; max-height: 560px; overflow: hidden; }+.event-image { height: 200px; margin-bottom: 8px; -unity-background-scale-mode: scale-and-crop; background-color: var(--navy-deep); }+.event-title { -unity-text-align: middle-center; margin-bottom: 6px; }+.event-text { white-space: normal; margin-bottom: 8px; }+.draft { color: var(--down); -unity-font-definition: url("project://database/Assets/UI/Fonts/EBGaramond-SemiBold.ttf"); -unity-text-align: middle-center; }+.info-panel { position: absolute; left: 16px; bottom: 16px; width: 520px; min-height: 160px; }+.minimap { position: absolute; right: 16px; bottom: 16px; width: 300px; height: 340px; padding: 6px; }+.minimap-image { flex-grow: 1; -unity-background-scale-mode: scale-to-fit; }+.minimap-view { position: absolute; border-color: var(--ink); border-width: 1px; }++/* Full screens (Cabinet, Budget, Defence, Why) open in the centre, one at a time. */+.screen { position: absolute; left: 552px; right: 452px; top: 112px; bottom: 16px; }+.screen-header { flex-direction: row; justify-content: space-between; align-items: center; border-bottom-width: 1px; border-color: var(--gold-dim); margin-bottom: 8px; }+.row { flex-direction: row; align-items: center; }+.rung { flex-direction: row; padding: 4px 8px; border-left-width: 3px; border-color: rgba(0, 0, 0, 0); }+.rung-current { border-color: var(--gold); background-color: rgba(196, 160, 92, 0.15); }+.grow { flex-grow: 1; }++.toast { position: absolute; left: 30%; right: 30%; top: 112px; -unity-text-align: middle-center; white-space: normal; }++.why-group { -unity-font-definition: url("project://database/Assets/UI/Fonts/EBGaramond-SemiBold.ttf"); color: var(--gold); margin-top: 8px; }+.why-line { white-space: normal; padding-left: 12px; }++.seat { flex-direction: row; align-items: center; }+.seat-portrait { width: 40px; height: 48px; margin-right: 8px; -unity-background-scale-mode: scale-and-crop; background-color: var(--navy-deep); }+.seat-selected { border-color: var(--gold); }+.appointed { color: var(--gold); }+.candidate { flex-direction: row; align-items: center; }+.reason { color: var(--ink-dim); font-size: 16px; white-space: normal; flex-shrink: 1; }diff --git a/unity/Assets/UI/Statecraft.uss.meta b/unity/Assets/UI/Statecraft.uss.metanew file mode 100644index 000000000..0092d00bc--- /dev/null+++ b/unity/Assets/UI/Statecraft.uss.meta@@ -0,0 +1,12 @@+fileFormatVersion: 2+guid: d75d7cb17d0fb492d8a50b0927b6283e+ScriptedImporter:+ internalIDToNameTable: []+ externalObjects: {}+ serializedVersion: 2+ userData:+ assetBundleName:+ assetBundleVariant:+ script: {fileID: 12385, guid: 0000000000000000e000000000000000, type: 0}+ disableValidation: 0+ unsupportedSelectorAction: 0diff --git a/unity/Assets/UI/StatecraftPanel.asset b/unity/Assets/UI/StatecraftPanel.assetnew file mode 100644index 000000000..742812fd2--- /dev/null+++ b/unity/Assets/UI/StatecraftPanel.asset@@ -0,0 +1,52 @@+%YAML 1.1+%TAG !u! tag:unity3d.com,2011:+--- !u!114 &11400000+MonoBehaviour:+ m_ObjectHideFlags: 0+ m_CorrespondingSourceObject: {fileID: 0}+ m_PrefabInstance: {fileID: 0}+ m_PrefabAsset: {fileID: 0}+ m_GameObject: {fileID: 0}+ m_Enabled: 1+ m_EditorHideFlags: 0+ m_Script: {fileID: 19101, guid: 0000000000000000e000000000000000, type: 0}+ m_Name: StatecraftPanel+ m_EditorClassIdentifier: UnityEngine.dll::UnityEngine.UIElements.PanelSettings+ themeUss: {fileID: -4733365628477956816, guid: b200212e9e5a6458da234faad5c1721e, type: 3}+ m_DisableNoThemeWarning: 0+ m_TargetTexture: {fileID: 0}+ m_RenderMode: 0+ m_ColliderUpdateMode: 0+ m_ColliderIsTrigger: 1+ m_ScaleMode: 2+ m_ReferenceSpritePixelsPerUnit: 100+ m_PixelsPerUnit: 100+ m_Scale: 1+ m_ReferenceDpi: 96+ m_FallbackDpi: 96+ m_ReferenceResolution: {x: 1920, y: 1080}+ m_ScreenMatchMode: 0+ m_Match: 0.5+ m_SortingOrder: 0+ m_TargetDisplay: 0+ m_BindingLogLevel: 0+ m_ClearDepthStencil: 1+ m_ClearColor: 0+ m_ColorClearValue: {r: 0, g: 0, b: 0, a: 0}+ m_VertexBudget: 0+ m_TextureSlotCount: 8+ m_DynamicAtlasSettings:+ m_MinAtlasSize: 64+ m_MaxAtlasSize: 4096+ m_MaxSubTextureSize: 64+ m_ActiveFilters: 31+ m_AtlasBlitShader: {fileID: 9101, guid: 0000000000000000f000000000000000, type: 0}+ m_DefaultShader: {fileID: 9100, guid: 0000000000000000f000000000000000, type: 0}+ m_RuntimeGaussianBlurShader: {fileID: 20300, guid: 0000000000000000f000000000000000, type: 0}+ m_RuntimeColorEffectShader: {fileID: 20301, guid: 0000000000000000f000000000000000, type: 0}+ m_SDFShader: {fileID: 19011, guid: 0000000000000000f000000000000000, type: 0}+ m_BitmapShader: {fileID: 9001, guid: 0000000000000000f000000000000000, type: 0}+ m_SpriteShader: {fileID: 19012, guid: 0000000000000000f000000000000000, type: 0}+ m_ICUDataAsset: {fileID: 0}+ forceGammaRendering: 0+ textSettings: {fileID: 0}diff --git a/unity/Assets/UI/StatecraftPanel.asset.meta b/unity/Assets/UI/StatecraftPanel.asset.metanew file mode 100644index 000000000..da91f000b--- /dev/null+++ b/unity/Assets/UI/StatecraftPanel.asset.meta@@ -0,0 +1,8 @@+fileFormatVersion: 2+guid: dab47673b21ed48abbc80a9747465d73+NativeFormatImporter:+ externalObjects: {}+ mainObjectFileID: 11400000+ userData:+ assetBundleName:+ assetBundleVariant:diff --git a/unity/Assets/UI/StatecraftTheme.tss b/unity/Assets/UI/StatecraftTheme.tssnew file mode 100644index 000000000..51924cb33--- /dev/null+++ b/unity/Assets/UI/StatecraftTheme.tss@@ -0,0 +1 @@+@import url("unity-theme://default");diff --git a/unity/Assets/UI/StatecraftTheme.tss.meta b/unity/Assets/UI/StatecraftTheme.tss.metanew file mode 100644index 000000000..9a27e5684--- /dev/null+++ b/unity/Assets/UI/StatecraftTheme.tss.meta@@ -0,0 +1,12 @@+fileFormatVersion: 2+guid: b200212e9e5a6458da234faad5c1721e+ScriptedImporter:+ internalIDToNameTable: []+ externalObjects: {}+ serializedVersion: 2+ userData:+ assetBundleName:+ assetBundleVariant:+ script: {fileID: 12388, guid: 0000000000000000e000000000000000, type: 0}+ disableValidation: 0+ unsupportedSelectorAction: 0diff --git a/unity/Assets/UI/strings.en.yaml b/unity/Assets/UI/strings.en.yamlnew file mode 100644index 000000000..611eda7ff--- /dev/null+++ b/unity/Assets/UI/strings.en.yaml@@ -0,0 +1,13 @@+# UI strings (English). Code looks strings up by key (Statecraft.Game.UI.UiText); placeholders are string.Format+# arguments ({0}, {1}) formatted with the invariant culture. Static labels live in the UXML files.+hud.turn: "Turn {0}"+hud.date: "{0:d MMMM yyyy}"+hud.attention: "Attention {0:0.0} of {1:0.0}"+hud.money: "{0:0.0}m"+hud.people: "{0:N0}"+hud.percent: "{0:0}"+hud.fx: "${0:0.0}m"+hud.level: "Level {0} of 5"+hud.delta: "{0:+0;-0}"+hud.delta_money: "{0:+0.0;-0.0}"+toast.refused: "Not done: {0}"diff --git a/unity/Assets/UI/strings.en.yaml.meta b/unity/Assets/UI/strings.en.yaml.metanew file mode 100644index 000000000..0d79f0124--- /dev/null+++ b/unity/Assets/UI/strings.en.yaml.meta@@ -0,0 +1,7 @@+fileFormatVersion: 2+guid: 1c2724b5422584e3dbeef4ab44d2e9da+TextScriptImporter:+ externalObjects: {}+ userData:+ assetBundleName:+ assetBundleVariant:diff --git a/unity/Assets/link.xml b/unity/Assets/link.xmlindex 9f22a0673..009177074 100644--- a/unity/Assets/link.xml+++ b/unity/Assets/link.xml@@ -1,5 +1,5 @@<linker><assembly fullname="YamlDotNet" preserve="all" /><assembly fullname="Statecraft.Sim" preserve="all" />- <assembly fullname="Statecraft.Game"><type fullname="Statecraft.Game.Map.*" preserve="all"/></assembly>+ <assembly fullname="Statecraft.Game"><type fullname="Statecraft.Game.Map.*" preserve="all"/><type fullname="Statecraft.Game.UI.*" preserve="all"/></assembly></linker>