Skip to content

Dodaios is an open-source agent OS for your desktop: it runs your coding agents, browser and apps by voice or chat, on your own machine. Formerly Personal Jarvis.

feat(verse): add the Unreal HUD, kill cam, armoury, menus and settings (#1155)

Ruben Lütke68681df03d3d
diff --git a/unreal/Verse/Data/ui/armoury.json b/unreal/Verse/Data/ui/armoury.json
new file mode 100644
index 0000000000..6acb227615
--- /dev/null
+++ b/unreal/Verse/Data/ui/armoury.json
@@ -0,0 +1,13 @@
+{
+ "schema": "verse.ui.armoury/1",
+ "note": "Armoury view (WP18.6). The loadout is the fixed deathmatch loadout of contracts/combat-state.md 2.2; names come from strings.json (verse.item.<id>.*).",
+ "tiers": ["normal", "hard", "elite", "adaptive"],
+ "default_tier": "hard",
+ "loadout": [
+ { "slot": "Primary", "item": "graveline", "kind": "firearm" },
+ { "slot": "Secondary", "item": "tallow", "kind": "firearm" },
+ { "slot": "Melee", "item": "hookbill", "kind": "melee" },
+ { "slot": "GadgetA", "item": "bulwark", "kind": "gadget" },
+ { "slot": "GadgetB", "item": "breach_charge", "kind": "gadget" }
+ ]
+}
diff --git a/unreal/Verse/Data/ui/hud.json b/unreal/Verse/Data/ui/hud.json
new file mode 100644
index 0000000000..f63445f129
--- /dev/null
+++ b/unreal/Verse/Data/ui/hud.json
@@ -0,0 +1,25 @@
+{
+ "schema": "verse.ui.hud/1",
+ "note": "HUD and kill cam tuning (WP18). Times in seconds, camera offsets in centimetres. set_target mirrors the ruleset's first-to value (combat-state 9.1) until AVersePlayerState carries it.",
+ "safe_fraction": 0.025,
+ "decks": ["bridge", "ops", "engineering", "hangar"],
+ "timing": {
+ "hit_marker_s": 0.30,
+ "headshot_marker_s": 0.40,
+ "kill_marker_s": 0.70,
+ "blocked_marker_s": 0.40,
+ "damage_indicator_s": 1.6,
+ "feed_entry_s": 6.0,
+ "feed_max": 5,
+ "set_target": 10
+ },
+ "kill_cam": {
+ "window_s": 4.0,
+ "end_margin_s": 0.25,
+ "min_length_s": 0.5,
+ "camera_back_cm": 260,
+ "camera_up_cm": 70,
+ "camera_right_cm": 45,
+ "finisher_cut_s": 2.5
+ }
+}
diff --git a/unreal/Verse/Data/ui/keys.json b/unreal/Verse/Data/ui/keys.json
new file mode 100644
index 0000000000..ae6e576a2f
--- /dev/null
+++ b/unreal/Verse/Data/ui/keys.json
@@ -0,0 +1,30 @@
+{
+ "schema": "verse.ui.keys/1",
+ "note": "Bindable actions and default keys (WP18.8). Key names are Unreal FKey names. Actions with a \"ui\" field are handled by VerseUI. Gameplay actions name the Enhanced Input action (\"input_action\") the input owner maps the default key to: VerseUI moves that one mapping in every mapping context applied to the local player (WP01 IMC_VersePerson: IA_Move, IA_Jump, ...; weapons, melee, gadgets and stations use the IA_ names listed here). The return key is app-backed (welcome.settings.return_key).",
+ "actions": [
+ { "action": "move_forward", "key": "W", "label": "verse.key.move_forward", "input_action": "IA_Move" },
+ { "action": "move_back", "key": "S", "label": "verse.key.move_back", "input_action": "IA_Move" },
+ { "action": "move_left", "key": "A", "label": "verse.key.move_left", "input_action": "IA_Move" },
+ { "action": "move_right", "key": "D", "label": "verse.key.move_right", "input_action": "IA_Move" },
+ { "action": "sprint", "key": "LeftShift", "label": "verse.key.sprint", "input_action": "IA_Sprint" },
+ { "action": "crouch", "key": "LeftControl", "label": "verse.key.crouch", "input_action": "IA_Crouch" },
+ { "action": "prone", "key": "Z", "label": "verse.key.prone", "input_action": "IA_Prone" },
+ { "action": "jump", "key": "SpaceBar", "label": "verse.key.jump", "input_action": "IA_Jump" },
+ { "action": "lean_left", "key": "Q", "label": "verse.key.lean_left", "input_action": "IA_LeanLeft" },
+ { "action": "lean_right", "key": "E", "label": "verse.key.lean_right", "input_action": "IA_LeanRight" },
+ { "action": "walk", "key": "LeftAlt", "label": "verse.key.walk", "input_action": "IA_Walk" },
+ { "action": "fire", "key": "LeftMouseButton", "label": "verse.key.fire", "input_action": "IA_Fire" },
+ { "action": "ads", "key": "RightMouseButton", "label": "verse.key.ads", "input_action": "IA_Ads" },
+ { "action": "reload", "key": "R", "label": "verse.key.reload", "input_action": "IA_Reload" },
+ { "action": "melee", "key": "V", "label": "verse.key.melee", "input_action": "IA_Melee" },
+ { "action": "gadget_a", "key": "G", "label": "verse.key.gadget_a", "input_action": "IA_GadgetA" },
+ { "action": "gadget_b", "key": "T", "label": "verse.key.gadget_b", "input_action": "IA_GadgetB" },
+ { "action": "slot_primary", "key": "One", "label": "verse.key.slot_primary", "input_action": "IA_SlotPrimary" },
+ { "action": "slot_secondary", "key": "Two", "label": "verse.key.slot_secondary", "input_action": "IA_SlotSecondary" },
+ { "action": "slot_melee", "key": "Three", "label": "verse.key.slot_melee", "input_action": "IA_SlotMelee" },
+ { "action": "interact", "key": "F", "label": "verse.key.interact", "input_action": "IA_Interact" },
+ { "action": "verse_bar", "key": "Tab", "label": "verse.key.verse_bar", "ui": "verse_bar" },
+ { "action": "skip_kill_cam", "key": "Enter", "label": "verse.key.skip_kill_cam", "ui": "skip_kill_cam" },
+ { "action": "return_to_app", "key": "F10", "label": "verse.key.return_to_app", "ui": "return_to_app" }
+ ]
+}
diff --git a/unreal/Verse/Data/ui/strings.de.json b/unreal/Verse/Data/ui/strings.de.json
new file mode 100644
index 0000000000..9e220b8c36
--- /dev/null
+++ b/unreal/Verse/Data/ui/strings.de.json
@@ -0,0 +1,171 @@
+{
+ "schema": "verse.ui.strings/1",
+ "lang": "de",
+ "note": "Verse UI strings (WP18, A18.4). welcome.locale.strings and settings.changed override these at runtime (bridge-protocol 3.2, 12).",
+ "strings": {
+ "verse.armoury.loadout": "AUSRÜSTUNG",
+ "verse.armoury.slot.gadgeta": "GERÄT",
+ "verse.armoury.slot.gadgetb": "GERÄT",
+ "verse.armoury.slot.melee": "NAHKAMPF",
+ "verse.armoury.slot.primary": "HAUPTWAFFE",
+ "verse.armoury.slot.secondary": "ZWEITWAFFE",
+ "verse.armoury.start": "Duell starten",
+ "verse.armoury.tier": "GEGNER",
+ "verse.armoury.title": "Waffenkammer",
+ "verse.bar.leave_duel": "Duell verlassen",
+ "verse.bar.quick_duel": "Schnelles Duell",
+ "verse.bar.return": "Zur App",
+ "verse.deck.bridge": "Brücke",
+ "verse.deck.engineering": "Maschinenraum",
+ "verse.deck.hangar": "Hangar",
+ "verse.deck.ops": "Einsatz",
+ "verse.duel.notice.left": "Du hast das Duell verlassen.",
+ "verse.duel.result.cancelled": "Duell beendet",
+ "verse.duel.result.leave": "Zurück aufs Schiff",
+ "verse.duel.result.rematch": "Revanche",
+ "verse.end.adaptive": "Stärke des adaptiven Gegners jetzt {skill} (0 normal, 0,5 schwer, 1 Elite)",
+ "verse.end.leave": "Duell verlassen",
+ "verse.end.lost": "Satz verloren",
+ "verse.end.next": "Nächster Satz",
+ "verse.end.opponent": "GEGNER",
+ "verse.end.row.accuracy": "Trefferquote",
+ "verse.end.row.damage": "Verursachter Schaden",
+ "verse.end.row.deaths": "Tode",
+ "verse.end.row.finishers": "Finisher",
+ "verse.end.row.headshots": "Kopftreffer",
+ "verse.end.row.kd": "K/D",
+ "verse.end.row.kills": "Abschüsse",
+ "verse.end.row.streak": "Beste Serie",
+ "verse.end.row.walls": "Wände durchbrochen",
+ "verse.end.score": "{person} : {opponent}",
+ "verse.end.set": "Satz {set}",
+ "verse.end.sets": "Sätze {won} : {lost}",
+ "verse.end.tier": "Gegner: {tier}",
+ "verse.end.unfinished": "Satz offen",
+ "verse.end.won": "Satz gewonnen",
+ "verse.end.you": "DU",
+ "verse.hud.chambered": "+1",
+ "verse.hud.cooldown": "{seconds} s",
+ "verse.hud.feed.finisher": "Finisher",
+ "verse.hud.feed.headshot": " · Kopftreffer",
+ "verse.hud.feed.kill": "{killer} · {weapon} · {victim}",
+ "verse.hud.feed.melee": "Nahkampf",
+ "verse.hud.feed.opponent": "Gegner",
+ "verse.hud.feed.respawn": "{name} ist zurück",
+ "verse.hud.feed.set_lost": "Satz verloren",
+ "verse.hud.feed.set_unfinished": "Satz offen",
+ "verse.hud.feed.set_won": "Satz gewonnen",
+ "verse.hud.feed.unknown": "Unbekannt",
+ "verse.hud.feed.wallshot": " · durch Deckung",
+ "verse.hud.feed.world": "Der Hangar",
+ "verse.hud.feed.you": "Du",
+ "verse.hud.health": "LEBEN",
+ "verse.hud.killcam": "Killcam · {name}",
+ "verse.hud.killcam_skip": "Überspringen: {key}",
+ "verse.hud.protected": "Spawnschutz {seconds} s",
+ "verse.hud.reload_empty": "LEER NACHLADEN",
+ "verse.hud.reload_tactical": "NACHLADEN",
+ "verse.hud.reserve": "/ {reserve}",
+ "verse.hud.respawn_in": "Zurück in {seconds}",
+ "verse.hud.score.opponent": "GEGNER",
+ "verse.hud.score.separator": ":",
+ "verse.hud.score.set": "Satz {set} · zuerst {target}",
+ "verse.hud.score.you": "DU",
+ "verse.hud.stance.crouch": "Geduckt",
+ "verse.hud.stance.prone": "Liegend",
+ "verse.hud.stance.slide": "Rutschend",
+ "verse.hud.stance.stand": "Stehend",
+ "verse.item.breach_charge.name": "Breach-Ladung",
+ "verse.item.breach_charge.role": "Sprengladung zum Durchbrechen",
+ "verse.item.breach_charge.short": "BREACH",
+ "verse.item.bulwark.name": "Bulwark",
+ "verse.item.bulwark.role": "Aufstellbare Energiebarriere",
+ "verse.item.bulwark.short": "BULWARK",
+ "verse.item.graveline.name": "Graveline",
+ "verse.item.graveline.role": "Sturmgewehr",
+ "verse.item.graveline.short": "RIFLE",
+ "verse.item.hookbill.name": "Hookbill",
+ "verse.item.hookbill.role": "Messer",
+ "verse.item.hookbill.short": "KNIFE",
+ "verse.item.longsight.name": "Longsight",
+ "verse.item.longsight.role": "Präzisionsgewehr",
+ "verse.item.longsight.short": "DMR",
+ "verse.item.skitter.name": "Skitter",
+ "verse.item.skitter.role": "Maschinenpistole",
+ "verse.item.skitter.short": "SMG",
+ "verse.item.tallow.name": "Tallow",
+ "verse.item.tallow.role": "Pistole",
+ "verse.item.tallow.short": "PISTOL",
+ "verse.key.ads": "Zielen",
+ "verse.key.crouch": "Ducken und rutschen",
+ "verse.key.fire": "Feuern",
+ "verse.key.gadget_a": "Bulwark",
+ "verse.key.gadget_b": "Breach-Ladung",
+ "verse.key.interact": "Benutzen",
+ "verse.key.jump": "Springen und klettern",
+ "verse.key.lean_left": "Links lehnen",
+ "verse.key.lean_right": "Rechts lehnen",
+ "verse.key.melee": "Messer",
+ "verse.key.move_back": "Rückwärts",
+ "verse.key.move_forward": "Vorwärts",
+ "verse.key.move_left": "Links",
+ "verse.key.move_right": "Rechts",
+ "verse.key.prone": "Hinlegen",
+ "verse.key.reload": "Nachladen",
+ "verse.key.return_to_app": "Zur App",
+ "verse.key.skip_kill_cam": "Killcam überspringen",
+ "verse.key.slot_melee": "Messer ziehen",
+ "verse.key.slot_primary": "Hauptwaffe",
+ "verse.key.slot_secondary": "Zweitwaffe",
+ "verse.key.sprint": "Sprinten",
+ "verse.key.verse_bar": "Verse-Leiste",
+ "verse.key.walk": "Gehen (leise Schritte)",
+ "verse.menu.leave_duel": "Duell verlassen",
+ "verse.menu.resume": "Weiter",
+ "verse.menu.return": "Zur App",
+ "verse.menu.settings": "Einstellungen",
+ "verse.menu.title": "Menü",
+ "verse.settings.duel_fov": "Sichtfeld im Duell",
+ "verse.settings.fov_first": "Sichtfeld erste Person",
+ "verse.settings.fov_third": "Sichtfeld dritte Person",
+ "verse.settings.gore": "Blut",
+ "verse.settings.gore.full": "Voll",
+ "verse.settings.gore.reduced": "Reduziert",
+ "verse.settings.invert_y": "Vertikal umkehren",
+ "verse.settings.level_sound": "Aufstiegston",
+ "verse.settings.markers_note": "Treffermarker unterscheiden sich in der Form: Striche, Striche mit Raute, Ring, Quadrat.",
+ "verse.settings.page.access": "Zugang",
+ "verse.settings.page.audio": "Ton",
+ "verse.settings.page.controls": "Tasten",
+ "verse.settings.page.gameplay": "Spiel",
+ "verse.settings.page.video": "Grafik",
+ "verse.settings.press_key": "Taste drücken",
+ "verse.settings.quality": "Qualität",
+ "verse.settings.quality.auto": "Automatisch",
+ "verse.settings.quality.cinematic": "Kino",
+ "verse.settings.quality.epic": "Episch",
+ "verse.settings.quality.high": "Hoch",
+ "verse.settings.quality.low": "Niedrig",
+ "verse.settings.quality.medium": "Mittel",
+ "verse.settings.reduced_motion": "Weniger Bewegung",
+ "verse.settings.reset": "Zurücksetzen",
+ "verse.settings.sensitivity": "Blickempfindlichkeit",
+ "verse.settings.text_size": "Textgröße",
+ "verse.settings.title": "Einstellungen",
+ "verse.settings.ui_sound": "Oberflächentöne",
+ "verse.settings.volume": "Lautstärke",
+ "verse.tier.adaptive": "Adaptiv",
+ "verse.tier.adaptive.desc": "Beginnt bei Schwer und nähert sich im Lauf des Satzes einem ausgeglichenen Kampf.",
+ "verse.tier.elite": "Elite",
+ "verse.tier.elite.desc": "Schnell, präzise und geduldig. Gewinnt meistens.",
+ "verse.tier.hard": "Schwer",
+ "verse.tier.hard.desc": "Bricht durch Wände, flankiert und bestraft denselben Trick beim zweiten Mal.",
+ "verse.tier.normal": "Normal",
+ "verse.tier.normal.desc": "Ein ruhiger Gegner, der dir Raum lässt, die Halle kennenzulernen.",
+ "verse.ui.back": "Zurück",
+ "verse.ui.next": ">",
+ "verse.ui.off": "Aus",
+ "verse.ui.on": "An",
+ "verse.ui.previous": "<"
+ }
+}
diff --git a/unreal/Verse/Data/ui/strings.en.json b/unreal/Verse/Data/ui/strings.en.json
new file mode 100644
index 0000000000..0246e3153c
--- /dev/null
+++ b/unreal/Verse/Data/ui/strings.en.json
@@ -0,0 +1,171 @@
+{
+ "schema": "verse.ui.strings/1",
+ "lang": "en",
+ "note": "Verse UI strings (WP18, A18.4). welcome.locale.strings and settings.changed override these at runtime (bridge-protocol 3.2, 12).",
+ "strings": {
+ "verse.armoury.loadout": "LOADOUT",
+ "verse.armoury.slot.gadgeta": "GADGET",
+ "verse.armoury.slot.gadgetb": "GADGET",
+ "verse.armoury.slot.melee": "MELEE",
+ "verse.armoury.slot.primary": "PRIMARY",
+ "verse.armoury.slot.secondary": "SECONDARY",
+ "verse.armoury.start": "Start duel",
+ "verse.armoury.tier": "OPPONENT",
+ "verse.armoury.title": "Armoury",
+ "verse.bar.leave_duel": "Leave duel",
+ "verse.bar.quick_duel": "Quick duel",
+ "verse.bar.return": "Back to app",
+ "verse.deck.bridge": "Bridge",
+ "verse.deck.engineering": "Engineering",
+ "verse.deck.hangar": "Hangar",
+ "verse.deck.ops": "Ops",
+ "verse.duel.notice.left": "You left the duel.",
+ "verse.duel.result.cancelled": "Duel ended",
+ "verse.duel.result.leave": "Back to the ship",
+ "verse.duel.result.rematch": "Rematch",
+ "verse.end.adaptive": "Adaptive opponent skill now {skill} (0 normal, 0.5 hard, 1 elite)",
+ "verse.end.leave": "Leave duel",
+ "verse.end.lost": "Set lost",
+ "verse.end.next": "Next set",
+ "verse.end.opponent": "OPPONENT",
+ "verse.end.row.accuracy": "Accuracy",
+ "verse.end.row.damage": "Damage dealt",
+ "verse.end.row.deaths": "Deaths",
+ "verse.end.row.finishers": "Finishers",
+ "verse.end.row.headshots": "Headshots",
+ "verse.end.row.kd": "K/D",
+ "verse.end.row.kills": "Kills",
+ "verse.end.row.streak": "Best streak",
+ "verse.end.row.walls": "Walls breached",
+ "verse.end.score": "{person} : {opponent}",
+ "verse.end.set": "Set {set}",
+ "verse.end.sets": "Sets {won} : {lost}",
+ "verse.end.tier": "Opponent: {tier}",
+ "verse.end.unfinished": "Set left open",
+ "verse.end.won": "Set won",
+ "verse.end.you": "YOU",
+ "verse.hud.chambered": "+1",
+ "verse.hud.cooldown": "{seconds} s",
+ "verse.hud.feed.finisher": "Finisher",
+ "verse.hud.feed.headshot": " · headshot",
+ "verse.hud.feed.kill": "{killer} · {weapon} · {victim}",
+ "verse.hud.feed.melee": "Melee",
+ "verse.hud.feed.opponent": "Opponent",
+ "verse.hud.feed.respawn": "{name} redeployed",
+ "verse.hud.feed.set_lost": "Set lost",
+ "verse.hud.feed.set_unfinished": "Set left open",
+ "verse.hud.feed.set_won": "Set won",
+ "verse.hud.feed.unknown": "Unknown",
+ "verse.hud.feed.wallshot": " · through cover",
+ "verse.hud.feed.world": "The hangar",
+ "verse.hud.feed.you": "You",
+ "verse.hud.health": "HEALTH",
+ "verse.hud.killcam": "Kill cam · {name}",
+ "verse.hud.killcam_skip": "Skip: {key}",
+ "verse.hud.protected": "Spawn protection {seconds} s",
+ "verse.hud.reload_empty": "EMPTY RELOAD",
+ "verse.hud.reload_tactical": "RELOADING",
+ "verse.hud.reserve": "/ {reserve}",
+ "verse.hud.respawn_in": "Redeploying in {seconds}",
+ "verse.hud.score.opponent": "OPPONENT",
+ "verse.hud.score.separator": ":",
+ "verse.hud.score.set": "Set {set} · first to {target}",
+ "verse.hud.score.you": "YOU",
+ "verse.hud.stance.crouch": "Crouched",
+ "verse.hud.stance.prone": "Prone",
+ "verse.hud.stance.slide": "Sliding",
+ "verse.hud.stance.stand": "Standing",
+ "verse.item.breach_charge.name": "Breach charge",
+ "verse.item.breach_charge.role": "Breaching explosive",
+ "verse.item.breach_charge.short": "BREACH",
+ "verse.item.bulwark.name": "Bulwark",
+ "verse.item.bulwark.role": "Deployable energy barricade",
+ "verse.item.bulwark.short": "BULWARK",
+ "verse.item.graveline.name": "Graveline",
+ "verse.item.graveline.role": "Assault rifle",
+ "verse.item.graveline.short": "RIFLE",
+ "verse.item.hookbill.name": "Hookbill",
+ "verse.item.hookbill.role": "Knife",
+ "verse.item.hookbill.short": "KNIFE",
+ "verse.item.longsight.name": "Longsight",
+ "verse.item.longsight.role": "Marksman rifle",
+ "verse.item.longsight.short": "DMR",
+ "verse.item.skitter.name": "Skitter",
+ "verse.item.skitter.role": "Submachine gun",
+ "verse.item.skitter.short": "SMG",
+ "verse.item.tallow.name": "Tallow",
+ "verse.item.tallow.role": "Pistol",
+ "verse.item.tallow.short": "PISTOL",
+ "verse.key.ads": "Aim",
+ "verse.key.crouch": "Crouch and slide",
+ "verse.key.fire": "Fire",
+ "verse.key.gadget_a": "Bulwark",
+ "verse.key.gadget_b": "Breach charge",
+ "verse.key.interact": "Use",
+ "verse.key.jump": "Jump and mantle",
+ "verse.key.lean_left": "Lean left",
+ "verse.key.lean_right": "Lean right",
+ "verse.key.melee": "Knife",
+ "verse.key.move_back": "Move back",
+ "verse.key.move_forward": "Move forward",
+ "verse.key.move_left": "Move left",
+ "verse.key.move_right": "Move right",
+ "verse.key.prone": "Prone",
+ "verse.key.reload": "Reload",
+ "verse.key.return_to_app": "Back to app",
+ "verse.key.skip_kill_cam": "Skip kill cam",
+ "verse.key.slot_melee": "Knife in hand",
+ "verse.key.slot_primary": "Primary weapon",
+ "verse.key.slot_secondary": "Secondary weapon",
+ "verse.key.sprint": "Sprint",
+ "verse.key.verse_bar": "Verse bar",
+ "verse.key.walk": "Walk (quiet steps)",
+ "verse.menu.leave_duel": "Leave duel",
+ "verse.menu.resume": "Resume",
+ "verse.menu.return": "Back to app",
+ "verse.menu.settings": "Settings",
+ "verse.menu.title": "Paused",
+ "verse.settings.duel_fov": "Duel field of view",
+ "verse.settings.fov_first": "First-person field of view",
+ "verse.settings.fov_third": "Third-person field of view",
+ "verse.settings.gore": "Gore",
+ "verse.settings.gore.full": "Full",
+ "verse.settings.gore.reduced": "Reduced",
+ "verse.settings.invert_y": "Invert vertical look",
+ "verse.settings.level_sound": "Level-up sound",
+ "verse.settings.markers_note": "Hit markers differ by shape: ticks, ticks with a diamond, a ring, a square.",
+ "verse.settings.page.access": "Access",
+ "verse.settings.page.audio": "Sound",
+ "verse.settings.page.controls": "Keys",
+ "verse.settings.page.gameplay": "Game",
+ "verse.settings.page.video": "Video",
+ "verse.settings.press_key": "Press a key",
+ "verse.settings.quality": "Quality",
+ "verse.settings.quality.auto": "Auto",
+ "verse.settings.quality.cinematic": "Cinematic",
+ "verse.settings.quality.epic": "Epic",
+ "verse.settings.quality.high": "High",
+ "verse.settings.quality.low": "Low",
+ "verse.settings.quality.medium": "Medium",
+ "verse.settings.reduced_motion": "Reduced motion",
+ "verse.settings.reset": "Reset",
+ "verse.settings.sensitivity": "Look sensitivity",
+ "verse.settings.text_size": "Text size",
+ "verse.settings.title": "Settings",
+ "verse.settings.ui_sound": "Interface sounds",
+ "verse.settings.volume": "Volume",
+ "verse.tier.adaptive": "Adaptive",
+ "verse.tier.adaptive.desc": "Starts at hard and moves towards an even fight as the set goes on.",
+ "verse.tier.elite": "Elite",
+ "verse.tier.elite.desc": "Fast, precise and patient. Wins more often than not.",
+ "verse.tier.hard": "Hard",
+ "verse.tier.hard.desc": "Breaches, flanks and punishes the same trick twice.",
+ "verse.tier.normal": "Normal",
+ "verse.tier.normal.desc": "A steady opponent who leaves you room to learn the hall.",
+ "verse.ui.back": "Back",
+ "verse.ui.next": ">",
+ "verse.ui.off": "Off",
+ "verse.ui.on": "On",
+ "verse.ui.previous": "<"
+ }
+}
diff --git a/unreal/Verse/Data/ui/strings.es.json b/unreal/Verse/Data/ui/strings.es.json
new file mode 100644
index 0000000000..dca6f76332
--- /dev/null
+++ b/unreal/Verse/Data/ui/strings.es.json
@@ -0,0 +1,171 @@
+{
+ "schema": "verse.ui.strings/1",
+ "lang": "es",
+ "note": "Verse UI strings (WP18, A18.4). welcome.locale.strings and settings.changed override these at runtime (bridge-protocol 3.2, 12).",
+ "strings": {
+ "verse.armoury.loadout": "EQUIPO",
+ "verse.armoury.slot.gadgeta": "EQUIPO",
+ "verse.armoury.slot.gadgetb": "EQUIPO",
+ "verse.armoury.slot.melee": "CUERPO A CUERPO",
+ "verse.armoury.slot.primary": "PRINCIPAL",
+ "verse.armoury.slot.secondary": "SECUNDARIA",
+ "verse.armoury.start": "Empezar duelo",
+ "verse.armoury.tier": "RIVAL",
+ "verse.armoury.title": "Armería",
+ "verse.bar.leave_duel": "Salir del duelo",
+ "verse.bar.quick_duel": "Duelo rápido",
+ "verse.bar.return": "Volver a la app",
+ "verse.deck.bridge": "Puente",
+ "verse.deck.engineering": "Ingeniería",
+ "verse.deck.hangar": "Hangar",
+ "verse.deck.ops": "Operaciones",
+ "verse.duel.notice.left": "Has salido del duelo.",
+ "verse.duel.result.cancelled": "Duelo terminado",
+ "verse.duel.result.leave": "Volver a la nave",
+ "verse.duel.result.rematch": "Revancha",
+ "verse.end.adaptive": "Nivel del rival adaptativo: {skill} (0 normal, 0,5 difícil, 1 élite)",
+ "verse.end.leave": "Salir del duelo",
+ "verse.end.lost": "Set perdido",
+ "verse.end.next": "Siguiente set",
+ "verse.end.opponent": "RIVAL",
+ "verse.end.row.accuracy": "Precisión",
+ "verse.end.row.damage": "Daño causado",
+ "verse.end.row.deaths": "Muertes",
+ "verse.end.row.finishers": "Remates",
+ "verse.end.row.headshots": "A la cabeza",
+ "verse.end.row.kd": "K/D",
+ "verse.end.row.kills": "Bajas",
+ "verse.end.row.streak": "Mejor racha",
+ "verse.end.row.walls": "Muros abiertos",
+ "verse.end.score": "{person} : {opponent}",
+ "verse.end.set": "Set {set}",
+ "verse.end.sets": "Sets {won} : {lost}",
+ "verse.end.tier": "Rival: {tier}",
+ "verse.end.unfinished": "Set sin terminar",
+ "verse.end.won": "Set ganado",
+ "verse.end.you": "TÚ",
+ "verse.hud.chambered": "+1",
+ "verse.hud.cooldown": "{seconds} s",
+ "verse.hud.feed.finisher": "Remate",
+ "verse.hud.feed.headshot": " · a la cabeza",
+ "verse.hud.feed.kill": "{killer} · {weapon} · {victim}",
+ "verse.hud.feed.melee": "Cuerpo a cuerpo",
+ "verse.hud.feed.opponent": "Rival",
+ "verse.hud.feed.respawn": "{name} reaparece",
+ "verse.hud.feed.set_lost": "Set perdido",
+ "verse.hud.feed.set_unfinished": "Set sin terminar",
+ "verse.hud.feed.set_won": "Set ganado",
+ "verse.hud.feed.unknown": "Desconocido",
+ "verse.hud.feed.wallshot": " · a través",
+ "verse.hud.feed.world": "El hangar",
+ "verse.hud.feed.you": "Tú",
+ "verse.hud.health": "SALUD",
+ "verse.hud.killcam": "Repetición · {name}",
+ "verse.hud.killcam_skip": "Saltar: {key}",
+ "verse.hud.protected": "Protección {seconds} s",
+ "verse.hud.reload_empty": "RECARGA VACÍA",
+ "verse.hud.reload_tactical": "RECARGANDO",
+ "verse.hud.reserve": "/ {reserve}",
+ "verse.hud.respawn_in": "Reaparición en {seconds}",
+ "verse.hud.score.opponent": "RIVAL",
+ "verse.hud.score.separator": ":",
+ "verse.hud.score.set": "Set {set} · a {target}",
+ "verse.hud.score.you": "TÚ",
+ "verse.hud.stance.crouch": "Agachado",
+ "verse.hud.stance.prone": "Cuerpo a tierra",
+ "verse.hud.stance.slide": "Deslizando",
+ "verse.hud.stance.stand": "De pie",
+ "verse.item.breach_charge.name": "Carga de brecha",
+ "verse.item.breach_charge.role": "Explosivo de brecha",
+ "verse.item.breach_charge.short": "BREACH",
+ "verse.item.bulwark.name": "Bulwark",
+ "verse.item.bulwark.role": "Barricada de energía desplegable",
+ "verse.item.bulwark.short": "BULWARK",
+ "verse.item.graveline.name": "Graveline",
+ "verse.item.graveline.role": "Fusil de asalto",
+ "verse.item.graveline.short": "RIFLE",
+ "verse.item.hookbill.name": "Hookbill",
+ "verse.item.hookbill.role": "Cuchillo",
+ "verse.item.hookbill.short": "KNIFE",
+ "verse.item.longsight.name": "Longsight",
+ "verse.item.longsight.role": "Fusil de tirador",
+ "verse.item.longsight.short": "DMR",
+ "verse.item.skitter.name": "Skitter",
+ "verse.item.skitter.role": "Subfusil",
+ "verse.item.skitter.short": "SMG",
+ "verse.item.tallow.name": "Tallow",
+ "verse.item.tallow.role": "Pistola",
+ "verse.item.tallow.short": "PISTOL",
+ "verse.key.ads": "Apuntar",
+ "verse.key.crouch": "Agacharse y deslizar",
+ "verse.key.fire": "Disparar",
+ "verse.key.gadget_a": "Bulwark",
+ "verse.key.gadget_b": "Carga de brecha",
+ "verse.key.interact": "Usar",
+ "verse.key.jump": "Saltar y trepar",
+ "verse.key.lean_left": "Asomarse izquierda",
+ "verse.key.lean_right": "Asomarse derecha",
+ "verse.key.melee": "Cuchillo",
+ "verse.key.move_back": "Retroceder",
+ "verse.key.move_forward": "Avanzar",
+ "verse.key.move_left": "Izquierda",
+ "verse.key.move_right": "Derecha",
+ "verse.key.prone": "Tumbarse",
+ "verse.key.reload": "Recargar",
+ "verse.key.return_to_app": "Volver a la app",
+ "verse.key.skip_kill_cam": "Saltar repetición",
+ "verse.key.slot_melee": "Sacar cuchillo",
+ "verse.key.slot_primary": "Arma principal",
+ "verse.key.slot_secondary": "Arma secundaria",
+ "verse.key.sprint": "Correr",
+ "verse.key.verse_bar": "Barra del Verse",
+ "verse.key.walk": "Caminar (pasos silenciosos)",
+ "verse.menu.leave_duel": "Salir del duelo",
+ "verse.menu.resume": "Continuar",
+ "verse.menu.return": "Volver a la app",
+ "verse.menu.settings": "Ajustes",
+ "verse.menu.title": "Menú",
+ "verse.settings.duel_fov": "Campo de visión en duelo",
+ "verse.settings.fov_first": "Visión en primera persona",
+ "verse.settings.fov_third": "Visión en tercera persona",
+ "verse.settings.gore": "Sangre",
+ "verse.settings.gore.full": "Completa",
+ "verse.settings.gore.reduced": "Reducida",
+ "verse.settings.invert_y": "Invertir eje vertical",
+ "verse.settings.level_sound": "Sonido de nivel",
+ "verse.settings.markers_note": "Los marcadores se distinguen por la forma: trazos, trazos con rombo, anillo, cuadrado.",
+ "verse.settings.page.access": "Acceso",
+ "verse.settings.page.audio": "Sonido",
+ "verse.settings.page.controls": "Teclas",
+ "verse.settings.page.gameplay": "Juego",
+ "verse.settings.page.video": "Gráficos",
+ "verse.settings.press_key": "Pulsa una tecla",
+ "verse.settings.quality": "Calidad",
+ "verse.settings.quality.auto": "Automática",
+ "verse.settings.quality.cinematic": "Cine",
+ "verse.settings.quality.epic": "Épica",
+ "verse.settings.quality.high": "Alta",
+ "verse.settings.quality.low": "Baja",
+ "verse.settings.quality.medium": "Media",
+ "verse.settings.reduced_motion": "Menos movimiento",
+ "verse.settings.reset": "Restablecer",
+ "verse.settings.sensitivity": "Sensibilidad",
+ "verse.settings.text_size": "Tamaño del texto",
+ "verse.settings.title": "Ajustes",
+ "verse.settings.ui_sound": "Sonidos de interfaz",
+ "verse.settings.volume": "Volumen",
+ "verse.tier.adaptive": "Adaptativo",
+ "verse.tier.adaptive.desc": "Empieza en difícil y busca un combate igualado durante el set.",
+ "verse.tier.elite": "Élite",
+ "verse.tier.elite.desc": "Rápido, preciso y paciente. Gana más veces de las que pierde.",
+ "verse.tier.hard": "Difícil",
+ "verse.tier.hard.desc": "Abre brechas, flanquea y castiga el mismo truco dos veces.",
+ "verse.tier.normal": "Normal",
+ "verse.tier.normal.desc": "Un rival constante que te deja aprender el hangar.",
+ "verse.ui.back": "Atrás",
+ "verse.ui.next": ">",
+ "verse.ui.off": "No",
+ "verse.ui.on": "Sí",
+ "verse.ui.previous": "<"
+ }
+}
diff --git a/unreal/Verse/Data/ui/strings.pt.json b/unreal/Verse/Data/ui/strings.pt.json
new file mode 100644
index 0000000000..cfe5688954
--- /dev/null
+++ b/unreal/Verse/Data/ui/strings.pt.json
@@ -0,0 +1,171 @@
+{
+ "schema": "verse.ui.strings/1",
+ "lang": "pt",
+ "note": "Verse UI strings (WP18, A18.4). welcome.locale.strings and settings.changed override these at runtime (bridge-protocol 3.2, 12).",
+ "strings": {
+ "verse.armoury.loadout": "EQUIPAMENTO",
+ "verse.armoury.slot.gadgeta": "EQUIPAMENTO",
+ "verse.armoury.slot.gadgetb": "EQUIPAMENTO",
+ "verse.armoury.slot.melee": "CORPO A CORPO",
+ "verse.armoury.slot.primary": "PRINCIPAL",
+ "verse.armoury.slot.secondary": "SECUNDÁRIA",
+ "verse.armoury.start": "Iniciar duelo",
+ "verse.armoury.tier": "RIVAL",
+ "verse.armoury.title": "Arsenal",
+ "verse.bar.leave_duel": "Sair do duelo",
+ "verse.bar.quick_duel": "Duelo rápido",
+ "verse.bar.return": "Voltar ao app",
+ "verse.deck.bridge": "Ponte",
+ "verse.deck.engineering": "Engenharia",
+ "verse.deck.hangar": "Hangar",
+ "verse.deck.ops": "Operações",
+ "verse.duel.notice.left": "Você saiu do duelo.",
+ "verse.duel.result.cancelled": "Duelo encerrado",
+ "verse.duel.result.leave": "Voltar à nave",
+ "verse.duel.result.rematch": "Revanche",
+ "verse.end.adaptive": "Nível do rival adaptativo: {skill} (0 normal, 0,5 difícil, 1 elite)",
+ "verse.end.leave": "Sair do duelo",
+ "verse.end.lost": "Set perdido",
+ "verse.end.next": "Próximo set",
+ "verse.end.opponent": "RIVAL",
+ "verse.end.row.accuracy": "Precisão",
+ "verse.end.row.damage": "Dano causado",
+ "verse.end.row.deaths": "Mortes",
+ "verse.end.row.finishers": "Finalizações",
+ "verse.end.row.headshots": "Na cabeça",
+ "verse.end.row.kd": "K/D",
+ "verse.end.row.kills": "Abates",
+ "verse.end.row.streak": "Melhor sequência",
+ "verse.end.row.walls": "Paredes rompidas",
+ "verse.end.score": "{person} : {opponent}",
+ "verse.end.set": "Set {set}",
+ "verse.end.sets": "Sets {won} : {lost}",
+ "verse.end.tier": "Rival: {tier}",
+ "verse.end.unfinished": "Set em aberto",
+ "verse.end.won": "Set vencido",
+ "verse.end.you": "VOCÊ",
+ "verse.hud.chambered": "+1",
+ "verse.hud.cooldown": "{seconds} s",
+ "verse.hud.feed.finisher": "Finalização",
+ "verse.hud.feed.headshot": " · na cabeça",
+ "verse.hud.feed.kill": "{killer} · {weapon} · {victim}",
+ "verse.hud.feed.melee": "Corpo a corpo",
+ "verse.hud.feed.opponent": "Rival",
+ "verse.hud.feed.respawn": "{name} voltou",
+ "verse.hud.feed.set_lost": "Set perdido",
+ "verse.hud.feed.set_unfinished": "Set em aberto",
+ "verse.hud.feed.set_won": "Set vencido",
+ "verse.hud.feed.unknown": "Desconhecido",
+ "verse.hud.feed.wallshot": " · através",
+ "verse.hud.feed.world": "O hangar",
+ "verse.hud.feed.you": "Você",
+ "verse.hud.health": "VIDA",
+ "verse.hud.killcam": "Replay · {name}",
+ "verse.hud.killcam_skip": "Pular: {key}",
+ "verse.hud.protected": "Proteção {seconds} s",
+ "verse.hud.reload_empty": "RECARGA VAZIA",
+ "verse.hud.reload_tactical": "RECARREGANDO",
+ "verse.hud.reserve": "/ {reserve}",
+ "verse.hud.respawn_in": "Retorno em {seconds}",
+ "verse.hud.score.opponent": "RIVAL",
+ "verse.hud.score.separator": ":",
+ "verse.hud.score.set": "Set {set} · até {target}",
+ "verse.hud.score.you": "VOCÊ",
+ "verse.hud.stance.crouch": "Agachado",
+ "verse.hud.stance.prone": "Deitado",
+ "verse.hud.stance.slide": "Deslizando",
+ "verse.hud.stance.stand": "Em pé",
+ "verse.item.breach_charge.name": "Carga de brecha",
+ "verse.item.breach_charge.role": "Explosivo de brecha",
+ "verse.item.breach_charge.short": "BREACH",
+ "verse.item.bulwark.name": "Bulwark",
+ "verse.item.bulwark.role": "Barreira de energia móvel",
+ "verse.item.bulwark.short": "BULWARK",
+ "verse.item.graveline.name": "Graveline",
+ "verse.item.graveline.role": "Fuzil de assalto",
+ "verse.item.graveline.short": "RIFLE",
+ "verse.item.hookbill.name": "Hookbill",
+ "verse.item.hookbill.role": "Faca",
+ "verse.item.hookbill.short": "KNIFE",
+ "verse.item.longsight.name": "Longsight",
+ "verse.item.longsight.role": "Fuzil de precisão",
+ "verse.item.longsight.short": "DMR",
+ "verse.item.skitter.name": "Skitter",
+ "verse.item.skitter.role": "Submetralhadora",
+ "verse.item.skitter.short": "SMG",
+ "verse.item.tallow.name": "Tallow",
+ "verse.item.tallow.role": "Pistola",
+ "verse.item.tallow.short": "PISTOL",
+ "verse.key.ads": "Mirar",
+ "verse.key.crouch": "Agachar e deslizar",
+ "verse.key.fire": "Atirar",
+ "verse.key.gadget_a": "Bulwark",
+ "verse.key.gadget_b": "Carga de brecha",
+ "verse.key.interact": "Usar",
+ "verse.key.jump": "Pular e escalar",
+ "verse.key.lean_left": "Inclinar à esquerda",
+ "verse.key.lean_right": "Inclinar à direita",
+ "verse.key.melee": "Faca",
+ "verse.key.move_back": "Recuar",
+ "verse.key.move_forward": "Avançar",
+ "verse.key.move_left": "Esquerda",
+ "verse.key.move_right": "Direita",
+ "verse.key.prone": "Deitar",
+ "verse.key.reload": "Recarregar",
+ "verse.key.return_to_app": "Voltar ao app",
+ "verse.key.skip_kill_cam": "Pular replay",
+ "verse.key.slot_melee": "Sacar faca",
+ "verse.key.slot_primary": "Arma principal",
+ "verse.key.slot_secondary": "Arma secundária",
+ "verse.key.sprint": "Correr",
+ "verse.key.verse_bar": "Barra do Verse",
+ "verse.key.walk": "Andar (passos silenciosos)",
+ "verse.menu.leave_duel": "Sair do duelo",
+ "verse.menu.resume": "Continuar",
+ "verse.menu.return": "Voltar ao app",
+ "verse.menu.settings": "Configurações",
+ "verse.menu.title": "Menu",
+ "verse.settings.duel_fov": "Campo de visão no duelo",
+ "verse.settings.fov_first": "Visão em primeira pessoa",
+ "verse.settings.fov_third": "Visão em terceira pessoa",
+ "verse.settings.gore": "Sangue",
+ "verse.settings.gore.full": "Completo",
+ "verse.settings.gore.reduced": "Reduzido",
+ "verse.settings.invert_y": "Inverter eixo vertical",
+ "verse.settings.level_sound": "Som de nível",
+ "verse.settings.markers_note": "Os marcadores diferem pela forma: traços, traços com losango, anel, quadrado.",
+ "verse.settings.page.access": "Acesso",
+ "verse.settings.page.audio": "Som",
+ "verse.settings.page.controls": "Teclas",
+ "verse.settings.page.gameplay": "Jogo",
+ "verse.settings.page.video": "Vídeo",
+ "verse.settings.press_key": "Pressione uma tecla",
+ "verse.settings.quality": "Qualidade",
+ "verse.settings.quality.auto": "Automática",
+ "verse.settings.quality.cinematic": "Cinema",
+ "verse.settings.quality.epic": "Épica",
+ "verse.settings.quality.high": "Alta",
+ "verse.settings.quality.low": "Baixa",
+ "verse.settings.quality.medium": "Média",
+ "verse.settings.reduced_motion": "Menos movimento",
+ "verse.settings.reset": "Redefinir",
+ "verse.settings.sensitivity": "Sensibilidade",
+ "verse.settings.text_size": "Tamanho do texto",
+ "verse.settings.title": "Configurações",
+ "verse.settings.ui_sound": "Sons da interface",
+ "verse.settings.volume": "Volume",
+ "verse.tier.adaptive": "Adaptativo",
+ "verse.tier.adaptive.desc": "Começa no difícil e busca uma luta equilibrada ao longo do set.",
+ "verse.tier.elite": "Elite",
+ "verse.tier.elite.desc": "Rápido, preciso e paciente. Vence na maioria das vezes.",
+ "verse.tier.hard": "Difícil",
+ "verse.tier.hard.desc": "Abre brechas, flanqueia e pune o mesmo truque duas vezes.",
+ "verse.tier.normal": "Normal",
+ "verse.tier.normal.desc": "Um rival constante que deixa você aprender o hangar.",
+ "verse.ui.back": "Voltar",
+ "verse.ui.next": ">",
+ "verse.ui.off": "Não",
+ "verse.ui.on": "Sim",
+ "verse.ui.previous": "<"
+ }
+}
diff --git a/unreal/Verse/Data/ui/strings.zh.json b/unreal/Verse/Data/ui/strings.zh.json
new file mode 100644
index 0000000000..b453e0a554
--- /dev/null
+++ b/unreal/Verse/Data/ui/strings.zh.json
@@ -0,0 +1,171 @@
+{
+ "schema": "verse.ui.strings/1",
+ "lang": "zh",
+ "note": "Verse UI strings (WP18, A18.4). welcome.locale.strings and settings.changed override these at runtime (bridge-protocol 3.2, 12).",
+ "strings": {
+ "verse.armoury.loadout": "装备",
+ "verse.armoury.slot.gadgeta": "装置",
+ "verse.armoury.slot.gadgetb": "装置",
+ "verse.armoury.slot.melee": "近战",
+ "verse.armoury.slot.primary": "主武器",
+ "verse.armoury.slot.secondary": "副武器",
+ "verse.armoury.start": "开始对决",
+ "verse.armoury.tier": "对手",
+ "verse.armoury.title": "军械库",
+ "verse.bar.leave_duel": "离开对决",
+ "verse.bar.quick_duel": "快速对决",
+ "verse.bar.return": "返回应用",
+ "verse.deck.bridge": "舰桥",
+ "verse.deck.engineering": "轮机",
+ "verse.deck.hangar": "机库",
+ "verse.deck.ops": "作战",
+ "verse.duel.notice.left": "你已退出决斗。",
+ "verse.duel.result.cancelled": "决斗结束",
+ "verse.duel.result.leave": "返回飞船",
+ "verse.duel.result.rematch": "再来一局",
+ "verse.end.adaptive": "自适应对手当前强度 {skill}(0 普通,0.5 困难,1 精英)",
+ "verse.end.leave": "离开对决",
+ "verse.end.lost": "本局失利",
+ "verse.end.next": "下一局",
+ "verse.end.opponent": "对手",
+ "verse.end.row.accuracy": "命中率",
+ "verse.end.row.damage": "造成伤害",
+ "verse.end.row.deaths": "阵亡",
+ "verse.end.row.finishers": "处决",
+ "verse.end.row.headshots": "爆头",
+ "verse.end.row.kd": "K/D",
+ "verse.end.row.kills": "击杀",
+ "verse.end.row.streak": "最高连杀",
+ "verse.end.row.walls": "破墙次数",
+ "verse.end.score": "{person} : {opponent}",
+ "verse.end.set": "第 {set} 局",
+ "verse.end.sets": "局数 {won} : {lost}",
+ "verse.end.tier": "对手:{tier}",
+ "verse.end.unfinished": "本局未完成",
+ "verse.end.won": "本局胜利",
+ "verse.end.you": "你",
+ "verse.hud.chambered": "+1",
+ "verse.hud.cooldown": "{seconds} 秒",
+ "verse.hud.feed.finisher": "处决",
+ "verse.hud.feed.headshot": " · 爆头",
+ "verse.hud.feed.kill": "{killer} · {weapon} · {victim}",
+ "verse.hud.feed.melee": "近战",
+ "verse.hud.feed.opponent": "对手",
+ "verse.hud.feed.respawn": "{name} 已重新部署",
+ "verse.hud.feed.set_lost": "本局失利",
+ "verse.hud.feed.set_unfinished": "本局未完成",
+ "verse.hud.feed.set_won": "本局胜利",
+ "verse.hud.feed.unknown": "未知",
+ "verse.hud.feed.wallshot": " · 穿墙",
+ "verse.hud.feed.world": "机库",
+ "verse.hud.feed.you": "你",
+ "verse.hud.health": "生命",
+ "verse.hud.killcam": "击杀回放 · {name}",
+ "verse.hud.killcam_skip": "跳过:{key}",
+ "verse.hud.protected": "出生保护 {seconds} 秒",
+ "verse.hud.reload_empty": "空仓换弹",
+ "verse.hud.reload_tactical": "换弹中",
+ "verse.hud.reserve": "/ {reserve}",
+ "verse.hud.respawn_in": "{seconds} 秒后重新部署",
+ "verse.hud.score.opponent": "对手",
+ "verse.hud.score.separator": ":",
+ "verse.hud.score.set": "第 {set} 局 · 先到 {target}",
+ "verse.hud.score.you": "你",
+ "verse.hud.stance.crouch": "蹲伏",
+ "verse.hud.stance.prone": "卧倒",
+ "verse.hud.stance.slide": "滑行",
+ "verse.hud.stance.stand": "站立",
+ "verse.item.breach_charge.name": "破墙炸药",
+ "verse.item.breach_charge.role": "破墙炸药",
+ "verse.item.breach_charge.short": "BREACH",
+ "verse.item.bulwark.name": "Bulwark",
+ "verse.item.bulwark.role": "可部署能量屏障",
+ "verse.item.bulwark.short": "BULWARK",
+ "verse.item.graveline.name": "Graveline",
+ "verse.item.graveline.role": "突击步枪",
+ "verse.item.graveline.short": "RIFLE",
+ "verse.item.hookbill.name": "Hookbill",
+ "verse.item.hookbill.role": "匕首",
+ "verse.item.hookbill.short": "KNIFE",
+ "verse.item.longsight.name": "Longsight",
+ "verse.item.longsight.role": "精确射手步枪",
+ "verse.item.longsight.short": "DMR",
+ "verse.item.skitter.name": "Skitter",
+ "verse.item.skitter.role": "冲锋枪",
+ "verse.item.skitter.short": "SMG",
+ "verse.item.tallow.name": "Tallow",
+ "verse.item.tallow.role": "手枪",
+ "verse.item.tallow.short": "PISTOL",
+ "verse.key.ads": "瞄准",
+ "verse.key.crouch": "蹲伏与滑行",
+ "verse.key.fire": "开火",
+ "verse.key.gadget_a": "Bulwark",
+ "verse.key.gadget_b": "破墙炸药",
+ "verse.key.interact": "使用",
+ "verse.key.jump": "跳跃与攀爬",
+ "verse.key.lean_left": "左探身",
+ "verse.key.lean_right": "右探身",
+ "verse.key.melee": "匕首",
+ "verse.key.move_back": "后退",
+ "verse.key.move_forward": "前进",
+ "verse.key.move_left": "左移",
+ "verse.key.move_right": "右移",
+ "verse.key.prone": "卧倒",
+ "verse.key.reload": "换弹",
+ "verse.key.return_to_app": "返回应用",
+ "verse.key.skip_kill_cam": "跳过击杀回放",
+ "verse.key.slot_melee": "持刀",
+ "verse.key.slot_primary": "主武器",
+ "verse.key.slot_secondary": "副武器",
+ "verse.key.sprint": "冲刺",
+ "verse.key.verse_bar": "Verse 工具栏",
+ "verse.key.walk": "慢走(脚步无声)",
+ "verse.menu.leave_duel": "离开对决",
+ "verse.menu.resume": "继续",
+ "verse.menu.return": "返回应用",
+ "verse.menu.settings": "设置",
+ "verse.menu.title": "菜单",
+ "verse.settings.duel_fov": "对决视野",
+ "verse.settings.fov_first": "第一人称视野",
+ "verse.settings.fov_third": "第三人称视野",
+ "verse.settings.gore": "血腥",
+ "verse.settings.gore.full": "完整",
+ "verse.settings.gore.reduced": "减弱",
+ "verse.settings.invert_y": "反转垂直视角",
+ "verse.settings.level_sound": "升级音效",
+ "verse.settings.markers_note": "命中标记以形状区分:短线、带菱形的短线、圆环、方框。",
+ "verse.settings.page.access": "辅助",
+ "verse.settings.page.audio": "声音",
+ "verse.settings.page.controls": "按键",
+ "verse.settings.page.gameplay": "游戏",
+ "verse.settings.page.video": "画面",
+ "verse.settings.press_key": "请按键",
+ "verse.settings.quality": "画质",
+ "verse.settings.quality.auto": "自动",
+ "verse.settings.quality.cinematic": "电影",
+ "verse.settings.quality.epic": "极高",
+ "verse.settings.quality.high": "高",
+ "verse.settings.quality.low": "低",
+ "verse.settings.quality.medium": "中",
+ "verse.settings.reduced_motion": "减少动态",
+ "verse.settings.reset": "重置",
+ "verse.settings.sensitivity": "视角灵敏度",
+ "verse.settings.text_size": "文字大小",
+ "verse.settings.title": "设置",
+ "verse.settings.ui_sound": "界面音效",
+ "verse.settings.volume": "音量",
+ "verse.tier.adaptive": "自适应",
+ "verse.tier.adaptive.desc": "从困难开始,随局势调整到势均力敌。",
+ "verse.tier.elite": "精英",
+ "verse.tier.elite.desc": "快速、精准、有耐心,胜多负少。",
+ "verse.tier.hard": "困难",
+ "verse.tier.hard.desc": "会破墙、包抄,同一招用两次就会被惩罚。",
+ "verse.tier.normal": "普通",
+ "verse.tier.normal.desc": "稳健的对手,给你时间熟悉机库。",
+ "verse.ui.back": "返回",
+ "verse.ui.next": ">",
+ "verse.ui.off": "关",
+ "verse.ui.on": "开",
+ "verse.ui.previous": "<"
+ }
+}
diff --git a/unreal/Verse/Source/VerseUI/Private/Core/VerseUiCore.cpp b/unreal/Verse/Source/VerseUI/Private/Core/VerseUiCore.cpp
new file mode 100644
index 0000000000..1de2a25077
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Private/Core/VerseUiCore.cpp
@@ -0,0 +1,295 @@
+#include "Core/VerseUiLayout.h"
+#include "Core/VerseUiStrings.h"
+#include "Core/VerseUiTheme.h"
+#include "Internationalization/Culture.h"
+#include "Internationalization/Internationalization.h"
+#include "Misc/FileHelper.h"
+#include "Misc/Paths.h"
+#include "Serialization/JsonReader.h"
+#include "Serialization/JsonSerializer.h"
+#include "VerseLog.h"
+
+// ---------------------------------------------------------------------------------------------
+// Theme
+
+bool VerseUiTheme::IsForbiddenAccent(const FLinearColor& Colour)
+{
+ const FLinearColor Hsv = Colour.LinearRGBToHSV();
+ const float Hue = Hsv.R;
+ const float Saturation = Hsv.G;
+ const float Value = Hsv.B;
+ return Saturation > 0.25f && Value > 0.05f && Hue >= 170.f && Hue <= 300.f;
+}
+
+TArray<FLinearColor> VerseUiTheme::AllColours()
+{
+ return {Steel, SteelLight, Edge, Text, TextDim, Amber, Red, Gold, Blocked, Shadow};
+}
+
+// ---------------------------------------------------------------------------------------------
+// Layout
+
+FVerseUiLayout FVerseUiLayout::Compute(const FVector2D& Viewport, float SafeFraction, const FMargin& PlatformPadding, float UserTextScale)
+{
+ FVerseUiLayout Layout;
+ Layout.Viewport = FVector2D(FMath::Max(1.0, Viewport.X), FMath::Max(1.0, Viewport.Y));
+ Layout.Scale = FMath::Clamp(float(FMath::Min(Layout.Viewport.X / ReferenceWidth, Layout.Viewport.Y / ReferenceHeight)), 0.5f, 4.f);
+ Layout.TextScale = Layout.Scale * FMath::Clamp(UserTextScale, 0.8f, 1.6f);
+
+ const float Fraction = FMath::Clamp(SafeFraction, 0.f, 0.2f);
+ const double Left = FMath::Max<double>(Layout.Viewport.X * Fraction, PlatformPadding.Left);
+ const double Right = FMath::Max<double>(Layout.Viewport.X * Fraction, PlatformPadding.Right);
+ const double Top = FMath::Max<double>(Layout.Viewport.Y * Fraction, PlatformPadding.Top);
+ const double Bottom = FMath::Max<double>(Layout.Viewport.Y * Fraction, PlatformPadding.Bottom);
+ Layout.SafeMin = FVector2D(Left, Top);
+ Layout.SafeMax = FVector2D(Layout.Viewport.X - Right, Layout.Viewport.Y - Bottom);
+ return Layout;
+}
+
+int32 FVerseUiLayout::FontSize(float ReferencePt) const
+{
+ return FMath::Max(6, FMath::RoundToInt(ReferencePt * TextScale));
+}
+
+FVector2D FVerseUiLayout::Place(EVerseUiAnchor Anchor, const FVector2D& Size, const FVector2D& Offset) const
+{
+ const FVector2D Inset = Offset * Scale;
+ const FVector2D Safe = SafeSize();
+ FVector2D P = SafeMin;
+ switch (Anchor)
+ {
+ case EVerseUiAnchor::TopLeft: P = SafeMin + Inset; break;
+ case EVerseUiAnchor::Top: P = FVector2D(SafeMin.X + (Safe.X - Size.X) * 0.5 + Inset.X, SafeMin.Y + Inset.Y); break;
+ case EVerseUiAnchor::TopRight: P = FVector2D(SafeMax.X - Size.X - Inset.X, SafeMin.Y + Inset.Y); break;
+ case EVerseUiAnchor::Left: P = FVector2D(SafeMin.X + Inset.X, SafeMin.Y + (Safe.Y - Size.Y) * 0.5 + Inset.Y); break;
+ case EVerseUiAnchor::Centre: P = SafeMin + (Safe - Size) * 0.5 + Inset; break;
+ case EVerseUiAnchor::Right: P = FVector2D(SafeMax.X - Size.X - Inset.X, SafeMin.Y + (Safe.Y - Size.Y) * 0.5 + Inset.Y); break;
+ case EVerseUiAnchor::BottomLeft: P = FVector2D(SafeMin.X + Inset.X, SafeMax.Y - Size.Y - Inset.Y); break;
+ case EVerseUiAnchor::Bottom: P = FVector2D(SafeMin.X + (Safe.X - Size.X) * 0.5 + Inset.X, SafeMax.Y - Size.Y - Inset.Y); break;
+ case EVerseUiAnchor::BottomRight: P = SafeMax - Size - Inset; break;
+ }
+ P.X = FMath::Clamp(P.X, SafeMin.X, FMath::Max(SafeMin.X, SafeMax.X - Size.X));
+ P.Y = FMath::Clamp(P.Y, SafeMin.Y, FMath::Max(SafeMin.Y, SafeMax.Y - Size.Y));
+ return P;
+}
+
+// ---------------------------------------------------------------------------------------------
+// Strings
+
+const TArray<FString>& FVerseUiStrings::SupportedLanguages()
+{
+ static const TArray<FString> Languages = {TEXT("en"), TEXT("de"), TEXT("es"), TEXT("pt"), TEXT("zh")};
+ return Languages;
+}
+
+FString FVerseUiStrings::DefaultCatalogueDir()
+{
+ return FPaths::Combine(FPaths::ProjectDir(), TEXT("Data"), TEXT("ui"));
+}
+
+bool FVerseUiStrings::LoadCatalogue(const FString& Dir, FString* OutError)
+{
+ Catalogue.Reset();
+ bool bAll = true;
+ for (const FString& Lang : SupportedLanguages())
+ {
+ const FString Path = FPaths::Combine(Dir, FString::Printf(TEXT("strings.%s.json"), *Lang));
+ FString Json;
+ if (!FFileHelper::LoadFileToString(Json, *Path) || !LoadCatalogueJson(Json, OutError))
+ {
+ if (OutError && OutError->IsEmpty())
+ {
+ *OutError = FString::Printf(TEXT("cannot read %s"), *Path);
+ }
+ bAll = false;
+ }
+ }
+ return bAll;
+}
+
+bool FVerseUiStrings::LoadCatalogueJson(const FString& Json, FString* OutError)
+{
+ TSharedPtr<FJsonObject> Root;
+ const TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(Json);
+ if (!FJsonSerializer::Deserialize(Reader, Root) || !Root.IsValid())
+ {
+ if (OutError)
+ {
+ *OutError = TEXT("strings catalogue is not JSON");
+ }
+ return false;
+ }
+ const TSharedPtr<FJsonObject>* Table = nullptr;
+ FString Lang;
+ if (!Root->TryGetObjectField(TEXT("strings"), Table) || !Root->TryGetStringField(TEXT("lang"), Lang))
+ {
+ if (OutError)
+ {
+ *OutError = TEXT("strings file needs \"lang\" and a \"strings\" object");
+ }
+ return false;
+ }
+ for (const TPair<FString, TSharedPtr<FJsonValue>>& Entry : (*Table)->Values)
+ {
+ FString Text;
+ if (Entry.Value.IsValid() && Entry.Value->TryGetString(Text))
+ {
+ Catalogue.FindOrAdd(Entry.Key).Add(Lang, Text);
+ }
+ }
+ return true;
+}
+
+void FVerseUiStrings::SetLanguage(const FString& Lang, const FString& InFallback)
+{
+ const FString Short = Lang.Left(2).ToLower();
+ const FString ShortFallback = InFallback.Left(2).ToLower();
+ Fallback = SupportedLanguages().Contains(ShortFallback) ? ShortFallback : FString(TEXT("en"));
+ Language = SupportedLanguages().Contains(Short) ? Short : Fallback;
+}
+
+void FVerseUiStrings::ApplyBridgeLocale(const TSharedPtr<FJsonObject>& Locale)
+{
+ if (!Locale.IsValid())
+ {
+ return;
+ }
+ FString Lang = Language;
+ FString Fb = Fallback;
+ Locale->TryGetStringField(TEXT("lang"), Lang);
+ Locale->TryGetStringField(TEXT("fallback"), Fb);
+ SetLanguage(Lang, Fb);
+ BridgeStrings.Reset();
+ const TSharedPtr<FJsonObject>* Table = nullptr;
+ if (Locale->TryGetObjectField(TEXT("strings"), Table))
+ {
+ for (const TPair<FString, TSharedPtr<FJsonValue>>& Entry : (*Table)->Values)
+ {
+ FString Text;
+ if (Entry.Value.IsValid() && Entry.Value->TryGetString(Text))
+ {
+ BridgeStrings.Add(Entry.Key, Text);
+ }
+ }
+ }
+}
+
+void FVerseUiStrings::ApplySettingsChanged(const TSharedPtr<FJsonObject>& Data)
+{
+ if (!Data.IsValid())
+ {
+ return;
+ }
+ FString Lang;
+ if (Data->TryGetStringField(TEXT("lang"), Lang))
+ {
+ const FString Before = Language;
+ SetLanguage(Lang, Fallback);
+ if (Before != Language)
+ {
+ // Bridge strings were for the old language; the new set follows in "strings".
+ BridgeStrings.Reset();
+ }
+ }
+ const TSharedPtr<FJsonObject>* Table = nullptr;
+ if (Data->TryGetObjectField(TEXT("strings"), Table))
+ {
+ for (const TPair<FString, TSharedPtr<FJsonValue>>& Entry : (*Table)->Values)
+ {
+ FString Text;
+ if (Entry.Value.IsValid() && Entry.Value->TryGetString(Text))
+ {
+ BridgeStrings.Add(Entry.Key, Text);
+ }
+ }
+ }
+}
+
+FString FVerseUiStrings::Resolve(const FString& Key) const
+{
+ if (const FString* Bridge = BridgeStrings.Find(Key))
+ {
+ return *Bridge;
+ }
+ if (const TMap<FString, FString>* PerLang = Catalogue.Find(Key))
+ {
+ for (const FString* Lang : {&Language, &Fallback})
+ {
+ if (const FString* Text = PerLang->Find(*Lang))
+ {
+ return *Text;
+ }
+ }
+ if (const FString* English = PerLang->Find(TEXT("en")))
+ {
+ return *English;
+ }
+ }
+ if (!ReportedMissing.Contains(Key))
+ {
+ ReportedMissing.Add(Key);
+ UE_LOG(LogVerseUI, Warning, TEXT("VerseUI: missing string %s"), *Key);
+ }
+ return Key;
+}
+
+FText FVerseUiStrings::Get(const FString& Key) const
+{
+ return FText::AsCultureInvariant(Resolve(Key));
+}
+
+FText FVerseUiStrings::Format(const FString& Key, const FFormatNamedArguments& Args) const
+{
+ return FText::Format(FTextFormat::FromString(Resolve(Key)), Args);
+}
+
+FString FVerseUiStrings::GetIn(const FString& Key, const FString& Lang) const
+{
+ if (const TMap<FString, FString>* PerLang = Catalogue.Find(Key))
+ {
+ if (const FString* Text = PerLang->Find(Lang))
+ {
+ return *Text;
+ }
+ }
+ return FString();
+}
+
+FCulturePtr FVerseUiStrings::GetCulture() const
+{
+ if (!CachedCulture.IsValid() || CachedCultureLang != Language)
+ {
+ CachedCultureLang = Language;
+ CachedCulture = FInternationalization::Get().GetCulture(Language);
+ if (!CachedCulture.IsValid())
+ {
+ CachedCulture = FInternationalization::Get().GetCulture(TEXT("en"));
+ }
+ }
+ return CachedCulture;
+}
+
+FText FVerseUiStrings::Number(double Value, int32 FractionDigits, bool bGrouping) const
+{
+ FNumberFormattingOptions Options;
+ Options.UseGrouping = bGrouping;
+ Options.MinimumFractionalDigits = FractionDigits;
+ Options.MaximumFractionalDigits = FractionDigits;
+ return FText::AsNumber(Value, &Options, GetCulture());
+}
+
+FText FVerseUiStrings::Percent(double Value, int32 FractionDigits) const
+{
+ FNumberFormattingOptions Options;
+ Options.MinimumFractionalDigits = FractionDigits;
+ Options.MaximumFractionalDigits = FractionDigits;
+ return FText::AsPercent(Value, &Options, GetCulture());
+}
+
+TArray<FString> FVerseUiStrings::GetKeys() const
+{
+ TArray<FString> Keys;
+ Catalogue.GetKeys(Keys);
+ Keys.Sort();
+ return Keys;
+}
diff --git a/unreal/Verse/Source/VerseUI/Private/Core/VerseUiDefaultPorts.cpp b/unreal/Verse/Source/VerseUI/Private/Core/VerseUiDefaultPorts.cpp
new file mode 100644
index 0000000000..13b79e56c4
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Private/Core/VerseUiDefaultPorts.cpp
@@ -0,0 +1,269 @@
+#include "Core/VerseUiDefaultPorts.h"
+
+#include "Camera/PlayerCameraManager.h"
+#include "Damage/VerseCombatStateComponent.h"
+#include "Engine/World.h"
+#include "GameFramework/GameStateBase.h"
+#include "GameFramework/Pawn.h"
+#include "GameFramework/PlayerController.h"
+#include "GameFramework/PlayerState.h"
+#include "Kismet/GameplayStatics.h"
+#include "Movement/VerseMovementQuery.h"
+#include "Policies/CondensedJsonPrintPolicy.h"
+#include "Qa/VerseQaRegistry.h"
+#include "Serialization/JsonSerializer.h"
+#include "Serialization/JsonWriter.h"
+#include "UObject/UnrealType.h"
+#include "VerseLog.h"
+
+namespace
+{
+ FString ToJsonString(const TSharedRef<FJsonObject>& Object)
+ {
+ FString Out;
+ const TSharedRef<TJsonWriter<TCHAR, TCondensedJsonPrintPolicy<TCHAR>>> Writer = TJsonWriterFactory<TCHAR, TCondensedJsonPrintPolicy<TCHAR>>::Create(&Out);
+ FJsonSerializer::Serialize(Object, Writer);
+ return Out;
+ }
+
+ bool IsQaRegistered(const FString& Command)
+ {
+ UVerseQaRegistry* Registry = UVerseQaRegistry::Get();
+ return Registry && Registry->IsRegistered(Command);
+ }
+
+ void RunQa(const FString& Command, const TArray<FString>& Args)
+ {
+ UVerseQaRegistry* Registry = UVerseQaRegistry::Get();
+ FString Result;
+ if (!Registry || !Registry->Execute(Command, Args, Result))
+ {
+ UE_LOG(LogVerseUI, Warning, TEXT("VerseUI: %s is not registered yet (%s)"), *Command, *Result);
+ return;
+ }
+ UE_LOG(LogVerseUI, Log, TEXT("VerseUI: %s -> %s"), *Command, *Result);
+ }
+}
+
+// ---------------------------------------------------------------------------------------------
+
+void FVerseUiLogBridgePort::SendSettingsSet(const TSharedRef<FJsonObject>& Data)
+{
+ ++NumSent;
+ UE_LOG(LogVerseUI, Log, TEXT("VerseUI: no bridge yet; settings.set %s"), *ToJsonString(Data));
+}
+
+void FVerseUiLogBridgePort::SendReturnToApp(const FString& Reason)
+{
+ ++NumSent;
+ UE_LOG(LogVerseUI, Log, TEXT("VerseUI: no bridge yet; focus.return_to_app {\"reason\":\"%s\"}"), *Reason);
+}
+
+// ---------------------------------------------------------------------------------------------
+
+void FVerseUiQaGamePort::StartDuel(FName Tier)
+{
+ RunQa(TEXT("Verse.QA.Duel.Start"), {Tier.ToString()});
+}
+
+void FVerseUiQaGamePort::LeaveDuel()
+{
+ RunQa(TEXT("Verse.QA.Duel.Leave"), {});
+}
+
+void FVerseUiQaGamePort::TravelToDeck(FName Deck)
+{
+ CurrentDeck = Deck;
+ RunQa(TEXT("Verse.QA.View.Set"), {FString::Printf(TEXT("deck=%s"), *Deck.ToString())});
+}
+
+void FVerseUiQaGamePort::SetPaused(bool bPaused)
+{
+ if (IsQaRegistered(TEXT("Verse.QA.Duel.Pause")))
+ {
+ RunQa(TEXT("Verse.QA.Duel.Pause"), {bPaused ? TEXT("on") : TEXT("off")});
+ return;
+ }
+ // The person hosts the duel (combat-state 5.1), so the engine pause holds the bot too.
+ if (UWorld* W = World.Get())
+ {
+ UGameplayStatics::SetGamePaused(W, bPaused);
+ }
+}
+
+void FVerseUiQaGamePort::NoteArenaSwitch(bool bOn, FName Deck)
+{
+ bArenaOn = bOn;
+ if (!Deck.IsNone())
+ {
+ CurrentDeck = Deck;
+ }
+}
+
+// ---------------------------------------------------------------------------------------------
+
+APlayerController* FVerseUiWorldHudSource::LocalController() const
+{
+ UWorld* W = World.Get();
+ return W ? W->GetFirstPlayerController() : nullptr;
+}
+
+APlayerState* FVerseUiWorldHudSource::FindPlayer(int32 PlayerId) const
+{
+ UWorld* W = World.Get();
+ AGameStateBase* GameState = W ? W->GetGameState() : nullptr;
+ if (!GameState)
+ {
+ return nullptr;
+ }
+ for (APlayerState* State : GameState->PlayerArray)
+ {
+ if (State && State->GetPlayerId() == PlayerId)
+ {
+ return State;
+ }
+ }
+ return nullptr;
+}
+
+int32 FVerseUiWorldHudSource::GetLocalPlayerId() const
+{
+ APlayerController* PC = LocalController();
+ return PC && PC->PlayerState ? PC->PlayerState->GetPlayerId() : INDEX_NONE;
+}
+
+double FVerseUiWorldHudSource::GetServerTime() const
+{
+ UWorld* W = World.Get();
+ if (!W)
+ {
+ return 0.0;
+ }
+ const AGameStateBase* GameState = W->GetGameState();
+ return GameState ? GameState->GetServerWorldTimeSeconds() : W->GetTimeSeconds();
+}
+
+void FVerseUiWorldHudSource::GetPawnState(FVerseHudPawnState& Out) const
+{
+ Out = FVerseHudPawnState();
+ APlayerController* PC = LocalController();
+ APawn* Pawn = PC ? PC->GetPawn() : nullptr;
+ if (!Pawn)
+ {
+ return;
+ }
+ Out.bValid = true;
+ // Health lives in WP02's attribute set; until it lands the UI tracks it from hit events.
+ Out.bHealthKnown = false;
+ if (const UVerseCombatStateComponent* Combat = Pawn->FindComponentByClass<UVerseCombatStateComponent>())
+ {
+ Out.Phase = Combat->Phase;
+ Out.bSpawnProtected = Combat->bSpawnProtected;
+ Out.SpawnProtectionRemaining = Combat->bSpawnProtected ? float(FMath::Max(0.0, Combat->SpawnProtectedUntil - GetServerTime())) : 0.f;
+ }
+ if (UActorComponent* Movement = Pawn->FindComponentByInterface(UVerseMovementQuery::StaticClass()))
+ {
+ if (const IVerseMovementQuery* Query = Cast<IVerseMovementQuery>(Movement))
+ {
+ Out.Stance = Query->GetStance();
+ }
+ }
+ // Magazine, reserve and gadgets come from WP02's inventory (combat-state 2.1), owner only.
+ Out.bHasWeapon = false;
+}
+
+bool FVerseUiWorldHudSource::GetView(FVerseHudView& Out) const
+{
+ APlayerController* PC = LocalController();
+ if (!PC || !PC->PlayerCameraManager)
+ {
+ return false;
+ }
+ const FMinimalViewInfo& View = PC->PlayerCameraManager->GetCameraCacheView();
+ Out.Location = View.Location;
+ Out.Rotation = View.Rotation;
+ Out.HorizontalFovDeg = View.FOV;
+ return true;
+}
+
+bool FVerseUiWorldHudSource::GetPredictedBoltDirection(FVector& OutDirection, float& OutSpreadHalfAngleDeg) const
+{
+ // Without WP02's weapon prediction the bolt leaves along the camera axis.
+ FVerseHudView View;
+ if (!GetView(View))
+ {
+ return false;
+ }
+ OutDirection = View.Rotation.Vector();
+ OutSpreadHalfAngleDeg = 0.f;
+ return true;
+}
+
+FText FVerseUiWorldHudSource::GetDisplayName(int32 PlayerId) const
+{
+ const APlayerState* State = FindPlayer(PlayerId);
+ // A player's own name is data, not a UI string.
+ return State ? FText::AsCultureInvariant(State->GetPlayerName()) : FText::GetEmpty();
+}
+
+bool FVerseUiWorldHudSource::IsBot(int32 PlayerId) const
+{
+ const APlayerState* State = FindPlayer(PlayerId);
+ return State && State->IsABot();
+}
+
+FName FVerseUiWorldHudSource::GetBotTier(int32 PlayerId) const
+{
+ const APlayerState* State = FindPlayer(PlayerId);
+ if (!State)
+ {
+ return NAME_None;
+ }
+ if (const FNameProperty* Prop = FindFProperty<FNameProperty>(State->GetClass(), TEXT("BotTier")))
+ {
+ return Prop->GetPropertyValue_InContainer(State);
+ }
+ return NAME_None;
+}
+
+float FVerseUiWorldHudSource::GetBotEffectiveSkill(int32 PlayerId) const
+{
+ const APlayerState* State = FindPlayer(PlayerId);
+ if (!State)
+ {
+ return -1.f;
+ }
+ if (const FFloatProperty* Prop = FindFProperty<FFloatProperty>(State->GetClass(), TEXT("BotEffectiveSkill")))
+ {
+ return Prop->GetPropertyValue_InContainer(State);
+ }
+ return -1.f;
+}
+
+void FVerseUiWorldHudSource::GetPawnPoses(TArray<FVersePawnPose>& Out) const
+{
+ Out.Reset();
+ UWorld* W = World.Get();
+ AGameStateBase* GameState = W ? W->GetGameState() : nullptr;
+ if (!GameState)
+ {
+ return;
+ }
+ for (APlayerState* State : GameState->PlayerArray)
+ {
+ const APawn* Pawn = State ? State->GetPawn() : nullptr;
+ if (Pawn)
+ {
+ FVersePawnPose Pose;
+ Pose.PlayerId = State->GetPlayerId();
+ Pose.Location = Pawn->GetActorLocation();
+ Pose.Rotation = Pawn->GetBaseAimRotation();
+ // The capsule of a simulated proxy sits at its newest replicated state (both smoothing
+ // modes move only the mesh), and the client's server clock (AGameStateBase: replicated
+ // server time minus local time at receipt) lags the server by the same one-way trip as
+ // that state, so the source's "now" stamps the capsule right (Pose.ServerTime < 0).
+ // The kill cam records and replays capsule positions, never the smoothed mesh.
+ Out.Add(Pose);
+ }
+ }
+}
diff --git a/unreal/Verse/Source/VerseUI/Private/Core/VerseUiDefaultPorts.h b/unreal/Verse/Source/VerseUI/Private/Core/VerseUiDefaultPorts.h
new file mode 100644
index 0000000000..193d5cfeda
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Private/Core/VerseUiDefaultPorts.h
@@ -0,0 +1,68 @@
+#pragma once
+
+#include "Core/VerseUiPorts.h"
+#include "CoreMinimal.h"
+
+class UWorld;
+
+/** Logs the frame it would send; WP17's VerseBridge client replaces it (SetBridgePort). */
+class FVerseUiLogBridgePort : public IVerseUiBridgePort
+{
+public:
+ virtual void SendSettingsSet(const TSharedRef<FJsonObject>& Data) override;
+ virtual void SendReturnToApp(const FString& Reason) override;
+
+ int32 NumSent = 0;
+};
+
+/**
+ * Runs the Verse.QA.Duel.* commands the duel owner registers (the one seam Core offers for it),
+ * and tracks the arena state from FVerseArenaSwitchEvent.
+ */
+class FVerseUiQaGamePort : public IVerseUiGamePort
+{
+public:
+ explicit FVerseUiQaGamePort(UWorld* InWorld = nullptr) : World(InWorld) {}
+
+ virtual void StartDuel(FName Tier) override;
+ virtual void LeaveDuel() override;
+ virtual void TravelToDeck(FName Deck) override;
+ virtual bool IsDuelRunning() const override { return bArenaOn; }
+ virtual FName GetCurrentDeck() const override { return CurrentDeck; }
+ /** Verse.QA.Duel.Pause when the duel owner registers it, else the engine pause. */
+ virtual void SetPaused(bool bPaused) override;
+
+ void NoteArenaSwitch(bool bOn, FName Deck);
+
+ TWeakObjectPtr<UWorld> World;
+ bool bArenaOn = false;
+ FName CurrentDeck = TEXT("bridge");
+};
+
+/**
+ * Reads the engine's player states and the local pawn: the combat state component, the
+ * movement query, and the contract fields of AVersePlayerState (BotTier, BotEffectiveSkill)
+ * by reflection, so VerseUI needs no include of the class that WP11 lands.
+ */
+class FVerseUiWorldHudSource : public IVerseHudSource
+{
+public:
+ explicit FVerseUiWorldHudSource(UWorld* InWorld) : World(InWorld) {}
+
+ virtual int32 GetLocalPlayerId() const override;
+ virtual double GetServerTime() const override;
+ virtual void GetPawnState(FVerseHudPawnState& Out) const override;
+ virtual bool GetView(FVerseHudView& Out) const override;
+ virtual bool GetPredictedBoltDirection(FVector& OutDirection, float& OutSpreadHalfAngleDeg) const override;
+ virtual FText GetDisplayName(int32 PlayerId) const override;
+ virtual bool IsBot(int32 PlayerId) const override;
+ virtual FName GetBotTier(int32 PlayerId) const override;
+ virtual float GetBotEffectiveSkill(int32 PlayerId) const override;
+ virtual void GetPawnPoses(TArray<FVersePawnPose>& Out) const override;
+
+private:
+ class APlayerController* LocalController() const;
+ class APlayerState* FindPlayer(int32 PlayerId) const;
+
+ TWeakObjectPtr<UWorld> World;
+};
diff --git a/unreal/Verse/Source/VerseUI/Private/Core/VerseUiSubsystem.cpp b/unreal/Verse/Source/VerseUI/Private/Core/VerseUiSubsystem.cpp
new file mode 100644
index 0000000000..483c598749
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Private/Core/VerseUiSubsystem.cpp
@@ -0,0 +1,1092 @@
+#include "Core/VerseUiSubsystem.h"
+
+#include "Camera/CameraActor.h"
+#include "Camera/CameraComponent.h"
+#include "CanvasItem.h"
+#include "Components/SkeletalMeshComponent.h"
+#include "Core/VerseUiDefaultPorts.h"
+#include "Core/VerseUiTheme.h"
+#include "Engine/Canvas.h"
+#include "Engine/Engine.h"
+#include "Engine/GameViewportClient.h"
+#include "Engine/LocalPlayer.h"
+#include "Engine/World.h"
+#include "EnhancedInputSubsystems.h"
+#include "Events/VerseEventHub.h"
+#include "Framework/Application/IInputProcessor.h"
+#include "Framework/Application/SlateApplication.h"
+#include "GameFramework/Character.h"
+#include "GameFramework/GameStateBase.h"
+#include "GameFramework/HUD.h"
+#include "GameFramework/Pawn.h"
+#include "GameFramework/PlayerController.h"
+#include "GameFramework/PlayerState.h"
+#include "HAL/IConsoleManager.h"
+#include "Menus/SVerseUiRoot.h"
+#include "Misc/App.h"
+#include "Misc/ConfigCacheIni.h"
+#include "Misc/FileHelper.h"
+#include "Misc/Paths.h"
+#include "QA/VerseUiQaCommands.h"
+#include "Scalability.h"
+#include "Serialization/JsonReader.h"
+#include "Serialization/JsonSerializer.h"
+#include "Subsystems/WorldSubsystem.h"
+#include "UObject/UnrealType.h"
+#include "VerseLog.h"
+
+/** Routes key presses to the UI before the game sees them; passes every key the UI does not use. */
+class FVerseUiInputProcessor : public IInputProcessor
+{
+public:
+ explicit FVerseUiInputProcessor(UVerseUiSubsystem* InOwner) : Owner(InOwner) {}
+
+ virtual void Tick(const float DeltaTime, FSlateApplication& SlateApp, TSharedRef<ICursor> Cursor) override {}
+
+ virtual bool HandleKeyDownEvent(FSlateApplication& SlateApp, const FKeyEvent& InKeyEvent) override
+ {
+ return !InKeyEvent.IsRepeat() && Owner.IsValid() && Owner->HandleKey(InKeyEvent.GetKey());
+ }
+
+ /** Mouse buttons finish a pending rebind (fire and ADS default to them); else they pass. */
+ virtual bool HandleMouseButtonDownEvent(FSlateApplication& SlateApp, const FPointerEvent& MouseEvent) override
+ {
+ return Owner.IsValid() && Owner->IsListeningForKey() && Owner->HandleKey(MouseEvent.GetEffectingButton());
+ }
+
+ virtual bool HandleMouseWheelOrGestureEvent(FSlateApplication& SlateApp, const FPointerEvent& InWheelEvent, const FPointerEvent* InGestureEvent) override
+ {
+ if (!Owner.IsValid() || !Owner->IsListeningForKey() || InWheelEvent.GetWheelDelta() == 0.f)
+ {
+ return false;
+ }
+ return Owner->HandleKey(InWheelEvent.GetWheelDelta() > 0.f ? EKeys::MouseScrollUp : EKeys::MouseScrollDown);
+ }
+
+ virtual const TCHAR* GetDebugName() const override { return TEXT("VerseUiInput"); }
+
+ TWeakObjectPtr<UVerseUiSubsystem> Owner;
+};
+
+namespace
+{
+ /** UVerseSettings (combat-state 8) as VerseGore reads it; VerseUI cannot include Verse. */
+ const TCHAR* VerseSettingsSection = TEXT("/Script/Verse.VerseSettings");
+ const TCHAR* VerseSettingsClass = TEXT("/Script/Verse.VerseSettings");
+ const TCHAR* VerseGoreSubsystemClass = TEXT("/Script/VerseGore.VerseGoreSubsystem");
+
+ /**
+ * Interim console variables for the view settings that have no contracted consumer yet
+ * (duel FOV, sensitivity, invert Y, deck FOVs, reduced motion, volume); a contract change
+ * request asks for their fields on UVerseSettings. Gore goes to UVerseSettings and the key
+ * bindings into Enhanced Input.
+ */
+ void PublishCVar(const TCHAR* Name, const FString& Value, const TCHAR* Help)
+ {
+ IConsoleManager& Console = IConsoleManager::Get();
+ IConsoleVariable* Var = Console.FindConsoleVariable(Name);
+ if (!Var)
+ {
+ Var = Console.RegisterConsoleVariable(Name, Value, Help, ECVF_Default);
+ }
+ if (Var)
+ {
+ Var->Set(*Value, ECVF_SetByCode);
+ }
+ }
+}
+
+UVerseUiSubsystem* UVerseUiSubsystem::Get(const UObject* WorldContextObject)
+{
+ UWorld* World = WorldContextObject ? WorldContextObject->GetWorld() : nullptr;
+ return World ? World->GetSubsystem<UVerseUiSubsystem>() : nullptr;
+}
+
+bool UVerseUiSubsystem::ShouldCreateSubsystem(UObject* Outer) const
+{
+ const UWorld* World = Cast<UWorld>(Outer);
+ // Client runtime only (architecture.md): a dedicated server has no person to show a UI to.
+ return World && (World->WorldType == EWorldType::Game || World->WorldType == EWorldType::PIE)
+ && !IsRunningDedicatedServer() && World->GetNetMode() != NM_DedicatedServer && Super::ShouldCreateSubsystem(Outer);
+}
+
+void UVerseUiSubsystem::Initialize(FSubsystemCollectionBase& Collection)
+{
+ Super::Initialize(Collection);
+ Collection.InitializeDependency<UVerseEventHub>();
+
+ UserSettings = NewObject<UVerseUiUserSettings>(this);
+ UserSettings->ReloadFromDisk();
+
+ BridgePort = MakeShared<FVerseUiLogBridgePort>();
+ GamePort = MakeShared<FVerseUiQaGamePort>(GetWorld());
+ HudSource = MakeShared<FVerseUiWorldHudSource>(GetWorld());
+
+ LoadData();
+ KeyMap.SetBindings(UserSettings->KeyBindings);
+ KeyMap.SetReturnKey(AppSettings.ReturnKey);
+ Armoury.SelectTier(UserSettings->LastTier);
+ Hud.Timing.FeedMax = FMath::Max(1, Hud.Timing.FeedMax);
+
+ KillCam.OnReplayFire = [this](const FVerseFireEvent& E)
+ {
+ AddReplayBolt(E);
+ if (OnKillCamFire)
+ {
+ OnKillCamFire(E);
+ }
+ };
+ KillCam.OnReplayFracture = [this](const FVerseFractureEvent& E) { if (OnKillCamFracture) { OnKillCamFracture(E); } };
+
+ BindHub();
+ PostRenderHandle = AHUD::OnHUDPostRender.AddUObject(this, &UVerseUiSubsystem::OnHudPostRender);
+
+ VerseUiQa::RegisterCommands(this);
+
+ // Publish the settings other modules read.
+ SetAppSettings(AppSettings);
+ SetDuelFov(UserSettings->DuelFov);
+}
+
+void UVerseUiSubsystem::OnWorldBeginPlay(UWorld& InWorld)
+{
+ Super::OnWorldBeginPlay(InWorld);
+ BindHub();
+ AttachSlate();
+ // The saved quality level applies at start, not only when the menu changes it.
+ if (!FApp::IsUnattended() && FApp::CanEverRender())
+ {
+ ApplyScalabilityLevel(UserSettings->Scalability);
+ }
+}
+
+void UVerseUiSubsystem::Deinitialize()
+{
+ ApplyKillCamView(false);
+ if (bPausedByUi)
+ {
+ GamePort->SetPaused(false);
+ bPausedByUi = false;
+ }
+ DetachSlate();
+ UnbindHub();
+ AHUD::OnHUDPostRender.Remove(PostRenderHandle);
+ VerseUiQa::Release(this);
+ Super::Deinitialize();
+}
+
+TStatId UVerseUiSubsystem::GetStatId() const
+{
+ RETURN_QUICK_DECLARE_CYCLE_STAT(UVerseUiSubsystem, STATGROUP_Tickables);
+}
+
+double UVerseUiSubsystem::LocalNow() const
+{
+ return Clock ? Clock() : FPlatformTime::Seconds();
+}
+
+void UVerseUiSubsystem::LoadData()
+{
+ FString Error;
+ if (!Strings.LoadCatalogue(FVerseUiStrings::DefaultCatalogueDir(), &Error))
+ {
+ UE_LOG(LogVerseUI, Error, TEXT("VerseUI: %s"), *Error);
+ }
+ if (!KeyMap.LoadFile(FVerseKeyMap::DefaultPath(), &Error))
+ {
+ UE_LOG(LogVerseUI, Error, TEXT("VerseUI: %s"), *Error);
+ }
+ if (!Armoury.LoadFile(FVerseArmouryModel::DefaultPath(), &Error))
+ {
+ UE_LOG(LogVerseUI, Error, TEXT("VerseUI: %s"), *Error);
+ }
+
+ FString Json;
+ const FString HudPath = FPaths::Combine(FPaths::ProjectDir(), TEXT("Data"), TEXT("ui"), TEXT("hud.json"));
+ TSharedPtr<FJsonObject> Root;
+ if (FFileHelper::LoadFileToString(Json, *HudPath) && FJsonSerializer::Deserialize(TJsonReaderFactory<>::Create(Json), Root) && Root.IsValid())
+ {
+ double N = 0.0;
+ if (Root->TryGetNumberField(TEXT("safe_fraction"), N))
+ {
+ SafeFraction = float(N);
+ }
+ const TSharedPtr<FJsonObject>* Timing = nullptr;
+ if (Root->TryGetObjectField(TEXT("timing"), Timing))
+ {
+ FVerseHudTiming& T = Hud.Timing;
+ if ((*Timing)->TryGetNumberField(TEXT("hit_marker_s"), N)) { T.HitMarker = float(N); }
+ if ((*Timing)->TryGetNumberField(TEXT("headshot_marker_s"), N)) { T.HeadshotMarker = float(N); }
+ if ((*Timing)->TryGetNumberField(TEXT("kill_marker_s"), N)) { T.KillMarker = float(N); }
+ if ((*Timing)->TryGetNumberField(TEXT("blocked_marker_s"), N)) { T.BlockedMarker = float(N); }
+ if ((*Timing)->TryGetNumberField(TEXT("damage_indicator_s"), N)) { T.DamageIndicator = float(N); }
+ if ((*Timing)->TryGetNumberField(TEXT("feed_entry_s"), N)) { T.FeedEntry = float(N); }
+ if ((*Timing)->TryGetNumberField(TEXT("feed_max"), N)) { T.FeedMax = int32(N); }
+ if ((*Timing)->TryGetNumberField(TEXT("set_target"), N)) { T.SetTarget = int32(N); }
+ }
+ const TSharedPtr<FJsonObject>* Cam = nullptr;
+ if (Root->TryGetObjectField(TEXT("kill_cam"), Cam))
+ {
+ FVerseKillCamTuning& T = KillCam.Tuning;
+ if ((*Cam)->TryGetNumberField(TEXT("window_s"), N)) { KillCamBuffer.Window = N; }
+ if ((*Cam)->TryGetNumberField(TEXT("end_margin_s"), N)) { T.EndMarginS = float(N); }
+ if ((*Cam)->TryGetNumberField(TEXT("min_length_s"), N)) { T.MinLengthS = float(N); }
+ if ((*Cam)->TryGetNumberField(TEXT("camera_back_cm"), N)) { T.CameraBack = float(N); }
+ if ((*Cam)->TryGetNumberField(TEXT("camera_up_cm"), N)) { T.CameraUp = float(N); }
+ if ((*Cam)->TryGetNumberField(TEXT("camera_right_cm"), N)) { T.CameraRight = float(N); }
+ if ((*Cam)->TryGetNumberField(TEXT("finisher_cut_s"), N)) { T.FinisherCutS = float(N); }
+ }
+ const TArray<TSharedPtr<FJsonValue>>* DeckList = nullptr;
+ if (Root->TryGetArrayField(TEXT("decks"), DeckList))
+ {
+ Decks.Reset();
+ for (const TSharedPtr<FJsonValue>& V : *DeckList)
+ {
+ Decks.Add(FName(*V->AsString()));
+ }
+ }
+ }
+ else
+ {
+ UE_LOG(LogVerseUI, Error, TEXT("VerseUI: cannot read %s"), *HudPath);
+ }
+}
+
+// ---------------------------------------------------------------------------------------------
+// Hub
+
+void UVerseUiSubsystem::BindHub()
+{
+ UVerseEventHub* HubPtr = UVerseEventHub::Get(GetWorld());
+ if (!HubPtr || BoundHub.Get() == HubPtr)
+ {
+ return;
+ }
+ UnbindHub();
+ BoundHub = HubPtr;
+ HubHandles.Add(HubPtr->OnHit.AddUObject(this, &UVerseUiSubsystem::HandleHit));
+ HubHandles.Add(HubPtr->OnDeath.AddUObject(this, &UVerseUiSubsystem::HandleDeath));
+ HubHandles.Add(HubPtr->OnSetEnded.AddUObject(this, &UVerseUiSubsystem::HandleSetEnded));
+ HubHandles.Add(HubPtr->OnFire.AddUObject(this, &UVerseUiSubsystem::HandleFire));
+ HubHandles.Add(HubPtr->OnFracture.AddUObject(this, &UVerseUiSubsystem::HandleFracture));
+ HubHandles.Add(HubPtr->OnStationUsed.AddUObject(this, &UVerseUiSubsystem::HandleStationUsed));
+ HubHandles.Add(HubPtr->OnArenaSwitch.AddLambda([this](const FVerseArenaSwitchEvent& E)
+ {
+ if (FVerseUiQaGamePort* Qa = static_cast<FVerseUiQaGamePort*>(GamePort.Get()); Qa && bOwnsGamePort)
+ {
+ Qa->NoteArenaSwitch(E.bArenaOn, E.Deck);
+ }
+ if (!E.bArenaOn)
+ {
+ Hud.Reset();
+ }
+ RebuildScreen();
+ }));
+}
+
+void UVerseUiSubsystem::UnbindHub()
+{
+ if (UVerseEventHub* HubPtr = BoundHub.Get())
+ {
+ FDelegateHandle* H = HubHandles.GetData();
+ HubPtr->OnHit.Remove(H[0]);
+ HubPtr->OnDeath.Remove(H[1]);
+ HubPtr->OnSetEnded.Remove(H[2]);
+ HubPtr->OnFire.Remove(H[3]);
+ HubPtr->OnFracture.Remove(H[4]);
+ HubPtr->OnStationUsed.Remove(H[5]);
+ HubPtr->OnArenaSwitch.Remove(H[6]);
+ }
+ HubHandles.Reset();
+ BoundHub.Reset();
+}
+
+void UVerseUiSubsystem::HandleHit(const FVerseHitEvent& Event)
+{
+ Hud.SetLocalPlayerId(HudSource->GetLocalPlayerId());
+ Hud.OnHit(Event, LocalNow());
+ if (Event.VictimId == Hud.GetLocalPlayerId() && !Event.bBlockedBySpawnProtection)
+ {
+ TrackedHealth = FMath::Max(0.f, TrackedHealth - Event.Damage);
+ }
+}
+
+void UVerseUiSubsystem::HandleDeath(const FVerseDeathEvent& Event)
+{
+ const int32 LocalId = HudSource->GetLocalPlayerId();
+ Hud.SetLocalPlayerId(LocalId);
+ const double Now = LocalNow();
+ Hud.OnDeath(Event, Now);
+ if (Event.VictimId == LocalId)
+ {
+ TrackedHealth = 0.f;
+ // Record the killer's last pose of this frame before the clip is copied.
+ TArray<FVersePawnPose> Poses;
+ HudSource->GetPawnPoses(Poses);
+ const double Server = HudSource->GetServerTime();
+ for (const FVersePawnPose& Pose : Poses)
+ {
+ KillCamBuffer.AddPose(Pose.PlayerId, Pose.ServerTime >= 0.0 ? Pose.ServerTime : Server, Pose.Location, Pose.Rotation);
+ }
+ ReplayBolts.Reset();
+ if (KillCam.Begin(KillCamBuffer, Event, LocalId, Now, Server, AppSettings.Gore == EVerseGoreLevel::Reduced))
+ {
+ ApplyKillCamView(true);
+ }
+ }
+}
+
+void UVerseUiSubsystem::HandleSetEnded(const FVerseSetSummary& Summary)
+{
+ Hud.OnSetEnded(Summary, LocalNow());
+ if (Summary.Outcome == EVerseSetOutcome::Unfinished)
+ {
+ return;
+ }
+ Session.AddSet(Summary);
+ EndScreen = FVerseEndScreen::Build(Summary, HudSource->GetBotEffectiveSkill(Summary.Opponent.PlayerId), Strings.GetLanguage());
+ ShowScreen(EVerseUiScreen::EndOfSet);
+}
+
+void UVerseUiSubsystem::HandleFire(const FVerseFireEvent& Event)
+{
+ KillCamBuffer.AddFire(Event, Event.ServerTime);
+}
+
+void UVerseUiSubsystem::HandleFracture(const FVerseFractureEvent& Event)
+{
+ KillCamBuffer.AddFracture(Event, Event.ServerTimeMs / 1000.0);
+}
+
+void UVerseUiSubsystem::HandleStationUsed(const FVerseStationUsedEvent& Event)
+{
+ if (Event.Kind == FName(TEXT("armoury")) && (Event.UserId == HudSource->GetLocalPlayerId() || HudSource->GetLocalPlayerId() == INDEX_NONE))
+ {
+ ShowScreen(EVerseUiScreen::Armoury);
+ }
+}
+
+// ---------------------------------------------------------------------------------------------
+// Tick
+
+void UVerseUiSubsystem::Tick(float DeltaTime)
+{
+ const double Now = LocalNow();
+ const double Server = HudSource->GetServerTime();
+ const int32 LocalId = HudSource->GetLocalPlayerId();
+ Hud.SetLocalPlayerId(LocalId);
+ const bool bWasDead = Hud.IsLocalDead();
+ Hud.Tick(Now, Server);
+ if (bWasDead && !Hud.IsLocalDead())
+ {
+ TrackedHealth = 100.f;
+ }
+
+ TArray<FVersePawnPose> Poses;
+ HudSource->GetPawnPoses(Poses);
+ for (const FVersePawnPose& Pose : Poses)
+ {
+ KillCamBuffer.AddPose(Pose.PlayerId, Pose.ServerTime >= 0.0 ? Pose.ServerTime : Server, Pose.Location, Pose.Rotation);
+ }
+ KillCamBuffer.Trim(Server);
+ TickKillCam(Now);
+ ReplayBolts.RemoveAll([Now](const FReplayBolt& Bolt) { return Now - Bolt.LocalTime > ReplayBoltLife; });
+
+ // Key bindings follow the contexts the input owners add after possession.
+ if (Now >= NextInputRemapAt)
+ {
+ NextInputRemapAt = Now + 0.25;
+ ApplyKeyBindingsToInput();
+ }
+
+ const bool bDuel = GamePort->IsDuelRunning();
+ if (bDuel != bLastDuelRunning)
+ {
+ bLastDuelRunning = bDuel;
+ RebuildScreen();
+ }
+}
+
+void UVerseUiSubsystem::TickKillCam(double Now)
+{
+ if (!KillCam.IsPlaying())
+ {
+ return;
+ }
+ KillCam.Tick(Now);
+ if (!KillCam.IsPlaying())
+ {
+ ApplyKillCamView(false);
+ return;
+ }
+ FVector Location;
+ FRotator Rotation;
+ if (KillCamCamera && KillCam.GetCamera(Location, Rotation))
+ {
+ KillCamCamera->SetActorLocationAndRotation(Location, Rotation);
+ }
+ FVector KillerLocation;
+ FRotator KillerRotation;
+ if (KillCamProxy && KillCam.GetKillerPose(KillerLocation, KillerRotation))
+ {
+ // The proxy root stands for the recorded capsule; the mesh copy keeps the pawn's mesh offset.
+ KillCamProxy->SetActorLocationAndRotation(KillerLocation, FRotator(0.f, KillerRotation.Yaw, 0.f));
+ }
+}
+
+void UVerseUiSubsystem::ApplyKillCamView(bool bStart)
+{
+ UWorld* World = GetWorld();
+ APlayerController* PC = World ? World->GetFirstPlayerController() : nullptr;
+ if (bStart)
+ {
+ if (!PC || !World->HasBegunPlay())
+ {
+ return;
+ }
+ FActorSpawnParameters Params;
+ Params.ObjectFlags |= RF_Transient;
+ Params.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
+ if (!KillCamCamera)
+ {
+ KillCamCamera = World->SpawnActor<ACameraActor>(Params);
+ }
+ if (KillCamCamera)
+ {
+ KillCamCamera->GetCameraComponent()->SetFieldOfView(AppSettings.FovThird);
+ KillCamCamera->GetCameraComponent()->bConstrainAspectRatio = false;
+ KillCamPreviousTarget = PC->GetViewTarget();
+ PC->SetViewTargetWithBlend(KillCamCamera, 0.f);
+ }
+ // The replayed killer: a pose-following copy of the killer's mesh at the recorded path
+ // (WP13's clips replace the live pose once they land); the live killer hides locally.
+ APlayerState* KillerState = nullptr;
+ if (AGameStateBase* GameState = World->GetGameState())
+ {
+ for (APlayerState* State : GameState->PlayerArray)
+ {
+ if (State && State->GetPlayerId() == KillCam.GetKillerId())
+ {
+ KillerState = State;
+ }
+ }
+ }
+ APawn* Killer = KillerState ? KillerState->GetPawn() : nullptr;
+ USkeletalMeshComponent* KillerMesh = Killer ? Killer->FindComponentByClass<USkeletalMeshComponent>() : nullptr;
+ if (KillerMesh && KillerMesh->GetSkeletalMeshAsset())
+ {
+ KillCamProxy = SpawnKillCamProxy(World, Params, Killer, KillerMesh);
+ // Hide the live killer in this view only: PlayerController::HiddenActors is local
+ // and never replicated (AActor::bHidden is, and the person hosts the duel).
+ PC->HiddenActors.AddUnique(Killer);
+ KillCamHiddenKiller = Killer;
+ }
+ return;
+ }
+
+ if (PC && KillCamCamera && PC->GetViewTarget() == KillCamCamera)
+ {
+ AActor* Back = KillCamPreviousTarget.IsValid() ? KillCamPreviousTarget.Get() : PC->GetPawn();
+ PC->SetViewTargetWithBlend(Back ? Back : PC, AppSettings.bReducedMotion ? 0.f : 0.15f);
+ }
+ if (KillCamProxy)
+ {
+ KillCamProxy->Destroy();
+ KillCamProxy = nullptr;
+ }
+ if (PC)
+ {
+ PC->HiddenActors.Remove(KillCamHiddenKiller.Get());
+ PC->HiddenActors.RemoveAll([](const TObjectPtr<AActor>& Actor) { return !IsValid(Actor); });
+ }
+ KillCamHiddenKiller.Reset();
+ ReplayBolts.Reset();
+}
+
+AActor* UVerseUiSubsystem::SpawnKillCamProxy(UWorld* World, const FActorSpawnParameters& Params, const APawn* Killer, USkeletalMeshComponent* KillerMesh)
+{
+ AActor* Proxy = World ? World->SpawnActor<AActor>(Params) : nullptr;
+ if (!Proxy || !Killer || !KillerMesh)
+ {
+ return Proxy;
+ }
+ // Root = the capsule centre the buffer records; the mesh hangs under it with the pawn's own
+ // offset (AVerseCharacter: -half height in Z, -90 deg yaw). On a character the base offsets
+ // are used, so a network smoothing offset of the live mesh is not copied.
+ USceneComponent* Root = NewObject<USceneComponent>(Proxy, TEXT("KillCamRoot"));
+ Proxy->SetRootComponent(Root);
+ Root->RegisterComponent();
+ FTransform MeshOffset = KillerMesh->GetRelativeTransform();
+ if (const ACharacter* Character = Cast<ACharacter>(Killer); Character && Character->GetMesh() == KillerMesh)
+ {
+ MeshOffset = FTransform(Character->GetBaseRotationOffset(), Character->GetBaseTranslationOffset(), KillerMesh->GetRelativeScale3D());
+ }
+ USkeletalMeshComponent* Copy = NewObject<USkeletalMeshComponent>(Proxy, TEXT("KillCamMesh"));
+ Copy->SetSkeletalMeshAsset(KillerMesh->GetSkeletalMeshAsset());
+ Copy->SetCollisionEnabled(ECollisionEnabled::NoCollision);
+ Copy->SetupAttachment(Root);
+ Copy->SetRelativeTransform(MeshOffset);
+ Copy->RegisterComponent();
+ Copy->SetLeaderPoseComponent(KillerMesh);
+ Proxy->SetActorLocationAndRotation(Killer->GetActorLocation(), FRotator(0.f, Killer->GetActorRotation().Yaw, 0.f));
+ return Proxy;
+}
+
+// ---------------------------------------------------------------------------------------------
+// HUD drawing
+
+FVerseUiLayout UVerseUiSubsystem::ComputeLayout(const FVector2D& Viewport) const
+{
+ FDisplayMetrics Metrics;
+ FMargin Padding(0.f);
+ if (FSlateApplication::IsInitialized())
+ {
+ FSlateApplication::Get().GetCachedDisplayMetrics(Metrics);
+ Padding = FMargin(Metrics.TitleSafePaddingSize.X, Metrics.TitleSafePaddingSize.Y, Metrics.TitleSafePaddingSize.Z, Metrics.TitleSafePaddingSize.W);
+ }
+ return FVerseUiLayout::Compute(Viewport, SafeFraction, Padding, UserSettings ? UserSettings->TextScale : 1.f);
+}
+
+void UVerseUiSubsystem::BuildHudFrame(const FVector2D& Viewport, FVerseHudDrawList& Out) const
+{
+ FVerseHudFrame Frame;
+ Frame.Model = &Hud;
+ Frame.Strings = &Strings;
+ Frame.Source = HudSource.Get();
+ Frame.Layout = ComputeLayout(Viewport);
+ HudSource->GetPawnState(Frame.Pawn);
+ if (!Frame.Pawn.bHealthKnown)
+ {
+ Frame.Pawn.Health = TrackedHealth;
+ Frame.Pawn.MaxHealth = 100.f;
+ }
+ Frame.bHasView = HudSource->GetView(Frame.View);
+ Frame.Now = LocalNow();
+ Frame.ServerTime = HudSource->GetServerTime();
+ Frame.bKillCam = KillCam.IsPlaying();
+ Frame.KillCamKillerId = KillCam.GetKillerId();
+ Frame.SkipKeyName = KeyMap.GetKey(TEXT("skip_kill_cam")).GetDisplayName();
+ Frame.bReducedMotion = AppSettings.bReducedMotion;
+ Frame.bInDuel = GamePort->IsDuelRunning();
+ FVerseHudPainter::Paint(Frame, Out, FVerseHudPainter::DefaultMeasure());
+}
+
+void UVerseUiSubsystem::OnHudPostRender(AHUD* InHud, UCanvas* Canvas)
+{
+ if (!bDrawHudOnPostRender || !InHud || !Canvas || InHud->GetWorld() != GetWorld() || !InHud->PlayerOwner || !InHud->PlayerOwner->IsLocalController())
+ {
+ return;
+ }
+ const double Start = FPlatformTime::Seconds();
+ BuildHudFrame(FVector2D(Canvas->ClipX, Canvas->ClipY), LastDrawList);
+ FVerseHudCanvasRenderer::Render(Canvas, LastDrawList);
+ DrawReplayBolts(Canvas);
+ HudCostAccum += (FPlatformTime::Seconds() - Start) * 1000.0;
+ if (++HudCostFrames >= 120)
+ {
+ HudCostMs = HudCostAccum / HudCostFrames;
+ HudCostAccum = 0.0;
+ HudCostFrames = 0;
+ }
+}
+
+void UVerseUiSubsystem::AddReplayBolt(const FVerseFireEvent& Event)
+{
+ FReplayBolt Bolt;
+ Bolt.Start = Event.Origin;
+ Bolt.End = Bolt.Start + FVector(Event.Direction).GetSafeNormal() * 10000.0;
+ Bolt.LocalTime = LocalNow();
+ if (UWorld* World = GetWorld())
+ {
+ FCollisionQueryParams Query(SCENE_QUERY_STAT(VerseKillCamBolt), false);
+ if (KillCamProxy)
+ {
+ Query.AddIgnoredActor(KillCamProxy);
+ }
+ FHitResult Hit;
+ if (World->LineTraceSingleByChannel(Hit, Bolt.Start, Bolt.End, ECC_Visibility, Query))
+ {
+ Bolt.End = Hit.ImpactPoint;
+ }
+ }
+ ReplayBolts.Add(Bolt);
+}
+
+void UVerseUiSubsystem::DrawReplayBolts(UCanvas* Canvas)
+{
+ if (!KillCam.IsPlaying() || ReplayBolts.Num() == 0)
+ {
+ return;
+ }
+ const double Now = LocalNow();
+ for (const FReplayBolt& Bolt : ReplayBolts)
+ {
+ const double Age = Now - Bolt.LocalTime;
+ if (Age < 0.0 || Age > ReplayBoltLife)
+ {
+ continue;
+ }
+ const FVector A = Canvas->Project(Bolt.Start, false);
+ const FVector B = Canvas->Project(Bolt.End, false);
+ if (A.Z <= 0.0 || B.Z <= 0.0)
+ {
+ continue;
+ }
+ FLinearColor Colour = VerseUiTheme::Amber;
+ Colour.A = float(1.0 - Age / ReplayBoltLife);
+ FCanvasLineItem Line(FVector2D(A.X, A.Y), FVector2D(B.X, B.Y));
+ Line.SetColor(Colour);
+ Line.LineThickness = 2.f;
+ Line.BlendMode = SE_BLEND_Translucent;
+ Canvas->DrawItem(Line);
+ }
+}
+
+// ---------------------------------------------------------------------------------------------
+// Slate
+
+void UVerseUiSubsystem::AttachSlate()
+{
+ UWorld* World = GetWorld();
+ UGameViewportClient* Viewport = World ? World->GetGameViewport() : nullptr;
+ if (!Viewport || SlateRoot.IsValid() || !FSlateApplication::IsInitialized())
+ {
+ return;
+ }
+ SlateRoot = SNew(SVerseUiRoot, this);
+ Viewport->AddViewportWidgetContent(SlateRoot.ToSharedRef(), 20);
+ InputProcessor = MakeShared<FVerseUiInputProcessor>(this);
+ FSlateApplication::Get().RegisterInputPreProcessor(InputProcessor);
+}
+
+void UVerseUiSubsystem::DetachSlate()
+{
+ if (InputProcessor.IsValid() && FSlateApplication::IsInitialized())
+ {
+ FSlateApplication::Get().UnregisterInputPreProcessor(InputProcessor);
+ }
+ InputProcessor.Reset();
+ if (SlateRoot.IsValid())
+ {
+ UWorld* World = GetWorld();
+ if (UGameViewportClient* Viewport = World ? World->GetGameViewport() : nullptr)
+ {
+ Viewport->RemoveViewportWidgetContent(SlateRoot.ToSharedRef());
+ }
+ }
+ SlateRoot.Reset();
+}
+
+void UVerseUiSubsystem::RebuildScreen()
+{
+ if (SlateRoot.IsValid())
+ {
+ SlateRoot->Refresh();
+ }
+}
+
+void UVerseUiSubsystem::ApplyInputMode()
+{
+ UWorld* World = GetWorld();
+ APlayerController* PC = World ? World->GetFirstPlayerController() : nullptr;
+ if (!PC || !SlateRoot.IsValid())
+ {
+ return;
+ }
+ if (Screen != EVerseUiScreen::None)
+ {
+ FInputModeGameAndUI Mode;
+ Mode.SetWidgetToFocus(SlateRoot);
+ Mode.SetHideCursorDuringCapture(false);
+ PC->SetInputMode(Mode);
+ PC->SetShowMouseCursor(true);
+ }
+ else
+ {
+ PC->SetInputMode(FInputModeGameOnly());
+ PC->SetShowMouseCursor(false);
+ }
+}
+
+void UVerseUiSubsystem::ShowScreen(EVerseUiScreen InScreen)
+{
+ Screen = InScreen;
+ if (SlateRoot.IsValid())
+ {
+ SlateRoot->StopListening();
+ }
+ RebuildScreen();
+ ApplyInputMode();
+ UpdatePause();
+ OnScreenChanged.Broadcast(Screen);
+}
+
+void UVerseUiSubsystem::UpdatePause()
+{
+ // Escape mid-match pauses (parity D-09); so does the end-of-set screen, so the endless match
+ // does not go on behind a panel. The match resumes when the screen closes.
+ const bool bWant = GamePort->IsDuelRunning()
+ && (Screen == EVerseUiScreen::EscMenu || Screen == EVerseUiScreen::Settings || Screen == EVerseUiScreen::EndOfSet);
+ if (bWant != bPausedByUi)
+ {
+ bPausedByUi = bWant;
+ GamePort->SetPaused(bWant);
+ }
+}
+
+// ---------------------------------------------------------------------------------------------
+// Bridge and settings
+
+void UVerseUiSubsystem::SetBridgePort(TSharedPtr<IVerseUiBridgePort> Port)
+{
+ BridgePort = Port.IsValid() ? Port : MakeShared<FVerseUiLogBridgePort>();
+}
+
+void UVerseUiSubsystem::SetGamePort(TSharedPtr<IVerseUiGamePort> Port)
+{
+ bOwnsGamePort = !Port.IsValid();
+ GamePort = Port.IsValid() ? Port : MakeShared<FVerseUiQaGamePort>(GetWorld());
+ RebuildScreen();
+}
+
+void UVerseUiSubsystem::SetHudSource(TSharedPtr<IVerseHudSource> Source)
+{
+ HudSource = Source.IsValid() ? Source : MakeShared<FVerseUiWorldHudSource>(GetWorld());
+}
+
+void UVerseUiSubsystem::ApplyWelcome(const TSharedPtr<FJsonObject>& Data)
+{
+ if (!Data.IsValid())
+ {
+ return;
+ }
+ const TSharedPtr<FJsonObject>* Locale = nullptr;
+ if (Data->TryGetObjectField(TEXT("locale"), Locale))
+ {
+ Strings.ApplyBridgeLocale(*Locale);
+ }
+ const TSharedPtr<FJsonObject>* Settings = nullptr;
+ if (Data->TryGetObjectField(TEXT("settings"), Settings))
+ {
+ AppSettings.ApplyJson(*Settings);
+ }
+ const TArray<TSharedPtr<FJsonValue>>* DeckList = nullptr;
+ if (Data->TryGetArrayField(TEXT("decks"), DeckList))
+ {
+ Decks.Reset();
+ for (const TSharedPtr<FJsonValue>& V : *DeckList)
+ {
+ Decks.Add(FName(*V->AsString()));
+ }
+ }
+ KeyMap.SetReturnKey(AppSettings.ReturnKey);
+ if (LifecycleState == FName(TEXT("booting")))
+ {
+ LifecycleState = TEXT("visible");
+ }
+ PublishSettings();
+ RebuildScreen();
+}
+
+void UVerseUiSubsystem::ApplySettingsChanged(const TSharedPtr<FJsonObject>& Data)
+{
+ if (!Data.IsValid())
+ {
+ return;
+ }
+ AppSettings.ApplyJson(Data);
+ Strings.ApplySettingsChanged(Data);
+ KeyMap.SetReturnKey(AppSettings.ReturnKey);
+ PublishSettings();
+ RebuildScreen();
+}
+
+void UVerseUiSubsystem::WriteGoreSetting(UWorld* World, EVerseGoreLevel Level)
+{
+ const FString Value = Level == EVerseGoreLevel::Reduced ? TEXT("Reduced") : TEXT("Full");
+ if (GConfig)
+ {
+ FString Stored;
+ if (!GConfig->GetString(VerseSettingsSection, TEXT("GoreLevel"), Stored, GGameUserSettingsIni) || Stored != Value)
+ {
+ GConfig->SetString(VerseSettingsSection, TEXT("GoreLevel"), *Value, GGameUserSettingsIni);
+ GConfig->Flush(false, GGameUserSettingsIni);
+ }
+ }
+ // The class default object, for code that reads GetDefault<UVerseSettings>().
+ if (UClass* Class = FindObject<UClass>(nullptr, VerseSettingsClass))
+ {
+ if (UObject* Defaults = Class->GetDefaultObject())
+ {
+ if (FEnumProperty* Prop = FindFProperty<FEnumProperty>(Class, TEXT("GoreLevel")))
+ {
+ Prop->GetUnderlyingProperty()->SetIntPropertyValue(Prop->ContainerPtrToValuePtr<void>(Defaults), int64(Level));
+ }
+ else if (FByteProperty* Byte = FindFProperty<FByteProperty>(Class, TEXT("GoreLevel")))
+ {
+ Byte->SetPropertyValue_InContainer(Defaults, uint8(Level));
+ }
+ }
+ }
+ // Live switch (WP05.7): a live VerseGore re-reads the level when it offers the call.
+ UClass* GoreClass = FindObject<UClass>(nullptr, VerseGoreSubsystemClass);
+ if (World && GoreClass && GoreClass->IsChildOf(UWorldSubsystem::StaticClass()))
+ {
+ if (UWorldSubsystem* Gore = World->GetSubsystemBase(GoreClass))
+ {
+ if (UFunction* Reload = Gore->FindFunction(TEXT("ReloadLevelFromSettings")))
+ {
+ Gore->ProcessEvent(Reload, nullptr);
+ }
+ }
+ }
+}
+
+EVerseGoreLevel UVerseUiSubsystem::ReadGoreSetting()
+{
+ // Exactly how VerseGore reads it (UVerseGoreSubsystem::ReloadLevelFromSettings).
+ FString Value;
+ if (GConfig && GConfig->GetString(VerseSettingsSection, TEXT("GoreLevel"), Value, GGameUserSettingsIni))
+ {
+ return Value.TrimStartAndEnd().Equals(TEXT("Reduced"), ESearchCase::IgnoreCase) ? EVerseGoreLevel::Reduced : EVerseGoreLevel::Full;
+ }
+ return EVerseGoreLevel::Full;
+}
+
+void UVerseUiSubsystem::SetAppSettings(const FVerseAppSettings& Next)
+{
+ const TSharedRef<FJsonObject> Diff = AppSettings.Diff(Next);
+ AppSettings = Next;
+ KeyMap.SetReturnKey(AppSettings.ReturnKey);
+ PublishSettings();
+ if (Diff->Values.Num() > 0)
+ {
+ BridgePort->SendSettingsSet(Diff);
+ }
+}
+
+void UVerseUiSubsystem::SetGore(EVerseGoreLevel Level)
+{
+ FVerseAppSettings Next = AppSettings;
+ Next.Gore = Level;
+ SetAppSettings(Next);
+}
+
+void UVerseUiSubsystem::SetReducedMotion(bool bReduced)
+{
+ FVerseAppSettings Next = AppSettings;
+ Next.bReducedMotion = bReduced;
+ SetAppSettings(Next);
+}
+
+void UVerseUiSubsystem::SetReturnKey(const FKey& Key)
+{
+ RebindKey(FVerseKeyMap::ReturnAction(), Key);
+}
+
+void UVerseUiSubsystem::RebindKey(FName Action, const FKey& Key)
+{
+ if (FVerseKeyMap::IsReserved(Key))
+ {
+ return;
+ }
+ KeyMap.Rebind(Action, Key);
+ UserSettings->KeyBindings = KeyMap.GetBindings();
+ UserSettings->SaveToDisk();
+ const FKey NewReturn = KeyMap.GetKey(FVerseKeyMap::ReturnAction());
+ if (NewReturn != AppSettings.ReturnKey)
+ {
+ FVerseAppSettings Next = AppSettings;
+ Next.ReturnKey = NewReturn;
+ SetAppSettings(Next);
+ }
+ else
+ {
+ PublishSettings();
+ }
+}
+
+void UVerseUiSubsystem::SetDuelFov(float Fov)
+{
+ UserSettings->DuelFov = Fov;
+ UserSettings->SaveToDisk();
+ PublishSettings();
+}
+
+void UVerseUiSubsystem::ApplyScalabilityLevel(int32 Level)
+{
+ Scalability::FQualityLevels Levels = Scalability::GetQualityLevels();
+ if (Level >= 0)
+ {
+ Levels.SetFromSingleQualityLevel(FMath::Clamp(Level, 0, 4));
+ }
+ else
+ {
+ // Auto: the engine's default levels.
+ Levels.SetDefaults();
+ }
+ Scalability::SetQualityLevels(Levels);
+}
+
+void UVerseUiSubsystem::SetScalability(int32 Level)
+{
+ UserSettings->Scalability = Level;
+ UserSettings->SaveToDisk();
+ if (!FApp::IsUnattended())
+ {
+ ApplyScalabilityLevel(UserSettings->Scalability);
+ }
+}
+
+void UVerseUiSubsystem::ResetSettings()
+{
+ FVerseAppSettings Next = AppSettings;
+ const FVerseAppSettings Defaults;
+ Next.Sensitivity = Defaults.Sensitivity;
+ Next.bInvertY = Defaults.bInvertY;
+ Next.Quality = Defaults.Quality;
+ Next.FovThird = Defaults.FovThird;
+ Next.FovFirst = Defaults.FovFirst;
+ Next.Volume = Defaults.Volume;
+ Next.ViewMode = Defaults.ViewMode;
+ SetScalability(-1);
+ SetAppSettings(Next);
+ RebuildScreen();
+}
+
+void UVerseUiSubsystem::SetTextScale(float Scale)
+{
+ UserSettings->TextScale = Scale;
+ UserSettings->SaveToDisk();
+ RebuildScreen();
+}
+
+void UVerseUiSubsystem::PublishSettings()
+{
+ PublishCVar(TEXT("Verse.Settings.DuelFov"), FString::SanitizeFloat(UserSettings ? UserSettings->DuelFov : 100.f), TEXT("Duel horizontal FOV, 80-110 (VerseUI)"));
+ PublishCVar(TEXT("Verse.Settings.FovThird"), FString::SanitizeFloat(AppSettings.FovThird), TEXT("Deck third-person FOV (VerseUI)"));
+ PublishCVar(TEXT("Verse.Settings.FovFirst"), FString::SanitizeFloat(AppSettings.FovFirst), TEXT("Deck first-person FOV (VerseUI)"));
+ PublishCVar(TEXT("Verse.Settings.Sensitivity"), FString::SanitizeFloat(AppSettings.Sensitivity), TEXT("Look sensitivity (VerseUI)"));
+ PublishCVar(TEXT("Verse.Settings.InvertY"), AppSettings.bInvertY ? TEXT("1") : TEXT("0"), TEXT("Invert look Y (VerseUI)"));
+ PublishCVar(TEXT("Verse.Settings.ReducedMotion"), AppSettings.bReducedMotion ? TEXT("1") : TEXT("0"), TEXT("Reduced motion (VerseUI)"));
+ PublishCVar(TEXT("Verse.Settings.Volume"), FString::SanitizeFloat(AppSettings.Volume), TEXT("Master volume 0-1 (VerseUI)"));
+ WriteGoreSetting(GetWorld(), AppSettings.Gore);
+ ApplyKeyBindingsToInput();
+}
+
+int32 UVerseUiSubsystem::ApplyKeyBindingsToInput()
+{
+ UWorld* World = GetWorld();
+ APlayerController* PC = World ? World->GetFirstPlayerController() : nullptr;
+ ULocalPlayer* Player = PC ? PC->GetLocalPlayer() : nullptr;
+ UEnhancedInputLocalPlayerSubsystem* Input = Player ? Player->GetSubsystem<UEnhancedInputLocalPlayerSubsystem>() : nullptr;
+ return InputRemap.ApplyToPlayer(Input, KeyMap);
+}
+
+// ---------------------------------------------------------------------------------------------
+// Actions
+
+void UVerseUiSubsystem::StartDuelFromArmoury()
+{
+ UserSettings->LastTier = Armoury.GetSelectedTier();
+ UserSettings->SaveToDisk();
+ Session.Reset();
+ GamePort->StartDuel(Armoury.GetSelectedTier());
+ ShowScreen(EVerseUiScreen::None);
+}
+
+void UVerseUiSubsystem::QuickStartDuel()
+{
+ Session.Reset();
+ GamePort->StartDuel(UserSettings->LastTier);
+ ShowScreen(EVerseUiScreen::None);
+}
+
+void UVerseUiSubsystem::LeaveDuel()
+{
+ // Endless sets: leaving anywhere but the end-of-set screen leaves a set open (parity D-10;
+ // the duel owner reports it as unfinished, W-08). The summary shows the session and "again".
+ Session.bLeftMidSet = GamePort->IsDuelRunning() && Screen != EVerseUiScreen::EndOfSet;
+ if (bPausedByUi)
+ {
+ GamePort->SetPaused(false);
+ bPausedByUi = false;
+ }
+ GamePort->LeaveDuel();
+ SessionScreen = Session.BuildScreen(Strings.GetLanguage());
+ ShowScreen(EVerseUiScreen::SessionSummary);
+}
+
+void UVerseUiSubsystem::ReturnToApp(const FString& Reason)
+{
+ BridgePort->SendReturnToApp(Reason);
+}
+
+void UVerseUiSubsystem::TravelToDeck(FName Deck)
+{
+ GamePort->TravelToDeck(Deck);
+ RebuildScreen();
+}
+
+void UVerseUiSubsystem::SkipKillCam()
+{
+ if (KillCam.IsPlaying())
+ {
+ KillCam.Skip(LocalNow());
+ ApplyKillCamView(false);
+ }
+}
+
+void UVerseUiSubsystem::ContinueAfterSet()
+{
+ ShowScreen(EVerseUiScreen::None);
+}
+
+void UVerseUiSubsystem::ToggleBar()
+{
+ bBarOpen = !bBarOpen;
+ RebuildScreen();
+}
+
+bool UVerseUiSubsystem::IsListeningForKey() const
+{
+ return SlateRoot.IsValid() && SlateRoot->IsListening();
+}
+
+bool UVerseUiSubsystem::HandleKey(const FKey& Key)
+{
+ if (SlateRoot.IsValid() && SlateRoot->IsListening())
+ {
+ const FName Action = SlateRoot->GetListeningAction();
+ SlateRoot->StopListening();
+ if (Key != EKeys::Escape)
+ {
+ RebindKey(Action, Key);
+ }
+ return true;
+ }
+ switch (KeyMap.Route(Key))
+ {
+ case EVerseUiCommand::ReturnToApp:
+ ReturnToApp(TEXT("return_key"));
+ return true;
+ case EVerseUiCommand::EscMenu:
+ ShowScreen(Screen == EVerseUiScreen::None ? EVerseUiScreen::EscMenu
+ : Screen == EVerseUiScreen::Settings ? EVerseUiScreen::EscMenu
+ : EVerseUiScreen::None);
+ return true;
+ case EVerseUiCommand::SkipKillCam:
+ if (KillCam.IsPlaying())
+ {
+ SkipKillCam();
+ return true;
+ }
+ return false;
+ case EVerseUiCommand::VerseBar:
+ ToggleBar();
+ return true;
+ case EVerseUiCommand::None:
+ break;
+ }
+ return false;
+}
diff --git a/unreal/Verse/Source/VerseUI/Private/Hud/VerseHudModel.cpp b/unreal/Verse/Source/VerseUI/Private/Hud/VerseHudModel.cpp
new file mode 100644
index 0000000000..d37cd3a73d
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Private/Hud/VerseHudModel.cpp
@@ -0,0 +1,232 @@
+#include "Hud/VerseHudModel.h"
+
+#include "Hud/VerseCrosshair.h"
+
+// ---------------------------------------------------------------------------------------------
+// HUD model
+
+void FVerseHudModel::Reset()
+{
+ HitMarkers.Reset();
+ DamageIndicators.Reset();
+ Feed.Reset();
+ LastHitOn.Reset();
+ PendingRespawn.Reset();
+ ScoreSelf = 0;
+ ScoreOpponent = 0;
+ SetIndex = 1;
+ bLocalDead = false;
+ LocalRespawnAt = 0.0;
+ LastSummary.Reset();
+}
+
+void FVerseHudModel::OnHit(const FVerseHitEvent& Event, double Now)
+{
+ LastHitOn.Add(Event.VictimId, Event);
+
+ if (LocalId != INDEX_NONE && Event.InstigatorId == LocalId && Event.VictimId != LocalId)
+ {
+ FVerseHitMarker Marker;
+ Marker.StartTime = Now;
+ if (Event.bBlockedBySpawnProtection)
+ {
+ Marker.Kind = EVerseHitMarkerKind::Blocked;
+ Marker.Duration = Timing.BlockedMarker;
+ }
+ else if (Event.bKillingBlow)
+ {
+ Marker.Kind = EVerseHitMarkerKind::Kill;
+ Marker.Duration = Timing.KillMarker;
+ }
+ else if (Event.bHeadshot)
+ {
+ Marker.Kind = EVerseHitMarkerKind::Headshot;
+ Marker.Duration = Timing.HeadshotMarker;
+ }
+ else
+ {
+ Marker.Kind = EVerseHitMarkerKind::Hit;
+ Marker.Duration = Timing.HitMarker;
+ }
+ // One marker of each kind at a time: a new hit restarts it (rapid fire stays readable).
+ HitMarkers.RemoveAll([&Marker](const FVerseHitMarker& M) { return M.Kind == Marker.Kind; });
+ HitMarkers.Add(Marker);
+ }
+
+ if (LocalId != INDEX_NONE && Event.VictimId == LocalId && Event.InstigatorId != LocalId && !Event.bBlockedBySpawnProtection)
+ {
+ FVerseDamageIndicator Indicator;
+ // Direction is the bolt's travel (shooter -> victim); the indicator points back at the source.
+ const FVector Travel = FVector(Event.Direction);
+ Indicator.FromDirection = Travel.IsNearlyZero() ? FVector::ForwardVector : -Travel.GetSafeNormal();
+ Indicator.StartTime = Now;
+ Indicator.Duration = Timing.DamageIndicator;
+ Indicator.Strength = FMath::Clamp(Event.Damage / 50.f, 0.35f, 1.f);
+ DamageIndicators.Add(Indicator);
+ if (DamageIndicators.Num() > 8)
+ {
+ DamageIndicators.RemoveAt(0);
+ }
+ }
+}
+
+void FVerseHudModel::OnDeath(const FVerseDeathEvent& Event, double Now)
+{
+ FVerseKillFeedEntry Entry;
+ Entry.Kind = EVerseFeedKind::Kill;
+ Entry.KillerId = Event.KillerId;
+ Entry.VictimId = Event.VictimId;
+ Entry.Cause = Event.Cause;
+ Entry.WeaponId = Event.WeaponId;
+ Entry.bHeadshot = Event.LastZone == EVerseHitZone::Head;
+ Entry.Time = Now;
+ if (const FVerseHitEvent* Last = LastHitOn.Find(Event.VictimId))
+ {
+ if (Last->InstigatorId == Event.KillerId)
+ {
+ Entry.bWallShot = Last->PenetrationCount > 0;
+ Entry.bHeadshot = Entry.bHeadshot || Last->bHeadshot;
+ }
+ }
+ PushFeed(Entry);
+ LastHitOn.Remove(Event.VictimId);
+
+ // Ids below 0 are the world (combat-state 11.1 uses -1); a world kill or a suicide scores nobody.
+ const bool bSuicide = Event.KillerId == Event.VictimId || Event.KillerId < 0;
+ if (LocalId != INDEX_NONE)
+ {
+ if (Event.VictimId == LocalId)
+ {
+ bLocalDead = true;
+ LocalRespawnAt = Event.RespawnAt;
+ if (!bSuicide)
+ {
+ ++ScoreOpponent;
+ }
+ }
+ else if (Event.KillerId == LocalId)
+ {
+ ++ScoreSelf;
+ }
+ else
+ {
+ // A kill by the world counts for nobody; a kill by the opponent of a third player does
+ // not exist in 1v1.
+ }
+ }
+ PendingRespawn.Add(Event.VictimId, Event.RespawnAt);
+}
+
+void FVerseHudModel::OnSetEnded(const FVerseSetSummary& Summary, double Now)
+{
+ LastSummary = Summary;
+ FVerseKillFeedEntry Entry;
+ Entry.Kind = EVerseFeedKind::SetEnd;
+ Entry.Outcome = Summary.Outcome;
+ Entry.Time = Now;
+ PushFeed(Entry);
+ // Score resets with every set (combat-state 9.1); the match itself never ends.
+ ScoreSelf = 0;
+ ScoreOpponent = 0;
+ SetIndex = Summary.SetIndex + 1;
+}
+
+void FVerseHudModel::Tick(double Now, double ServerTime)
+{
+ HitMarkers.RemoveAll([Now](const FVerseHitMarker& M) { return Now - M.StartTime >= M.Duration; });
+ DamageIndicators.RemoveAll([Now](const FVerseDamageIndicator& D) { return Now - D.StartTime >= D.Duration; });
+ Feed.RemoveAll([Now, this](const FVerseKillFeedEntry& E) { return Now - E.Time >= Timing.FeedEntry; });
+
+ for (auto It = PendingRespawn.CreateIterator(); It; ++It)
+ {
+ if (ServerTime >= It.Value())
+ {
+ FVerseKillFeedEntry Entry;
+ Entry.Kind = EVerseFeedKind::Respawn;
+ Entry.VictimId = It.Key();
+ Entry.Time = Now;
+ if (It.Key() == LocalId)
+ {
+ bLocalDead = false;
+ LocalRespawnAt = 0.0;
+ }
+ else
+ {
+ // bot.md 3.3: the kill feed says the opponent respawned; the person's own respawn
+ // needs no line.
+ PushFeed(Entry);
+ }
+ It.RemoveCurrent();
+ }
+ }
+}
+
+float FVerseHudModel::GetRespawnRemaining(double ServerTime) const
+{
+ return bLocalDead ? float(FMath::Max(0.0, LocalRespawnAt - ServerTime)) : 0.f;
+}
+
+float FVerseHudModel::MarkerAlpha(const FVerseHitMarker& Marker, double Now)
+{
+ if (Marker.Duration <= 0.f)
+ {
+ return 0.f;
+ }
+ const float T = float((Now - Marker.StartTime) / Marker.Duration);
+ // Full for the first half, then a linear fade.
+ return FMath::Clamp(T < 0.5f ? 1.f : 2.f * (1.f - T), 0.f, 1.f);
+}
+
+void FVerseHudModel::PushFeed(const FVerseKillFeedEntry& Entry)
+{
+ Feed.Add(Entry);
+ while (Feed.Num() > FMath::Max(1, Timing.FeedMax))
+ {
+ Feed.RemoveAt(0);
+ }
+}
+
+// ---------------------------------------------------------------------------------------------
+// Crosshair
+
+FMatrix FVerseCrosshair::ViewProjection(const FVerseHudView& View, const FVector2D& Viewport)
+{
+ // As ULocalPlayer::GetProjectionData with AspectRatio_MaintainXFOV: view rotation into
+ // Unreal's camera space (X forward -> Z depth), then a reversed-Z perspective.
+ const FMatrix ViewRotation = FInverseRotationMatrix(View.Rotation) *
+ FMatrix(FPlane(0, 0, 1, 0), FPlane(1, 0, 0, 0), FPlane(0, 1, 0, 0), FPlane(0, 0, 0, 1));
+ const float HalfFov = FMath::DegreesToRadians(FMath::Clamp(View.HorizontalFovDeg, 1.f, 170.f)) * 0.5f;
+ const float Width = float(FMath::Max(1.0, Viewport.X));
+ const float Height = float(FMath::Max(1.0, Viewport.Y));
+ const float NearPlane = 10.f;
+ const FMatrix Projection = FReversedZPerspectiveMatrix(HalfFov, HalfFov, 1.f, Width / Height, NearPlane, NearPlane);
+ return ViewRotation * Projection;
+}
+
+bool FVerseCrosshair::ProjectDirection(const FVerseHudView& View, const FVector2D& Viewport, const FVector& Direction, FVector2D& OutPixel)
+{
+ const FVector Dir = Direction.GetSafeNormal();
+ if (Dir.IsNearlyZero() || FVector::DotProduct(Dir, View.Rotation.Vector()) <= KINDA_SMALL_NUMBER)
+ {
+ return false;
+ }
+ const FMatrix ViewProj = ViewProjection(View, Viewport);
+ // A point far along the direction, relative to the eye (translation cancels out).
+ const FVector4 Clip = ViewProj.TransformFVector4(FVector4(Dir * 100000.0, 1.0));
+ if (Clip.W <= 0.0)
+ {
+ return false;
+ }
+ const double NdcX = Clip.X / Clip.W;
+ const double NdcY = Clip.Y / Clip.W;
+ OutPixel.X = (NdcX * 0.5 + 0.5) * Viewport.X;
+ OutPixel.Y = (0.5 - NdcY * 0.5) * Viewport.Y;
+ return true;
+}
+
+float FVerseCrosshair::SpreadRadiusPx(const FVerseHudView& View, const FVector2D& Viewport, float HalfAngleDeg)
+{
+ const float HalfFov = FMath::DegreesToRadians(FMath::Clamp(View.HorizontalFovDeg, 1.f, 170.f)) * 0.5f;
+ const float Spread = FMath::DegreesToRadians(FMath::Clamp(HalfAngleDeg, 0.f, 45.f));
+ return float(FMath::Tan(Spread) / FMath::Tan(HalfFov) * Viewport.X * 0.5);
+}
diff --git a/unreal/Verse/Source/VerseUI/Private/Hud/VerseHudPainter.cpp b/unreal/Verse/Source/VerseUI/Private/Hud/VerseHudPainter.cpp
new file mode 100644
index 0000000000..4349d63469
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Private/Hud/VerseHudPainter.cpp
@@ -0,0 +1,727 @@
+#include "Hud/VerseHudPainter.h"
+
+#include "CanvasItem.h"
+#include "CanvasTypes.h"
+#include "Core/VerseUiStrings.h"
+#include "Core/VerseUiTheme.h"
+#include "Engine/Canvas.h"
+#include "Engine/Engine.h"
+#include "Engine/Font.h"
+#include "Fonts/FontMeasure.h"
+#include "GlobalRenderResources.h"
+#include "Framework/Application/SlateApplication.h"
+#include "Hud/VerseCrosshair.h"
+#include "Rendering/SlateRenderer.h"
+#include "Styling/CoreStyle.h"
+
+namespace
+{
+ const FName TagCrosshair(TEXT("crosshair"));
+ const FName TagSpread(TEXT("crosshair.spread"));
+ const FName TagDamage(TEXT("damage"));
+ const FName TagVitals(TEXT("vitals"));
+ const FName TagWeapon(TEXT("weapon"));
+ const FName TagGadget(TEXT("gadget"));
+ const FName TagScore(TEXT("score"));
+ const FName TagFeed(TEXT("feed"));
+ const FName TagCentre(TEXT("centre"));
+
+ FName MarkerTag(EVerseHitMarkerKind Kind)
+ {
+ switch (Kind)
+ {
+ case EVerseHitMarkerKind::Hit: return TEXT("marker.hit");
+ case EVerseHitMarkerKind::Headshot: return TEXT("marker.headshot");
+ case EVerseHitMarkerKind::Kill: return TEXT("marker.kill");
+ case EVerseHitMarkerKind::Blocked: return TEXT("marker.blocked");
+ }
+ return NAME_None;
+ }
+
+ FLinearColor WithAlpha(FLinearColor Colour, float Alpha)
+ {
+ Colour.A *= FMath::Clamp(Alpha, 0.f, 1.f);
+ return Colour;
+ }
+
+ void Line(FVerseHudDrawList& Out, const FVector2D& A, const FVector2D& B, float Thickness, const FLinearColor& Colour, FName Tag)
+ {
+ Out.Lines.Add({A, B, Thickness, Colour, Tag});
+ }
+
+ void FillRect(FVerseHudDrawList& Out, const FVector2D& Min, const FVector2D& Size, const FLinearColor& Colour, FName Tag)
+ {
+ Out.Rects.Add({Min, Min + Size, Colour, Tag});
+ }
+
+ void Outline(FVerseHudDrawList& Out, const FVector2D& Min, const FVector2D& Size, float Thickness, const FLinearColor& Colour, FName Tag)
+ {
+ const FVector2D A = Min, B(Min.X + Size.X, Min.Y), C = Min + Size, D(Min.X, Min.Y + Size.Y);
+ Line(Out, A, B, Thickness, Colour, Tag);
+ Line(Out, B, C, Thickness, Colour, Tag);
+ Line(Out, C, D, Thickness, Colour, Tag);
+ Line(Out, D, A, Thickness, Colour, Tag);
+ }
+
+ /** Adds a label; Anchor is the left edge, centre or right edge of the label's top. Returns its size. */
+ FVector2D Text(FVerseHudDrawList& Out, const FVerseTextMeasure& Measure, const FVector2D& Anchor, const FText& Value, int32 Size,
+ bool bBold, const FLinearColor& Colour, EVerseTextAlign Align, float MaxWidth, FName Tag)
+ {
+ FVerseHudDrawList::FLabel Label;
+ Label.Text = Value;
+ Label.FontSize = Size;
+ Label.bBold = bBold;
+ Label.Colour = Colour;
+ Label.Align = Align;
+ Label.MaxWidth = MaxWidth;
+ Label.Tag = Tag;
+ Label.Size = Measure(Value, Size, bBold);
+ FVector2D TopLeft = Anchor;
+ if (Align == EVerseTextAlign::Centre)
+ {
+ TopLeft.X -= Label.Size.X * 0.5;
+ }
+ else if (Align == EVerseTextAlign::Right)
+ {
+ TopLeft.X -= Label.Size.X;
+ }
+ Label.Position = TopLeft;
+ Out.Labels.Add(Label);
+ return Label.Size;
+ }
+
+ // Numbers follow the Verse UI language, never the machine's culture.
+ FText Num(const FVerseUiStrings& Strings, int32 Value)
+ {
+ return Strings.Number(Value, 0, false);
+ }
+
+ FText Seconds(const FVerseUiStrings& Strings, float Value)
+ {
+ return Strings.Number(FMath::Max(0.f, Value), 1, false);
+ }
+
+ FString StanceKey(EVerseStance Stance)
+ {
+ switch (Stance)
+ {
+ case EVerseStance::Stand: return TEXT("verse.hud.stance.stand");
+ case EVerseStance::Crouch: return TEXT("verse.hud.stance.crouch");
+ case EVerseStance::Prone: return TEXT("verse.hud.stance.prone");
+ case EVerseStance::Slide: return TEXT("verse.hud.stance.slide");
+ }
+ return TEXT("verse.hud.stance.stand");
+ }
+
+ FText PlayerName(const FVerseHudFrame& Frame, int32 PlayerId)
+ {
+ if (PlayerId != INDEX_NONE && Frame.Model && PlayerId == Frame.Model->GetLocalPlayerId())
+ {
+ return Frame.Strings->Get(TEXT("verse.hud.feed.you"));
+ }
+ if (PlayerId < 0)
+ {
+ return Frame.Strings->Get(TEXT("verse.hud.feed.world"));
+ }
+ if (Frame.Source)
+ {
+ if (Frame.Source->IsBot(PlayerId))
+ {
+ return Frame.Strings->Get(TEXT("verse.hud.feed.opponent"));
+ }
+ const FText Name = Frame.Source->GetDisplayName(PlayerId);
+ if (!Name.IsEmpty())
+ {
+ return Name;
+ }
+ }
+ return Frame.Strings->Get(TEXT("verse.hud.feed.opponent"));
+ }
+
+ FText ItemName(const FVerseUiStrings& Strings, FName ItemId)
+ {
+ return Strings.Get(FString::Printf(TEXT("verse.item.%s.name"), *ItemId.ToString().ToLower()));
+ }
+}
+
+// ---------------------------------------------------------------------------------------------
+// Draw list
+
+void FVerseHudDrawList::Reset()
+{
+ Lines.Reset();
+ Rects.Reset();
+ Tris.Reset();
+ Labels.Reset();
+ CrosshairCentre = FVector2D::ZeroVector;
+ bCrosshairVisible = false;
+}
+
+int32 FVerseHudDrawList::CountTag(FName Tag) const
+{
+ int32 Count = 0;
+ for (const FLine& L : Lines) { Count += L.Tag == Tag; }
+ for (const FRect& R : Rects) { Count += R.Tag == Tag; }
+ for (const FTri& T : Tris) { Count += T.Tag == Tag; }
+ for (const FLabel& T : Labels) { Count += T.Tag == Tag; }
+ return Count;
+}
+
+const FVerseHudDrawList::FLabel* FVerseHudDrawList::FindLabel(FName Tag) const
+{
+ return Labels.FindByPredicate([Tag](const FLabel& L) { return L.Tag == Tag; });
+}
+
+// ---------------------------------------------------------------------------------------------
+// Painter
+
+FVerseTextMeasure FVerseHudPainter::DefaultMeasure()
+{
+ return [](const FText& Value, int32 Size, bool bBold) -> FVector2D
+ {
+ if (FSlateApplication::IsInitialized())
+ {
+ const TSharedRef<FSlateFontMeasure> FontMeasure = FSlateApplication::Get().GetRenderer()->GetFontMeasureService();
+ const FVector2D Measured = FontMeasure->Measure(Value, FCoreStyle::GetDefaultFontStyle(bBold ? "Bold" : "Regular", Size));
+ return Measured;
+ }
+ // Without Slate: a generous estimate (wide glyphs count double).
+ const FString& S = Value.ToString();
+ double Width = 0.0;
+ for (TCHAR Ch : S)
+ {
+ Width += Ch > 0x2E80 ? 1.0 : 0.62;
+ }
+ return FVector2D(Width * Size * 1.333, Size * 1.6);
+ };
+}
+
+FIntVector FVerseHudPainter::MarkerShape(EVerseHitMarkerKind Kind)
+{
+ // Same code path as a frame: raise one marker through the model, draw it, count by tag.
+ FVerseHudFrame Frame;
+ FVerseHudDrawList List;
+ List.CrosshairCentre = FVector2D(960, 540);
+ const FName Tag = MarkerTag(Kind);
+ FVerseHudModel Single;
+ Single.SetLocalPlayerId(1);
+ FVerseHitEvent Hit;
+ Hit.InstigatorId = 1;
+ Hit.VictimId = 2;
+ Hit.bHeadshot = Kind == EVerseHitMarkerKind::Headshot;
+ Hit.bKillingBlow = Kind == EVerseHitMarkerKind::Kill;
+ Hit.bBlockedBySpawnProtection = Kind == EVerseHitMarkerKind::Blocked;
+ Single.OnHit(Hit, 0.0);
+ Frame.Model = &Single;
+ Frame.Now = 0.0;
+ PaintMarkers(Frame, List);
+ FIntVector Shape(0, 0, 0);
+ for (const FVerseHudDrawList::FLine& L : List.Lines) { Shape.X += L.Tag == Tag; }
+ for (const FVerseHudDrawList::FRect& R : List.Rects) { Shape.Y += R.Tag == Tag; }
+ for (const FVerseHudDrawList::FTri& T : List.Tris) { Shape.Z += T.Tag == Tag; }
+ return Shape;
+}
+
+float FVerseHudPainter::IndicatorAngleDeg(const FVerseHudView& View, const FVector& FromDirection)
+{
+ const FRotator Yaw(0.f, View.Rotation.Yaw, 0.f);
+ const FVector Local = Yaw.UnrotateVector(FromDirection);
+ // X ahead, Y right: atan2(Y, X) is the clockwise angle from straight ahead.
+ return float(FMath::RadiansToDegrees(FMath::Atan2(Local.Y, Local.X)));
+}
+
+void FVerseHudPainter::Paint(const FVerseHudFrame& Frame, FVerseHudDrawList& Out, const FVerseTextMeasure& Measure)
+{
+ Out.Reset();
+ if (!Frame.Model || !Frame.Strings)
+ {
+ return;
+ }
+ if (Frame.bInDuel)
+ {
+ PaintCrosshair(Frame, Out);
+ PaintMarkers(Frame, Out);
+ PaintDamage(Frame, Out);
+ PaintVitals(Frame, Out, Measure);
+ PaintWeapon(Frame, Out, Measure);
+ PaintScore(Frame, Out, Measure);
+ }
+ PaintFeed(Frame, Out, Measure);
+ PaintCentre(Frame, Out, Measure);
+}
+
+void FVerseHudPainter::PaintCrosshair(const FVerseHudFrame& Frame, FVerseHudDrawList& Out)
+{
+ const FVerseUiLayout& L = Frame.Layout;
+ FVector2D Centre = L.Viewport * 0.5;
+ float Spread = 0.f;
+ if (Frame.bHasView && Frame.Source)
+ {
+ FVector Dir;
+ float HalfAngle = 0.f;
+ if (Frame.Source->GetPredictedBoltDirection(Dir, HalfAngle))
+ {
+ FVector2D Pixel;
+ if (FVerseCrosshair::ProjectDirection(Frame.View, L.Viewport, Dir, Pixel))
+ {
+ Centre = Pixel;
+ }
+ Spread = FVerseCrosshair::SpreadRadiusPx(Frame.View, L.Viewport, HalfAngle);
+ }
+ }
+ // Markers centre on the crosshair even while it is hidden.
+ Out.CrosshairCentre = Centre;
+
+ const bool bHidden = Frame.bKillCam || Frame.Model->IsLocalDead() || Frame.Pawn.Phase != EVerseCombatPhase::Alive;
+ if (bHidden)
+ {
+ return;
+ }
+ Out.bCrosshairVisible = true;
+
+ const float Gap = FMath::Max(L.Px(5.f), Spread);
+ const float Length = L.Px(9.f);
+ const float Thick = FMath::Max(1.f, L.Px(2.f));
+ const FVector2D Dirs[4] = {FVector2D(1, 0), FVector2D(-1, 0), FVector2D(0, 1), FVector2D(0, -1)};
+ for (const FVector2D& D : Dirs)
+ {
+ Line(Out, Centre + D * Gap, Centre + D * (Gap + Length), Thick + 2.f, VerseUiTheme::Shadow, TagCrosshair);
+ }
+ for (const FVector2D& D : Dirs)
+ {
+ Line(Out, Centre + D * Gap, Centre + D * (Gap + Length), Thick, VerseUiTheme::Text, TagCrosshair);
+ }
+ const float Dot = FMath::Max(2.f, L.Px(2.f));
+ FillRect(Out, Centre - FVector2D(Dot, Dot) * 0.5, FVector2D(Dot, Dot), VerseUiTheme::Amber, TagCrosshair);
+
+ if (Spread > Gap * 0.5f && Spread > L.Px(6.f))
+ {
+ // Spread circle: thin, faint, 32 segments.
+ const int32 Segments = 32;
+ for (int32 I = 0; I < Segments; ++I)
+ {
+ const double A0 = 2.0 * PI * I / Segments;
+ const double A1 = 2.0 * PI * (I + 1) / Segments;
+ Line(Out, Centre + FVector2D(FMath::Cos(A0), FMath::Sin(A0)) * Spread,
+ Centre + FVector2D(FMath::Cos(A1), FMath::Sin(A1)) * Spread, 1.f, WithAlpha(VerseUiTheme::Text, 0.25f), TagSpread);
+ }
+ }
+}
+
+void FVerseHudPainter::PaintMarkers(const FVerseHudFrame& Frame, FVerseHudDrawList& Out)
+{
+ const FVerseUiLayout& L = Frame.Layout;
+ const FVector2D C = Out.CrosshairCentre;
+ const FVector2D Diagonals[4] = {FVector2D(1, 1), FVector2D(-1, 1), FVector2D(1, -1), FVector2D(-1, -1)};
+ for (const FVerseHitMarker& Marker : Frame.Model->GetHitMarkers())
+ {
+ const float Alpha = FVerseHudModel::MarkerAlpha(Marker, Frame.Now);
+ const FName Tag = MarkerTag(Marker.Kind);
+ switch (Marker.Kind)
+ {
+ case EVerseHitMarkerKind::Hit:
+ {
+ // Shape: four short diagonal ticks.
+ for (const FVector2D& D : Diagonals)
+ {
+ const FVector2D N = D.GetSafeNormal();
+ Line(Out, C + N * L.Px(8.f), C + N * L.Px(15.f), FMath::Max(1.f, L.Px(2.f)), WithAlpha(VerseUiTheme::Text, Alpha), Tag);
+ }
+ break;
+ }
+ case EVerseHitMarkerKind::Headshot:
+ {
+ // Shape: diagonal ticks plus a diamond.
+ for (const FVector2D& D : Diagonals)
+ {
+ const FVector2D N = D.GetSafeNormal();
+ Line(Out, C + N * L.Px(8.f), C + N * L.Px(17.f), FMath::Max(1.f, L.Px(2.5f)), WithAlpha(VerseUiTheme::Gold, Alpha), Tag);
+ }
+ const float R = L.Px(5.f);
+ const FVector2D Up(0, -R), Right(R, 0), Down(0, R), Left(-R, 0);
+ Line(Out, C + Up, C + Right, FMath::Max(1.f, L.Px(1.5f)), WithAlpha(VerseUiTheme::Gold, Alpha), Tag);
+ Line(Out, C + Right, C + Down, FMath::Max(1.f, L.Px(1.5f)), WithAlpha(VerseUiTheme::Gold, Alpha), Tag);
+ Line(Out, C + Down, C + Left, FMath::Max(1.f, L.Px(1.5f)), WithAlpha(VerseUiTheme::Gold, Alpha), Tag);
+ Line(Out, C + Left, C + Up, FMath::Max(1.f, L.Px(1.5f)), WithAlpha(VerseUiTheme::Gold, Alpha), Tag);
+ break;
+ }
+ case EVerseHitMarkerKind::Kill:
+ {
+ // Shape: long thick diagonals plus a ring.
+ for (const FVector2D& D : Diagonals)
+ {
+ const FVector2D N = D.GetSafeNormal();
+ Line(Out, C + N * L.Px(8.f), C + N * L.Px(22.f), FMath::Max(1.f, L.Px(3.f)), WithAlpha(VerseUiTheme::Red, Alpha), Tag);
+ }
+ const int32 Segments = 16;
+ const float R = L.Px(27.f);
+ for (int32 I = 0; I < Segments; ++I)
+ {
+ const double A0 = 2.0 * PI * I / Segments;
+ const double A1 = 2.0 * PI * (I + 1) / Segments;
+ Line(Out, C + FVector2D(FMath::Cos(A0), FMath::Sin(A0)) * R, C + FVector2D(FMath::Cos(A1), FMath::Sin(A1)) * R,
+ FMath::Max(1.f, L.Px(2.f)), WithAlpha(VerseUiTheme::Red, Alpha), Tag);
+ }
+ break;
+ }
+ case EVerseHitMarkerKind::Blocked:
+ {
+ // Shape: a square plate with a bar: the shot hit a protected player.
+ const float S = L.Px(18.f);
+ Outline(Out, C - FVector2D(S, S) * 0.5, FVector2D(S, S), FMath::Max(1.f, L.Px(2.f)), WithAlpha(VerseUiTheme::Blocked, Alpha), Tag);
+ FillRect(Out, C - FVector2D(S * 0.35, L.Px(1.5f)), FVector2D(S * 0.7, L.Px(3.f)), WithAlpha(VerseUiTheme::Blocked, Alpha), Tag);
+ break;
+ }
+ }
+ }
+}
+
+void FVerseHudPainter::PaintDamage(const FVerseHudFrame& Frame, FVerseHudDrawList& Out)
+{
+ if (!Frame.bHasView)
+ {
+ return;
+ }
+ const FVerseUiLayout& L = Frame.Layout;
+ const FVector2D C = L.Viewport * 0.5;
+ const float Radius = L.Px(150.f);
+ for (const FVerseDamageIndicator& D : Frame.Model->GetDamageIndicators())
+ {
+ const float T = float((Frame.Now - D.StartTime) / FMath::Max(0.01f, D.Duration));
+ const float Alpha = D.Strength * FMath::Clamp(1.f - T, 0.f, 1.f);
+ const float Angle = FMath::DegreesToRadians(IndicatorAngleDeg(Frame.View, D.FromDirection));
+ const FVector2D Dir(FMath::Sin(Angle), -FMath::Cos(Angle));
+ const FVector2D Side(-Dir.Y, Dir.X);
+ const FVector2D Base = C + Dir * Radius;
+ const FVector2D Tip = C + Dir * (Radius + L.Px(22.f));
+ Out.Tris.Add({Tip, Base + Side * L.Px(20.f), Base - Side * L.Px(20.f), WithAlpha(VerseUiTheme::Red, Alpha), TagDamage});
+ }
+}
+
+void FVerseHudPainter::PaintVitals(const FVerseHudFrame& Frame, FVerseHudDrawList& Out, const FVerseTextMeasure& Measure)
+{
+ if (!Frame.Pawn.bValid)
+ {
+ return;
+ }
+ const FVerseUiLayout& L = Frame.Layout;
+ const FVerseUiStrings& S = *Frame.Strings;
+ const FVector2D BlockSize(L.Px(340.f), L.Px(104.f));
+ const FVector2D P = L.Place(EVerseUiAnchor::BottomLeft, BlockSize, FVector2D(8.f, 8.f));
+ FillRect(Out, P, BlockSize, VerseUiTheme::Steel, TagVitals);
+ FillRect(Out, P, FVector2D(L.Px(3.f), BlockSize.Y), VerseUiTheme::Amber, TagVitals);
+
+ const float Pad = L.Px(14.f);
+ const float MaxLabel = BlockSize.X - 2 * Pad;
+ Text(Out, Measure, P + FVector2D(Pad, L.Px(8.f)), S.Get(TEXT("verse.hud.health")), L.FontSize(10.f), true, VerseUiTheme::TextDim,
+ EVerseTextAlign::Left, MaxLabel * 0.5f, TEXT("vitals.health_label"));
+
+ const float Fraction = Frame.Pawn.MaxHealth > 0.f ? FMath::Clamp(Frame.Pawn.Health / Frame.Pawn.MaxHealth, 0.f, 1.f) : 0.f;
+ const bool bLow = Fraction < 0.3f;
+ Text(Out, Measure, P + FVector2D(Pad, L.Px(24.f)), Num(*Frame.Strings, FMath::CeilToInt(Frame.Pawn.Health)), L.FontSize(26.f), true,
+ bLow ? VerseUiTheme::Red : VerseUiTheme::Text, EVerseTextAlign::Left, 0.f, TEXT("vitals.health"));
+
+ const FVector2D BarPos = P + FVector2D(Pad, L.Px(72.f));
+ const FVector2D BarSize(BlockSize.X - 2 * Pad, L.Px(8.f));
+ FillRect(Out, BarPos, BarSize, VerseUiTheme::SteelLight, TagVitals);
+ FillRect(Out, BarPos, FVector2D(BarSize.X * Fraction, BarSize.Y), bLow ? VerseUiTheme::Red : VerseUiTheme::Amber, TagVitals);
+ // Low health also shows as notches (not colour alone).
+ if (bLow)
+ {
+ for (int32 I = 1; I <= 3; ++I)
+ {
+ const float X = BarPos.X + BarSize.X * (0.1f * I);
+ Line(Out, FVector2D(X, BarPos.Y - L.Px(4.f)), FVector2D(X, BarPos.Y), FMath::Max(1.f, L.Px(2.f)), VerseUiTheme::Red, TagVitals);
+ }
+ }
+
+ Text(Out, Measure, P + FVector2D(BlockSize.X - Pad, L.Px(8.f)), S.Get(StanceKey(Frame.Pawn.Stance)), L.FontSize(10.f), true,
+ VerseUiTheme::Text, EVerseTextAlign::Right, MaxLabel * 0.5f, TEXT("vitals.stance"));
+
+ if (Frame.Pawn.bSpawnProtected)
+ {
+ FFormatNamedArguments Args;
+ Args.Add(TEXT("seconds"), Seconds(*Frame.Strings, Frame.Pawn.SpawnProtectionRemaining));
+ const FVector2D Above = P - FVector2D(0, L.Px(34.f));
+ const float Sq = L.Px(16.f);
+ Outline(Out, Above + FVector2D(0, L.Px(4.f)), FVector2D(Sq, Sq), FMath::Max(1.f, L.Px(2.f)), VerseUiTheme::Blocked, TEXT("vitals.protected"));
+ Text(Out, Measure, Above + FVector2D(Sq + L.Px(8.f), 0), S.Format(TEXT("verse.hud.protected"), Args), L.FontSize(12.f), true,
+ VerseUiTheme::Blocked, EVerseTextAlign::Left, BlockSize.X - Sq - L.Px(8.f), TEXT("vitals.protected"));
+ }
+}
+
+void FVerseHudPainter::PaintWeapon(const FVerseHudFrame& Frame, FVerseHudDrawList& Out, const FVerseTextMeasure& Measure)
+{
+ if (!Frame.Pawn.bValid || Frame.bKillCam)
+ {
+ return;
+ }
+ const FVerseUiLayout& L = Frame.Layout;
+ const FVerseUiStrings& S = *Frame.Strings;
+ const FVerseHudPawnState& Pawn = Frame.Pawn;
+ const FVector2D BlockSize(L.Px(380.f), L.Px(104.f));
+ const FVector2D P = L.Place(EVerseUiAnchor::BottomRight, BlockSize, FVector2D(8.f, 8.f));
+ const float Pad = L.Px(14.f);
+ const FVector2D RightTop(P.X + BlockSize.X - Pad, P.Y);
+
+ if (Pawn.bHasWeapon)
+ {
+ FillRect(Out, P, BlockSize, VerseUiTheme::Steel, TagWeapon);
+ FillRect(Out, FVector2D(P.X + BlockSize.X - L.Px(3.f), P.Y), FVector2D(L.Px(3.f), BlockSize.Y), VerseUiTheme::Amber, TagWeapon);
+ Text(Out, Measure, RightTop + FVector2D(0, L.Px(8.f)), ItemName(S, Pawn.WeaponId), L.FontSize(11.f), true, VerseUiTheme::Text,
+ EVerseTextAlign::Right, BlockSize.X * 0.6f, TEXT("weapon.name"));
+
+ const bool bLow = Pawn.MagazineSize > 0 && Pawn.Magazine * 4 <= Pawn.MagazineSize;
+ FFormatNamedArguments Reserve;
+ Reserve.Add(TEXT("reserve"), Num(*Frame.Strings, Pawn.Reserve));
+ const FVector2D ReserveSize = Text(Out, Measure, RightTop + FVector2D(0, L.Px(40.f)), S.Format(TEXT("verse.hud.reserve"), Reserve),
+ L.FontSize(14.f), false, VerseUiTheme::TextDim, EVerseTextAlign::Right, 0.f, TEXT("weapon.reserve"));
+ float X = RightTop.X - ReserveSize.X - L.Px(10.f);
+ if (Pawn.bChambered && Pawn.Magazine > 0)
+ {
+ const FVector2D Plus = Text(Out, Measure, FVector2D(X, P.Y + L.Px(30.f)), S.Get(TEXT("verse.hud.chambered")), L.FontSize(12.f), true,
+ VerseUiTheme::Gold, EVerseTextAlign::Right, 0.f, TEXT("weapon.chambered"));
+ X -= Plus.X + L.Px(4.f);
+ }
+ Text(Out, Measure, FVector2D(X, P.Y + L.Px(22.f)), Num(*Frame.Strings, Pawn.Magazine), L.FontSize(30.f), true, bLow ? VerseUiTheme::Red : VerseUiTheme::Text,
+ EVerseTextAlign::Right, 0.f, TEXT("weapon.magazine"));
+
+ if (Pawn.bReloading)
+ {
+ const FString Key = Pawn.bTacticalReload ? TEXT("verse.hud.reload_tactical") : TEXT("verse.hud.reload_empty");
+ Text(Out, Measure, FVector2D(P.X + Pad, P.Y + L.Px(8.f)), S.Get(Key), L.FontSize(11.f), true, VerseUiTheme::Amber, EVerseTextAlign::Left,
+ BlockSize.X * 0.4f - Pad, TEXT("weapon.reload"));
+ const FVector2D BarPos(P.X + Pad, P.Y + BlockSize.Y - L.Px(14.f));
+ const FVector2D BarSize(BlockSize.X - 2 * Pad, L.Px(4.f));
+ FillRect(Out, BarPos, BarSize, VerseUiTheme::SteelLight, TagWeapon);
+ FillRect(Out, BarPos, FVector2D(BarSize.X * FMath::Clamp(Pawn.ReloadProgress, 0.f, 1.f), BarSize.Y), VerseUiTheme::Amber, TagWeapon);
+ }
+ }
+
+ // Gadgets sit above the weapon block, right-aligned: name, charge pips, cooldown.
+ float GX = P.X + BlockSize.X;
+ const float GW = L.Px(150.f);
+ const float GH = L.Px(40.f);
+ for (int32 I = Pawn.Gadgets.Num() - 1; I >= 0; --I)
+ {
+ const FVerseHudGadgetState& G = Pawn.Gadgets[I];
+ GX -= GW;
+ const FVector2D GP(GX, P.Y - GH - L.Px(8.f));
+ GX -= L.Px(8.f);
+ FillRect(Out, GP, FVector2D(GW, GH), VerseUiTheme::Steel, TagGadget);
+ const bool bReady = G.Charges > 0 && G.CooldownRemaining <= 0.f;
+ Text(Out, Measure, GP + FVector2D(L.Px(8.f), L.Px(4.f)), S.Get(FString::Printf(TEXT("verse.item.%s.short"), *G.GadgetId.ToString().ToLower())),
+ L.FontSize(10.f), true, bReady ? VerseUiTheme::Text : VerseUiTheme::TextDim, EVerseTextAlign::Left, GW - L.Px(16.f), TEXT("gadget.name"));
+ const float Pip = L.Px(9.f);
+ for (int32 C = 0; C < FMath::Max(G.MaxCharges, G.Charges); ++C)
+ {
+ const FVector2D PipPos = GP + FVector2D(L.Px(8.f) + C * (Pip + L.Px(5.f)), GH - Pip - L.Px(6.f));
+ if (C < G.Charges)
+ {
+ FillRect(Out, PipPos, FVector2D(Pip, Pip), VerseUiTheme::Amber, TagGadget);
+ }
+ else
+ {
+ Outline(Out, PipPos, FVector2D(Pip, Pip), 1.f, VerseUiTheme::TextDim, TagGadget);
+ }
+ }
+ if (G.CooldownRemaining > 0.f)
+ {
+ FFormatNamedArguments Args;
+ Args.Add(TEXT("seconds"), Num(*Frame.Strings, FMath::CeilToInt(G.CooldownRemaining)));
+ Text(Out, Measure, GP + FVector2D(GW - L.Px(8.f), GH - L.Px(22.f)), S.Format(TEXT("verse.hud.cooldown"), Args), L.FontSize(10.f), false,
+ VerseUiTheme::TextDim, EVerseTextAlign::Right, GW * 0.5f, TEXT("gadget.cooldown"));
+ }
+ }
+}
+
+void FVerseHudPainter::PaintScore(const FVerseHudFrame& Frame, FVerseHudDrawList& Out, const FVerseTextMeasure& Measure)
+{
+ const FVerseUiLayout& L = Frame.Layout;
+ const FVerseUiStrings& S = *Frame.Strings;
+ const FVector2D BlockSize(L.Px(300.f), L.Px(66.f));
+ const FVector2D P = L.Place(EVerseUiAnchor::Top, BlockSize, FVector2D(0.f, 4.f));
+ FillRect(Out, P, BlockSize, VerseUiTheme::Steel, TagScore);
+ const float Mid = P.X + BlockSize.X * 0.5f;
+ const float Half = BlockSize.X * 0.5f - L.Px(42.f);
+
+ Text(Out, Measure, FVector2D(Mid - L.Px(14.f), P.Y + L.Px(4.f)), Num(*Frame.Strings, Frame.Model->GetScoreSelf()), L.FontSize(22.f), true, VerseUiTheme::Amber,
+ EVerseTextAlign::Right, 0.f, TEXT("score.self"));
+ Text(Out, Measure, FVector2D(Mid, P.Y + L.Px(4.f)), S.Get(TEXT("verse.hud.score.separator")), L.FontSize(22.f), true, VerseUiTheme::TextDim,
+ EVerseTextAlign::Centre, 0.f, TEXT("score.separator"));
+ Text(Out, Measure, FVector2D(Mid + L.Px(14.f), P.Y + L.Px(4.f)), Num(*Frame.Strings, Frame.Model->GetScoreOpponent()), L.FontSize(22.f), true, VerseUiTheme::Red,
+ EVerseTextAlign::Left, 0.f, TEXT("score.opponent"));
+
+ Text(Out, Measure, FVector2D(P.X + L.Px(10.f), P.Y + L.Px(14.f)), S.Get(TEXT("verse.hud.score.you")), L.FontSize(9.f), true, VerseUiTheme::TextDim,
+ EVerseTextAlign::Left, Half - L.Px(10.f), TEXT("score.you_label"));
+ Text(Out, Measure, FVector2D(P.X + BlockSize.X - L.Px(10.f), P.Y + L.Px(14.f)), S.Get(TEXT("verse.hud.score.opponent")), L.FontSize(9.f), true,
+ VerseUiTheme::TextDim, EVerseTextAlign::Right, Half - L.Px(10.f), TEXT("score.opponent_label"));
+
+ FFormatNamedArguments Args;
+ Args.Add(TEXT("set"), Num(*Frame.Strings, Frame.Model->GetSetIndex()));
+ Args.Add(TEXT("target"), Num(*Frame.Strings, Frame.Model->Timing.SetTarget));
+ Text(Out, Measure, FVector2D(Mid, P.Y + L.Px(44.f)), S.Format(TEXT("verse.hud.score.set"), Args), L.FontSize(9.f), false, VerseUiTheme::TextDim,
+ EVerseTextAlign::Centre, BlockSize.X - L.Px(16.f), TEXT("score.set"));
+}
+
+void FVerseHudPainter::PaintFeed(const FVerseHudFrame& Frame, FVerseHudDrawList& Out, const FVerseTextMeasure& Measure)
+{
+ const FVerseUiLayout& L = Frame.Layout;
+ const FVerseUiStrings& S = *Frame.Strings;
+ const float Width = L.Px(560.f);
+ const float LineH = L.Px(30.f);
+ const FVector2D Origin = L.Place(EVerseUiAnchor::TopRight, FVector2D(Width, LineH), FVector2D(4.f, 4.f));
+ const TArray<FVerseKillFeedEntry>& Feed = Frame.Model->GetKillFeed();
+ const int32 LocalId = Frame.Model->GetLocalPlayerId();
+ for (int32 I = 0; I < Feed.Num(); ++I)
+ {
+ const FVerseKillFeedEntry& E = Feed[I];
+ const float Age = float(Frame.Now - E.Time);
+ const float Alpha = FMath::Clamp((Frame.Model->Timing.FeedEntry - Age) / 0.6f, 0.f, 1.f);
+ FText Line;
+ FLinearColor Colour = VerseUiTheme::Text;
+ if (E.Kind == EVerseFeedKind::Kill)
+ {
+ FText How;
+ switch (E.Cause)
+ {
+ case EVerseDamageSource::Finisher: How = S.Get(TEXT("verse.hud.feed.finisher")); break;
+ case EVerseDamageSource::Melee:
+ How = E.WeaponId.IsNone() ? S.Get(TEXT("verse.hud.feed.melee")) : ItemName(S, E.WeaponId);
+ break;
+ default: How = E.WeaponId.IsNone() ? S.Get(TEXT("verse.hud.feed.unknown")) : ItemName(S, E.WeaponId); break;
+ }
+ FFormatNamedArguments Args;
+ Args.Add(TEXT("killer"), PlayerName(Frame, E.KillerId));
+ Args.Add(TEXT("weapon"), How);
+ Args.Add(TEXT("victim"), PlayerName(Frame, E.VictimId));
+ FString Composed = S.Format(TEXT("verse.hud.feed.kill"), Args).ToString();
+ if (E.bHeadshot)
+ {
+ Composed += S.Get(TEXT("verse.hud.feed.headshot")).ToString();
+ }
+ if (E.bWallShot)
+ {
+ Composed += S.Get(TEXT("verse.hud.feed.wallshot")).ToString();
+ }
+ Line = FText::AsCultureInvariant(Composed);
+ Colour = E.KillerId == LocalId ? VerseUiTheme::Amber : (E.VictimId == LocalId ? VerseUiTheme::Red : VerseUiTheme::Text);
+ }
+ else if (E.Kind == EVerseFeedKind::Respawn)
+ {
+ FFormatNamedArguments Args;
+ Args.Add(TEXT("name"), PlayerName(Frame, E.VictimId));
+ Line = S.Format(TEXT("verse.hud.feed.respawn"), Args);
+ Colour = VerseUiTheme::TextDim;
+ }
+ else
+ {
+ const TCHAR* Key = E.Outcome == EVerseSetOutcome::Won ? TEXT("verse.hud.feed.set_won")
+ : E.Outcome == EVerseSetOutcome::Lost ? TEXT("verse.hud.feed.set_lost")
+ : TEXT("verse.hud.feed.set_unfinished");
+ Line = S.Get(Key);
+ Colour = E.Outcome == EVerseSetOutcome::Won ? VerseUiTheme::Gold : VerseUiTheme::Text;
+ }
+ const FVector2D Row(Origin.X, Origin.Y + I * (LineH + L.Px(4.f)));
+ const FVector2D Size = Measure(Line, L.FontSize(11.f), true);
+ const float Plate = FMath::Min<float>(Size.X, Width) + L.Px(20.f);
+ FillRect(Out, FVector2D(Row.X + Width - Plate, Row.Y), FVector2D(Plate, LineH), WithAlpha(VerseUiTheme::Steel, Alpha), TagFeed);
+ Text(Out, Measure, FVector2D(Row.X + Width - L.Px(10.f), Row.Y + (LineH - Size.Y) * 0.5f), Line, L.FontSize(11.f), true,
+ WithAlpha(Colour, Alpha), EVerseTextAlign::Right, Width - L.Px(20.f), TagFeed);
+ }
+}
+
+void FVerseHudPainter::PaintCentre(const FVerseHudFrame& Frame, FVerseHudDrawList& Out, const FVerseTextMeasure& Measure)
+{
+ const FVerseUiLayout& L = Frame.Layout;
+ const FVerseUiStrings& S = *Frame.Strings;
+ const float Width = L.SafeSize().X * 0.6f;
+ const float Mid = L.SafeMin.X + L.SafeSize().X * 0.5f;
+
+ if (Frame.bKillCam)
+ {
+ FFormatNamedArguments Args;
+ Args.Add(TEXT("name"), PlayerName(Frame, Frame.KillCamKillerId));
+ const float Y = L.SafeMin.Y + L.Px(96.f);
+ const FVector2D Size = Measure(S.Format(TEXT("verse.hud.killcam"), Args), L.FontSize(16.f), true);
+ FillRect(Out, FVector2D(Mid - Size.X * 0.5f - L.Px(16.f), Y - L.Px(6.f)), FVector2D(Size.X + L.Px(32.f), Size.Y + L.Px(12.f)), VerseUiTheme::Steel, TagCentre);
+ FillRect(Out, FVector2D(Mid - Size.X * 0.5f - L.Px(16.f), Y - L.Px(6.f)), FVector2D(L.Px(4.f), Size.Y + L.Px(12.f)), VerseUiTheme::Red, TagCentre);
+ Text(Out, Measure, FVector2D(Mid, Y), S.Format(TEXT("verse.hud.killcam"), Args), L.FontSize(16.f), true, VerseUiTheme::Text,
+ EVerseTextAlign::Centre, Width, TEXT("centre.killcam"));
+ FFormatNamedArguments Skip;
+ Skip.Add(TEXT("key"), Frame.SkipKeyName);
+ Text(Out, Measure, FVector2D(Mid, Y + Size.Y + L.Px(14.f)), S.Format(TEXT("verse.hud.killcam_skip"), Skip), L.FontSize(10.f), false,
+ VerseUiTheme::TextDim, EVerseTextAlign::Centre, Width, TEXT("centre.killcam_skip"));
+ }
+
+ if (Frame.Model->IsLocalDead())
+ {
+ FFormatNamedArguments Args;
+ Args.Add(TEXT("seconds"), Seconds(*Frame.Strings, Frame.Model->GetRespawnRemaining(Frame.ServerTime)));
+ const float Y = L.SafeMin.Y + L.SafeSize().Y * 0.70f;
+ Text(Out, Measure, FVector2D(Mid, Y), S.Format(TEXT("verse.hud.respawn_in"), Args), L.FontSize(20.f), true, VerseUiTheme::Text,
+ EVerseTextAlign::Centre, Width, TEXT("centre.respawn"));
+ }
+}
+
+// ---------------------------------------------------------------------------------------------
+// Canvas renderer
+
+const UFont* FVerseHudCanvasRenderer::LabelFont()
+{
+ static TWeakObjectPtr<const UFont> Cached;
+ if (const UFont* Font = Cached.Get())
+ {
+ return Font;
+ }
+ const UFont* Font = GEngine ? GEngine->GetMediumFont() : nullptr;
+ if (!Font || Font->FontCacheType != EFontCacheType::Runtime)
+ {
+ Font = LoadObject<UFont>(nullptr, TEXT("/Engine/EngineFonts/Roboto.Roboto"));
+ }
+ Cached = Font;
+ return Font;
+}
+
+void FVerseHudCanvasRenderer::Render(UCanvas* Canvas, const FVerseHudDrawList& List)
+{
+ if (!Canvas || !Canvas->Canvas)
+ {
+ return;
+ }
+ FCanvas* C = Canvas->Canvas;
+ for (const FVerseHudDrawList::FRect& R : List.Rects)
+ {
+ FCanvasTileItem Tile(R.Min, R.Max - R.Min, R.Colour);
+ Tile.BlendMode = SE_BLEND_Translucent;
+ C->DrawItem(Tile);
+ }
+ for (const FVerseHudDrawList::FTri& T : List.Tris)
+ {
+ FCanvasTriangleItem Tri(T.A, T.B, T.C, GWhiteTexture);
+ Tri.SetColor(T.Colour);
+ Tri.BlendMode = SE_BLEND_Translucent;
+ C->DrawItem(Tri);
+ }
+ for (const FVerseHudDrawList::FLine& L : List.Lines)
+ {
+ FCanvasLineItem Line(L.A, L.B);
+ Line.LineThickness = L.Thickness;
+ Line.SetColor(L.Colour);
+ Line.BlendMode = SE_BLEND_Translucent;
+ C->DrawItem(Line);
+ }
+ const UFont* Font = LabelFont();
+ if (!Font)
+ {
+ return;
+ }
+ for (const FVerseHudDrawList::FLabel& T : List.Labels)
+ {
+ FCanvasTextItem Text(T.Position, T.Text, FCoreStyle::GetDefaultFontStyle(T.bBold ? "Bold" : "Regular", T.FontSize), T.Colour);
+ Text.Font = Font;
+ Text.EnableShadow(FLinearColor(0.f, 0.f, 0.f, 0.8f * T.Colour.A), FVector2D(1.0, 1.0));
+ Text.BlendMode = SE_BLEND_Translucent;
+ C->DrawItem(Text);
+ }
+}
diff --git a/unreal/Verse/Source/VerseUI/Private/KillCam/VerseKillCam.cpp b/unreal/Verse/Source/VerseUI/Private/KillCam/VerseKillCam.cpp
new file mode 100644
index 0000000000..6b44bd2882
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Private/KillCam/VerseKillCam.cpp
@@ -0,0 +1,232 @@
+#include "KillCam/VerseKillCam.h"
+
+// ---------------------------------------------------------------------------------------------
+// Buffer
+
+void FVerseKillCamBuffer::Reset()
+{
+ Poses.Reset();
+ Fires.Reset();
+ Fractures.Reset();
+}
+
+void FVerseKillCamBuffer::AddPose(int32 PlayerId, double ServerTime, const FVector& Location, const FRotator& Rotation)
+{
+ TArray<FPoseSample>& Samples = Poses.FindOrAdd(PlayerId);
+ if (Samples.Num() > 0 && ServerTime <= Samples.Last().Time)
+ {
+ // Same server time seen twice (client faster than the replicated clock): keep the newest.
+ if (FMath::IsNearlyEqual(ServerTime, Samples.Last().Time))
+ {
+ Samples.Last().Location = Location;
+ Samples.Last().Rotation = Rotation;
+ }
+ return;
+ }
+ Samples.Add({ServerTime, Location, Rotation});
+}
+
+void FVerseKillCamBuffer::AddFire(const FVerseFireEvent& Event, double ServerTime)
+{
+ Fires.Add({ServerTime, Event});
+}
+
+void FVerseKillCamBuffer::AddFracture(const FVerseFractureEvent& Event, double ServerTime)
+{
+ Fractures.Add({ServerTime, Event});
+}
+
+void FVerseKillCamBuffer::Trim(double ServerNow)
+{
+ const double Oldest = ServerNow - Window;
+ for (TPair<int32, TArray<FPoseSample>>& Pair : Poses)
+ {
+ TArray<FPoseSample>& Samples = Pair.Value;
+ // Keep one sample before the window so interpolation at its start still works.
+ int32 Cut = 0;
+ while (Cut + 1 < Samples.Num() && Samples[Cut + 1].Time < Oldest)
+ {
+ ++Cut;
+ }
+ if (Cut > 0)
+ {
+ Samples.RemoveAt(0, Cut, EAllowShrinking::No);
+ }
+ }
+ Fires.RemoveAll([Oldest](const FFireSample& S) { return S.Time < Oldest; });
+ Fractures.RemoveAll([Oldest](const FFractureSample& S) { return S.Time < Oldest; });
+}
+
+bool FVerseKillCamBuffer::PoseAt(int32 PlayerId, double Time, FVector& OutLocation, FRotator& OutRotation) const
+{
+ const TArray<FPoseSample>* Samples = Poses.Find(PlayerId);
+ if (!Samples || Samples->Num() == 0)
+ {
+ return false;
+ }
+ const TArray<FPoseSample>& S = *Samples;
+ if (Time <= S[0].Time)
+ {
+ OutLocation = S[0].Location;
+ OutRotation = S[0].Rotation;
+ return Time >= S[0].Time - 0.1;
+ }
+ if (Time >= S.Last().Time)
+ {
+ OutLocation = S.Last().Location;
+ OutRotation = S.Last().Rotation;
+ return Time <= S.Last().Time + 0.25;
+ }
+ // Binary search for the segment.
+ int32 Lo = 0;
+ int32 Hi = S.Num() - 1;
+ while (Hi - Lo > 1)
+ {
+ const int32 Mid = (Lo + Hi) / 2;
+ if (S[Mid].Time <= Time)
+ {
+ Lo = Mid;
+ }
+ else
+ {
+ Hi = Mid;
+ }
+ }
+ const double Span = S[Hi].Time - S[Lo].Time;
+ const float Alpha = Span > 0.0 ? float((Time - S[Lo].Time) / Span) : 0.f;
+ OutLocation = FMath::Lerp(S[Lo].Location, S[Hi].Location, Alpha);
+ OutRotation = FQuat::Slerp(S[Lo].Rotation.Quaternion(), S[Hi].Rotation.Quaternion(), Alpha).Rotator();
+ return true;
+}
+
+double FVerseKillCamBuffer::EarliestPose(int32 PlayerId) const
+{
+ const TArray<FPoseSample>* Samples = Poses.Find(PlayerId);
+ return Samples && Samples->Num() > 0 ? (*Samples)[0].Time : TNumericLimits<double>::Max();
+}
+
+int32 FVerseKillCamBuffer::NumPoses(int32 PlayerId) const
+{
+ const TArray<FPoseSample>* Samples = Poses.Find(PlayerId);
+ return Samples ? Samples->Num() : 0;
+}
+
+// ---------------------------------------------------------------------------------------------
+// Player
+
+bool FVerseKillCamPlayer::Begin(const FVerseKillCamBuffer& Buffer, const FVerseDeathEvent& Death, int32 LocalPlayerId,
+ double LocalNow, double ServerNow, bool bCutFinisher)
+{
+ Stop();
+ if (Death.VictimId != LocalPlayerId || Death.KillerId == LocalPlayerId || Death.KillerId < 0)
+ {
+ return false;
+ }
+ if (Buffer.NumPoses(Death.KillerId) == 0)
+ {
+ return false;
+ }
+ // The replay may run until EndMargin before respawn; it shows the seconds up to the death.
+ const double Available = Death.RespawnAt - ServerNow - Tuning.EndMarginS;
+ double End = Death.ServerTime;
+ if (bCutFinisher && Death.Cause == EVerseDamageSource::Finisher)
+ {
+ End -= Tuning.FinisherCutS;
+ }
+ const double Earliest = FMath::Max(Buffer.EarliestPose(Death.KillerId), Death.ServerTime - Buffer.Window);
+ const double Length = FMath::Min(End - Earliest, Available);
+ if (Length < Tuning.MinLengthS)
+ {
+ return false;
+ }
+
+ Clip = Buffer;
+ KillerId = Death.KillerId;
+ ClipEnd = End;
+ ClipStart = End - Length;
+ PlayStart = LocalNow;
+ ReplayTime = ClipStart;
+ NextFire = 0;
+ NextFracture = 0;
+ while (NextFire < Clip.GetFires().Num() && Clip.GetFires()[NextFire].Time < ClipStart)
+ {
+ ++NextFire;
+ }
+ while (NextFracture < Clip.GetFractures().Num() && Clip.GetFractures()[NextFracture].Time < ClipStart)
+ {
+ ++NextFracture;
+ }
+ State = EVerseKillCamState::Playing;
+ return true;
+}
+
+void FVerseKillCamPlayer::Tick(double LocalNow)
+{
+ if (State != EVerseKillCamState::Playing)
+ {
+ return;
+ }
+ ReplayTime = FMath::Min(ClipEnd, ClipStart + (LocalNow - PlayStart));
+ const TArray<FVerseKillCamBuffer::FFireSample>& Fires = Clip.GetFires();
+ while (NextFire < Fires.Num() && Fires[NextFire].Time <= ReplayTime)
+ {
+ if (OnReplayFire)
+ {
+ OnReplayFire(Fires[NextFire].Event);
+ }
+ ++NextFire;
+ }
+ const TArray<FVerseKillCamBuffer::FFractureSample>& Fractures = Clip.GetFractures();
+ while (NextFracture < Fractures.Num() && Fractures[NextFracture].Time <= ReplayTime)
+ {
+ if (OnReplayFracture)
+ {
+ OnReplayFracture(Fractures[NextFracture].Event);
+ }
+ ++NextFracture;
+ }
+ if (ReplayTime >= ClipEnd)
+ {
+ State = EVerseKillCamState::Finished;
+ EndedAt = LocalNow;
+ }
+}
+
+void FVerseKillCamPlayer::Skip(double LocalNow)
+{
+ if (State == EVerseKillCamState::Playing)
+ {
+ State = EVerseKillCamState::Skipped;
+ EndedAt = LocalNow;
+ }
+}
+
+void FVerseKillCamPlayer::Stop()
+{
+ State = EVerseKillCamState::Idle;
+ Clip.Reset();
+ KillerId = INDEX_NONE;
+}
+
+bool FVerseKillCamPlayer::GetKillerPose(FVector& OutLocation, FRotator& OutRotation) const
+{
+ return State == EVerseKillCamState::Playing && Clip.PoseAt(KillerId, ReplayTime, OutLocation, OutRotation);
+}
+
+bool FVerseKillCamPlayer::GetCamera(FVector& OutLocation, FRotator& OutRotation) const
+{
+ FVector Killer;
+ FRotator View;
+ if (!GetKillerPose(Killer, View))
+ {
+ return false;
+ }
+ // Over the killer's shoulder, looking where the killer looked (third person, README Camera).
+ const FRotator Yaw(0.f, View.Yaw, 0.f);
+ const FVector Forward = Yaw.Vector();
+ const FVector Right = FRotationMatrix(Yaw).GetUnitAxis(EAxis::Y);
+ OutLocation = Killer - Forward * Tuning.CameraBack + Right * Tuning.CameraRight + FVector::UpVector * Tuning.CameraUp;
+ const FVector Target = Killer + View.Vector() * 1000.f;
+ OutRotation = (Target - OutLocation).Rotation();
+ return true;
+}
diff --git a/unreal/Verse/Source/VerseUI/Private/Menus/SVerseUiRoot.cpp b/unreal/Verse/Source/VerseUI/Private/Menus/SVerseUiRoot.cpp
new file mode 100644
index 0000000000..0c32c34c47
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Private/Menus/SVerseUiRoot.cpp
@@ -0,0 +1,641 @@
+#include "Menus/SVerseUiRoot.h"
+
+#include "Brushes/SlateColorBrush.h"
+#include "Core/VerseUiSubsystem.h"
+#include "Core/VerseUiTheme.h"
+#include "Styling/CoreStyle.h"
+#include "Styling/SlateTypes.h"
+#include "Widgets/Input/SButton.h"
+#include "Widgets/Layout/SBorder.h"
+#include "Widgets/Layout/SBox.h"
+#include "Widgets/Layout/SScrollBox.h"
+#include "Widgets/Layout/SSpacer.h"
+#include "Widgets/SBoxPanel.h"
+#include "Widgets/SNullWidget.h"
+#include "Widgets/SOverlay.h"
+#include "Widgets/Text/STextBlock.h"
+
+namespace
+{
+ const FSlateBrush* ColourBrush(const FLinearColor& Colour)
+ {
+ // Brushes live as long as the module: one per distinct colour.
+ static TMap<uint32, TUniquePtr<FSlateColorBrush>> Brushes;
+ const uint32 Key = Colour.ToFColor(false).ToPackedARGB();
+ TUniquePtr<FSlateColorBrush>& Brush = Brushes.FindOrAdd(Key);
+ if (!Brush)
+ {
+ Brush = MakeUnique<FSlateColorBrush>(Colour);
+ }
+ return Brush.Get();
+ }
+
+ const FButtonStyle& ButtonStyle(bool bPrimary)
+ {
+ auto Make = [](bool bIsPrimary)
+ {
+ FButtonStyle Style = FCoreStyle::Get().GetWidgetStyle<FButtonStyle>("Button");
+ const FLinearColor Base = bIsPrimary ? FLinearColor(0.32f, 0.16f, 0.02f, 1.f) : VerseUiTheme::SteelLight;
+ Style.SetNormal(*ColourBrush(Base));
+ Style.SetHovered(*ColourBrush(bIsPrimary ? FLinearColor(0.48f, 0.25f, 0.03f, 1.f) : VerseUiTheme::Edge));
+ Style.SetPressed(*ColourBrush(VerseUiTheme::Amber * FLinearColor(0.6f, 0.6f, 0.6f, 1.f)));
+ Style.SetDisabled(*ColourBrush(FLinearColor(0.02f, 0.02f, 0.02f, 0.6f)));
+ Style.SetNormalPadding(FMargin(16.f, 8.f));
+ Style.SetPressedPadding(FMargin(16.f, 9.f, 16.f, 7.f));
+ return Style;
+ };
+ static const FButtonStyle Normal = Make(false);
+ static const FButtonStyle Primary = Make(true);
+ return bPrimary ? Primary : Normal;
+ }
+
+ FText OnOff(const UVerseUiSubsystem* Ui, bool bOn)
+ {
+ return Ui->GetStrings().Get(bOn ? TEXT("verse.ui.on") : TEXT("verse.ui.off"));
+ }
+
+
+ const TCHAR* ScalabilityKey(int32 Level)
+ {
+ switch (Level)
+ {
+ case 0: return TEXT("verse.settings.quality.low");
+ case 1: return TEXT("verse.settings.quality.medium");
+ case 2: return TEXT("verse.settings.quality.high");
+ case 3: return TEXT("verse.settings.quality.epic");
+ case 4: return TEXT("verse.settings.quality.cinematic");
+ default: return TEXT("verse.settings.quality.auto");
+ }
+ }
+}
+
+void SVerseUiRoot::Construct(const FArguments& InArgs, UVerseUiSubsystem* InOwner)
+{
+ Owner = InOwner;
+ ChildSlot
+ [
+ SNew(SOverlay)
+ + SOverlay::Slot()
+ .HAlign(HAlign_Center)
+ .VAlign(VAlign_Top)
+ .Padding(FMargin(0.f, 12.f, 0.f, 0.f))
+ [
+ SAssignNew(BarSlot, SBox)
+ ]
+ + SOverlay::Slot()
+ .HAlign(HAlign_Center)
+ .VAlign(VAlign_Center)
+ [
+ SAssignNew(ScreenSlot, SBox)
+ ]
+ ];
+ Refresh();
+}
+
+FText SVerseUiRoot::S(const FString& Key) const
+{
+ return Owner.IsValid() ? Owner->GetStrings().Get(Key) : FText::AsCultureInvariant(Key);
+}
+
+void SVerseUiRoot::Refresh()
+{
+ if (!Owner.IsValid())
+ {
+ return;
+ }
+ BarSlot->SetContent(BuildBar());
+ ScreenSlot->SetContent(BuildScreen());
+}
+
+void SVerseUiRoot::SetSettingsPage(int32 Page)
+{
+ SettingsPage = FMath::Clamp(Page, 0, NumSettingsPages - 1);
+ if (PageSlot.IsValid())
+ {
+ PageSlot->SetContent(BuildSettingsPage());
+ }
+}
+
+TSharedRef<SWidget> SVerseUiRoot::BuildScreen()
+{
+ switch (Owner->GetScreen())
+ {
+ case EVerseUiScreen::EscMenu: return BuildEscMenu();
+ case EVerseUiScreen::Settings: return BuildSettings();
+ case EVerseUiScreen::Armoury: return BuildArmoury();
+ case EVerseUiScreen::EndOfSet: return BuildEndOfSet();
+ case EVerseUiScreen::SessionSummary: return BuildSessionSummary();
+ case EVerseUiScreen::None: break;
+ }
+ return SNullWidget::NullWidget;
+}
+
+TSharedRef<SWidget> SVerseUiRoot::Label(TAttribute<FText> Text, float Size, bool bBold, const FLinearColor& Colour)
+{
+ const float Scale = Owner.IsValid() && Owner->GetUserSettings() ? Owner->GetUserSettings()->TextScale : 1.f;
+ return SNew(STextBlock)
+ .Text(Text)
+ .Font(FCoreStyle::GetDefaultFontStyle(bBold ? "Bold" : "Regular", FMath::RoundToInt(Size * Scale)))
+ .ColorAndOpacity(FSlateColor(Colour))
+ .ShadowColorAndOpacity(VerseUiTheme::Shadow)
+ .ShadowOffset(FVector2D(1.0, 1.0));
+}
+
+TSharedRef<SWidget> SVerseUiRoot::Button(TAttribute<FText> Text, FSimpleDelegate OnClick, bool bPrimary, TAttribute<bool> bSelected)
+{
+ return SNew(SHorizontalBox)
+ + SHorizontalBox::Slot()
+ .AutoWidth()
+ [
+ // Selection is a bar beside the button (a shape), not only a colour.
+ SNew(SBox)
+ .WidthOverride(5.f)
+ [
+ SNew(SBorder)
+ .BorderImage(ColourBrush(VerseUiTheme::Amber))
+ .Visibility_Lambda([bSelected] { return bSelected.Get() ? EVisibility::Visible : EVisibility::Hidden; })
+ ]
+ ]
+ + SHorizontalBox::Slot()
+ .FillWidth(1.f)
+ [
+ SNew(SButton)
+ .ButtonStyle(&ButtonStyle(bPrimary))
+ .HAlign(HAlign_Center)
+ .OnClicked_Lambda([OnClick] { OnClick.ExecuteIfBound(); return FReply::Handled(); })
+ [
+ Label(Text, 15.f, true, VerseUiTheme::Text)
+ ]
+ ];
+}
+
+TSharedRef<SWidget> SVerseUiRoot::Panel(const FString& TitleKey, TSharedRef<SWidget> Body, float Width)
+{
+ return SNew(SBox)
+ .WidthOverride(Width)
+ [
+ SNew(SBorder)
+ .BorderImage(ColourBrush(VerseUiTheme::Steel))
+ .Padding(FMargin(0.f))
+ [
+ SNew(SHorizontalBox)
+ + SHorizontalBox::Slot()
+ .AutoWidth()
+ [
+ SNew(SBox)
+ .WidthOverride(4.f)
+ [
+ SNew(SBorder).BorderImage(ColourBrush(VerseUiTheme::Amber))
+ ]
+ ]
+ + SHorizontalBox::Slot()
+ .FillWidth(1.f)
+ .Padding(FMargin(28.f, 22.f))
+ [
+ SNew(SVerticalBox)
+ + SVerticalBox::Slot()
+ .AutoHeight()
+ .Padding(FMargin(0.f, 0.f, 0.f, 16.f))
+ [
+ Label(S(TitleKey), 26.f, true, VerseUiTheme::Text)
+ ]
+ + SVerticalBox::Slot()
+ .AutoHeight()
+ [
+ Body
+ ]
+ ]
+ ]
+ ];
+}
+
+TSharedRef<SWidget> SVerseUiRoot::Stepper(const FString& LabelKey, TAttribute<FText> Value, TFunction<void(int32)> Step)
+{
+ return SNew(SHorizontalBox)
+ + SHorizontalBox::Slot()
+ .FillWidth(1.f)
+ .VAlign(VAlign_Center)
+ [
+ Label(S(LabelKey), 15.f, false, VerseUiTheme::Text)
+ ]
+ + SHorizontalBox::Slot()
+ .AutoWidth()
+ [
+ SNew(SBox)
+ .WidthOverride(52.f)
+ [
+ Button(S(TEXT("verse.ui.previous")), FSimpleDelegate::CreateLambda([Step] { Step(-1); }))
+ ]
+ ]
+ + SHorizontalBox::Slot()
+ .AutoWidth()
+ .VAlign(VAlign_Center)
+ [
+ SNew(SBox)
+ .WidthOverride(200.f)
+ .HAlign(HAlign_Center)
+ [
+ Label(Value, 15.f, true, VerseUiTheme::Amber)
+ ]
+ ]
+ + SHorizontalBox::Slot()
+ .AutoWidth()
+ [
+ SNew(SBox)
+ .WidthOverride(52.f)
+ [
+ Button(S(TEXT("verse.ui.next")), FSimpleDelegate::CreateLambda([Step] { Step(1); }))
+ ]
+ ];
+}
+
+TSharedRef<SWidget> SVerseUiRoot::BuildBar()
+{
+ TWeakObjectPtr<UVerseUiSubsystem> Ui = Owner;
+ const bool bDuel = Owner->GetGamePort().IsDuelRunning();
+ const bool bShow = !bDuel || Owner->IsBarOpen() || Owner->GetScreen() != EVerseUiScreen::None;
+ if (!bShow)
+ {
+ return SNullWidget::NullWidget;
+ }
+ TSharedRef<SHorizontalBox> Row = SNew(SHorizontalBox);
+ for (const FVerseBarEntry& Entry : FVerseBarModel::Build(Owner->GetDecks(), Owner->GetGamePort().GetCurrentDeck(), bDuel))
+ {
+ FSimpleDelegate Click;
+ switch (Entry.Kind)
+ {
+ case EVerseBarEntryKind::QuickStartDuel:
+ Click = FSimpleDelegate::CreateLambda([Ui, bDuel] { if (Ui.IsValid()) { bDuel ? Ui->LeaveDuel() : Ui->QuickStartDuel(); } });
+ break;
+ case EVerseBarEntryKind::Deck:
+ {
+ const FName Deck = Entry.Id;
+ Click = FSimpleDelegate::CreateLambda([Ui, Deck] { if (Ui.IsValid()) { Ui->TravelToDeck(Deck); } });
+ break;
+ }
+ case EVerseBarEntryKind::ReturnToApp:
+ Click = FSimpleDelegate::CreateLambda([Ui] { if (Ui.IsValid()) { Ui->ReturnToApp(TEXT("esc_menu")); } });
+ break;
+ }
+ const bool bActive = Entry.bActive;
+ TSharedRef<SWidget> Item = Button(S(Entry.LabelKey), Click, Entry.Kind == EVerseBarEntryKind::QuickStartDuel, bActive);
+ Item->SetEnabled(Entry.bEnabled);
+ Row->AddSlot().AutoWidth().Padding(FMargin(3.f, 0.f))[Item];
+ }
+ return SNew(SBorder)
+ .BorderImage(ColourBrush(VerseUiTheme::Steel))
+ .Padding(FMargin(8.f, 6.f))
+ [
+ Row
+ ];
+}
+
+TSharedRef<SWidget> SVerseUiRoot::BuildEscMenu()
+{
+ TWeakObjectPtr<UVerseUiSubsystem> Ui = Owner;
+ TSharedRef<SVerticalBox> Body = SNew(SVerticalBox);
+ auto Add = [&Body](TSharedRef<SWidget> W) { Body->AddSlot().AutoHeight().Padding(FMargin(0.f, 4.f))[W]; };
+ Add(Button(S(TEXT("verse.menu.resume")), FSimpleDelegate::CreateLambda([Ui] { if (Ui.IsValid()) { Ui->ShowScreen(EVerseUiScreen::None); } }), true));
+ Add(Button(S(TEXT("verse.menu.settings")), FSimpleDelegate::CreateLambda([Ui] { if (Ui.IsValid()) { Ui->ShowScreen(EVerseUiScreen::Settings); } })));
+ if (Owner->GetGamePort().IsDuelRunning())
+ {
+ Add(Button(S(TEXT("verse.menu.leave_duel")), FSimpleDelegate::CreateLambda([Ui] { if (Ui.IsValid()) { Ui->LeaveDuel(); } })));
+ }
+ Add(Button(S(TEXT("verse.menu.return")), FSimpleDelegate::CreateLambda([Ui] { if (Ui.IsValid()) { Ui->ReturnToApp(TEXT("esc_menu")); } })));
+ return Panel(TEXT("verse.menu.title"), Body, 460.f);
+}
+
+TSharedRef<SWidget> SVerseUiRoot::BuildSettings()
+{
+ TSharedRef<SHorizontalBox> Tabs = SNew(SHorizontalBox);
+ static const TCHAR* PageKeys[NumSettingsPages] = {
+ TEXT("verse.settings.page.gameplay"), TEXT("verse.settings.page.controls"), TEXT("verse.settings.page.audio"),
+ TEXT("verse.settings.page.video"), TEXT("verse.settings.page.access"),
+ };
+ TWeakPtr<SVerseUiRoot> Self = SharedThis(this);
+ for (int32 I = 0; I < NumSettingsPages; ++I)
+ {
+ Tabs->AddSlot().FillWidth(1.f).Padding(FMargin(2.f, 0.f))
+ [
+ Button(S(PageKeys[I]), FSimpleDelegate::CreateLambda([Self, I] { if (TSharedPtr<SVerseUiRoot> P = Self.Pin()) { P->SetSettingsPage(I); } }), false,
+ TAttribute<bool>::CreateLambda([Self, I] { TSharedPtr<SVerseUiRoot> P = Self.Pin(); return P.IsValid() && P->SettingsPage == I; }))
+ ];
+ }
+ TWeakObjectPtr<UVerseUiSubsystem> Ui = Owner;
+ TSharedRef<SVerticalBox> Body = SNew(SVerticalBox)
+ + SVerticalBox::Slot().AutoHeight().Padding(FMargin(0.f, 0.f, 0.f, 12.f))[Tabs]
+ + SVerticalBox::Slot().AutoHeight()
+ [
+ SNew(SBox)
+ .HeightOverride(520.f)
+ [
+ SAssignNew(PageSlot, SBox)
+ ]
+ ]
+ + SVerticalBox::Slot().AutoHeight().HAlign(HAlign_Right).Padding(FMargin(0.f, 12.f, 0.f, 0.f))
+ [
+ SNew(SHorizontalBox)
+ + SHorizontalBox::Slot().AutoWidth().Padding(FMargin(0.f, 0.f, 8.f, 0.f))
+ [
+ SNew(SBox).WidthOverride(240.f)
+ [
+ // parity T-01: reset restores the view defaults.
+ Button(S(TEXT("verse.settings.reset")), FSimpleDelegate::CreateLambda([Ui] { if (Ui.IsValid()) { Ui->ResetSettings(); } }))
+ ]
+ ]
+ + SHorizontalBox::Slot().AutoWidth()
+ [
+ SNew(SBox).WidthOverride(240.f)
+ [
+ Button(S(TEXT("verse.ui.back")), FSimpleDelegate::CreateLambda([Ui] { if (Ui.IsValid()) { Ui->ShowScreen(EVerseUiScreen::EscMenu); } }))
+ ]
+ ]
+ ];
+ PageSlot->SetContent(BuildSettingsPage());
+ return Panel(TEXT("verse.settings.title"), Body, 1000.f);
+}
+
+TSharedRef<SWidget> SVerseUiRoot::BuildSettingsPage()
+{
+ TWeakObjectPtr<UVerseUiSubsystem> Ui = Owner;
+ TSharedRef<SScrollBox> Box = SNew(SScrollBox);
+ auto Add = [&Box](TSharedRef<SWidget> W) { Box->AddSlot().Padding(FMargin(0.f, 4.f))[W]; };
+ auto App = [Ui]() -> FVerseAppSettings { return Ui.IsValid() ? Ui->GetAppSettings() : FVerseAppSettings(); };
+ auto SetApp = [Ui](TFunction<void(FVerseAppSettings&)> Change)
+ {
+ if (Ui.IsValid())
+ {
+ FVerseAppSettings Next = Ui->GetAppSettings();
+ Change(Next);
+ Ui->SetAppSettings(Next);
+ }
+ };
+
+ switch (SettingsPage)
+ {
+ case 0: // Gameplay and view
+ Add(Stepper(TEXT("verse.settings.gore"),
+ TAttribute<FText>::CreateLambda([Ui] { return Ui.IsValid() ? Ui->GetStrings().Get(Ui->GetAppSettings().Gore == EVerseGoreLevel::Full ? TEXT("verse.settings.gore.full") : TEXT("verse.settings.gore.reduced")) : FText(); }),
+ [Ui](int32) { if (Ui.IsValid()) { Ui->SetGore(Ui->GetAppSettings().Gore == EVerseGoreLevel::Full ? EVerseGoreLevel::Reduced : EVerseGoreLevel::Full); } }));
+ Add(Stepper(TEXT("verse.settings.reduced_motion"),
+ TAttribute<FText>::CreateLambda([Ui] { return Ui.IsValid() ? OnOff(Ui.Get(), Ui->GetAppSettings().bReducedMotion) : FText(); }),
+ [Ui](int32) { if (Ui.IsValid()) { Ui->SetReducedMotion(!Ui->GetAppSettings().bReducedMotion); } }));
+ Add(Stepper(TEXT("verse.settings.duel_fov"),
+ TAttribute<FText>::CreateLambda([Ui] { return Ui.IsValid() ? Ui->GetStrings().Number(Ui->GetUserSettings()->DuelFov) : FText(); }),
+ [Ui](int32 D) { if (Ui.IsValid()) { Ui->SetDuelFov(Ui->GetUserSettings()->DuelFov + 5.f * D); } }));
+ Add(Stepper(TEXT("verse.settings.fov_third"),
+ TAttribute<FText>::CreateLambda([Ui, App] { return Ui.IsValid() ? Ui->GetStrings().Number(App().FovThird) : FText(); }),
+ [SetApp](int32 D) { SetApp([D](FVerseAppSettings& S) { S.FovThird = FMath::Clamp(S.FovThird + 5.f * D, 50.f, 110.f); }); }));
+ Add(Stepper(TEXT("verse.settings.fov_first"),
+ TAttribute<FText>::CreateLambda([Ui, App] { return Ui.IsValid() ? Ui->GetStrings().Number(App().FovFirst) : FText(); }),
+ [SetApp](int32 D) { SetApp([D](FVerseAppSettings& S) { S.FovFirst = FMath::Clamp(S.FovFirst + 5.f * D, 50.f, 110.f); }); }));
+ Add(Stepper(TEXT("verse.settings.sensitivity"),
+ TAttribute<FText>::CreateLambda([Ui, App] { return Ui.IsValid() ? Ui->GetStrings().Number(App().Sensitivity, 1) : FText(); }),
+ [SetApp](int32 D) { SetApp([D](FVerseAppSettings& S) { S.Sensitivity = FMath::Clamp(FMath::RoundToFloat((S.Sensitivity + 0.1f * D) * 10.f) / 10.f, 0.1f, 5.f); }); }));
+ Add(Stepper(TEXT("verse.settings.invert_y"),
+ TAttribute<FText>::CreateLambda([Ui, App] { return Ui.IsValid() ? OnOff(Ui.Get(), App().bInvertY) : FText(); }),
+ [SetApp](int32) { SetApp([](FVerseAppSettings& S) { S.bInvertY = !S.bInvertY; }); }));
+ break;
+
+ case 1: // Controls
+ {
+ TWeakPtr<SVerseUiRoot> Self = SharedThis(this);
+ for (const FVerseKeyMap::FAction& Action : Owner->GetKeyMap().GetActions())
+ {
+ const FName Name = Action.Action;
+ Add(SNew(SHorizontalBox)
+ + SHorizontalBox::Slot().FillWidth(1.f).VAlign(VAlign_Center)
+ [
+ Label(S(Action.LabelKey), 15.f, false, VerseUiTheme::Text)
+ ]
+ + SHorizontalBox::Slot().AutoWidth()
+ [
+ SNew(SBox).WidthOverride(240.f)
+ [
+ Button(TAttribute<FText>::CreateLambda([Self, Ui, Name]
+ {
+ TSharedPtr<SVerseUiRoot> P = Self.Pin();
+ if (P.IsValid() && P->ListeningAction == Name && Ui.IsValid())
+ {
+ return Ui->GetStrings().Get(TEXT("verse.settings.press_key"));
+ }
+ return Ui.IsValid() ? Ui->GetKeyMap().GetKey(Name).GetDisplayName() : FText();
+ }),
+ FSimpleDelegate::CreateLambda([Self, Name] { if (TSharedPtr<SVerseUiRoot> P = Self.Pin()) { P->ListeningAction = Name; } }), false,
+ TAttribute<bool>::CreateLambda([Self, Name] { TSharedPtr<SVerseUiRoot> P = Self.Pin(); return P.IsValid() && P->ListeningAction == Name; }))
+ ]
+ ]);
+ }
+ break;
+ }
+
+ case 2: // Audio
+ Add(Stepper(TEXT("verse.settings.volume"),
+ TAttribute<FText>::CreateLambda([Ui, App] { return Ui.IsValid() ? Ui->GetStrings().Percent(App().Volume) : FText(); }),
+ [SetApp](int32 D) { SetApp([D](FVerseAppSettings& S) { S.Volume = FMath::Clamp(FMath::RoundToFloat((S.Volume + 0.05f * D) * 20.f) / 20.f, 0.f, 1.f); }); }));
+ Add(Stepper(TEXT("verse.settings.ui_sound"),
+ TAttribute<FText>::CreateLambda([Ui, App] { return Ui.IsValid() ? OnOff(Ui.Get(), App().bUiSound) : FText(); }),
+ [SetApp](int32) { SetApp([](FVerseAppSettings& S) { S.bUiSound = !S.bUiSound; }); }));
+ Add(Stepper(TEXT("verse.settings.level_sound"),
+ TAttribute<FText>::CreateLambda([Ui, App] { return Ui.IsValid() ? OnOff(Ui.Get(), App().bLevelSound) : FText(); }),
+ [SetApp](int32) { SetApp([](FVerseAppSettings& S) { S.bLevelSound = !S.bLevelSound; }); }));
+ break;
+
+ case 3: // Video
+ Add(Stepper(TEXT("verse.settings.quality"),
+ TAttribute<FText>::CreateLambda([Ui] { return Ui.IsValid() ? Ui->GetStrings().Get(ScalabilityKey(Ui->GetUserSettings()->Scalability)) : FText(); }),
+ [Ui](int32 D)
+ {
+ if (Ui.IsValid())
+ {
+ const int32 Next = Ui->GetUserSettings()->Scalability + D;
+ Ui->SetScalability(Next > 4 ? -1 : (Next < -1 ? 4 : Next));
+ }
+ }));
+ break;
+
+ default: // Accessibility
+ Add(Stepper(TEXT("verse.settings.text_size"),
+ TAttribute<FText>::CreateLambda([Ui] { return Ui.IsValid() ? Ui->GetStrings().Percent(Ui->GetUserSettings()->TextScale) : FText(); }),
+ [Ui](int32 D) { if (Ui.IsValid()) { Ui->SetTextScale(Ui->GetUserSettings()->TextScale + 0.1f * D); } }));
+ Add(Label(S(TEXT("verse.settings.markers_note")), 13.f, false, VerseUiTheme::TextDim));
+ break;
+ }
+ return Box;
+}
+
+TSharedRef<SWidget> SVerseUiRoot::BuildArmoury()
+{
+ TWeakObjectPtr<UVerseUiSubsystem> Ui = Owner;
+ FVerseArmouryModel& Armoury = Owner->GetArmoury();
+ TSharedRef<SVerticalBox> Loadout = SNew(SVerticalBox);
+ for (const FVerseArmouryItem& Item : Armoury.GetLoadout())
+ {
+ const FString Id = Item.ItemId.ToString().ToLower();
+ const FString SlotKey = FString::Printf(TEXT("verse.armoury.slot.%s"), *StaticEnum<EVerseLoadoutSlot>()->GetNameStringByValue(int64(Item.Slot)).ToLower());
+ Loadout->AddSlot().AutoHeight().Padding(FMargin(0.f, 3.f))
+ [
+ SNew(SBorder)
+ .BorderImage(ColourBrush(VerseUiTheme::SteelLight))
+ .Padding(FMargin(12.f, 8.f))
+ [
+ SNew(SHorizontalBox)
+ + SHorizontalBox::Slot().AutoWidth().VAlign(VAlign_Center)
+ [
+ SNew(SBox).WidthOverride(170.f)
+ [
+ Label(S(SlotKey), 12.f, true, VerseUiTheme::TextDim)
+ ]
+ ]
+ + SHorizontalBox::Slot().FillWidth(1.f)
+ [
+ SNew(SVerticalBox)
+ + SVerticalBox::Slot().AutoHeight()[Label(S(FString::Printf(TEXT("verse.item.%s.name"), *Id)), 17.f, true, VerseUiTheme::Text)]
+ + SVerticalBox::Slot().AutoHeight()[Label(S(FString::Printf(TEXT("verse.item.%s.role"), *Id)), 13.f, false, VerseUiTheme::TextDim)]
+ ]
+ ]
+ ];
+ }
+
+ TSharedRef<SHorizontalBox> Tiers = SNew(SHorizontalBox);
+ for (const FName& Tier : Armoury.GetTiers())
+ {
+ Tiers->AddSlot().FillWidth(1.f).Padding(FMargin(2.f, 0.f))
+ [
+ Button(S(FString::Printf(TEXT("verse.tier.%s"), *Tier.ToString())),
+ FSimpleDelegate::CreateLambda([Ui, Tier] { if (Ui.IsValid()) { Ui->GetArmoury().SelectTier(Tier); } }), false,
+ TAttribute<bool>::CreateLambda([Ui, Tier] { return Ui.IsValid() && Ui->GetArmoury().GetSelectedTier() == Tier; }))
+ ];
+ }
+
+ TSharedRef<SVerticalBox> Body = SNew(SVerticalBox)
+ + SVerticalBox::Slot().AutoHeight().Padding(FMargin(0.f, 0.f, 0.f, 6.f))[Label(S(TEXT("verse.armoury.loadout")), 13.f, true, VerseUiTheme::Amber)]
+ + SVerticalBox::Slot().AutoHeight()[Loadout]
+ + SVerticalBox::Slot().AutoHeight().Padding(FMargin(0.f, 18.f, 0.f, 6.f))[Label(S(TEXT("verse.armoury.tier")), 13.f, true, VerseUiTheme::Amber)]
+ + SVerticalBox::Slot().AutoHeight()[Tiers]
+ + SVerticalBox::Slot().AutoHeight().Padding(FMargin(0.f, 8.f, 0.f, 0.f))
+ [
+ Label(TAttribute<FText>::CreateLambda([Ui]
+ {
+ return Ui.IsValid() ? Ui->GetStrings().Get(FString::Printf(TEXT("verse.tier.%s.desc"), *Ui->GetArmoury().GetSelectedTier().ToString())) : FText();
+ }), 13.f, false, VerseUiTheme::Text)
+ ]
+ + SVerticalBox::Slot().AutoHeight().Padding(FMargin(0.f, 22.f, 0.f, 0.f))
+ [
+ SNew(SHorizontalBox)
+ + SHorizontalBox::Slot().FillWidth(1.f).Padding(FMargin(0.f, 0.f, 6.f, 0.f))
+ [
+ Button(S(TEXT("verse.ui.back")), FSimpleDelegate::CreateLambda([Ui] { if (Ui.IsValid()) { Ui->ShowScreen(EVerseUiScreen::None); } }))
+ ]
+ + SHorizontalBox::Slot().FillWidth(2.f)
+ [
+ Button(S(TEXT("verse.armoury.start")), FSimpleDelegate::CreateLambda([Ui] { if (Ui.IsValid()) { Ui->StartDuelFromArmoury(); } }), true)
+ ]
+ ];
+ return Panel(TEXT("verse.armoury.title"), Body, 860.f);
+}
+
+TSharedRef<SWidget> SVerseUiRoot::BuildStatsTable(const FVerseEndScreen& End)
+{
+ TSharedRef<SVerticalBox> Table = SNew(SVerticalBox);
+ Table->AddSlot().AutoHeight().Padding(FMargin(0.f, 2.f))
+ [
+ SNew(SHorizontalBox)
+ + SHorizontalBox::Slot().FillWidth(2.f)[SNew(SSpacer)]
+ + SHorizontalBox::Slot().FillWidth(1.f).HAlign(HAlign_Right)[Label(S(TEXT("verse.end.you")), 13.f, true, VerseUiTheme::Amber)]
+ + SHorizontalBox::Slot().FillWidth(1.f).HAlign(HAlign_Right)[Label(S(TEXT("verse.end.opponent")), 13.f, true, VerseUiTheme::Red)]
+ ];
+ for (const FVerseEndScreenRow& Row : End.Rows)
+ {
+ Table->AddSlot().AutoHeight().Padding(FMargin(0.f, 2.f))
+ [
+ SNew(SHorizontalBox)
+ + SHorizontalBox::Slot().FillWidth(2.f)[Label(S(Row.LabelKey), 15.f, false, VerseUiTheme::Text)]
+ + SHorizontalBox::Slot().FillWidth(1.f).HAlign(HAlign_Right)[Label(Row.Person, 15.f, true, VerseUiTheme::Text)]
+ + SHorizontalBox::Slot().FillWidth(1.f).HAlign(HAlign_Right)[Label(Row.Opponent, 15.f, true, VerseUiTheme::Text)]
+ ];
+ }
+ return Table;
+}
+
+TSharedRef<SWidget> SVerseUiRoot::BuildEndOfSet()
+{
+ TWeakObjectPtr<UVerseUiSubsystem> Ui = Owner;
+ const FVerseEndScreen& End = Owner->GetEndScreen();
+ const FVerseUiStrings& Strings = Owner->GetStrings();
+
+ FFormatNamedArguments SetArgs;
+ SetArgs.Add(TEXT("set"), Strings.Number(End.SetIndex));
+ FFormatNamedArguments ScoreArgs;
+ ScoreArgs.Add(TEXT("person"), Strings.Number(End.PersonKills));
+ ScoreArgs.Add(TEXT("opponent"), Strings.Number(End.OpponentKills));
+
+ TSharedRef<SWidget> Table = BuildStatsTable(End);
+
+ TSharedRef<SVerticalBox> Body = SNew(SVerticalBox)
+ + SVerticalBox::Slot().AutoHeight()[Label(Strings.Format(TEXT("verse.end.set"), SetArgs), 14.f, false, VerseUiTheme::TextDim)]
+ + SVerticalBox::Slot().AutoHeight().Padding(FMargin(0.f, 4.f, 0.f, 14.f))
+ [
+ Label(Strings.Format(TEXT("verse.end.score"), ScoreArgs), 34.f, true, End.Outcome == EVerseSetOutcome::Won ? VerseUiTheme::Gold : VerseUiTheme::Text)
+ ]
+ + SVerticalBox::Slot().AutoHeight()[Table];
+ if (End.bShowSkill)
+ {
+ FFormatNamedArguments SkillArgs;
+ SkillArgs.Add(TEXT("skill"), Strings.Number(End.Skill, 2));
+ Body->AddSlot().AutoHeight().Padding(FMargin(0.f, 14.f, 0.f, 0.f))[Label(Strings.Format(TEXT("verse.end.adaptive"), SkillArgs), 14.f, true, VerseUiTheme::Amber)];
+ }
+ else if (!End.Tier.IsNone())
+ {
+ FFormatNamedArguments TierArgs;
+ TierArgs.Add(TEXT("tier"), S(FString::Printf(TEXT("verse.tier.%s"), *End.Tier.ToString())));
+ Body->AddSlot().AutoHeight().Padding(FMargin(0.f, 14.f, 0.f, 0.f))[Label(Strings.Format(TEXT("verse.end.tier"), TierArgs), 14.f, false, VerseUiTheme::TextDim)];
+ }
+ Body->AddSlot().AutoHeight().Padding(FMargin(0.f, 22.f, 0.f, 0.f))
+ [
+ SNew(SHorizontalBox)
+ + SHorizontalBox::Slot().FillWidth(1.f).Padding(FMargin(0.f, 0.f, 6.f, 0.f))
+ [
+ Button(S(TEXT("verse.end.leave")), FSimpleDelegate::CreateLambda([Ui] { if (Ui.IsValid()) { Ui->LeaveDuel(); } }))
+ ]
+ + SHorizontalBox::Slot().FillWidth(2.f)
+ [
+ Button(S(TEXT("verse.end.next")), FSimpleDelegate::CreateLambda([Ui] { if (Ui.IsValid()) { Ui->ContinueAfterSet(); } }), true)
+ ]
+ ];
+ return Panel(End.TitleKey, Body, 720.f);
+}
+
+TSharedRef<SWidget> SVerseUiRoot::BuildSessionSummary()
+{
+ // parity D-10: leave shows the session summary and "again"; a mid-set leave says so.
+ TWeakObjectPtr<UVerseUiSubsystem> Ui = Owner;
+ const FVerseEndScreen& Summary = Owner->GetSessionScreen();
+ const FVerseUiStrings& Strings = Owner->GetStrings();
+ TSharedRef<SVerticalBox> Body = SNew(SVerticalBox);
+ if (Owner->GetSession().bLeftMidSet)
+ {
+ Body->AddSlot().AutoHeight().Padding(FMargin(0.f, 0.f, 0.f, 10.f))[Label(S(TEXT("verse.duel.notice.left")), 15.f, true, VerseUiTheme::Amber)];
+ }
+ FFormatNamedArguments SetsArgs;
+ SetsArgs.Add(TEXT("won"), Strings.Number(Summary.PersonKills));
+ SetsArgs.Add(TEXT("lost"), Strings.Number(Summary.OpponentKills));
+ Body->AddSlot().AutoHeight().Padding(FMargin(0.f, 0.f, 0.f, 14.f))[Label(Strings.Format(TEXT("verse.end.sets"), SetsArgs), 26.f, true, VerseUiTheme::Text)];
+ if (Summary.SetIndex > 0)
+ {
+ Body->AddSlot().AutoHeight()[BuildStatsTable(Summary)];
+ }
+ Body->AddSlot().AutoHeight().Padding(FMargin(0.f, 22.f, 0.f, 0.f))
+ [
+ SNew(SHorizontalBox)
+ + SHorizontalBox::Slot().FillWidth(1.f).Padding(FMargin(0.f, 0.f, 6.f, 0.f))
+ [
+ Button(S(TEXT("verse.duel.result.leave")), FSimpleDelegate::CreateLambda([Ui] { if (Ui.IsValid()) { Ui->ShowScreen(EVerseUiScreen::None); } }))
+ ]
+ + SHorizontalBox::Slot().FillWidth(2.f)
+ [
+ Button(S(TEXT("verse.duel.result.rematch")), FSimpleDelegate::CreateLambda([Ui] { if (Ui.IsValid()) { Ui->QuickStartDuel(); } }), true)
+ ]
+ ];
+ return Panel(Summary.TitleKey, Body, 720.f);
+}
diff --git a/unreal/Verse/Source/VerseUI/Private/Menus/SVerseUiRoot.h b/unreal/Verse/Source/VerseUI/Private/Menus/SVerseUiRoot.h
new file mode 100644
index 0000000000..8de3b9c179
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Private/Menus/SVerseUiRoot.h
@@ -0,0 +1,60 @@
+#pragma once
+
+#include "CoreMinimal.h"
+#include "Menus/VerseUiMenus.h"
+#include "Widgets/DeclarativeSyntaxSupport.h"
+#include "Widgets/SCompoundWidget.h"
+
+class SBox;
+class UVerseUiSubsystem;
+
+/**
+ * Slate root of the Verse menus over the game viewport: the Verse bar (WP18.7) and one screen
+ * at a time (Esc menu, settings, armoury, end of set; WP18.6, 18.8, 18.9). Every text is a
+ * strings key (A18.4). Sizes are authored at 1080p; the viewport's DPI curve scales them.
+ */
+class SVerseUiRoot : public SCompoundWidget
+{
+public:
+ SLATE_BEGIN_ARGS(SVerseUiRoot) {}
+ SLATE_END_ARGS()
+
+ void Construct(const FArguments& InArgs, UVerseUiSubsystem* InOwner);
+
+ /** Rebuilds the screen layer for the owner's current screen. */
+ void Refresh();
+
+ /** Key rebinding: the next key goes to this action. */
+ bool IsListening() const { return !ListeningAction.IsNone(); }
+ FName GetListeningAction() const { return ListeningAction; }
+ void StopListening() { ListeningAction = NAME_None; }
+
+ /** Settings page index (tests and captures pick a page). */
+ void SetSettingsPage(int32 Page);
+
+ static constexpr int32 NumSettingsPages = 5;
+
+private:
+ TSharedRef<SWidget> BuildScreen();
+ TSharedRef<SWidget> BuildBar();
+ TSharedRef<SWidget> BuildEscMenu();
+ TSharedRef<SWidget> BuildSettings();
+ TSharedRef<SWidget> BuildSettingsPage();
+ TSharedRef<SWidget> BuildArmoury();
+ TSharedRef<SWidget> BuildEndOfSet();
+ TSharedRef<SWidget> BuildSessionSummary();
+ TSharedRef<SWidget> BuildStatsTable(const struct FVerseEndScreen& Screen);
+
+ TSharedRef<SWidget> Panel(const FString& TitleKey, TSharedRef<SWidget> Body, float Width);
+ TSharedRef<SWidget> Button(TAttribute<FText> Label, FSimpleDelegate OnClick, bool bPrimary = false, TAttribute<bool> bSelected = false);
+ TSharedRef<SWidget> Stepper(const FString& LabelKey, TAttribute<FText> Value, TFunction<void(int32)> Step);
+ TSharedRef<SWidget> Label(TAttribute<FText> Text, float Size, bool bBold, const FLinearColor& Colour);
+ FText S(const FString& Key) const;
+
+ TWeakObjectPtr<UVerseUiSubsystem> Owner;
+ TSharedPtr<SBox> ScreenSlot;
+ TSharedPtr<SBox> BarSlot;
+ TSharedPtr<SBox> PageSlot;
+ FName ListeningAction;
+ int32 SettingsPage = 0;
+};
diff --git a/unreal/Verse/Source/VerseUI/Private/Menus/VerseUiMenus.cpp b/unreal/Verse/Source/VerseUI/Private/Menus/VerseUiMenus.cpp
new file mode 100644
index 0000000000..46720d534c
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Private/Menus/VerseUiMenus.cpp
@@ -0,0 +1,252 @@
+#include "Menus/VerseUiMenus.h"
+
+#include "Internationalization/Culture.h"
+#include "Internationalization/Internationalization.h"
+#include "Misc/FileHelper.h"
+#include "Misc/Paths.h"
+#include "Serialization/JsonReader.h"
+#include "Serialization/JsonSerializer.h"
+
+// ---------------------------------------------------------------------------------------------
+// Armoury
+
+FString FVerseArmouryModel::DefaultPath()
+{
+ return FPaths::Combine(FPaths::ProjectDir(), TEXT("Data"), TEXT("ui"), TEXT("armoury.json"));
+}
+
+bool FVerseArmouryModel::LoadFile(const FString& Path, FString* OutError)
+{
+ FString Json;
+ if (!FFileHelper::LoadFileToString(Json, *Path))
+ {
+ if (OutError)
+ {
+ *OutError = FString::Printf(TEXT("cannot read %s"), *Path);
+ }
+ return false;
+ }
+ return LoadJson(Json, OutError);
+}
+
+bool FVerseArmouryModel::LoadJson(const FString& Json, FString* OutError)
+{
+ TSharedPtr<FJsonObject> Root;
+ const TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(Json);
+ if (!FJsonSerializer::Deserialize(Reader, Root) || !Root.IsValid())
+ {
+ if (OutError)
+ {
+ *OutError = TEXT("armoury.json is not JSON");
+ }
+ return false;
+ }
+ Tiers.Reset();
+ const TArray<TSharedPtr<FJsonValue>>* TierList = nullptr;
+ if (Root->TryGetArrayField(TEXT("tiers"), TierList))
+ {
+ for (const TSharedPtr<FJsonValue>& V : *TierList)
+ {
+ FString Tier;
+ if (V.IsValid() && V->TryGetString(Tier))
+ {
+ Tiers.Add(FName(*Tier));
+ }
+ }
+ }
+ Loadout.Reset();
+ const TArray<TSharedPtr<FJsonValue>>* Items = nullptr;
+ if (Root->TryGetArrayField(TEXT("loadout"), Items))
+ {
+ const UEnum* SlotEnum = StaticEnum<EVerseLoadoutSlot>();
+ for (const TSharedPtr<FJsonValue>& V : *Items)
+ {
+ const TSharedPtr<FJsonObject>* Obj = nullptr;
+ if (!V.IsValid() || !V->TryGetObject(Obj))
+ {
+ continue;
+ }
+ FVerseArmouryItem Item;
+ FString Slot;
+ FString Id;
+ (*Obj)->TryGetStringField(TEXT("slot"), Slot);
+ (*Obj)->TryGetStringField(TEXT("item"), Id);
+ (*Obj)->TryGetStringField(TEXT("kind"), Item.Kind);
+ const int64 SlotValue = SlotEnum->GetValueByNameString(Slot);
+ if (SlotValue == INDEX_NONE || Id.IsEmpty())
+ {
+ if (OutError)
+ {
+ *OutError = FString::Printf(TEXT("bad loadout entry %s / %s"), *Slot, *Id);
+ }
+ return false;
+ }
+ Item.Slot = EVerseLoadoutSlot(SlotValue);
+ Item.ItemId = FName(*Id);
+ Loadout.Add(Item);
+ }
+ }
+ FString Default;
+ if (Root->TryGetStringField(TEXT("default_tier"), Default))
+ {
+ SelectTier(FName(*Default));
+ }
+ return Tiers.Num() > 0 && Loadout.Num() > 0;
+}
+
+bool FVerseArmouryModel::SelectTier(FName Tier)
+{
+ if (!Tiers.Contains(Tier))
+ {
+ return false;
+ }
+ SelectedTier = Tier;
+ return true;
+}
+
+void FVerseArmouryModel::CycleTier(int32 Direction)
+{
+ if (Tiers.Num() == 0)
+ {
+ return;
+ }
+ const int32 Index = FMath::Max(0, Tiers.IndexOfByKey(SelectedTier));
+ SelectedTier = Tiers[(Index + Direction % Tiers.Num() + Tiers.Num()) % Tiers.Num()];
+}
+
+// ---------------------------------------------------------------------------------------------
+// Verse bar
+
+TArray<FVerseBarEntry> FVerseBarModel::Build(const TArray<FName>& Decks, FName CurrentDeck, bool bDuelRunning)
+{
+ TArray<FVerseBarEntry> Out;
+ FVerseBarEntry Quick;
+ Quick.Kind = EVerseBarEntryKind::QuickStartDuel;
+ Quick.LabelKey = bDuelRunning ? TEXT("verse.bar.leave_duel") : TEXT("verse.bar.quick_duel");
+ Quick.bActive = bDuelRunning;
+ Out.Add(Quick);
+ for (const FName& Deck : Decks)
+ {
+ FVerseBarEntry Entry;
+ Entry.Kind = EVerseBarEntryKind::Deck;
+ Entry.Id = Deck;
+ Entry.LabelKey = FString::Printf(TEXT("verse.deck.%s"), *Deck.ToString().ToLower());
+ Entry.bActive = Deck == CurrentDeck;
+ // Leaving the hangar mid-duel goes through "leave duel" first.
+ Entry.bEnabled = !bDuelRunning || Deck == CurrentDeck;
+ Out.Add(Entry);
+ }
+ FVerseBarEntry Return;
+ Return.Kind = EVerseBarEntryKind::ReturnToApp;
+ Return.LabelKey = TEXT("verse.bar.return");
+ Out.Add(Return);
+ return Out;
+}
+
+// ---------------------------------------------------------------------------------------------
+// End of set
+
+FVerseEndScreen FVerseEndScreen::Build(const FVerseSetSummary& Summary, float BotEffectiveSkill, const FString& Lang)
+{
+ FVerseEndScreen Screen;
+ Screen.Outcome = Summary.Outcome;
+ Screen.TitleKey = Summary.Outcome == EVerseSetOutcome::Won ? TEXT("verse.end.won")
+ : Summary.Outcome == EVerseSetOutcome::Lost ? TEXT("verse.end.lost")
+ : TEXT("verse.end.unfinished");
+ Screen.SetIndex = Summary.SetIndex;
+ Screen.PersonKills = Summary.Person.Kills;
+ Screen.OpponentKills = Summary.Opponent.Kills;
+ Screen.Tier = Summary.BotTier;
+ Screen.bShowSkill = Summary.BotTier == FName(TEXT("adaptive")) && BotEffectiveSkill >= 0.f;
+ Screen.Skill = Screen.bShowSkill ? FMath::Clamp(BotEffectiveSkill, 0.f, 1.f) : -1.f;
+
+ FCulturePtr Culture = FInternationalization::Get().GetCulture(Lang);
+ if (!Culture.IsValid())
+ {
+ Culture = FInternationalization::Get().GetCulture(TEXT("en"));
+ }
+ auto Int = [Culture](int32 V) { return FText::AsNumber(V, &FNumberFormattingOptions::DefaultNoGrouping(), Culture); };
+ auto Percent = [Culture](const FVerseSetLine& Line)
+ {
+ FNumberFormattingOptions Options;
+ Options.MaximumFractionalDigits = 0;
+ const double Ratio = Line.ShotsFired > 0 ? double(Line.ShotsHit) / Line.ShotsFired : 0.0;
+ return FText::AsPercent(Ratio, &Options, Culture);
+ };
+ auto Ratio = [Culture](const FVerseSetLine& Line)
+ {
+ FNumberFormattingOptions Options;
+ Options.MinimumFractionalDigits = 2;
+ Options.MaximumFractionalDigits = 2;
+ return FText::AsNumber(Line.Deaths > 0 ? double(Line.Kills) / Line.Deaths : double(Line.Kills), &Options, Culture);
+ };
+ const FVerseSetLine& P = Summary.Person;
+ const FVerseSetLine& O = Summary.Opponent;
+ Screen.Rows = {
+ {TEXT("verse.end.row.kills"), Int(P.Kills), Int(O.Kills)},
+ {TEXT("verse.end.row.deaths"), Int(P.Deaths), Int(O.Deaths)},
+ {TEXT("verse.end.row.kd"), Ratio(P), Ratio(O)},
+ {TEXT("verse.end.row.headshots"), Int(P.Headshots), Int(O.Headshots)},
+ {TEXT("verse.end.row.finishers"), Int(P.Finishers), Int(O.Finishers)},
+ {TEXT("verse.end.row.accuracy"), Percent(P), Percent(O)},
+ {TEXT("verse.end.row.damage"), Int(P.DamageDealt), Int(O.DamageDealt)},
+ {TEXT("verse.end.row.walls"), Int(P.WallsBreached), Int(O.WallsBreached)},
+ {TEXT("verse.end.row.streak"), Int(P.BestStreak), Int(O.BestStreak)},
+ };
+ return Screen;
+}
+
+// ---------------------------------------------------------------------------------------------
+// Session summary
+
+namespace
+{
+ void AddLine(FVerseSetLine& Sum, const FVerseSetLine& Line)
+ {
+ Sum.PlayerId = Line.PlayerId;
+ Sum.bIsBot = Line.bIsBot;
+ Sum.Kills += Line.Kills;
+ Sum.Deaths += Line.Deaths;
+ Sum.Headshots += Line.Headshots;
+ Sum.Finishers += Line.Finishers;
+ Sum.MeleeKills += Line.MeleeKills;
+ Sum.ShotsFired += Line.ShotsFired;
+ Sum.ShotsHit += Line.ShotsHit;
+ Sum.DamageDealt += Line.DamageDealt;
+ Sum.DamageTaken += Line.DamageTaken;
+ Sum.WallsBreached += Line.WallsBreached;
+ Sum.BestStreak = FMath::Max(Sum.BestStreak, Line.BestStreak);
+ }
+}
+
+void FVerseSessionSummary::AddSet(const FVerseSetSummary& Set)
+{
+ if (Set.Outcome == EVerseSetOutcome::Won)
+ {
+ ++SetsWon;
+ }
+ else if (Set.Outcome == EVerseSetOutcome::Lost)
+ {
+ ++SetsLost;
+ }
+ else
+ {
+ return;
+ }
+ AddLine(Totals.Person, Set.Person);
+ AddLine(Totals.Opponent, Set.Opponent);
+ Totals.BotTier = Set.BotTier;
+ Totals.SetIndex = Set.SetIndex;
+}
+
+FVerseEndScreen FVerseSessionSummary::BuildScreen(const FString& Lang) const
+{
+ FVerseSetSummary Sum = Totals;
+ Sum.Outcome = EVerseSetOutcome::Unfinished;
+ FVerseEndScreen Screen = FVerseEndScreen::Build(Sum, -1.f, Lang);
+ Screen.TitleKey = TEXT("verse.duel.result.cancelled");
+ Screen.SetIndex = NumSets();
+ Screen.PersonKills = SetsWon;
+ Screen.OpponentKills = SetsLost;
+ return Screen;
+}
diff --git a/unreal/Verse/Source/VerseUI/Private/QA/VerseUiQaCommands.cpp b/unreal/Verse/Source/VerseUI/Private/QA/VerseUiQaCommands.cpp
new file mode 100644
index 0000000000..1a42d2c4d9
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Private/QA/VerseUiQaCommands.cpp
@@ -0,0 +1,54 @@
+#include "QA/VerseUiQaCommands.h"
+
+#include "Core/VerseUiSubsystem.h"
+#include "Misc/App.h"
+#include "Qa/VerseQaRegistry.h"
+#include "Scalability.h"
+
+namespace
+{
+ TWeakObjectPtr<UVerseUiSubsystem> GOwner;
+
+ const TCHAR* QualityName(int32 Level)
+ {
+ switch (Level)
+ {
+ case 0: return TEXT("low");
+ case 1: return TEXT("medium");
+ case 2: return TEXT("high");
+ case 3: return TEXT("epic");
+ case 4: return TEXT("cinematic");
+ default: return TEXT("custom");
+ }
+ }
+
+ FString Stats(const TArray<FString>&)
+ {
+ // parity Q-01: {fps, frame_ms, tier, state}; hud_ms is the A18.3 game-thread number.
+ const double Delta = FMath::Max(1e-6, FApp::GetDeltaTime());
+ const int32 Level = Scalability::GetQualityLevels().GetSingleQualityLevel();
+ const double HudMs = GOwner.IsValid() ? GOwner->GetHudCostMs() : 0.0;
+ // Lifecycle as the bridge reports it (WP17 sets visible, panel, dormant; booting until welcome).
+ const FString State = GOwner.IsValid() ? GOwner->GetLifecycleState().ToString() : FString(TEXT("booting"));
+ return FString::Printf(TEXT("{\"fps\":%.1f,\"frame_ms\":%.2f,\"tier\":\"%s\",\"state\":\"%s\",\"hud_ms\":%.3f}"),
+ 1.0 / Delta, Delta * 1000.0, QualityName(Level), *State, HudMs);
+ }
+}
+
+void VerseUiQa::RegisterCommands(UVerseUiSubsystem* Owner)
+{
+ GOwner = Owner;
+ UVerseQaRegistry* Registry = UVerseQaRegistry::Get();
+ if (Registry && !Registry->IsRegistered(TEXT("Verse.QA.Stats")))
+ {
+ Registry->Register(TEXT("Verse.QA.Stats"), TEXT("Frame numbers: fps, frame_ms, tier, state, hud_ms"), &Stats);
+ }
+}
+
+void VerseUiQa::Release(UVerseUiSubsystem* Owner)
+{
+ if (GOwner.Get() == Owner)
+ {
+ GOwner.Reset();
+ }
+}
diff --git a/unreal/Verse/Source/VerseUI/Private/QA/VerseUiQaCommands.h b/unreal/Verse/Source/VerseUI/Private/QA/VerseUiQaCommands.h
new file mode 100644
index 0000000000..cb79d8b926
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Private/QA/VerseUiQaCommands.h
@@ -0,0 +1,13 @@
+#pragma once
+
+class UVerseUiSubsystem;
+
+/** The Verse.QA.* commands of the UI area (parity 19, work-packages 0.2: UI owns Stats). */
+namespace VerseUiQa
+{
+ /** Registers Verse.QA.Stats once; it reports on the most recent game-world UI. */
+ void RegisterCommands(UVerseUiSubsystem* Owner);
+
+ /** The UI is going away; the command keeps answering without HUD numbers. */
+ void Release(UVerseUiSubsystem* Owner);
+}
diff --git a/unreal/Verse/Source/VerseUI/Private/Settings/VerseUiInputRemap.cpp b/unreal/Verse/Source/VerseUI/Private/Settings/VerseUiInputRemap.cpp
new file mode 100644
index 0000000000..9f0bafb65b
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Private/Settings/VerseUiInputRemap.cpp
@@ -0,0 +1,86 @@
+#include "Settings/VerseUiInputRemap.h"
+
+#include "EnhancedActionKeyMapping.h"
+#include "EnhancedInputSubsystems.h"
+#include "InputAction.h"
+#include "InputMappingContext.h"
+#include "UObject/UObjectIterator.h"
+
+bool FVerseUiInputRemap::Apply(UInputMappingContext* Context, const FVerseKeyMap& KeyMap)
+{
+ if (!Context)
+ {
+ return false;
+ }
+ TMap<int32, FName>* Bound = Slots.Find(Context);
+ if (!Bound)
+ {
+ // First sight of this context: find the mapping each binding moves, by its default key.
+ Bound = &Slots.Add(Context);
+ const TArray<FEnhancedActionKeyMapping>& Mappings = Context->GetMappings();
+ TSet<int32> Taken;
+ for (const FVerseKeyMap::FAction& Action : KeyMap.GetActions())
+ {
+ if (Action.InputAction.IsNone())
+ {
+ continue;
+ }
+ for (int32 Index = 0; Index < Mappings.Num(); ++Index)
+ {
+ const UInputAction* InputAction = Mappings[Index].Action;
+ if (!Taken.Contains(Index) && InputAction && InputAction->GetFName() == Action.InputAction && Mappings[Index].Key == Action.DefaultKey)
+ {
+ Bound->Add(Index, Action.Action);
+ Taken.Add(Index);
+ break;
+ }
+ }
+ }
+ }
+ bool bChanged = false;
+ for (const TPair<int32, FName>& Slot : *Bound)
+ {
+ if (!Context->GetMappings().IsValidIndex(Slot.Key))
+ {
+ continue;
+ }
+ const FKey Want = KeyMap.GetKey(Slot.Value);
+ FEnhancedActionKeyMapping& Mapping = Context->GetMapping(Slot.Key);
+ if (Want.IsValid() && Mapping.Key != Want)
+ {
+ Mapping.Key = Want;
+ bChanged = true;
+ }
+ }
+ return bChanged;
+}
+
+int32 FVerseUiInputRemap::ApplyToPlayer(UEnhancedInputLocalPlayerSubsystem* Subsystem, const FVerseKeyMap& KeyMap)
+{
+ if (!Subsystem)
+ {
+ return 0;
+ }
+ int32 Changed = 0;
+ for (TObjectIterator<UInputMappingContext> It; It; ++It)
+ {
+ UInputMappingContext* Context = *It;
+ if (IsValid(Context) && Subsystem->HasMappingContext(Context) && Apply(Context, KeyMap))
+ {
+ ++Changed;
+ }
+ }
+ if (Changed > 0)
+ {
+ FModifyContextOptions Options;
+ Options.bForceImmediately = true;
+ Subsystem->RequestRebuildControlMappings(Options);
+ }
+ return Changed;
+}
+
+int32 FVerseUiInputRemap::NumBound(const UInputMappingContext* Context) const
+{
+ const TMap<int32, FName>* Bound = Slots.Find(MakeWeakObjectPtr(const_cast<UInputMappingContext*>(Context)));
+ return Bound ? Bound->Num() : 0;
+}
diff --git a/unreal/Verse/Source/VerseUI/Private/Settings/VerseUiSettings.cpp b/unreal/Verse/Source/VerseUI/Private/Settings/VerseUiSettings.cpp
new file mode 100644
index 0000000000..be3096bb24
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Private/Settings/VerseUiSettings.cpp
@@ -0,0 +1,351 @@
+#include "Settings/VerseUiSettings.h"
+
+#include "Misc/ConfigCacheIni.h"
+#include "Misc/FileHelper.h"
+#include "Misc/Paths.h"
+#include "Serialization/JsonReader.h"
+#include "Serialization/JsonSerializer.h"
+
+// ---------------------------------------------------------------------------------------------
+// App settings
+
+FString FVerseAppSettings::GoreToString(EVerseGoreLevel Level)
+{
+ return Level == EVerseGoreLevel::Reduced ? TEXT("reduced") : TEXT("full");
+}
+
+bool FVerseAppSettings::GoreFromString(const FString& Text, EVerseGoreLevel& Out)
+{
+ if (Text == TEXT("full"))
+ {
+ Out = EVerseGoreLevel::Full;
+ return true;
+ }
+ if (Text == TEXT("reduced"))
+ {
+ Out = EVerseGoreLevel::Reduced;
+ return true;
+ }
+ return false;
+}
+
+void FVerseAppSettings::ApplyJson(const TSharedPtr<FJsonObject>& Json)
+{
+ if (!Json.IsValid())
+ {
+ return;
+ }
+ FString Text;
+ if (Json->TryGetStringField(TEXT("gore"), Text))
+ {
+ GoreFromString(Text, Gore);
+ }
+ Json->TryGetBoolField(TEXT("reduced_motion"), bReducedMotion);
+ if (Json->TryGetStringField(TEXT("return_key"), Text))
+ {
+ const FKey Key(*Text);
+ if (Key.IsValid())
+ {
+ ReturnKey = Key;
+ }
+ }
+ Json->TryGetBoolField(TEXT("ui_sound"), bUiSound);
+ Json->TryGetBoolField(TEXT("level_sound"), bLevelSound);
+ Json->TryGetStringField(TEXT("uniform"), Uniform);
+ const TSharedPtr<FJsonObject>* View = nullptr;
+ if (Json->TryGetObjectField(TEXT("view"), View))
+ {
+ (*View)->TryGetStringField(TEXT("mode"), ViewMode);
+ double Number = 0.0;
+ if ((*View)->TryGetNumberField(TEXT("sensitivity"), Number))
+ {
+ Sensitivity = float(FMath::Clamp(Number, 0.1, 5.0));
+ }
+ (*View)->TryGetBoolField(TEXT("invert_y"), bInvertY);
+ if ((*View)->TryGetNumberField(TEXT("fov_third"), Number))
+ {
+ FovThird = float(FMath::Clamp(Number, 50.0, 110.0));
+ }
+ if ((*View)->TryGetNumberField(TEXT("fov_first"), Number))
+ {
+ FovFirst = float(FMath::Clamp(Number, 50.0, 110.0));
+ }
+ (*View)->TryGetStringField(TEXT("quality"), Quality);
+ if ((*View)->TryGetNumberField(TEXT("volume"), Number))
+ {
+ Volume = float(FMath::Clamp(Number, 0.0, 1.0));
+ }
+ }
+}
+
+TSharedRef<FJsonObject> FVerseAppSettings::ToJson() const
+{
+ TSharedRef<FJsonObject> Json = MakeShared<FJsonObject>();
+ Json->SetStringField(TEXT("gore"), GoreToString(Gore));
+ Json->SetBoolField(TEXT("reduced_motion"), bReducedMotion);
+ Json->SetStringField(TEXT("return_key"), ReturnKey.GetFName().ToString());
+ Json->SetBoolField(TEXT("ui_sound"), bUiSound);
+ Json->SetBoolField(TEXT("level_sound"), bLevelSound);
+ Json->SetStringField(TEXT("uniform"), Uniform);
+ TSharedRef<FJsonObject> View = MakeShared<FJsonObject>();
+ View->SetStringField(TEXT("mode"), ViewMode);
+ View->SetNumberField(TEXT("sensitivity"), Sensitivity);
+ View->SetBoolField(TEXT("invert_y"), bInvertY);
+ View->SetNumberField(TEXT("fov_third"), FovThird);
+ View->SetNumberField(TEXT("fov_first"), FovFirst);
+ View->SetStringField(TEXT("quality"), Quality);
+ View->SetNumberField(TEXT("volume"), Volume);
+ Json->SetObjectField(TEXT("view"), View);
+ return Json;
+}
+
+TSharedRef<FJsonObject> FVerseAppSettings::Diff(const FVerseAppSettings& Other) const
+{
+ TSharedRef<FJsonObject> Json = MakeShared<FJsonObject>();
+ if (Gore != Other.Gore) { Json->SetStringField(TEXT("gore"), GoreToString(Other.Gore)); }
+ if (bReducedMotion != Other.bReducedMotion) { Json->SetBoolField(TEXT("reduced_motion"), Other.bReducedMotion); }
+ if (ReturnKey != Other.ReturnKey) { Json->SetStringField(TEXT("return_key"), Other.ReturnKey.GetFName().ToString()); }
+ if (bUiSound != Other.bUiSound) { Json->SetBoolField(TEXT("ui_sound"), Other.bUiSound); }
+ if (bLevelSound != Other.bLevelSound) { Json->SetBoolField(TEXT("level_sound"), Other.bLevelSound); }
+ if (Uniform != Other.Uniform) { Json->SetStringField(TEXT("uniform"), Other.Uniform); }
+
+ TSharedRef<FJsonObject> View = MakeShared<FJsonObject>();
+ if (ViewMode != Other.ViewMode) { View->SetStringField(TEXT("mode"), Other.ViewMode); }
+ if (!FMath::IsNearlyEqual(Sensitivity, Other.Sensitivity)) { View->SetNumberField(TEXT("sensitivity"), Other.Sensitivity); }
+ if (bInvertY != Other.bInvertY) { View->SetBoolField(TEXT("invert_y"), Other.bInvertY); }
+ if (!FMath::IsNearlyEqual(FovThird, Other.FovThird)) { View->SetNumberField(TEXT("fov_third"), Other.FovThird); }
+ if (!FMath::IsNearlyEqual(FovFirst, Other.FovFirst)) { View->SetNumberField(TEXT("fov_first"), Other.FovFirst); }
+ if (Quality != Other.Quality) { View->SetStringField(TEXT("quality"), Other.Quality); }
+ if (!FMath::IsNearlyEqual(Volume, Other.Volume)) { View->SetNumberField(TEXT("volume"), Other.Volume); }
+ if (View->Values.Num() > 0)
+ {
+ Json->SetObjectField(TEXT("view"), View);
+ }
+ return Json;
+}
+
+// ---------------------------------------------------------------------------------------------
+// User settings
+
+void UVerseUiUserSettings::Clamp()
+{
+ DuelFov = FMath::Clamp(DuelFov, DuelFovMin, DuelFovMax);
+ Scalability = FMath::Clamp(Scalability, -1, 4);
+ TextScale = FMath::Clamp(TextScale, 0.8f, 1.6f);
+ static const FName Tiers[] = {TEXT("normal"), TEXT("hard"), TEXT("elite"), TEXT("adaptive")};
+ bool bKnown = false;
+ for (const FName& Tier : Tiers)
+ {
+ bKnown |= Tier == LastTier;
+ }
+ if (!bKnown)
+ {
+ LastTier = TEXT("hard");
+ }
+}
+
+void UVerseUiUserSettings::SaveToDisk()
+{
+ Clamp();
+ ++SaveCount;
+ SaveConfig(CPF_Config, *GetClass()->GetConfigName());
+ if (GConfig)
+ {
+ GConfig->Flush(false, GetClass()->GetConfigName());
+ }
+}
+
+void UVerseUiUserSettings::ReloadFromDisk()
+{
+ LoadConfig(GetClass(), *GetClass()->GetConfigName());
+ Clamp();
+}
+
+// ---------------------------------------------------------------------------------------------
+// Key map
+
+FString FVerseKeyMap::DefaultPath()
+{
+ return FPaths::Combine(FPaths::ProjectDir(), TEXT("Data"), TEXT("ui"), TEXT("keys.json"));
+}
+
+bool FVerseKeyMap::LoadFile(const FString& Path, FString* OutError)
+{
+ FString Json;
+ if (!FFileHelper::LoadFileToString(Json, *Path))
+ {
+ if (OutError)
+ {
+ *OutError = FString::Printf(TEXT("cannot read %s"), *Path);
+ }
+ return false;
+ }
+ return LoadJson(Json, OutError);
+}
+
+bool FVerseKeyMap::LoadJson(const FString& Json, FString* OutError)
+{
+ TSharedPtr<FJsonObject> Root;
+ const TSharedRef<TJsonReader<>> Reader = TJsonReaderFactory<>::Create(Json);
+ const TArray<TSharedPtr<FJsonValue>>* List = nullptr;
+ if (!FJsonSerializer::Deserialize(Reader, Root) || !Root.IsValid() || !Root->TryGetArrayField(TEXT("actions"), List))
+ {
+ if (OutError)
+ {
+ *OutError = TEXT("keys.json needs an \"actions\" array");
+ }
+ return false;
+ }
+ Actions.Reset();
+ for (const TSharedPtr<FJsonValue>& Value : *List)
+ {
+ const TSharedPtr<FJsonObject>* Obj = nullptr;
+ if (!Value.IsValid() || !Value->TryGetObject(Obj))
+ {
+ continue;
+ }
+ FAction Action;
+ FString Text;
+ (*Obj)->TryGetStringField(TEXT("action"), Text);
+ Action.Action = FName(*Text);
+ (*Obj)->TryGetStringField(TEXT("key"), Text);
+ Action.DefaultKey = FKey(*Text);
+ (*Obj)->TryGetStringField(TEXT("label"), Action.LabelKey);
+ FString InputAction;
+ if ((*Obj)->TryGetStringField(TEXT("input_action"), InputAction))
+ {
+ Action.InputAction = FName(*InputAction);
+ }
+ FString Command;
+ if ((*Obj)->TryGetStringField(TEXT("ui"), Command))
+ {
+ Action.Command = Command == TEXT("return_to_app") ? EVerseUiCommand::ReturnToApp
+ : Command == TEXT("esc_menu") ? EVerseUiCommand::EscMenu
+ : Command == TEXT("skip_kill_cam") ? EVerseUiCommand::SkipKillCam
+ : Command == TEXT("verse_bar") ? EVerseUiCommand::VerseBar
+ : EVerseUiCommand::None;
+ }
+ if (Action.Action.IsNone() || !Action.DefaultKey.IsValid())
+ {
+ if (OutError)
+ {
+ *OutError = FString::Printf(TEXT("bad action entry %s"), *Action.Action.ToString());
+ }
+ return false;
+ }
+ Actions.Add(Action);
+ }
+ if (const FAction* Return = FindAction(ReturnAction()))
+ {
+ ReturnKey = Return->DefaultKey;
+ }
+ return Actions.Num() > 0;
+}
+
+const FVerseKeyMap::FAction* FVerseKeyMap::FindAction(FName Action) const
+{
+ return Actions.FindByPredicate([Action](const FAction& A) { return A.Action == Action; });
+}
+
+FKey FVerseKeyMap::GetKey(FName Action) const
+{
+ if (Action == ReturnAction())
+ {
+ return ReturnKey;
+ }
+ if (const FKey* Override = Overrides.Find(Action))
+ {
+ return *Override;
+ }
+ const FAction* Found = FindAction(Action);
+ return Found ? Found->DefaultKey : EKeys::Invalid;
+}
+
+void FVerseKeyMap::SetBindings(const TArray<FVerseKeyBinding>& Bindings)
+{
+ Overrides.Reset();
+ for (const FVerseKeyBinding& Binding : Bindings)
+ {
+ if (Binding.Action != ReturnAction() && FindAction(Binding.Action) && Binding.Key.IsValid())
+ {
+ Overrides.Add(Binding.Action, Binding.Key);
+ }
+ }
+}
+
+TArray<FVerseKeyBinding> FVerseKeyMap::GetBindings() const
+{
+ TArray<FVerseKeyBinding> Out;
+ for (const FAction& Action : Actions)
+ {
+ if (Action.Action == ReturnAction())
+ {
+ continue;
+ }
+ const FKey Key = GetKey(Action.Action);
+ if (Key != Action.DefaultKey)
+ {
+ FVerseKeyBinding Binding;
+ Binding.Action = Action.Action;
+ Binding.Key = Key;
+ Out.Add(Binding);
+ }
+ }
+ return Out;
+}
+
+bool FVerseKeyMap::IsReserved(const FKey& Key)
+{
+ return Key == EKeys::Escape || Key == EKeys::LeftCommand || Key == EKeys::RightCommand || !Key.IsValid();
+}
+
+FName FVerseKeyMap::Rebind(FName Action, const FKey& Key)
+{
+ if (IsReserved(Key) || !FindAction(Action))
+ {
+ return NAME_None;
+ }
+ const FKey Old = GetKey(Action);
+ FName Swapped = NAME_None;
+ for (const FAction& Other : Actions)
+ {
+ if (Other.Action != Action && GetKey(Other.Action) == Key)
+ {
+ Swapped = Other.Action;
+ break;
+ }
+ }
+ auto Assign = [this](FName Target, const FKey& NewKey)
+ {
+ if (Target == ReturnAction())
+ {
+ ReturnKey = NewKey;
+ }
+ else
+ {
+ Overrides.Add(Target, NewKey);
+ }
+ };
+ Assign(Action, Key);
+ if (!Swapped.IsNone())
+ {
+ Assign(Swapped, Old);
+ }
+ return Swapped;
+}
+
+EVerseUiCommand FVerseKeyMap::Route(const FKey& Key) const
+{
+ if (Key == EKeys::Escape)
+ {
+ return EVerseUiCommand::EscMenu;
+ }
+ for (const FAction& Action : Actions)
+ {
+ if (Action.Command != EVerseUiCommand::None && GetKey(Action.Action) == Key)
+ {
+ return Action.Command;
+ }
+ }
+ return EVerseUiCommand::None;
+}
diff --git a/unreal/Verse/Source/VerseUI/Private/Tests/UI/Fakes/VerseUiFakes.h b/unreal/Verse/Source/VerseUI/Private/Tests/UI/Fakes/VerseUiFakes.h
new file mode 100644
index 0000000000..4ebefbfdb5
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Private/Tests/UI/Fakes/VerseUiFakes.h
@@ -0,0 +1,209 @@
+#pragma once
+
+#if WITH_DEV_AUTOMATION_TESTS
+
+#include "Core/VerseUiPorts.h"
+#include "Core/VerseUiSubsystem.h"
+#include "CoreMinimal.h"
+#include "Engine/Engine.h"
+#include "Engine/World.h"
+#include "Policies/CondensedJsonPrintPolicy.h"
+#include "Serialization/JsonSerializer.h"
+#include "Serialization/JsonWriter.h"
+#include "Settings/VerseUiSettings.h"
+
+// Fakes of the UI's ports (work-packages 0.3: implement the interface exactly, no extra
+// methods on the interface; the recorded frames are plain members of the fake).
+
+/**
+ * The bridge as the app backend answers it (bridge-protocol 3.2, 14): settings.set is
+ * validated and written into the app config, the next welcome carries the stored settings.
+ */
+class FFakeVerseUiBridgePort : public IVerseUiBridgePort
+{
+public:
+ struct FFrame
+ {
+ FString Type;
+ TSharedPtr<FJsonObject> Data;
+ };
+
+ virtual void SendSettingsSet(const TSharedRef<FJsonObject>& Data) override
+ {
+ Frames.Add({TEXT("settings.set"), Data});
+ AppConfig.ApplyJson(Data);
+ }
+
+ virtual void SendReturnToApp(const FString& Reason) override
+ {
+ TSharedRef<FJsonObject> Data = MakeShared<FJsonObject>();
+ Data->SetStringField(TEXT("reason"), Reason);
+ Frames.Add({TEXT("focus.return_to_app"), Data});
+ }
+
+ int32 Count(const FString& Type) const
+ {
+ int32 N = 0;
+ for (const FFrame& F : Frames)
+ {
+ N += F.Type == Type;
+ }
+ return N;
+ }
+
+ const FFrame* Last(const FString& Type) const
+ {
+ for (int32 I = Frames.Num() - 1; I >= 0; --I)
+ {
+ if (Frames[I].Type == Type)
+ {
+ return &Frames[I];
+ }
+ }
+ return nullptr;
+ }
+
+ /** welcome.data the backend would send on the next connect. */
+ TSharedRef<FJsonObject> MakeWelcome(const FString& Lang = TEXT("en")) const
+ {
+ TSharedRef<FJsonObject> Data = MakeShared<FJsonObject>();
+ Data->SetStringField(TEXT("protocol"), TEXT("verse.bridge/1"));
+ TSharedRef<FJsonObject> Locale = MakeShared<FJsonObject>();
+ Locale->SetStringField(TEXT("lang"), Lang);
+ Locale->SetStringField(TEXT("fallback"), TEXT("en"));
+ Locale->SetObjectField(TEXT("strings"), MakeShared<FJsonObject>());
+ Data->SetObjectField(TEXT("locale"), Locale);
+ Data->SetObjectField(TEXT("settings"), AppConfig.ToJson());
+ TArray<TSharedPtr<FJsonValue>> Decks;
+ for (const TCHAR* D : {TEXT("bridge"), TEXT("ops"), TEXT("engineering"), TEXT("hangar")})
+ {
+ Decks.Add(MakeShared<FJsonValueString>(D));
+ }
+ Data->SetArrayField(TEXT("decks"), Decks);
+ return Data;
+ }
+
+ static FString ToString(const TSharedPtr<FJsonObject>& Object)
+ {
+ FString Out;
+ const TSharedRef<TJsonWriter<TCHAR, TCondensedJsonPrintPolicy<TCHAR>>> Writer = TJsonWriterFactory<TCHAR, TCondensedJsonPrintPolicy<TCHAR>>::Create(&Out);
+ FJsonSerializer::Serialize(Object.ToSharedRef(), Writer);
+ return Out;
+ }
+
+ TArray<FFrame> Frames;
+ /** The app config the backend keeps (verse.* keys). */
+ FVerseAppSettings AppConfig;
+};
+
+class FFakeVerseUiGamePort : public IVerseUiGamePort
+{
+public:
+ virtual void StartDuel(FName Tier) override
+ {
+ Started.Add(Tier);
+ bDuel = true;
+ }
+ virtual void LeaveDuel() override
+ {
+ ++Left;
+ bDuel = false;
+ }
+ virtual void TravelToDeck(FName Deck) override { CurrentDeck = Deck; }
+ virtual bool IsDuelRunning() const override { return bDuel; }
+ virtual FName GetCurrentDeck() const override { return CurrentDeck; }
+ virtual void SetPaused(bool bPaused) override
+ {
+ bIsPaused = bPaused;
+ ++PauseCalls;
+ }
+
+ TArray<FName> Started;
+ bool bIsPaused = false;
+ int32 PauseCalls = 0;
+ int32 Left = 0;
+ bool bDuel = false;
+ FName CurrentDeck = TEXT("hangar");
+};
+
+/** A HUD source with every value set by the test. */
+class FFakeVerseHudSource : public IVerseHudSource
+{
+public:
+ virtual int32 GetLocalPlayerId() const override { return LocalId; }
+ virtual double GetServerTime() const override { return ServerTime; }
+ virtual void GetPawnState(FVerseHudPawnState& Out) const override { Out = Pawn; }
+ virtual bool GetView(FVerseHudView& Out) const override
+ {
+ Out = View;
+ return bHasView;
+ }
+ virtual bool GetPredictedBoltDirection(FVector& OutDirection, float& OutSpreadHalfAngleDeg) const override
+ {
+ OutDirection = BoltDirection.IsNearlyZero() ? View.Rotation.Vector() : BoltDirection;
+ OutSpreadHalfAngleDeg = SpreadDeg;
+ return bHasView;
+ }
+ virtual FText GetDisplayName(int32 PlayerId) const override
+ {
+ const FString* Name = Names.Find(PlayerId);
+ return Name ? FText::AsCultureInvariant(*Name) : FText::GetEmpty();
+ }
+ virtual bool IsBot(int32 PlayerId) const override { return Bots.Contains(PlayerId); }
+ virtual FName GetBotTier(int32 PlayerId) const override { return Bots.Contains(PlayerId) ? Tier : NAME_None; }
+ virtual float GetBotEffectiveSkill(int32 PlayerId) const override { return Bots.Contains(PlayerId) ? Skill : -1.f; }
+ virtual void GetPawnPoses(TArray<FVersePawnPose>& Out) const override { Out = Poses; }
+
+ int32 LocalId = 1;
+ double ServerTime = 100.0;
+ FVerseHudPawnState Pawn;
+ FVerseHudView View;
+ bool bHasView = true;
+ FVector BoltDirection = FVector::ZeroVector;
+ float SpreadDeg = 0.f;
+ TMap<int32, FString> Names;
+ TSet<int32> Bots;
+ FName Tier = TEXT("adaptive");
+ float Skill = 0.62f;
+ TArray<FVersePawnPose> Poses;
+};
+
+/** A game world with the UI subsystem wired to the fakes, destroyed at scope end. */
+struct FVerseUiTestWorld
+{
+ UWorld* World = nullptr;
+ UVerseUiSubsystem* Ui = nullptr;
+ TSharedPtr<FFakeVerseUiBridgePort> Bridge;
+ TSharedPtr<FFakeVerseUiGamePort> Game;
+ TSharedPtr<FFakeVerseHudSource> Source;
+ double Now = 1000.0;
+
+ explicit FVerseUiTestWorld(TSharedPtr<FFakeVerseUiBridgePort> InBridge = nullptr)
+ {
+ World = UWorld::CreateWorld(EWorldType::Game, false, TEXT("VerseUiTestWorld"));
+ FWorldContext& Context = GEngine->CreateNewWorldContext(EWorldType::Game);
+ Context.SetCurrentWorld(World);
+ Ui = World->GetSubsystem<UVerseUiSubsystem>();
+ Bridge = InBridge.IsValid() ? InBridge : MakeShared<FFakeVerseUiBridgePort>();
+ Game = MakeShared<FFakeVerseUiGamePort>();
+ Source = MakeShared<FFakeVerseHudSource>();
+ if (Ui)
+ {
+ Ui->SetBridgePort(Bridge);
+ Ui->SetGamePort(Game);
+ Ui->SetHudSource(Source);
+ Ui->Clock = [this] { return Now; };
+ }
+ }
+
+ ~FVerseUiTestWorld()
+ {
+ if (World)
+ {
+ GEngine->DestroyWorldContext(World);
+ World->DestroyWorld(false);
+ }
+ }
+};
+
+#endif // WITH_DEV_AUTOMATION_TESTS
diff --git a/unreal/Verse/Source/VerseUI/Private/Tests/UI/VerseUiHudTest.cpp b/unreal/Verse/Source/VerseUI/Private/Tests/UI/VerseUiHudTest.cpp
new file mode 100644
index 0000000000..6dfe825826
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Private/Tests/UI/VerseUiHudTest.cpp
@@ -0,0 +1,345 @@
+#include "Core/VerseUiLayout.h"
+#include "Core/VerseUiStrings.h"
+#include "Core/VerseUiTheme.h"
+#include "Hud/VerseCrosshair.h"
+#include "Hud/VerseHudModel.h"
+#include "Hud/VerseHudPainter.h"
+#include "Engine/Font.h"
+#include "Misc/AutomationTest.h"
+#include "Tests/UI/Fakes/VerseUiFakes.h"
+
+#if WITH_DEV_AUTOMATION_TESTS
+
+namespace VerseUiHudTest
+{
+ constexpr EAutomationTestFlags Flags = EAutomationTestFlags_ApplicationContextMask | EAutomationTestFlags::EngineFilter;
+
+ FVerseUiStrings LoadStrings()
+ {
+ FVerseUiStrings Strings;
+ Strings.LoadCatalogue(FVerseUiStrings::DefaultCatalogueDir());
+ return Strings;
+ }
+
+ /** Independent pinhole projection (horizontal FOV kept), to check the renderer path. */
+ FVector2D Analytic(const FVerseHudView& View, const FVector2D& Viewport, const FVector& Dir)
+ {
+ const FRotationMatrix M(View.Rotation);
+ const FVector F = M.GetUnitAxis(EAxis::X);
+ const FVector R = M.GetUnitAxis(EAxis::Y);
+ const FVector U = M.GetUnitAxis(EAxis::Z);
+ const double Depth = FVector::DotProduct(Dir, F);
+ const double Focal = (Viewport.X * 0.5) / FMath::Tan(FMath::DegreesToRadians(View.HorizontalFovDeg) * 0.5);
+ return FVector2D(Viewport.X * 0.5 + FVector::DotProduct(Dir, R) / Depth * Focal,
+ Viewport.Y * 0.5 - FVector::DotProduct(Dir, U) / Depth * Focal);
+ }
+
+ FVerseHitEvent Hit(int32 From, int32 To, float Damage = 20.f)
+ {
+ FVerseHitEvent E;
+ E.InstigatorId = From;
+ E.VictimId = To;
+ E.Damage = Damage;
+ E.WeaponId = TEXT("graveline");
+ return E;
+ }
+}
+
+using namespace VerseUiHudTest;
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiLayoutTest, "Verse.UI.Layout.Scaling", Flags)
+bool FVerseUiLayoutTest::RunTest(const FString&)
+{
+ const FVerseUiLayout L1080 = FVerseUiLayout::Compute(FVector2D(1920, 1080), 0.025f, FMargin(0), 1.f);
+ const FVerseUiLayout L1440 = FVerseUiLayout::Compute(FVector2D(2560, 1440), 0.025f, FMargin(0), 1.f);
+ const FVerseUiLayout L4K = FVerseUiLayout::Compute(FVector2D(3840, 2160), 0.025f, FMargin(0), 1.f);
+ TestEqual(TEXT("1080p scale"), L1080.Scale, 1.f);
+ TestTrue(TEXT("1440p scale"), FMath::IsNearlyEqual(L1440.Scale, 4.f / 3.f, 1e-4f));
+ TestEqual(TEXT("4K scale"), L4K.Scale, 2.f);
+ TestTrue(TEXT("safe area 2.5 % at 4K"), FMath::IsNearlyEqual(L4K.SafeMin.X, 96.0, 0.01));
+ const FVerseUiLayout Padded = FVerseUiLayout::Compute(FVector2D(1920, 1080), 0.025f, FMargin(100, 10, 0, 0), 1.2f);
+ TestTrue(TEXT("platform padding wins when larger"), FMath::IsNearlyEqual(Padded.SafeMin.X, 100.0, 0.01));
+ TestTrue(TEXT("text scale follows the person's size"), FMath::IsNearlyEqual(Padded.TextScale, 1.2f, 1e-4f));
+ // Every anchor lands inside the safe rectangle, even with an offset pushing out.
+ for (int32 A = 0; A <= int32(EVerseUiAnchor::BottomRight); ++A)
+ {
+ const FVector2D Size(400, 120);
+ const FVector2D P = L4K.Place(EVerseUiAnchor(A), Size * L4K.Scale, FVector2D(-5000, -5000));
+ TestTrue(FString::Printf(TEXT("anchor %d inside safe area"), A),
+ P.X >= L4K.SafeMin.X - 0.01 && P.Y >= L4K.SafeMin.Y - 0.01 && P.X + Size.X * L4K.Scale <= L4K.SafeMax.X + 0.01 && P.Y + Size.Y * L4K.Scale <= L4K.SafeMax.Y + 0.01);
+ }
+ return true;
+}
+
+// A18.1: centre of the crosshair and the predicted bolt direction differ by 0 px at 1440p over 1,000 shots.
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiCrosshairTest, "Verse.UI.Hud.Crosshair", Flags)
+bool FVerseUiCrosshairTest::RunTest(const FString&)
+{
+ const FVerseUiStrings Strings = LoadStrings();
+ FFakeVerseHudSource Source;
+ Source.Pawn.bValid = true;
+ FVerseHudModel Model;
+ Model.SetLocalPlayerId(Source.LocalId);
+ FRandomStream Rng(1440);
+ const FVector2D Viewport(2560, 1440);
+ int32 Mismatch = 0;
+ double WorstPx = 0.0;
+ for (int32 Shot = 0; Shot < 1000; ++Shot)
+ {
+ Source.View.Location = FVector(Rng.FRandRange(-5000, 5000), Rng.FRandRange(-5000, 5000), Rng.FRandRange(0, 600));
+ Source.View.Rotation = FRotator(Rng.FRandRange(-80, 80), Rng.FRandRange(-180, 180), Rng.FRandRange(-12, 12));
+ Source.View.HorizontalFovDeg = Rng.FRandRange(80.f, 110.f);
+ // Recoil, sway and lean push the bolt up to 6 degrees off the camera axis.
+ const FRotator Off(Rng.FRandRange(-6, 6), Rng.FRandRange(-6, 6), 0);
+ Source.BoltDirection = (Source.View.Rotation.Quaternion() * Off.Quaternion()).GetForwardVector();
+ Source.SpreadDeg = Rng.FRandRange(0.f, 3.f);
+
+ FVerseHudFrame Frame;
+ Frame.Model = &Model;
+ Frame.Strings = &Strings;
+ Frame.Source = &Source;
+ Frame.Layout = FVerseUiLayout::Compute(Viewport, 0.025f, FMargin(0), 1.f);
+ Source.GetPawnState(Frame.Pawn);
+ Frame.bHasView = Source.GetView(Frame.View);
+ FVerseHudDrawList List;
+ FVerseHudPainter::Paint(Frame, List, FVerseHudPainter::DefaultMeasure());
+
+ const FVector2D Expected = Analytic(Source.View, Viewport, Source.BoltDirection);
+ WorstPx = FMath::Max(WorstPx, FVector2D::Distance(Expected, List.CrosshairCentre));
+ Mismatch += FVerseCrosshair::PixelCell(Expected) != FVerseCrosshair::PixelCell(List.CrosshairCentre) || !List.bCrosshairVisible;
+ }
+ AddInfo(FString::Printf(TEXT("worst sub-pixel distance %.6f px"), WorstPx));
+ TestEqual(TEXT("shots whose crosshair pixel differs from the bolt pixel"), Mismatch, 0);
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiMarkersTest, "Verse.UI.Hud.Markers", Flags)
+bool FVerseUiMarkersTest::RunTest(const FString&)
+{
+ FVerseHudModel Model;
+ Model.SetLocalPlayerId(1);
+ FVerseHitEvent H = Hit(1, 2);
+ Model.OnHit(H, 0.0);
+ H.bHeadshot = 1;
+ Model.OnHit(H, 0.0);
+ H.bHeadshot = 0;
+ H.bKillingBlow = 1;
+ Model.OnHit(H, 0.0);
+ H.bKillingBlow = 0;
+ H.bBlockedBySpawnProtection = 1;
+ Model.OnHit(H, 0.0);
+ TestEqual(TEXT("four marker kinds"), Model.GetHitMarkers().Num(), 4);
+ Model.OnHit(Hit(2, 3), 0.0);
+ TestEqual(TEXT("no marker for someone else's hit"), Model.GetHitMarkers().Num(), 4);
+ Model.Tick(0.35, 0.0);
+ TestFalse(TEXT("hit marker gone after 0.3 s"), Model.GetHitMarkers().ContainsByPredicate([](const FVerseHitMarker& M) { return M.Kind == EVerseHitMarkerKind::Hit; }));
+ TestTrue(TEXT("kill marker still up at 0.35 s"), Model.GetHitMarkers().ContainsByPredicate([](const FVerseHitMarker& M) { return M.Kind == EVerseHitMarkerKind::Kill; }));
+ Model.Tick(1.0, 0.0);
+ TestEqual(TEXT("all markers gone after 1 s"), Model.GetHitMarkers().Num(), 0);
+
+ // WP18.10: every kind has its own shape, so none depends on colour.
+ const EVerseHitMarkerKind Kinds[] = {EVerseHitMarkerKind::Hit, EVerseHitMarkerKind::Headshot, EVerseHitMarkerKind::Kill, EVerseHitMarkerKind::Blocked};
+ TSet<FIntVector> Shapes;
+ for (EVerseHitMarkerKind Kind : Kinds)
+ {
+ const FIntVector Shape = FVerseHudPainter::MarkerShape(Kind);
+ TestTrue(TEXT("marker draws something"), Shape.X + Shape.Y + Shape.Z > 0);
+ Shapes.Add(Shape);
+ }
+ TestEqual(TEXT("four distinct marker shapes"), Shapes.Num(), 4);
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiDamageDirectionTest, "Verse.UI.Hud.DamageDirection", Flags)
+bool FVerseUiDamageDirectionTest::RunTest(const FString&)
+{
+ FVerseHudModel Model;
+ Model.SetLocalPlayerId(1);
+ FVerseHitEvent H = Hit(2, 1);
+ // Shooter on the person's left: the bolt travels toward +Y (right) when the person faces +X.
+ H.Direction = FVector_NetQuantizeNormal(0.0, 1.0, 0.0);
+ Model.OnHit(H, 0.0);
+ TestEqual(TEXT("one indicator"), Model.GetDamageIndicators().Num(), 1);
+ FVerseHudView View;
+ View.Rotation = FRotator::ZeroRotator;
+ const float Left = FVerseHudPainter::IndicatorAngleDeg(View, Model.GetDamageIndicators()[0].FromDirection);
+ TestTrue(TEXT("points left (-90)"), FMath::IsNearlyEqual(Left, -90.f, 0.5f));
+ View.Rotation = FRotator(0, -90, 0);
+ const float Ahead = FVerseHudPainter::IndicatorAngleDeg(View, Model.GetDamageIndicators()[0].FromDirection);
+ TestTrue(TEXT("turning toward the source puts it ahead"), FMath::IsNearlyEqual(Ahead, 0.f, 0.5f));
+ FVerseHitEvent Blocked = Hit(2, 1);
+ Blocked.bBlockedBySpawnProtection = 1;
+ Model.OnHit(Blocked, 0.0);
+ TestEqual(TEXT("a blocked hit shows no damage"), Model.GetDamageIndicators().Num(), 1);
+ Model.Tick(2.0, 0.0);
+ TestEqual(TEXT("indicator fades out"), Model.GetDamageIndicators().Num(), 0);
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiKillFeedTest, "Verse.UI.Hud.KillFeed", Flags)
+bool FVerseUiKillFeedTest::RunTest(const FString&)
+{
+ FVerseHudModel Model;
+ Model.SetLocalPlayerId(1);
+ FVerseHitEvent Wall = Hit(1, 2, 60.f);
+ Wall.PenetrationCount = 1;
+ Wall.bHeadshot = 1;
+ Model.OnHit(Wall, 0.0);
+ FVerseDeathEvent Death;
+ Death.KillerId = 1;
+ Death.VictimId = 2;
+ Death.WeaponId = TEXT("graveline");
+ Death.ServerTime = 10.0;
+ Death.RespawnAt = 13.0;
+ Model.OnDeath(Death, 0.0);
+ TestEqual(TEXT("one feed line"), Model.GetKillFeed().Num(), 1);
+ TestTrue(TEXT("wall shot flagged"), Model.GetKillFeed()[0].bWallShot);
+ TestTrue(TEXT("headshot flagged"), Model.GetKillFeed()[0].bHeadshot);
+ TestEqual(TEXT("own score"), Model.GetScoreSelf(), 1);
+
+ Model.Tick(1.0, 13.0);
+ TestEqual(TEXT("opponent respawn line"), Model.GetKillFeed().Last().Kind, EVerseFeedKind::Respawn);
+
+ FVerseDeathEvent Mine;
+ Mine.KillerId = 2;
+ Mine.VictimId = 1;
+ Mine.Cause = EVerseDamageSource::Finisher;
+ Mine.ServerTime = 20.0;
+ Mine.RespawnAt = 23.0;
+ Model.OnDeath(Mine, 2.0);
+ TestTrue(TEXT("person dead"), Model.IsLocalDead());
+ TestEqual(TEXT("opponent score"), Model.GetScoreOpponent(), 1);
+ TestTrue(TEXT("respawn countdown 3.0 s"), FMath::IsNearlyEqual(Model.GetRespawnRemaining(20.0), 3.f, 1e-3f));
+ TestTrue(TEXT("respawn countdown 1.0 s"), FMath::IsNearlyEqual(Model.GetRespawnRemaining(22.0), 1.f, 1e-3f));
+ Model.Tick(3.0, 23.0);
+ TestFalse(TEXT("person alive after RespawnAt"), Model.IsLocalDead());
+
+ FVerseDeathEvent World;
+ World.KillerId = -1;
+ World.VictimId = 1;
+ World.RespawnAt = 40.0;
+ Model.OnDeath(World, 4.0);
+ TestEqual(TEXT("a world kill scores nobody"), Model.GetScoreOpponent(), 1);
+
+ FVerseSetSummary Summary;
+ Summary.SetIndex = 1;
+ Summary.Outcome = EVerseSetOutcome::Won;
+ Model.OnSetEnded(Summary, 5.0);
+ TestEqual(TEXT("set score resets"), Model.GetScoreSelf() + Model.GetScoreOpponent(), 0);
+ TestEqual(TEXT("next set index"), Model.GetSetIndex(), 2);
+ for (int32 I = 0; I < 12; ++I)
+ {
+ Model.OnDeath(Death, 5.0);
+ }
+ TestEqual(TEXT("feed keeps at most 5 lines"), Model.GetKillFeed().Num(), 5);
+ // The tick at 20 s expires the kill lines and posts the opponent's respawn (RespawnAt 13);
+ // that line expires 6 s later like any other.
+ Model.Tick(20.0, 50.0);
+ TestEqual(TEXT("kill lines expired, respawn line posted"), Model.GetKillFeed().Num(), 1);
+ Model.Tick(26.0, 50.0);
+ TestEqual(TEXT("feed lines expire after 6 s"), Model.GetKillFeed().Num(), 0);
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiPaletteTest, "Verse.UI.Theme.Palette", Flags)
+bool FVerseUiPaletteTest::RunTest(const FString&)
+{
+ for (const FLinearColor& C : VerseUiTheme::AllColours())
+ {
+ TestFalse(FString::Printf(TEXT("%s is not cyan or violet"), *C.ToString()), VerseUiTheme::IsForbiddenAccent(C));
+ }
+ TestTrue(TEXT("the check catches cyan"), VerseUiTheme::IsForbiddenAccent(FLinearColor(0.f, 0.8f, 0.9f)));
+ TestTrue(TEXT("the check catches violet"), VerseUiTheme::IsForbiddenAccent(FLinearColor(0.5f, 0.1f, 0.9f)));
+ return true;
+}
+
+/** A busy fight frame: every block on screen. */
+static void FillFightFrame(FFakeVerseHudSource& Source, FVerseHudModel& Model)
+{
+ Source.LocalId = 1;
+ Source.Names.Add(2, TEXT("Opponent"));
+ Source.Bots.Add(2);
+ Source.Pawn.bValid = true;
+ Source.Pawn.Health = 64.f;
+ Source.Pawn.Stance = EVerseStance::Crouch;
+ Source.Pawn.bSpawnProtected = true;
+ Source.Pawn.SpawnProtectionRemaining = 1.4f;
+ Source.Pawn.bHasWeapon = true;
+ Source.Pawn.WeaponId = TEXT("graveline");
+ Source.Pawn.Magazine = 7;
+ Source.Pawn.MagazineSize = 30;
+ Source.Pawn.bChambered = true;
+ Source.Pawn.Reserve = 90;
+ Source.Pawn.bReloading = true;
+ Source.Pawn.ReloadProgress = 0.4f;
+ Source.Pawn.Gadgets = {{TEXT("bulwark"), 1, 1, 0.f}, {TEXT("breach_charge"), 1, 2, 0.f}};
+ Source.SpreadDeg = 1.2f;
+ Model.SetLocalPlayerId(1);
+ FVerseHitEvent H = Hit(1, 2);
+ H.bHeadshot = 1;
+ Model.OnHit(H, 0.0);
+ FVerseHitEvent In = Hit(2, 1);
+ In.Direction = FVector_NetQuantizeNormal(-0.7, 0.7, 0.0);
+ Model.OnHit(In, 0.0);
+ FVerseDeathEvent D;
+ D.KillerId = 1;
+ D.VictimId = 2;
+ D.WeaponId = TEXT("graveline");
+ D.RespawnAt = 1e9;
+ Model.OnDeath(D, 0.0);
+ D.KillerId = 2;
+ D.VictimId = 1;
+ D.Cause = EVerseDamageSource::Finisher;
+ D.RespawnAt = 103.0;
+ Model.OnDeath(D, 0.0);
+}
+
+// Regression: canvas text items need a runtime-cache UFont or the engine skips them, which left
+// every HUD label blank in the first captures.
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiHudLabelFontTest, "Verse.UI.Hud.LabelFont", Flags)
+bool FVerseUiHudLabelFontTest::RunTest(const FString&)
+{
+ const UFont* Font = FVerseHudCanvasRenderer::LabelFont();
+ TestNotNull(TEXT("label font"), Font);
+ if (Font)
+ {
+ TestTrue(TEXT("runtime font cache"), Font->FontCacheType == EFontCacheType::Runtime);
+ }
+ return true;
+}
+
+// A18.3 (game-thread part): building the HUD draw list stays far under 0.3 ms.
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiHudCostTest, "Verse.UI.Hud.Cost", Flags)
+bool FVerseUiHudCostTest::RunTest(const FString&)
+{
+ const FVerseUiStrings Strings = LoadStrings();
+ FFakeVerseHudSource Source;
+ FVerseHudModel Model;
+ FillFightFrame(Source, Model);
+ const FVerseTextMeasure Measure = FVerseHudPainter::DefaultMeasure();
+ FVerseHudDrawList List;
+ const int32 Frames = 2000;
+ const double Start = FPlatformTime::Seconds();
+ for (int32 I = 0; I < Frames; ++I)
+ {
+ FVerseHudFrame Frame;
+ Frame.Model = &Model;
+ Frame.Strings = &Strings;
+ Frame.Source = &Source;
+ Frame.Layout = FVerseUiLayout::Compute(FVector2D(2560, 1440), 0.025f, FMargin(0), 1.f);
+ Source.GetPawnState(Frame.Pawn);
+ Frame.bHasView = Source.GetView(Frame.View);
+ Frame.Now = 0.1;
+ Frame.ServerTime = 101.0;
+ Frame.bKillCam = true;
+ Frame.KillCamKillerId = 2;
+ FVerseHudPainter::Paint(Frame, List, Measure);
+ Model.Tick(0.1, 101.0);
+ }
+ const double MeanMs = (FPlatformTime::Seconds() - Start) * 1000.0 / Frames;
+ AddInfo(FString::Printf(TEXT("HUD model tick + draw list: %.4f ms per frame, %d primitives"), MeanMs, List.Num()));
+ TestTrue(TEXT("HUD game-thread build under 0.3 ms"), MeanMs < 0.3);
+ return true;
+}
+
+#endif // WITH_DEV_AUTOMATION_TESTS
diff --git a/unreal/Verse/Source/VerseUI/Private/Tests/UI/VerseUiKillCamTest.cpp b/unreal/Verse/Source/VerseUI/Private/Tests/UI/VerseUiKillCamTest.cpp
new file mode 100644
index 0000000000..6150aa5586
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Private/Tests/UI/VerseUiKillCamTest.cpp
@@ -0,0 +1,176 @@
+#include "Events/VerseEventHub.h"
+#include "KillCam/VerseKillCam.h"
+#include "Misc/AutomationTest.h"
+#include "Tests/UI/Fakes/VerseUiFakes.h"
+
+#if WITH_DEV_AUTOMATION_TESTS
+
+namespace VerseUiKillCamTest
+{
+ constexpr EAutomationTestFlags Flags = EAutomationTestFlags_ApplicationContextMask | EAutomationTestFlags::EngineFilter;
+
+ /** The server's log of the killer: a sprint on a curve, 60 Hz (architecture 3.2). */
+ FVector ServerPath(double T)
+ {
+ const double Radius = 600.0; // cm
+ const double Speed = 650.0; // cm/s, sprint
+ const double A = Speed * T / Radius;
+ return FVector(Radius * FMath::Cos(A), Radius * FMath::Sin(A), 90.0 + 15.0 * FMath::Sin(T * 3.0));
+ }
+
+ FRotator ServerAim(double T)
+ {
+ return FRotator(-5.0 + 3.0 * FMath::Sin(T), FMath::RadiansToDegrees(650.0 * T / 600.0) + 90.0, 0.0);
+ }
+}
+
+using namespace VerseUiKillCamTest;
+
+// A18.2: starts within 150 ms of FVerseDeathEvent, ends at least 200 ms before respawn; the
+// replayed killer path is within 10 cm of the server log.
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiKillCamTimingTest, "Verse.UI.KillCam.Timing", Flags)
+bool FVerseUiKillCamTimingTest::RunTest(const FString&)
+{
+ FVerseUiTestWorld W;
+ if (!TestNotNull(TEXT("UI subsystem in a game world"), W.Ui))
+ {
+ return false;
+ }
+ UVerseEventHub* Hub = UVerseEventHub::Get(W.World);
+ if (!TestNotNull(TEXT("event hub"), Hub))
+ {
+ return false;
+ }
+ const int32 Person = 1;
+ const int32 Killer = 2;
+ W.Source->LocalId = Person;
+
+ // Client frames at an uneven ~45 fps; each frame sees the replicated server pose of its time.
+ FRandomStream Rng(7);
+ double Server = 50.0;
+ const double DeathAt = 56.0;
+ while (Server < DeathAt)
+ {
+ W.Source->ServerTime = Server;
+ W.Source->Poses = {{Killer, ServerPath(Server), ServerAim(Server)}, {Person, FVector(0, 0, 90), FRotator::ZeroRotator}};
+ W.Ui->Tick(0.02f);
+ const double Step = Rng.FRandRange(0.012, 0.034);
+ Server += Step;
+ W.Now += Step;
+ }
+ W.Source->ServerTime = DeathAt;
+ W.Source->Poses = {{Killer, ServerPath(DeathAt), ServerAim(DeathAt)}};
+
+ FVerseDeathEvent Death;
+ Death.KillerId = Killer;
+ Death.VictimId = Person;
+ Death.WeaponId = TEXT("graveline");
+ Death.ServerTime = DeathAt;
+ Death.RespawnAt = DeathAt + 3.0;
+ const double EventArrived = W.Now;
+ Hub->OnDeath.Broadcast(Death);
+
+ const FVerseKillCamPlayer& Cam = W.Ui->GetKillCam();
+ TestTrue(TEXT("kill cam playing"), Cam.IsPlaying());
+ TestTrue(TEXT("starts within 150 ms of the death event"), Cam.GetPlayStart() - EventArrived <= 0.150);
+ const double RespawnLocal = EventArrived + (Death.RespawnAt - DeathAt);
+ TestTrue(TEXT("planned end at least 200 ms before respawn"), RespawnLocal - Cam.GetPlannedEnd() >= 0.200);
+
+ double WorstCm = 0.0;
+ int32 Samples = 0;
+ while (Cam.IsPlaying() && W.Now < RespawnLocal + 1.0)
+ {
+ const double Step = Rng.FRandRange(0.012, 0.034);
+ W.Now += Step;
+ W.Source->ServerTime += Step;
+ W.Ui->Tick(float(Step));
+ FVector Pose;
+ FRotator Aim;
+ if (Cam.GetKillerPose(Pose, Aim))
+ {
+ WorstCm = FMath::Max(WorstCm, FVector::Distance(Pose, ServerPath(Cam.GetReplayTime())));
+ ++Samples;
+ }
+ }
+ AddInfo(FString::Printf(TEXT("replay %.3f s, %d frames, worst path error %.3f cm, ended %.3f s before respawn"),
+ Cam.GetClipEnd() - Cam.GetClipStart(), Samples, WorstCm, RespawnLocal - Cam.GetEndedAt()));
+ TestTrue(TEXT("replay ran for most of the 3 s respawn"), Cam.GetClipEnd() - Cam.GetClipStart() >= 2.5);
+ TestEqual(TEXT("kill cam finished on its own"), Cam.GetState(), EVerseKillCamState::Finished);
+ TestTrue(TEXT("ended at least 200 ms before respawn"), RespawnLocal - Cam.GetEndedAt() >= 0.200);
+ TestTrue(TEXT("killer path within 10 cm of the server log"), WorstCm <= 10.0);
+ TestTrue(TEXT("frames sampled"), Samples > 50);
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiKillCamEventsTest, "Verse.UI.KillCam.Events", Flags)
+bool FVerseUiKillCamEventsTest::RunTest(const FString&)
+{
+ FVerseKillCamBuffer Buffer;
+ for (int32 I = 0; I <= 300; ++I)
+ {
+ const double T = 10.0 + I / 60.0;
+ Buffer.AddPose(2, T, ServerPath(T), ServerAim(T));
+ }
+ for (int32 I = 0; I < 5; ++I)
+ {
+ FVerseFireEvent Fire;
+ Fire.ShooterId = 2;
+ Fire.ShotCounter = uint16(I);
+ Buffer.AddFire(Fire, 13.0 + I * 0.3);
+ }
+ FVerseFractureEvent Break;
+ Break.PieceIndex = 17;
+ Buffer.AddFracture(Break, 14.2);
+ FVerseFractureEvent Old;
+ Old.PieceIndex = 3;
+ Buffer.AddFracture(Old, 9.0);
+ Buffer.Trim(15.0);
+ TestEqual(TEXT("trim drops what is older than 4 s"), Buffer.GetFractures().Num(), 1);
+
+ FVerseDeathEvent Death;
+ Death.KillerId = 2;
+ Death.VictimId = 1;
+ Death.ServerTime = 15.0;
+ Death.RespawnAt = 18.0;
+
+ FVerseKillCamPlayer Player;
+ TArray<uint16> Shots;
+ TArray<uint16> Pieces;
+ Player.OnReplayFire = [&Shots](const FVerseFireEvent& E) { Shots.Add(E.ShotCounter); };
+ Player.OnReplayFracture = [&Pieces](const FVerseFractureEvent& E) { Pieces.Add(E.PieceIndex); };
+ TestTrue(TEXT("begins"), Player.Begin(Buffer, Death, 1, 0.0, 15.0, false));
+ for (double T = 0.0; T <= 3.0; T += 1.0 / 60.0)
+ {
+ Player.Tick(T);
+ }
+ TestEqual(TEXT("every shot in the window replays once, in order"), Shots, TArray<uint16>({0, 1, 2, 3, 4}));
+ TestEqual(TEXT("the break in the window replays"), Pieces, TArray<uint16>({17}));
+
+ FVector Cam;
+ FRotator CamRot;
+ TestTrue(TEXT("begins again"), Player.Begin(Buffer, Death, 1, 0.0, 15.0, false));
+ Player.Tick(0.5);
+ TestTrue(TEXT("camera available"), Player.GetCamera(Cam, CamRot));
+ FVector Killer;
+ FRotator Aim;
+ Player.GetKillerPose(Killer, Aim);
+ TestTrue(TEXT("third-person camera stands behind the killer"), FVector::Dist(Cam, Killer) > 150.f && FVector::Dist(Cam, Killer) < 400.f);
+ Player.Skip(0.6);
+ TestEqual(TEXT("skip"), Player.GetState(), EVerseKillCamState::Skipped);
+
+ TestTrue(TEXT("finisher with reduced gore"), Player.Begin(Buffer, [&] { FVerseDeathEvent F = Death; F.Cause = EVerseDamageSource::Finisher; return F; }(), 1, 0.0, 15.0, true));
+ TestTrue(TEXT("reduced gore cuts the finisher out of the replay"), Player.GetClipEnd() <= Death.ServerTime - 2.5 + 1e-6);
+
+ FVerseDeathEvent Suicide = Death;
+ Suicide.KillerId = 1;
+ TestFalse(TEXT("no kill cam for a suicide"), Player.Begin(Buffer, Suicide, 1, 0.0, 15.0, false));
+ FVerseDeathEvent WorldKill = Death;
+ WorldKill.KillerId = -1;
+ TestFalse(TEXT("no kill cam for a world kill"), Player.Begin(Buffer, WorldKill, 1, 0.0, 15.0, false));
+ FVerseDeathEvent Late = Death;
+ Late.RespawnAt = 15.5;
+ TestFalse(TEXT("no kill cam when respawn is too close"), Player.Begin(Buffer, Late, 1, 0.0, 15.0, false));
+ return true;
+}
+
+#endif // WITH_DEV_AUTOMATION_TESTS
diff --git a/unreal/Verse/Source/VerseUI/Private/Tests/UI/VerseUiSeamsTest.cpp b/unreal/Verse/Source/VerseUI/Private/Tests/UI/VerseUiSeamsTest.cpp
new file mode 100644
index 0000000000..910d67d310
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Private/Tests/UI/VerseUiSeamsTest.cpp
@@ -0,0 +1,389 @@
+#include "Components/CapsuleComponent.h"
+#include "Components/SkeletalMeshComponent.h"
+#include "Core/VerseUiStrings.h"
+#include "EnhancedActionKeyMapping.h"
+#include "Events/VerseEventHub.h"
+#include "GameFramework/Character.h"
+#include "InputAction.h"
+#include "InputMappingContext.h"
+#include "InputModifiers.h"
+#include "Internationalization/Culture.h"
+#include "Internationalization/Internationalization.h"
+#include "Misc/AutomationTest.h"
+#include "Misc/ScopeExit.h"
+#include "Scalability.h"
+#include "Settings/VerseUiInputRemap.h"
+#include "Tests/UI/Fakes/VerseUiFakes.h"
+
+#if WITH_DEV_AUTOMATION_TESTS
+
+// The UI's seams to the packages around it: key bindings into Enhanced Input (WP01), the kill
+// cam proxy on a real character, pause, leave and reset (parity D-09, D-10, T-01), scalability
+// at start, numbers in the Verse language, the kill cam under a lagged connection.
+
+namespace VerseUiSeamsTest
+{
+ constexpr EAutomationTestFlags Flags = EAutomationTestFlags_ApplicationContextMask | EAutomationTestFlags::EngineFilter;
+
+ UInputAction* MakeAction(UObject* Outer, const TCHAR* Name)
+ {
+ UInputAction* Action = NewObject<UInputAction>(Outer, Name);
+ Action->ValueType = EInputActionValueType::Boolean;
+ return Action;
+ }
+
+ FVerseSetSummary MakeSet(int32 Index, EVerseSetOutcome Outcome, int32 Kills, int32 Deaths)
+ {
+ FVerseSetSummary Set;
+ Set.SetIndex = Index;
+ Set.Outcome = Outcome;
+ Set.BotTier = TEXT("hard");
+ Set.Person.PlayerId = 1;
+ Set.Person.Kills = Kills;
+ Set.Person.Deaths = Deaths;
+ Set.Person.Headshots = 2;
+ Set.Person.BestStreak = Kills;
+ Set.Opponent.PlayerId = 2;
+ Set.Opponent.bIsBot = true;
+ Set.Opponent.Kills = Deaths;
+ Set.Opponent.Deaths = Kills;
+ return Set;
+ }
+}
+
+using namespace VerseUiSeamsTest;
+
+// A rebind changes the key the input owner's mapping context actually uses (WP18.8).
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiInputRemapTest, "Verse.UI.Settings.InputRemap", Flags)
+bool FVerseUiInputRemapTest::RunTest(const FString&)
+{
+ // The layout of WP01's IMC_VersePerson (VerseInputFrameBuilder.cpp): actions by name, a
+ // keyboard and a gamepad key for jump, modifiers on the move keys.
+ UInputMappingContext* Context = NewObject<UInputMappingContext>(GetTransientPackage(), TEXT("IMC_VerseUiRemapTest"));
+ UInputAction* Move = MakeAction(Context, TEXT("IA_Move"));
+ UInputAction* Jump = MakeAction(Context, TEXT("IA_Jump"));
+ UInputAction* Crouch = MakeAction(Context, TEXT("IA_Crouch"));
+ Context->MapKey(Move, EKeys::W);
+ FEnhancedActionKeyMapping& Back = Context->MapKey(Move, EKeys::S);
+ Back.Modifiers.Add(NewObject<UInputModifierNegate>(Context));
+ Context->MapKey(Jump, EKeys::SpaceBar);
+ Context->MapKey(Jump, EKeys::Gamepad_FaceButton_Bottom);
+ Context->MapKey(Crouch, EKeys::LeftControl);
+ Context->MapKey(Crouch, EKeys::C);
+
+ FVerseKeyMap KeyMap;
+ FString Error;
+ if (!TestTrue(TEXT("keys.json loads"), KeyMap.LoadFile(FVerseKeyMap::DefaultPath(), &Error)))
+ {
+ AddError(Error);
+ return false;
+ }
+ const FVerseKeyMap::FAction* JumpAction = KeyMap.FindAction(TEXT("jump"));
+ TestTrue(TEXT("jump names WP01's IA_Jump"), JumpAction && JumpAction->InputAction == FName(TEXT("IA_Jump")));
+
+ FVerseUiInputRemap Remap;
+ TestFalse(TEXT("default keys change nothing"), Remap.Apply(Context, KeyMap));
+ TestEqual(TEXT("bound mappings: move forward, move back, jump, crouch"), Remap.NumBound(Context), 4);
+
+ KeyMap.Rebind(TEXT("jump"), EKeys::F);
+ KeyMap.Rebind(TEXT("move_back"), EKeys::Down);
+ TestTrue(TEXT("rebinds apply"), Remap.Apply(Context, KeyMap));
+ const TArray<FEnhancedActionKeyMapping>& M = Context->GetMappings();
+ TestEqual(TEXT("IA_Jump now on F"), M[2].Key, EKeys::F);
+ TestEqual(TEXT("the gamepad jump stays"), M[3].Key, EKeys::Gamepad_FaceButton_Bottom);
+ TestEqual(TEXT("move back now on Down"), M[1].Key, EKeys::Down);
+ TestEqual(TEXT("the move-back mapping keeps its negate modifier"), M[1].Modifiers.Num(), 1);
+ TestEqual(TEXT("the second crouch key stays"), M[5].Key, EKeys::C);
+
+ // Interact took F before: the swap gives it jump's old key; the mapping follows a second rebind.
+ KeyMap.Rebind(TEXT("jump"), EKeys::SpaceBar);
+ TestTrue(TEXT("rebinding back applies"), Remap.Apply(Context, KeyMap));
+ TestEqual(TEXT("IA_Jump back on space"), Context->GetMappings()[2].Key, EKeys::SpaceBar);
+
+ // Fire defaults to a mouse button; a rebind can return to it.
+ KeyMap.Rebind(TEXT("fire"), EKeys::K);
+ KeyMap.Rebind(TEXT("fire"), EKeys::LeftMouseButton);
+ TestEqual(TEXT("fire can be bound back to the left mouse button"), KeyMap.GetKey(TEXT("fire")), EKeys::LeftMouseButton);
+ return true;
+}
+
+// The kill cam proxy stands where the character's mesh stands (mesh offset kept).
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiKillCamProxyTest, "Verse.UI.KillCam.Proxy", Flags)
+bool FVerseUiKillCamProxyTest::RunTest(const FString&)
+{
+ FVerseUiTestWorld W;
+ if (!TestNotNull(TEXT("UI subsystem"), W.Ui))
+ {
+ return false;
+ }
+ FActorSpawnParameters Params;
+ Params.SpawnCollisionHandlingOverride = ESpawnActorCollisionHandlingMethod::AlwaysSpawn;
+ ACharacter* Killer = W.World->SpawnActor<ACharacter>(FVector(300.0, -120.0, 92.0), FRotator(0.0, 35.0, 0.0), Params);
+ if (!TestNotNull(TEXT("character"), Killer))
+ {
+ return false;
+ }
+ // AVerseCharacter's mesh offset (WP01): -half height in Z, -90 deg yaw.
+ const float HalfHeight = Killer->GetCapsuleComponent()->GetUnscaledCapsuleHalfHeight();
+ Killer->GetMesh()->SetRelativeLocationAndRotation(FVector(0.0, 0.0, -HalfHeight), FRotator(0.0, -90.0, 0.0));
+ Killer->CacheInitialMeshOffset(Killer->GetMesh()->GetRelativeLocation(), Killer->GetMesh()->GetRelativeRotation());
+ // A network smoothing offset on the live mesh must not be copied.
+ Killer->GetMesh()->SetRelativeLocation(FVector(0.0, 0.0, -HalfHeight + 7.0));
+
+ AActor* Proxy = W.Ui->SpawnKillCamProxy(W.World, Params, Killer, Killer->GetMesh());
+ if (!TestNotNull(TEXT("proxy"), Proxy))
+ {
+ return false;
+ }
+ USkeletalMeshComponent* Copy = Proxy->FindComponentByClass<USkeletalMeshComponent>();
+ if (!TestNotNull(TEXT("proxy mesh"), Copy))
+ {
+ return false;
+ }
+ TestTrue(TEXT("proxy root is not the mesh"), Proxy->GetRootComponent() != Copy);
+ const FTransform Expected = FTransform(Killer->GetBaseRotationOffset(), Killer->GetBaseTranslationOffset()) * Killer->GetActorTransform();
+ AddInfo(FString::Printf(TEXT("proxy mesh %s, character mesh base %s"), *Copy->GetComponentLocation().ToString(), *Expected.GetLocation().ToString()));
+ TestTrue(TEXT("feet on the floor: proxy mesh within 1 cm of the character's mesh base"), FVector::Dist(Copy->GetComponentLocation(), Expected.GetLocation()) < 1.0);
+ TestTrue(TEXT("facing: proxy mesh yaw equals the character's mesh yaw"),
+ FMath::Abs(FRotator::NormalizeAxis(Copy->GetComponentRotation().Yaw - Expected.Rotator().Yaw)) < 0.5);
+ Proxy->Destroy();
+ Killer->Destroy();
+ return true;
+}
+
+// Escape mid-match pauses, the end-of-set screen pauses, leaving shows the summary (D-09, D-10).
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiPauseLeaveTest, "Verse.UI.Menus.PauseLeave", Flags)
+bool FVerseUiPauseLeaveTest::RunTest(const FString&)
+{
+ FVerseUiTestWorld W;
+ if (!TestNotNull(TEXT("UI subsystem"), W.Ui))
+ {
+ return false;
+ }
+ W.Ui->ApplyWelcome(W.Bridge->MakeWelcome());
+ W.Ui->QuickStartDuel();
+ TestTrue(TEXT("duel running"), W.Game->bDuel);
+ TestTrue(TEXT("Esc opens the menu"), W.Ui->HandleKey(EKeys::Escape));
+ TestEqual(TEXT("Esc menu"), W.Ui->GetScreen(), EVerseUiScreen::EscMenu);
+ TestTrue(TEXT("Escape mid-match pauses"), W.Game->bIsPaused);
+ W.Ui->ShowScreen(EVerseUiScreen::Settings);
+ TestTrue(TEXT("still paused in settings"), W.Game->bIsPaused);
+ W.Ui->HandleKey(EKeys::Escape);
+ W.Ui->HandleKey(EKeys::Escape);
+ TestEqual(TEXT("closed"), W.Ui->GetScreen(), EVerseUiScreen::None);
+ TestFalse(TEXT("resume releases the pause"), W.Game->bIsPaused);
+
+ UVerseEventHub* Hub = UVerseEventHub::Get(W.World);
+ if (!TestNotNull(TEXT("hub"), Hub))
+ {
+ return false;
+ }
+ Hub->OnSetEnded.Broadcast(MakeSet(1, EVerseSetOutcome::Won, 10, 4));
+ TestEqual(TEXT("end-of-set screen"), W.Ui->GetScreen(), EVerseUiScreen::EndOfSet);
+ TestTrue(TEXT("the end-of-set screen holds the match"), W.Game->bIsPaused);
+ W.Ui->ContinueAfterSet();
+ TestFalse(TEXT("next set resumes"), W.Game->bIsPaused);
+ Hub->OnSetEnded.Broadcast(MakeSet(2, EVerseSetOutcome::Lost, 6, 10));
+ W.Ui->ContinueAfterSet();
+
+ // Leave mid-set: notice, summary over both sets, "again" starts a new session.
+ W.Ui->HandleKey(EKeys::Escape);
+ W.Ui->LeaveDuel();
+ TestEqual(TEXT("leave shows the session summary"), W.Ui->GetScreen(), EVerseUiScreen::SessionSummary);
+ TestTrue(TEXT("left mid-set (verse.duel.notice.left)"), W.Ui->GetSession().bLeftMidSet);
+ TestFalse(TEXT("leaving releases the pause"), W.Game->bIsPaused);
+ TestEqual(TEXT("one leave"), W.Game->Left, 1);
+ TestEqual(TEXT("sets won"), W.Ui->GetSession().SetsWon, 1);
+ TestEqual(TEXT("sets lost"), W.Ui->GetSession().SetsLost, 1);
+ TestEqual(TEXT("session kills summed"), W.Ui->GetSession().Totals.Person.Kills, 16);
+ TestEqual(TEXT("best streak is the best set"), W.Ui->GetSession().Totals.Person.BestStreak, 10);
+ TestEqual(TEXT("summary title"), W.Ui->GetSessionScreen().TitleKey, FString(TEXT("verse.duel.result.cancelled")));
+ TestTrue(TEXT("summary has rows"), W.Ui->GetSessionScreen().Rows.Num() > 0);
+ TestEqual(TEXT("app string for the notice"), W.Ui->GetStrings().Get(TEXT("verse.duel.notice.left")).ToString(), FString(TEXT("You left the duel.")));
+ W.Ui->QuickStartDuel();
+ TestEqual(TEXT("again starts a duel"), W.Game->Started.Num(), 2);
+ TestEqual(TEXT("again starts a new session"), W.Ui->GetSession().NumSets(), 0);
+
+ // Leaving from the end-of-set screen is not mid-set.
+ Hub->OnSetEnded.Broadcast(MakeSet(1, EVerseSetOutcome::Won, 10, 2));
+ W.Ui->LeaveDuel();
+ TestFalse(TEXT("leave from the end-of-set screen is not mid-set"), W.Ui->GetSession().bLeftMidSet);
+ return true;
+}
+
+// parity T-01: reset restores sensitivity 1, invert off, quality auto, FOV 70/85, volume 0.7, view third.
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiResetTest, "Verse.UI.Settings.Reset", Flags)
+bool FVerseUiResetTest::RunTest(const FString&)
+{
+ FVerseUiTestWorld W;
+ if (!TestNotNull(TEXT("UI subsystem"), W.Ui))
+ {
+ return false;
+ }
+ UVerseUiUserSettings* User = W.Ui->GetUserSettings();
+ const int32 ScalabilityBefore = User->Scalability;
+ ON_SCOPE_EXIT { User->Scalability = ScalabilityBefore; User->SaveToDisk(); };
+ const EVerseGoreLevel GoreBefore = UVerseUiSubsystem::ReadGoreSetting();
+ ON_SCOPE_EXIT { UVerseUiSubsystem::WriteGoreSetting(nullptr, GoreBefore); };
+ W.Ui->ApplyWelcome(W.Bridge->MakeWelcome());
+ FVerseAppSettings Changed = W.Ui->GetAppSettings();
+ Changed.Sensitivity = 2.3f;
+ Changed.bInvertY = true;
+ Changed.Quality = TEXT("low");
+ Changed.FovThird = 90.f;
+ Changed.FovFirst = 100.f;
+ Changed.Volume = 0.2f;
+ Changed.ViewMode = TEXT("first");
+ Changed.Gore = EVerseGoreLevel::Reduced;
+ W.Ui->SetAppSettings(Changed);
+ W.Ui->SetScalability(1);
+ W.Bridge->Frames.Reset();
+
+ W.Ui->ResetSettings();
+ const FVerseAppSettings& S = W.Ui->GetAppSettings();
+ TestEqual(TEXT("sensitivity 1"), S.Sensitivity, 1.f);
+ TestFalse(TEXT("invert off"), S.bInvertY);
+ TestEqual(TEXT("quality auto"), S.Quality, FString(TEXT("auto")));
+ TestEqual(TEXT("FOV third 70"), S.FovThird, 70.f);
+ TestEqual(TEXT("FOV first 85"), S.FovFirst, 85.f);
+ TestTrue(TEXT("volume 0.7"), FMath::IsNearlyEqual(S.Volume, 0.7f));
+ TestEqual(TEXT("view third"), S.ViewMode, FString(TEXT("third")));
+ TestEqual(TEXT("Unreal quality auto"), User->Scalability, -1);
+ TestEqual(TEXT("gore is not a view setting: unchanged"), S.Gore, EVerseGoreLevel::Reduced);
+ TestEqual(TEXT("one settings.set for the reset"), W.Bridge->Count(TEXT("settings.set")), 1);
+ return true;
+}
+
+// The saved quality level applies (at start and from the menu); auto maps to the engine defaults.
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiScalabilityTest, "Verse.UI.Settings.Scalability", Flags)
+bool FVerseUiScalabilityTest::RunTest(const FString&)
+{
+ const Scalability::FQualityLevels Before = Scalability::GetQualityLevels();
+ ON_SCOPE_EXIT { Scalability::SetQualityLevels(Before); };
+ UVerseUiSubsystem::ApplyScalabilityLevel(1);
+ TestEqual(TEXT("level 1 applied"), Scalability::GetQualityLevels().GetSingleQualityLevel(), 1);
+ UVerseUiSubsystem::ApplyScalabilityLevel(-1);
+ const Scalability::FQualityLevels Defaults;
+ TestTrue(TEXT("auto applies the engine's default levels"), Scalability::GetQualityLevels() == Defaults);
+ return true;
+}
+
+// Numbers follow the Verse language, not the machine's culture.
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiNumberCultureTest, "Verse.UI.Strings.NumberCulture", Flags)
+bool FVerseUiNumberCultureTest::RunTest(const FString&)
+{
+ FInternationalization& I18n = FInternationalization::Get();
+ const FString Before = I18n.GetCurrentCulture()->GetName();
+ ON_SCOPE_EXIT { I18n.SetCurrentCulture(Before); };
+ if (!I18n.GetCulture(TEXT("de")).IsValid())
+ {
+ AddWarning(TEXT("no German culture data in this build; culture switch not tested"));
+ return true;
+ }
+ I18n.SetCurrentCulture(TEXT("de"));
+
+ FVerseUiStrings Strings;
+ Strings.LoadCatalogue(FVerseUiStrings::DefaultCatalogueDir());
+ Strings.SetLanguage(TEXT("en"));
+ TestEqual(TEXT("adaptive s in English on a German machine"), Strings.Number(0.62, 2).ToString(), FString(TEXT("0.62")));
+ TestEqual(TEXT("percent in English"), Strings.Percent(0.45).ToString(), FString(TEXT("45%")));
+ TestEqual(TEXT("sensitivity in English"), Strings.Number(1.4, 1).ToString(), FString(TEXT("1.4")));
+ Strings.SetLanguage(TEXT("de"));
+ TestEqual(TEXT("adaptive s in German"), Strings.Number(0.62, 2).ToString(), FString(TEXT("0,62")));
+
+ return true;
+}
+
+// A18.2 under a lagged link: the client's server clock and the replicated poses lag by the same
+// one-way trip (AGameStateBase), updates come at 30 Hz and are extrapolated in between.
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiKillCamLaggedTest, "Verse.UI.KillCam.Lagged", Flags)
+bool FVerseUiKillCamLaggedTest::RunTest(const FString&)
+{
+ FVerseUiTestWorld W;
+ UVerseEventHub* Hub = W.World ? UVerseEventHub::Get(W.World) : nullptr;
+ if (!TestNotNull(TEXT("UI subsystem"), W.Ui) || !TestNotNull(TEXT("hub"), Hub))
+ {
+ return false;
+ }
+ auto Path = [](double T)
+ {
+ const double A = 650.0 * T / 600.0;
+ return FVector(600.0 * FMath::Cos(A), 600.0 * FMath::Sin(A), 90.0);
+ };
+ auto Velocity = [](double T)
+ {
+ const double A = 650.0 * T / 600.0;
+ return FVector(-650.0 * FMath::Sin(A), 650.0 * FMath::Cos(A), 0.0);
+ };
+ const double OneWay = 0.030; // PktLag 60: 30 ms each way
+ const double UpdateDt = 1.0 / 30.0;
+ const int32 Person = 1;
+ const int32 Killer = 2;
+ W.Source->LocalId = Person;
+ FRandomStream Rng(11);
+
+ // True server time T; the client's server clock reads T - OneWay (plus a little jitter).
+ double T = 40.0;
+ const double DeathAt = 46.0;
+ auto Feed = [&](double TrueTime)
+ {
+ const double Clock = TrueTime - OneWay + Rng.FRandRange(-0.004, 0.004);
+ const double LastUpdate = FMath::FloorToDouble((TrueTime - OneWay) / UpdateDt) * UpdateDt;
+ const FVector Shown = Path(LastUpdate) + Velocity(LastUpdate) * (Clock - LastUpdate);
+ W.Source->ServerTime = Clock;
+ W.Source->Poses = {{Killer, Shown, FRotator::ZeroRotator}};
+ };
+ while (T < DeathAt + OneWay)
+ {
+ Feed(T);
+ if (FMath::Fmod(T, 0.5) < 0.02)
+ {
+ FVerseFireEvent Fire;
+ Fire.ShooterId = Killer;
+ Fire.Origin = Path(T - OneWay);
+ Fire.Direction = FVector(1.0, 0.0, 0.0);
+ Fire.ServerTime = T - OneWay;
+ Hub->OnFire.Broadcast(Fire);
+ }
+ W.Ui->Tick(0.016f);
+ const double Step = Rng.FRandRange(0.012, 0.030);
+ T += Step;
+ W.Now += Step;
+ }
+ FVerseDeathEvent Death;
+ Death.KillerId = Killer;
+ Death.VictimId = Person;
+ Death.ServerTime = DeathAt;
+ Death.RespawnAt = DeathAt + 3.0;
+ Hub->OnDeath.Broadcast(Death);
+
+ const FVerseKillCamPlayer& Cam = W.Ui->GetKillCam();
+ TestTrue(TEXT("kill cam playing"), Cam.IsPlaying());
+ double WorstCm = 0.0;
+ int32 Samples = 0;
+ bool bSawBolt = false;
+ while (Cam.IsPlaying() && Samples < 1000)
+ {
+ const double Step = Rng.FRandRange(0.012, 0.030);
+ T += Step;
+ W.Now += Step;
+ Feed(T);
+ W.Ui->Tick(float(Step));
+ bSawBolt |= W.Ui->GetReplayBolts().Num() > 0;
+ FVector Pose;
+ FRotator Aim;
+ if (Cam.GetKillerPose(Pose, Aim))
+ {
+ // The server log at the replayed server time.
+ WorstCm = FMath::Max(WorstCm, FVector::Distance(Pose, Path(Cam.GetReplayTime())));
+ ++Samples;
+ }
+ }
+ AddInfo(FString::Printf(TEXT("one-way %.0f ms, 30 Hz updates: worst replay error %.2f cm over %d frames"), OneWay * 1000.0, WorstCm, Samples));
+ TestTrue(TEXT("frames sampled"), Samples > 50);
+ TestTrue(TEXT("killer path within 10 cm of the server log at 60 ms round trip"), WorstCm <= 10.0);
+ TestTrue(TEXT("replayed fire events draw bolts"), bSawBolt);
+ return true;
+}
+
+#endif // WITH_DEV_AUTOMATION_TESTS
diff --git a/unreal/Verse/Source/VerseUI/Private/Tests/UI/VerseUiSettingsTest.cpp b/unreal/Verse/Source/VerseUI/Private/Tests/UI/VerseUiSettingsTest.cpp
new file mode 100644
index 0000000000..5a7e404c78
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Private/Tests/UI/VerseUiSettingsTest.cpp
@@ -0,0 +1,334 @@
+#include "Events/VerseEventHub.h"
+#include "HAL/IConsoleManager.h"
+#include "Misc/AutomationTest.h"
+#include "Misc/FileHelper.h"
+#include "Misc/Paths.h"
+#include "Misc/ScopeExit.h"
+#include "Qa/VerseQaRegistry.h"
+#include "Serialization/JsonReader.h"
+#include "Serialization/JsonSerializer.h"
+#include "Settings/VerseUiSettings.h"
+#include "Tests/UI/Fakes/VerseUiFakes.h"
+#include "UObject/UnrealType.h"
+
+#if WITH_DEV_AUTOMATION_TESTS
+
+namespace VerseUiSettingsTest
+{
+ constexpr EAutomationTestFlags Flags = EAutomationTestFlags_ApplicationContextMask | EAutomationTestFlags::EngineFilter;
+
+ /** The golden fixtures of G0.11 (bridge-protocol BW11). */
+ TArray<TSharedPtr<FJsonValue>> Golden(const FString& Name)
+ {
+ FString Json;
+ TArray<TSharedPtr<FJsonValue>> Out;
+ const FString Path = FPaths::Combine(FPaths::ProjectDir(), TEXT("Tests"), TEXT("Data"), TEXT("bridge"), TEXT("messages"), Name + TEXT(".json"));
+ if (FFileHelper::LoadFileToString(Json, *Path))
+ {
+ FJsonSerializer::Deserialize(TJsonReaderFactory<>::Create(Json), Out);
+ }
+ return Out;
+ }
+
+ /** Restores the person's Unreal user settings after a test changed them. */
+ struct FUserSettingsGuard
+ {
+ UVerseUiUserSettings* Settings;
+ float DuelFov;
+ TArray<FVerseKeyBinding> Keys;
+ int32 Scalability;
+ float TextScale;
+ FName Tier;
+
+ explicit FUserSettingsGuard(UVerseUiUserSettings* In)
+ : Settings(In), DuelFov(In->DuelFov), Keys(In->KeyBindings), Scalability(In->Scalability), TextScale(In->TextScale), Tier(In->LastTier)
+ {
+ }
+ ~FUserSettingsGuard()
+ {
+ Settings->DuelFov = DuelFov;
+ Settings->KeyBindings = Keys;
+ Settings->Scalability = Scalability;
+ Settings->TextScale = TextScale;
+ Settings->LastTier = Tier;
+ Settings->SaveToDisk();
+ }
+ };
+}
+
+using namespace VerseUiSettingsTest;
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiAppSettingsJsonTest, "Verse.UI.Settings.Json", Flags)
+bool FVerseUiAppSettingsJsonTest::RunTest(const FString&)
+{
+ const TArray<TSharedPtr<FJsonValue>> Welcome = Golden(TEXT("welcome"));
+ if (!TestTrue(TEXT("welcome golden fixture present"), Welcome.Num() >= 2))
+ {
+ return false;
+ }
+ FVerseAppSettings A;
+ A.ApplyJson(Welcome[1]->AsObject()->GetObjectField(TEXT("data"))->GetObjectField(TEXT("settings")));
+ TestEqual(TEXT("gore from welcome"), A.Gore, EVerseGoreLevel::Reduced);
+ TestEqual(TEXT("return key from welcome"), A.ReturnKey, EKeys::F10);
+ TestEqual(TEXT("third-person FOV 70 (parity V-09)"), A.FovThird, 70.f);
+ TestEqual(TEXT("first-person FOV 85 (parity V-09)"), A.FovFirst, 85.f);
+
+ // Every settings.set the UI writes is a subset of welcome.settings (bridge-protocol 14).
+ const TSharedPtr<FJsonObject> Full = Welcome[0]->AsObject()->GetObjectField(TEXT("data"))->GetObjectField(TEXT("settings"));
+ FVerseAppSettings B = A;
+ B.Gore = EVerseGoreLevel::Full;
+ B.FovFirst = 90.f;
+ B.ReturnKey = EKeys::F8;
+ const TSharedRef<FJsonObject> Diff = A.Diff(B);
+ TestEqual(TEXT("diff carries the 3 changes"), Diff->Values.Num(), 3);
+ for (const TPair<FString, TSharedPtr<FJsonValue>>& Pair : Diff->Values)
+ {
+ TestTrue(FString::Printf(TEXT("%s is a welcome.settings key"), *Pair.Key), Full->HasField(Pair.Key));
+ }
+ TestEqual(TEXT("view subset"), Diff->GetObjectField(TEXT("view"))->Values.Num(), 1);
+ TestEqual(TEXT("no change, empty diff"), A.Diff(A)->Values.Num(), 0);
+
+ // The settings.set and settings.changed golden fixtures apply cleanly.
+ for (const TSharedPtr<FJsonValue>& Frame : Golden(TEXT("settings.changed")))
+ {
+ FVerseAppSettings C;
+ C.ApplyJson(Frame->AsObject()->GetObjectField(TEXT("data")));
+ if (Frame->AsObject()->GetObjectField(TEXT("data"))->HasField(TEXT("return_key")))
+ {
+ TestEqual(TEXT("settings.changed return key F9"), C.ReturnKey, EKeys::F9);
+ TestTrue(TEXT("settings.changed reduced motion"), C.bReducedMotion);
+ }
+ }
+ for (const TSharedPtr<FJsonValue>& Frame : Golden(TEXT("settings.set")))
+ {
+ FVerseAppSettings C;
+ C.ApplyJson(Frame->AsObject()->GetObjectField(TEXT("data")));
+ TestTrue(TEXT("settings.set fixture applies"), true);
+ }
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiKeyMapTest, "Verse.UI.Settings.KeyMap", Flags)
+bool FVerseUiKeyMapTest::RunTest(const FString&)
+{
+ FVerseKeyMap Map;
+ FString Error;
+ if (!TestTrue(TEXT("keys.json loads"), Map.LoadFile(FVerseKeyMap::DefaultPath(), &Error)))
+ {
+ AddError(Error);
+ return false;
+ }
+ TSet<FKey> Used;
+ for (const FVerseKeyMap::FAction& A : Map.GetActions())
+ {
+ TestFalse(FString::Printf(TEXT("default key of %s is unique"), *A.Action.ToString()), Used.Contains(A.DefaultKey));
+ Used.Add(A.DefaultKey);
+ }
+ TestEqual(TEXT("F10 returns to the app"), Map.Route(EKeys::F10), EVerseUiCommand::ReturnToApp);
+ TestEqual(TEXT("Esc opens the menu"), Map.Route(EKeys::Escape), EVerseUiCommand::EscMenu);
+ TestEqual(TEXT("W is gameplay input"), Map.Route(EKeys::W), EVerseUiCommand::None);
+
+ const FName Swapped = Map.Rebind(TEXT("reload"), EKeys::F);
+ TestEqual(TEXT("rebinding to a used key swaps"), Swapped, FName(TEXT("interact")));
+ TestEqual(TEXT("reload on F"), Map.GetKey(TEXT("reload")), EKeys::F);
+ TestEqual(TEXT("interact took R"), Map.GetKey(TEXT("interact")), EKeys::R);
+ TestEqual(TEXT("Esc cannot be bound"), Map.Rebind(TEXT("jump"), EKeys::Escape), FName(NAME_None));
+ TestEqual(TEXT("jump unchanged"), Map.GetKey(TEXT("jump")), EKeys::SpaceBar);
+
+ FVerseKeyMap Reloaded;
+ Reloaded.LoadFile(FVerseKeyMap::DefaultPath());
+ Reloaded.SetBindings(Map.GetBindings());
+ TestEqual(TEXT("bindings round-trip"), Reloaded.GetKey(TEXT("reload")), EKeys::F);
+ return true;
+}
+
+// A18.5: every setting keeps its value across a Verse restart.
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiSettingsPersistTest, "Verse.UI.Settings.Persist", Flags)
+bool FVerseUiSettingsPersistTest::RunTest(const FString&)
+{
+ TSharedPtr<FFakeVerseUiBridgePort> Backend = MakeShared<FFakeVerseUiBridgePort>();
+ {
+ FVerseUiTestWorld First(Backend);
+ if (!TestNotNull(TEXT("UI subsystem"), First.Ui))
+ {
+ return false;
+ }
+ FUserSettingsGuard Guard(First.Ui->GetUserSettings());
+ const EVerseGoreLevel GoreBefore = UVerseUiSubsystem::ReadGoreSetting();
+ ON_SCOPE_EXIT { UVerseUiSubsystem::WriteGoreSetting(nullptr, GoreBefore); };
+ First.Ui->ApplyWelcome(Backend->MakeWelcome());
+
+ // Unreal-side settings.
+ First.Ui->SetDuelFov(95.f);
+ First.Ui->SetScalability(2);
+ First.Ui->SetTextScale(1.3f);
+ First.Ui->RebindKey(TEXT("reload"), EKeys::H);
+ First.Ui->GetArmoury().SelectTier(TEXT("elite"));
+ First.Ui->StartDuelFromArmoury();
+ // App-backed settings.
+ First.Ui->SetGore(EVerseGoreLevel::Reduced);
+ First.Ui->SetReducedMotion(true);
+ FVerseAppSettings Next = First.Ui->GetAppSettings();
+ Next.FovThird = 75.f;
+ Next.FovFirst = 90.f;
+ Next.Sensitivity = 1.4f;
+ Next.bInvertY = true;
+ Next.Volume = 0.45f;
+ Next.bUiSound = false;
+ First.Ui->SetAppSettings(Next);
+
+ // "Restart": a fresh settings object reads the user settings file back.
+ UVerseUiUserSettings* Fresh = NewObject<UVerseUiUserSettings>();
+ Fresh->ReloadFromDisk();
+ TestEqual(TEXT("duel FOV persists"), Fresh->DuelFov, 95.f);
+ TestEqual(TEXT("scalability persists"), Fresh->Scalability, 2);
+ TestTrue(TEXT("text size persists"), FMath::IsNearlyEqual(Fresh->TextScale, 1.3f, 1e-4f));
+ TestEqual(TEXT("last tier persists"), Fresh->LastTier, FName(TEXT("elite")));
+ FVerseKeyMap Map;
+ Map.LoadFile(FVerseKeyMap::DefaultPath());
+ Map.SetBindings(Fresh->KeyBindings);
+ TestEqual(TEXT("key binding persists"), Map.GetKey(TEXT("reload")), EKeys::H);
+
+ // A new Verse process gets the app's stored settings in welcome.
+ {
+ FVerseUiTestWorld Second(MakeShared<FFakeVerseUiBridgePort>());
+ Second.Ui->ApplyWelcome(Backend->MakeWelcome());
+ const FVerseAppSettings& S = Second.Ui->GetAppSettings();
+ TestEqual(TEXT("gore persists"), S.Gore, EVerseGoreLevel::Reduced);
+ TestTrue(TEXT("reduced motion persists"), S.bReducedMotion);
+ TestEqual(TEXT("third-person FOV persists"), S.FovThird, 75.f);
+ TestEqual(TEXT("first-person FOV persists"), S.FovFirst, 90.f);
+ TestTrue(TEXT("sensitivity persists"), FMath::IsNearlyEqual(S.Sensitivity, 1.4f, 1e-4f));
+ TestTrue(TEXT("invert persists"), S.bInvertY);
+ TestTrue(TEXT("volume persists"), FMath::IsNearlyEqual(S.Volume, 0.45f, 1e-4f));
+ TestFalse(TEXT("interface sound persists"), S.bUiSound);
+ TestEqual(TEXT("duel FOV restored in the new process"), Second.Ui->GetUserSettings()->DuelFov, 95.f);
+ TestEqual(TEXT("armoury tier restored"), Second.Ui->GetArmoury().GetSelectedTier(), FName(TEXT("elite")));
+ IConsoleVariable* Fov = IConsoleManager::Get().FindConsoleVariable(TEXT("Verse.Settings.DuelFov"));
+ TestTrue(TEXT("duel FOV published for the camera owner"), Fov && FMath::IsNearlyEqual(Fov->GetFloat(), 95.f));
+ }
+ }
+ return true;
+}
+
+// A18.5: rebinding the return key to F8 makes F8 send focus.return_to_app and F10 do nothing.
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiReturnKeyTest, "Verse.UI.Settings.ReturnKey", Flags)
+bool FVerseUiReturnKeyTest::RunTest(const FString&)
+{
+ FVerseUiTestWorld W;
+ if (!TestNotNull(TEXT("UI subsystem"), W.Ui))
+ {
+ return false;
+ }
+ FUserSettingsGuard Guard(W.Ui->GetUserSettings());
+ W.Ui->ApplyWelcome(W.Bridge->MakeWelcome());
+ TestTrue(TEXT("F10 returns by default"), W.Ui->HandleKey(EKeys::F10));
+ TestEqual(TEXT("one return frame"), W.Bridge->Count(TEXT("focus.return_to_app")), 1);
+ W.Bridge->Frames.Reset();
+
+ W.Ui->SetReturnKey(EKeys::F8);
+ TestEqual(TEXT("one settings.set for the rebind"), W.Bridge->Count(TEXT("settings.set")), 1);
+ FString Key;
+ TestTrue(TEXT("settings.set carries return_key F8"),
+ W.Bridge->Last(TEXT("settings.set"))->Data->TryGetStringField(TEXT("return_key"), Key) && Key == TEXT("F8"));
+
+ TestTrue(TEXT("F8 is used"), W.Ui->HandleKey(EKeys::F8));
+ const FFakeVerseUiBridgePort::FFrame* Return = W.Bridge->Last(TEXT("focus.return_to_app"));
+ TestTrue(TEXT("F8 sends focus.return_to_app {reason: return_key}"), Return && Return->Data->GetStringField(TEXT("reason")) == TEXT("return_key"));
+ const int32 Before = W.Bridge->Frames.Num();
+ TestFalse(TEXT("F10 is not used any more"), W.Ui->HandleKey(EKeys::F10));
+ TestEqual(TEXT("F10 sends nothing"), W.Bridge->Frames.Num(), Before);
+
+ // The app's echo (settings.changed) keeps it, and the next welcome carries it.
+ FVerseUiTestWorld Restart;
+ Restart.Ui->ApplyWelcome(W.Bridge->MakeWelcome());
+ TestEqual(TEXT("return key after restart"), Restart.Ui->GetKeyMap().GetKey(FVerseKeyMap::ReturnAction()), EKeys::F8);
+ TestTrue(TEXT("F8 after restart"), Restart.Ui->HandleKey(EKeys::F8));
+ TestFalse(TEXT("F10 after restart"), Restart.Ui->HandleKey(EKeys::F10));
+ return true;
+}
+
+// A18.5: a gore change sends one settings.set and the next welcome carries it.
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiGoreSettingTest, "Verse.UI.Settings.Gore", Flags)
+bool FVerseUiGoreSettingTest::RunTest(const FString&)
+{
+ FVerseUiTestWorld W;
+ if (!TestNotNull(TEXT("UI subsystem"), W.Ui))
+ {
+ return false;
+ }
+ const EVerseGoreLevel Before = UVerseUiSubsystem::ReadGoreSetting();
+ ON_SCOPE_EXIT { UVerseUiSubsystem::WriteGoreSetting(nullptr, Before); };
+ W.Ui->ApplyWelcome(W.Bridge->MakeWelcome());
+ W.Bridge->Frames.Reset();
+ W.Ui->SetGore(EVerseGoreLevel::Reduced);
+ TestEqual(TEXT("exactly one settings.set"), W.Bridge->Count(TEXT("settings.set")), 1);
+ TestEqual(TEXT("frame data"), FFakeVerseUiBridgePort::ToString(W.Bridge->Frames[0].Data), FString(TEXT("{\"gore\":\"reduced\"}")));
+ W.Ui->SetGore(EVerseGoreLevel::Reduced);
+ TestEqual(TEXT("setting the same value again sends nothing"), W.Bridge->Count(TEXT("settings.set")), 1);
+
+ const TSharedRef<FJsonObject> Welcome = W.Bridge->MakeWelcome();
+ TestEqual(TEXT("the next welcome carries gore reduced"), Welcome->GetObjectField(TEXT("settings"))->GetStringField(TEXT("gore")), FString(TEXT("reduced")));
+ FVerseUiTestWorld Restart;
+ Restart.Ui->ApplyWelcome(Welcome);
+ TestEqual(TEXT("restarted Verse reads gore reduced"), Restart.Ui->GetAppSettings().Gore, EVerseGoreLevel::Reduced);
+ // VerseGore reads UVerseSettings::GoreLevel from GameUserSettings (combat-state 8, WP05).
+ TestEqual(TEXT("UVerseSettings GoreLevel as VerseGore reads it"), UVerseUiSubsystem::ReadGoreSetting(), EVerseGoreLevel::Reduced);
+ if (UClass* VerseSettings = FindObject<UClass>(nullptr, TEXT("/Script/Verse.VerseSettings")))
+ {
+ const FEnumProperty* Prop = FindFProperty<FEnumProperty>(VerseSettings, TEXT("GoreLevel"));
+ TestTrue(TEXT("UVerseSettings default object carries Reduced"),
+ Prop && Prop->GetUnderlyingProperty()->GetSignedIntPropertyValue(Prop->ContainerPtrToValuePtr<void>(VerseSettings->GetDefaultObject())) == int64(EVerseGoreLevel::Reduced));
+ }
+ else
+ {
+ AddWarning(TEXT("Verse module not loaded: UVerseSettings default object not checked"));
+ }
+
+ // settings.changed from the app applies live.
+ TSharedRef<FJsonObject> Changed = MakeShared<FJsonObject>();
+ Changed->SetStringField(TEXT("gore"), TEXT("full"));
+ Restart.Ui->ApplySettingsChanged(Changed);
+ TestEqual(TEXT("settings.changed applies"), Restart.Ui->GetAppSettings().Gore, EVerseGoreLevel::Full);
+ TestEqual(TEXT("settings.changed reaches VerseGore's setting"), UVerseUiSubsystem::ReadGoreSetting(), EVerseGoreLevel::Full);
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiDuelFovTest, "Verse.UI.Settings.DuelFov", Flags)
+bool FVerseUiDuelFovTest::RunTest(const FString&)
+{
+ UVerseUiUserSettings* Defaults = NewObject<UVerseUiUserSettings>();
+ TestEqual(TEXT("default duel FOV 100 (bot.md 3.1)"), Defaults->DuelFov, 100.f);
+ Defaults->DuelFov = 140.f;
+ Defaults->Clamp();
+ TestEqual(TEXT("clamped to 110"), Defaults->DuelFov, 110.f);
+ Defaults->DuelFov = 40.f;
+ Defaults->Clamp();
+ TestEqual(TEXT("clamped to 80"), Defaults->DuelFov, 80.f);
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiQaStatsTest, "Verse.UI.QA.Stats", Flags)
+bool FVerseUiQaStatsTest::RunTest(const FString&)
+{
+ FVerseUiTestWorld W;
+ UVerseQaRegistry* Registry = UVerseQaRegistry::Get();
+ if (!TestNotNull(TEXT("QA registry"), Registry))
+ {
+ return false;
+ }
+ FString Result;
+ TestTrue(TEXT("Verse.QA.Stats is registered"), Registry->Execute(TEXT("Verse.QA.Stats"), {}, Result));
+ TSharedPtr<FJsonObject> Json;
+ TestTrue(TEXT("returns JSON"), FJsonSerializer::Deserialize(TJsonReaderFactory<>::Create(Result), Json) && Json.IsValid());
+ if (Json.IsValid())
+ {
+ for (const TCHAR* Field : {TEXT("fps"), TEXT("frame_ms"), TEXT("tier"), TEXT("state")})
+ {
+ TestTrue(FString::Printf(TEXT("field %s (parity Q-01)"), Field), Json->HasField(Field));
+ }
+ }
+ return true;
+}
+
+#endif // WITH_DEV_AUTOMATION_TESTS
diff --git a/unreal/Verse/Source/VerseUI/Private/Tests/UI/VerseUiStringsMenusTest.cpp b/unreal/Verse/Source/VerseUI/Private/Tests/UI/VerseUiStringsMenusTest.cpp
new file mode 100644
index 0000000000..07f8feb3a6
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Private/Tests/UI/VerseUiStringsMenusTest.cpp
@@ -0,0 +1,445 @@
+#include "Core/VerseUiStrings.h"
+#include "Events/VerseEventHub.h"
+#include "Framework/Application/SlateApplication.h"
+#include "Hud/VerseHudPainter.h"
+#include "HAL/FileManager.h"
+#include "Internationalization/Regex.h"
+#include "Menus/VerseUiMenus.h"
+#include "Misc/AutomationTest.h"
+#include "Misc/FileHelper.h"
+#include "Misc/Paths.h"
+#include "Tests/UI/Fakes/VerseUiFakes.h"
+
+#if WITH_DEV_AUTOMATION_TESTS
+
+namespace VerseUiStringsTest
+{
+ constexpr EAutomationTestFlags Flags = EAutomationTestFlags_ApplicationContextMask | EAutomationTestFlags::EngineFilter;
+
+ FString SourceDir()
+ {
+ return FPaths::Combine(FPaths::GameSourceDir(), TEXT("VerseUI"));
+ }
+
+ TSet<FString> Placeholders(const FString& Text)
+ {
+ TSet<FString> Out;
+ FRegexMatcher M(FRegexPattern(TEXT("\\{([a-z_]+)\\}")), Text);
+ while (M.FindNext())
+ {
+ Out.Add(M.GetCaptureGroup(1));
+ }
+ return Out;
+ }
+
+ /** Every text WP18 lays out in a box of fixed width: key, reference width, point size, bold. */
+ struct FFixedBox
+ {
+ FString Key;
+ float Width;
+ int32 Size;
+ bool bBold;
+ };
+}
+
+using namespace VerseUiStringsTest;
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiCatalogueTest, "Verse.UI.Strings.Catalogue", Flags)
+bool FVerseUiCatalogueTest::RunTest(const FString&)
+{
+ FVerseUiStrings Strings;
+ FString Error;
+ if (!TestTrue(TEXT("the strings catalogue loads"), Strings.LoadCatalogue(FVerseUiStrings::DefaultCatalogueDir(), &Error)))
+ {
+ AddError(Error);
+ return false;
+ }
+ int32 Missing = 0;
+ for (const FString& Key : Strings.GetKeys())
+ {
+ const TSet<FString> English = Placeholders(Strings.GetIn(Key, TEXT("en")));
+ for (const FString& Lang : FVerseUiStrings::SupportedLanguages())
+ {
+ const FString Text = Strings.GetIn(Key, Lang);
+ if (Text.IsEmpty())
+ {
+ AddError(FString::Printf(TEXT("%s has no %s text"), *Key, *Lang));
+ ++Missing;
+ continue;
+ }
+ const TSet<FString> Here = Placeholders(Text);
+ TestTrue(FString::Printf(TEXT("%s/%s keeps the placeholders"), *Key, *Lang), Here.Num() == English.Num() && Here.Includes(English));
+ }
+ }
+ TestEqual(TEXT("missing translations"), Missing, 0);
+ TestTrue(TEXT("catalogue is not empty"), Strings.GetKeys().Num() > 100);
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiBridgeStringsTest, "Verse.UI.Strings.Bridge", Flags)
+bool FVerseUiBridgeStringsTest::RunTest(const FString&)
+{
+ FVerseUiStrings Strings;
+ Strings.LoadCatalogue(FVerseUiStrings::DefaultCatalogueDir());
+ TSharedRef<FJsonObject> Locale = MakeShared<FJsonObject>();
+ Locale->SetStringField(TEXT("lang"), TEXT("de"));
+ Locale->SetStringField(TEXT("fallback"), TEXT("en"));
+ TSharedRef<FJsonObject> Table = MakeShared<FJsonObject>();
+ Table->SetStringField(TEXT("verse.menu.resume"), TEXT("Fortsetzen"));
+ Locale->SetObjectField(TEXT("strings"), Table);
+ Strings.ApplyBridgeLocale(Locale);
+ TestEqual(TEXT("language from welcome"), Strings.GetLanguage(), FString(TEXT("de")));
+ TestEqual(TEXT("bridge string wins"), Strings.Get(TEXT("verse.menu.resume")).ToString(), FString(TEXT("Fortsetzen")));
+ TestEqual(TEXT("catalogue in the language"), Strings.Get(TEXT("verse.settings.text_size")).ToString(), FString(TEXT("Textgröße")));
+
+ TSharedRef<FJsonObject> Changed = MakeShared<FJsonObject>();
+ Changed->SetStringField(TEXT("lang"), TEXT("zh-CN"));
+ Strings.ApplySettingsChanged(Changed);
+ TestEqual(TEXT("settings.changed switches language"), Strings.GetLanguage(), FString(TEXT("zh")));
+ TestEqual(TEXT("old bridge strings dropped on a switch"), Strings.NumBridgeStrings(), 0);
+ TestEqual(TEXT("chinese text"), Strings.Get(TEXT("verse.ui.back")).ToString(), FString(TEXT("返回")));
+
+ Strings.SetLanguage(TEXT("fr"));
+ TestEqual(TEXT("an unknown language falls back to English"), Strings.GetLanguage(), FString(TEXT("en")));
+ TestEqual(TEXT("a missing key shows itself"), Strings.Get(TEXT("verse.no.such.key")).ToString(), FString(TEXT("verse.no.such.key")));
+ FFormatNamedArguments Args;
+ Args.Add(TEXT("seconds"), FText::AsNumber(2));
+ TestEqual(TEXT("format"), Strings.Format(TEXT("verse.hud.respawn_in"), Args).ToString(), FString(TEXT("Redeploying in 2")));
+ return true;
+}
+
+// A18.4 (scan): 0 hard-coded user strings in VerseUI; every key the code names exists.
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiNoHardCodedStringsTest, "Verse.UI.Strings.NoHardCoded", Flags)
+bool FVerseUiNoHardCodedStringsTest::RunTest(const FString&)
+{
+ TArray<FString> Files;
+ IFileManager::Get().FindFilesRecursive(Files, *SourceDir(), TEXT("*.cpp"), true, false);
+ IFileManager::Get().FindFilesRecursive(Files, *SourceDir(), TEXT("*.h"), true, false, false);
+ if (!TestTrue(TEXT("VerseUI sources found"), Files.Num() > 5))
+ {
+ return false;
+ }
+ FVerseUiStrings Strings;
+ Strings.LoadCatalogue(FVerseUiStrings::DefaultCatalogueDir());
+ const TSet<FString> Keys(Strings.GetKeys());
+
+ // Text literals that would reach a person without the string table.
+ const FRegexPattern Forbidden(TEXT("LOCTEXT\\s*\\(|NSLOCTEXT\\s*\\(|INVTEXT\\s*\\(|FText::FromString\\s*\\(\\s*TEXT|AsCultureInvariant\\s*\\(\\s*TEXT|FText::FromName\\s*\\(\\s*TEXT"));
+ const FRegexPattern KeyLiteral(TEXT("TEXT\\(\"(verse\\.[a-z0-9_.]+)\"\\)"));
+ int32 HardCoded = 0;
+ int32 Unknown = 0;
+ int32 Named = 0;
+ for (const FString& File : Files)
+ {
+ const FString Normal = FPaths::ConvertRelativePathToFull(File).Replace(TEXT("\\"), TEXT("/"));
+ // Tests may name strings freely; Stations, ServiceRecord and Audio belong to other packages.
+ if (Normal.Contains(TEXT("/Tests/")) || Normal.Contains(TEXT("/Stations/")) || Normal.Contains(TEXT("/ServiceRecord/")) || Normal.Contains(TEXT("/Audio/")))
+ {
+ continue;
+ }
+ FString Text;
+ FFileHelper::LoadFileToString(Text, *File);
+ FRegexMatcher Bad(Forbidden, Text);
+ while (Bad.FindNext())
+ {
+ ++HardCoded;
+ AddError(FString::Printf(TEXT("hard-coded text in %s at %d"), *FPaths::GetCleanFilename(File), Bad.GetMatchBeginning()));
+ }
+ FRegexMatcher K(KeyLiteral, Text);
+ while (K.FindNext())
+ {
+ const FString Key = K.GetCaptureGroup(1);
+ // Prefixes that the code completes with an id (verse.item.%s.name and the like) are
+ // checked below from the data that supplies the ids.
+ if (Key.EndsWith(TEXT(".")) || Key.StartsWith(TEXT("verse.qa")))
+ {
+ continue;
+ }
+ ++Named;
+ if (!Keys.Contains(Key))
+ {
+ // Console variable and command names share the verse. prefix only in lower case
+ // by accident; every one of them is capitalised (Verse.Settings.*), so any
+ // lower-case verse.* literal is a string key.
+ ++Unknown;
+ AddError(FString::Printf(TEXT("%s names %s, which the strings catalogue lacks"), *FPaths::GetCleanFilename(File), *Key));
+ }
+ }
+ }
+ AddInfo(FString::Printf(TEXT("%d source files, %d string keys named"), Files.Num(), Named));
+ TestEqual(TEXT("hard-coded user strings"), HardCoded, 0);
+ TestEqual(TEXT("keys missing from the strings catalogue"), Unknown, 0);
+
+ // Keys built from data.
+ FVerseKeyMap Map;
+ Map.LoadFile(FVerseKeyMap::DefaultPath());
+ for (const FVerseKeyMap::FAction& A : Map.GetActions())
+ {
+ TestTrue(FString::Printf(TEXT("label %s"), *A.LabelKey), Keys.Contains(A.LabelKey));
+ }
+ FVerseArmouryModel Armoury;
+ Armoury.LoadFile(FVerseArmouryModel::DefaultPath());
+ for (const FVerseArmouryItem& Item : Armoury.GetLoadout())
+ {
+ for (const TCHAR* Field : {TEXT("name"), TEXT("role"), TEXT("short")})
+ {
+ const FString Key = FString::Printf(TEXT("verse.item.%s.%s"), *Item.ItemId.ToString(), Field);
+ TestTrue(Key, Keys.Contains(Key));
+ }
+ const FString SlotKey = FString::Printf(TEXT("verse.armoury.slot.%s"), *StaticEnum<EVerseLoadoutSlot>()->GetNameStringByValue(int64(Item.Slot)).ToLower());
+ TestTrue(SlotKey, Keys.Contains(SlotKey));
+ }
+ for (const FName& Tier : Armoury.GetTiers())
+ {
+ TestTrue(TEXT("tier name"), Keys.Contains(FString::Printf(TEXT("verse.tier.%s"), *Tier.ToString())));
+ TestTrue(TEXT("tier description"), Keys.Contains(FString::Printf(TEXT("verse.tier.%s.desc"), *Tier.ToString())));
+ }
+ for (const TCHAR* Deck : {TEXT("bridge"), TEXT("ops"), TEXT("engineering"), TEXT("hangar")})
+ {
+ TestTrue(TEXT("deck name"), Keys.Contains(FString::Printf(TEXT("verse.deck.%s"), Deck)));
+ }
+ return true;
+}
+
+// A18.4 (layout): the 5 locales render without clipping at 1080p.
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiNoClippingTest, "Verse.UI.Strings.NoClipping", Flags)
+bool FVerseUiNoClippingTest::RunTest(const FString&)
+{
+ const FVerseTextMeasure Measure = FVerseHudPainter::DefaultMeasure();
+ AddInfo(FSlateApplication::IsInitialized() ? TEXT("measuring with the Slate font cache") : TEXT("measuring with the estimate"));
+ int32 Clipped = 0;
+ for (const FString& Lang : FVerseUiStrings::SupportedLanguages())
+ {
+ FVerseUiStrings Strings;
+ Strings.LoadCatalogue(FVerseUiStrings::DefaultCatalogueDir());
+ Strings.SetLanguage(Lang);
+
+ // HUD: a frame with every block, long names, through the real painter.
+ FFakeVerseHudSource Source;
+ Source.Names.Add(2, TEXT("Opponent"));
+ Source.Bots.Add(2);
+ Source.Pawn.bValid = true;
+ Source.Pawn.Stance = EVerseStance::Prone;
+ Source.Pawn.bSpawnProtected = true;
+ Source.Pawn.SpawnProtectionRemaining = 1.9f;
+ Source.Pawn.bHasWeapon = true;
+ Source.Pawn.WeaponId = TEXT("breach_charge");
+ Source.Pawn.Magazine = 888;
+ Source.Pawn.MagazineSize = 999;
+ Source.Pawn.Reserve = 888;
+ Source.Pawn.bReloading = true;
+ Source.Pawn.bTacticalReload = false;
+ Source.Pawn.Gadgets = {{TEXT("bulwark"), 1, 1, 18.f}, {TEXT("breach_charge"), 2, 2, 0.f}};
+ FVerseHudModel Model;
+ Model.SetLocalPlayerId(1);
+ FVerseHitEvent Wall;
+ Wall.InstigatorId = 2;
+ Wall.VictimId = 1;
+ Wall.PenetrationCount = 2;
+ Wall.bHeadshot = 1;
+ Model.OnHit(Wall, 0.0);
+ FVerseDeathEvent D;
+ D.KillerId = 2;
+ D.VictimId = 1;
+ D.WeaponId = TEXT("breach_charge");
+ D.Cause = EVerseDamageSource::Gadget;
+ D.RespawnAt = 102.0;
+ Model.OnDeath(D, 0.0);
+ FVerseSetSummary Sum;
+ Sum.Outcome = EVerseSetOutcome::Unfinished;
+ Model.OnSetEnded(Sum, 0.0);
+ for (int32 Mode = 0; Mode < 2; ++Mode)
+ {
+ FVerseHudFrame Frame;
+ Frame.Model = &Model;
+ Frame.Strings = &Strings;
+ Frame.Source = &Source;
+ Frame.Layout = FVerseUiLayout::Compute(FVector2D(1920, 1080), 0.025f, FMargin(0), 1.f);
+ Source.GetPawnState(Frame.Pawn);
+ Frame.bHasView = true;
+ Frame.ServerTime = 100.0;
+ Frame.bKillCam = Mode == 0;
+ Frame.KillCamKillerId = 2;
+ Frame.SkipKeyName = EKeys::Enter.GetDisplayName();
+ FVerseHudDrawList List;
+ FVerseHudPainter::Paint(Frame, List, Measure);
+ for (const FVerseHudDrawList::FLabel& L : List.Labels)
+ {
+ const bool bFits = (L.MaxWidth <= 0.f || L.Size.X <= L.MaxWidth + 0.5f) && L.Position.X >= -0.5 && L.Position.X + L.Size.X <= 1920.5;
+ if (!bFits)
+ {
+ ++Clipped;
+ AddError(FString::Printf(TEXT("%s: HUD %s \"%s\" is %.0f px in %.0f px"), *Lang, *L.Tag.ToString(), *L.Text.ToString(), L.Size.X, L.MaxWidth));
+ }
+ }
+ }
+
+ // Menus: the fixed-width boxes of SVerseUiRoot (1080p reference, the DPI curve scales them).
+ TArray<FFixedBox> Boxes;
+ for (const FString& Key : Strings.GetKeys())
+ {
+ if (Key.StartsWith(TEXT("verse.settings.")) && !Key.Contains(TEXT(".page.")) && !Key.Contains(TEXT(".quality.")) && !Key.Contains(TEXT(".gore.")) && Key != TEXT("verse.settings.title") && Key != TEXT("verse.settings.markers_note") && Key != TEXT("verse.settings.press_key"))
+ {
+ Boxes.Add({Key, 1000.f - 4.f - 56.f - 304.f - 20.f, 15, false});
+ }
+ if (Key.StartsWith(TEXT("verse.key.")))
+ {
+ Boxes.Add({Key, 1000.f - 4.f - 56.f - 240.f - 20.f, 15, false});
+ }
+ if (Key.StartsWith(TEXT("verse.settings.page.")))
+ {
+ Boxes.Add({Key, (1000.f - 60.f) / 5.f - 4.f - 5.f - 32.f, 15, true});
+ }
+ if (Key.StartsWith(TEXT("verse.settings.quality.")) || Key.StartsWith(TEXT("verse.settings.gore.")) || Key == TEXT("verse.ui.on") || Key == TEXT("verse.ui.off"))
+ {
+ Boxes.Add({Key, 200.f, 15, true});
+ }
+ if (Key.StartsWith(TEXT("verse.armoury.slot.")))
+ {
+ Boxes.Add({Key, 170.f, 12, true});
+ }
+ if (Key.StartsWith(TEXT("verse.tier.")) && !Key.EndsWith(TEXT(".desc")))
+ {
+ Boxes.Add({Key, (860.f - 60.f) / 4.f - 4.f - 5.f - 32.f, 15, true});
+ }
+ if (Key.StartsWith(TEXT("verse.end.row.")))
+ {
+ Boxes.Add({Key, (720.f - 60.f) * 0.5f, 15, false});
+ }
+ if (Key.StartsWith(TEXT("verse.menu.")) && Key != TEXT("verse.menu.title"))
+ {
+ Boxes.Add({Key, 460.f - 60.f - 5.f - 32.f, 15, true});
+ }
+ if (Key == TEXT("verse.armoury.start") || Key == TEXT("verse.end.next"))
+ {
+ Boxes.Add({Key, (860.f - 60.f) * 2.f / 3.f - 37.f, 15, true});
+ }
+ if (Key == TEXT("verse.end.leave"))
+ {
+ Boxes.Add({Key, (720.f - 60.f) / 3.f - 43.f, 15, true});
+ }
+ }
+ // Settings press-key text and key names sit in the 240 px key button.
+ Boxes.Add({TEXT("verse.settings.press_key"), 240.f - 37.f, 15, true});
+ for (const FFixedBox& Box : Boxes)
+ {
+ const FVector2D Size = Measure(Strings.Get(Box.Key), Box.Size, Box.bBold);
+ if (Size.X > Box.Width)
+ {
+ ++Clipped;
+ AddError(FString::Printf(TEXT("%s: %s \"%s\" is %.0f px in %.0f px"), *Lang, *Box.Key, *Strings.Get(Box.Key).ToString(), Size.X, Box.Width));
+ }
+ }
+ }
+ TestEqual(TEXT("clipped texts over 5 locales at 1080p"), Clipped, 0);
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiArmouryTest, "Verse.UI.Menus.Armoury", Flags)
+bool FVerseUiArmouryTest::RunTest(const FString&)
+{
+ FVerseUiTestWorld W;
+ if (!TestNotNull(TEXT("UI subsystem"), W.Ui))
+ {
+ return false;
+ }
+ const FName SavedTier = W.Ui->GetUserSettings()->LastTier;
+ FVerseArmouryModel& Armoury = W.Ui->GetArmoury();
+ TestEqual(TEXT("loadout of combat-state 2.2"), Armoury.GetLoadout().Num(), 5);
+ TestEqual(TEXT("primary is the rifle"), Armoury.GetLoadout()[0].ItemId, FName(TEXT("graveline")));
+ TestEqual(TEXT("four tiers"), Armoury.GetTiers().Num(), 4);
+ TestFalse(TEXT("unknown tier refused"), Armoury.SelectTier(TEXT("impossible")));
+
+ FVerseStationUsedEvent Used;
+ Used.Kind = TEXT("armoury");
+ Used.StationId = TEXT("hangar.armoury.1");
+ Used.UserId = W.Source->LocalId;
+ UVerseEventHub::Get(W.World)->OnStationUsed.Broadcast(Used);
+ TestEqual(TEXT("the armoury station opens the armoury"), W.Ui->GetScreen(), EVerseUiScreen::Armoury);
+
+ Armoury.SelectTier(TEXT("normal"));
+ Armoury.CycleTier(-1);
+ TestEqual(TEXT("cycling wraps"), Armoury.GetSelectedTier(), FName(TEXT("adaptive")));
+ W.Ui->StartDuelFromArmoury();
+ TestEqual(TEXT("start duel asks for the chosen tier"), W.Game->Started.Num() > 0 ? W.Game->Started.Last() : FName(), FName(TEXT("adaptive")));
+ TestEqual(TEXT("armoury closes"), W.Ui->GetScreen(), EVerseUiScreen::None);
+ W.Ui->GetUserSettings()->LastTier = SavedTier;
+ W.Ui->GetUserSettings()->SaveToDisk();
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiBarTest, "Verse.UI.Menus.Bar", Flags)
+bool FVerseUiBarTest::RunTest(const FString&)
+{
+ const TArray<FName> Decks = {TEXT("bridge"), TEXT("ops"), TEXT("engineering"), TEXT("hangar")};
+ TArray<FVerseBarEntry> Idle = FVerseBarModel::Build(Decks, TEXT("ops"), false);
+ TestEqual(TEXT("quick duel, 4 decks, return"), Idle.Num(), 6);
+ TestEqual(TEXT("first is quick duel"), Idle[0].Kind, EVerseBarEntryKind::QuickStartDuel);
+ TestTrue(TEXT("current deck marked"), Idle[2].bActive);
+ TestEqual(TEXT("last returns to the app"), Idle.Last().Kind, EVerseBarEntryKind::ReturnToApp);
+ TArray<FVerseBarEntry> InDuel = FVerseBarModel::Build(Decks, TEXT("hangar"), true);
+ TestEqual(TEXT("in a duel the first entry leaves it"), InDuel[0].LabelKey, FString(TEXT("verse.bar.leave_duel")));
+ TestFalse(TEXT("other decks wait until the duel is left"), InDuel[1].bEnabled);
+
+ FVerseUiTestWorld W;
+ W.Ui->QuickStartDuel();
+ TestEqual(TEXT("quick start uses the last tier"), W.Game->Started.Num(), 1);
+ TestEqual(TEXT("quick start tier"), W.Game->Started[0], W.Ui->GetUserSettings()->LastTier);
+ W.Ui->LeaveDuel();
+ TestEqual(TEXT("leave"), W.Game->Left, 1);
+ TestEqual(TEXT("leave shows the session summary"), W.Ui->GetScreen(), EVerseUiScreen::SessionSummary);
+ W.Ui->ShowScreen(EVerseUiScreen::None);
+ W.Ui->TravelToDeck(TEXT("engineering"));
+ TestEqual(TEXT("deck navigation"), W.Game->CurrentDeck, FName(TEXT("engineering")));
+ W.Ui->ReturnToApp(TEXT("esc_menu"));
+ TestEqual(TEXT("return to app from the bar"), W.Bridge->Count(TEXT("focus.return_to_app")), 1);
+ TestTrue(TEXT("Tab toggles the bar"), W.Ui->HandleKey(EKeys::Tab) && W.Ui->IsBarOpen());
+ TestTrue(TEXT("Esc opens the menu"), W.Ui->HandleKey(EKeys::Escape) && W.Ui->GetScreen() == EVerseUiScreen::EscMenu);
+ TestTrue(TEXT("Esc closes it"), W.Ui->HandleKey(EKeys::Escape) && W.Ui->GetScreen() == EVerseUiScreen::None);
+ TestFalse(TEXT("Enter is free when no kill cam runs"), W.Ui->HandleKey(EKeys::Enter));
+ return true;
+}
+
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiEndScreenTest, "Verse.UI.Menus.EndOfSet", Flags)
+bool FVerseUiEndScreenTest::RunTest(const FString&)
+{
+ FVerseSetSummary Summary;
+ Summary.SetIndex = 3;
+ Summary.BotTier = TEXT("adaptive");
+ Summary.Outcome = EVerseSetOutcome::Won;
+ Summary.Person.PlayerId = 1;
+ Summary.Person.Kills = 10;
+ Summary.Person.Deaths = 7;
+ Summary.Person.ShotsFired = 200;
+ Summary.Person.ShotsHit = 61;
+ Summary.Opponent.PlayerId = 2;
+ Summary.Opponent.bIsBot = true;
+ Summary.Opponent.Kills = 7;
+ Summary.Opponent.Deaths = 10;
+ const FVerseEndScreen Screen = FVerseEndScreen::Build(Summary, 0.62f);
+ TestEqual(TEXT("won title"), Screen.TitleKey, FString(TEXT("verse.end.won")));
+ TestTrue(TEXT("adaptive s shown"), Screen.bShowSkill && FMath::IsNearlyEqual(Screen.Skill, 0.62f));
+ TestEqual(TEXT("nine rows"), Screen.Rows.Num(), 9);
+ TestEqual(TEXT("K/D"), Screen.Rows[2].Person.ToString(), FString(TEXT("1.43")));
+ // The Verse language picks the number format, whatever the machine's culture is.
+ TestEqual(TEXT("K/D in German"), FVerseEndScreen::Build(Summary, 0.62f, TEXT("de")).Rows[2].Person.ToString(), FString(TEXT("1,43")));
+ FVerseSetSummary Hard = Summary;
+ Hard.BotTier = TEXT("hard");
+ TestFalse(TEXT("no s for a fixed tier"), FVerseEndScreen::Build(Hard, -1.f).bShowSkill);
+
+ FVerseUiTestWorld W;
+ W.Source->Bots.Add(2);
+ W.Source->Skill = 0.62f;
+ UVerseEventHub::Get(W.World)->OnSetEnded.Broadcast(Summary);
+ TestEqual(TEXT("set end opens the end screen"), W.Ui->GetScreen(), EVerseUiScreen::EndOfSet);
+ TestTrue(TEXT("end screen reads s from the bot's player state"), FMath::IsNearlyEqual(W.Ui->GetEndScreen().Skill, 0.62f));
+ W.Ui->ContinueAfterSet();
+ TestEqual(TEXT("next set closes it"), W.Ui->GetScreen(), EVerseUiScreen::None);
+ FVerseSetSummary Left = Summary;
+ Left.Outcome = EVerseSetOutcome::Unfinished;
+ UVerseEventHub::Get(W.World)->OnSetEnded.Broadcast(Left);
+ TestEqual(TEXT("an unfinished set (leaving) opens nothing"), W.Ui->GetScreen(), EVerseUiScreen::None);
+ return true;
+}
+
+#endif // WITH_DEV_AUTOMATION_TESTS
diff --git a/unreal/Verse/Source/VerseUI/Private/Tests/UI/VerseUiVisualTest.cpp b/unreal/Verse/Source/VerseUI/Private/Tests/UI/VerseUiVisualTest.cpp
new file mode 100644
index 0000000000..ce3b252265
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Private/Tests/UI/VerseUiVisualTest.cpp
@@ -0,0 +1,518 @@
+#include "CanvasItem.h"
+#include "CanvasTypes.h"
+#include "Core/VerseUiSubsystem.h"
+#include "Core/VerseUiTheme.h"
+#include "DynamicRHI.h"
+#include "Events/VerseEventHub.h"
+#include "Misc/App.h"
+#include "Engine/Canvas.h"
+#include "Engine/Engine.h"
+#include "Engine/GameViewportClient.h"
+#include "Engine/TextureRenderTarget2D.h"
+#include "HAL/FileManager.h"
+#include "Hud/VerseHudPainter.h"
+#include "ImageUtils.h"
+#include "Kismet/KismetRenderingLibrary.h"
+#include "KillCam/VerseKillCam.h"
+#include "Misc/AutomationTest.h"
+#include "Misc/FileHelper.h"
+#include "Misc/Paths.h"
+#include "Styling/CoreStyle.h"
+#include "Tests/UI/Fakes/VerseUiFakes.h"
+#include "UnrealClient.h"
+
+#if WITH_DEV_AUTOMATION_TESTS
+
+// Verse.Visual.WP18.*: the evidence of work-packages WP18 (HUD in a fight at 1080p, 1440p and
+// 4K, kill cam contact sheet, the armoury in every locale, the HUD cost). Runs on the GPU in
+// -game through scripts/unreal/screenshot.py; files go to Saved/Harness/proof/WP18/.
+// No arena exists yet (WP11), so the HUD is drawn over a plain backdrop in the captures and
+// over the empty entry map in the viewport shots.
+
+namespace VerseUiVisual
+{
+ constexpr EAutomationTestFlags Flags = EAutomationTestFlags_ApplicationContextMask | EAutomationTestFlags::EngineFilter;
+
+ FString ProofDir(const TCHAR* SubTask)
+ {
+ const FString Dir = FPaths::Combine(FPaths::ProjectSavedDir(), TEXT("Harness"), TEXT("proof"), TEXT("WP18"), SubTask);
+ IFileManager::Get().MakeDirectory(*Dir, true);
+ return Dir;
+ }
+
+ /** Headless runs (-nullrhi) skip the captures; screenshot.py runs them on the GPU. */
+ bool SkipHeadless(FAutomationTestBase& Test)
+ {
+ if (!FApp::CanEverRender())
+ {
+ Test.AddInfo(TEXT("skipped: no renderer (-nullrhi); scripts/unreal/screenshot.py runs this suite"));
+ return true;
+ }
+ return false;
+ }
+
+ UWorld* GameWorld()
+ {
+ for (const FWorldContext& Context : GEngine->GetWorldContexts())
+ {
+ if ((Context.WorldType == EWorldType::Game || Context.WorldType == EWorldType::PIE) && Context.World() && Context.GameViewport)
+ {
+ return Context.World();
+ }
+ }
+ return nullptr;
+ }
+
+ /** A dark hangar-like backdrop: gradient, wall plates, a catwalk rail, work lights. */
+ void Backdrop(UCanvas* Canvas, const FVector2D& Size, uint32 Seed)
+ {
+ FCanvas* C = Canvas->Canvas;
+ const int32 Bands = 48;
+ for (int32 I = 0; I < Bands; ++I)
+ {
+ const float T = float(I) / Bands;
+ const FLinearColor Colour = FMath::Lerp(FLinearColor(0.030f, 0.028f, 0.026f), FLinearColor(0.004f, 0.004f, 0.005f), T);
+ FCanvasTileItem Tile(FVector2D(0, Size.Y * T), FVector2D(Size.X, Size.Y / Bands + 1), Colour);
+ C->DrawItem(Tile);
+ }
+ FRandomStream Rng{int32(Seed)};
+ for (int32 I = 0; I < 9; ++I)
+ {
+ const FVector2D P(Size.X * Rng.FRandRange(-0.05f, 0.95f), Size.Y * Rng.FRandRange(0.15f, 0.55f));
+ const FVector2D S(Size.X * Rng.FRandRange(0.08f, 0.22f), Size.Y * Rng.FRandRange(0.2f, 0.5f));
+ FCanvasTileItem Plate(P, S, FLinearColor(0.018f, 0.017f, 0.016f, 1.f));
+ C->DrawItem(Plate);
+ }
+ FCanvasTileItem Rail(FVector2D(0, Size.Y * 0.36f), FVector2D(Size.X, Size.Y * 0.012f), FLinearColor(0.05f, 0.045f, 0.04f));
+ C->DrawItem(Rail);
+ FCanvasTileItem Floor(FVector2D(0, Size.Y * 0.72f), FVector2D(Size.X, Size.Y * 0.28f), FLinearColor(0.012f, 0.011f, 0.010f));
+ C->DrawItem(Floor);
+ for (int32 I = 0; I < 4; ++I)
+ {
+ FCanvasTileItem Light(FVector2D(Size.X * (0.12f + 0.25f * I), Size.Y * 0.05f), FVector2D(Size.X * 0.05f, Size.Y * 0.008f), FLinearColor(0.9f, 0.7f, 0.4f));
+ C->DrawItem(Light);
+ }
+ }
+
+ bool SavePng(UWorld* World, UTextureRenderTarget2D* Target, const FString& Path)
+ {
+ FImage Image;
+ return FImageUtils::GetRenderTargetImage(Target, Image) && FImageUtils::SaveImageByExtension(*Path, Image);
+ }
+
+ /** The fight state every capture shows. */
+ void FightSource(FFakeVerseHudSource& Source, FVerseHudModel& Model, double Now)
+ {
+ Source.LocalId = 1;
+ Source.Bots.Add(2);
+ Source.Names.Add(2, TEXT("Opponent"));
+ Source.Pawn.bValid = true;
+ Source.Pawn.Health = 64.f;
+ Source.Pawn.Stance = EVerseStance::Crouch;
+ Source.Pawn.bHasWeapon = true;
+ Source.Pawn.WeaponId = TEXT("graveline");
+ Source.Pawn.Magazine = 17;
+ Source.Pawn.MagazineSize = 30;
+ Source.Pawn.bChambered = true;
+ Source.Pawn.Reserve = 90;
+ Source.Pawn.Gadgets = {{TEXT("bulwark"), 1, 1, 0.f}, {TEXT("breach_charge"), 1, 2, 0.f}};
+ Source.View.Rotation = FRotator(-2.f, 35.f, 0.f);
+ Source.View.HorizontalFovDeg = 100.f;
+ Source.BoltDirection = (Source.View.Rotation + FRotator(1.4f, 0.6f, 0.f)).Vector();
+ Source.SpreadDeg = 1.1f;
+ Model.SetLocalPlayerId(1);
+ FVerseHitEvent Hit;
+ Hit.InstigatorId = 1;
+ Hit.VictimId = 2;
+ Hit.bHeadshot = 1;
+ Model.OnHit(Hit, Now);
+ FVerseHitEvent Taken;
+ Taken.InstigatorId = 2;
+ Taken.VictimId = 1;
+ Taken.Damage = 36.f;
+ Taken.Direction = FVector_NetQuantizeNormal(FRotator(0.f, 35.f + 120.f, 0.f).Vector() * -1.f);
+ Model.OnHit(Taken, Now);
+ FVerseDeathEvent Earlier;
+ Earlier.KillerId = 1;
+ Earlier.VictimId = 2;
+ Earlier.WeaponId = TEXT("graveline");
+ Earlier.LastZone = EVerseHitZone::Head;
+ Earlier.RespawnAt = 1e9;
+ Model.OnDeath(Earlier, Now - 2.0);
+ Earlier.KillerId = 2;
+ Earlier.VictimId = 1;
+ Earlier.WeaponId = TEXT("tallow");
+ Earlier.LastZone = EVerseHitZone::UpperTorso;
+ Earlier.RespawnAt = -1.0;
+ Model.OnDeath(Earlier, Now - 1.0);
+ Model.Tick(Now, 0.0);
+ }
+
+ void DrawFrame(UCanvas* Canvas, const FVerseHudFrame& Frame, const FVector2D& Offset)
+ {
+ FVerseHudDrawList List;
+ FVerseHudPainter::Paint(Frame, List, FVerseHudPainter::DefaultMeasure());
+ for (FVerseHudDrawList::FLine& L : List.Lines) { L.A += Offset; L.B += Offset; }
+ for (FVerseHudDrawList::FRect& R : List.Rects) { R.Min += Offset; R.Max += Offset; }
+ for (FVerseHudDrawList::FTri& T : List.Tris) { T.A += Offset; T.B += Offset; T.C += Offset; }
+ for (FVerseHudDrawList::FLabel& T : List.Labels) { T.Position += Offset; }
+ FVerseHudCanvasRenderer::Render(Canvas, List);
+ }
+
+ /** Runs one step per frame until every step reports done. */
+ struct FSteps
+ {
+ TArray<TFunction<bool()>> Steps;
+ int32 Index = 0;
+ bool Update()
+ {
+ while (Index < Steps.Num())
+ {
+ if (!Steps[Index]())
+ {
+ return false;
+ }
+ ++Index;
+ }
+ return true;
+ }
+ };
+}
+
+using namespace VerseUiVisual;
+
+// Evidence: HUD screenshots in a fight at 1080p, 1440p, 4K (drawn by the real painter and canvas
+// renderer into a render target of that size) and the kill cam contact sheet.
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiVisualHudTest, "Verse.Visual.WP18.Hud", Flags)
+bool FVerseUiVisualHudTest::RunTest(const FString&)
+{
+ if (SkipHeadless(*this))
+ {
+ return true;
+ }
+ UWorld* World = GameWorld();
+ if (!World)
+ {
+ AddError(TEXT("needs a game world with a viewport (run through scripts/unreal/screenshot.py)"));
+ return false;
+ }
+ UVerseUiSubsystem* Ui = UVerseUiSubsystem::Get(World);
+ if (!TestNotNull(TEXT("UI subsystem"), Ui))
+ {
+ return false;
+ }
+ const FString Dir = ProofDir(TEXT("18.1-18.4"));
+ const double Now = 100.0;
+ FFakeVerseHudSource Source;
+ FVerseHudModel Model;
+ FightSource(Source, Model, Now);
+
+ const FIntPoint Sizes[] = {FIntPoint(1920, 1080), FIntPoint(2560, 1440), FIntPoint(3840, 2160)};
+ for (const FIntPoint& Size : Sizes)
+ {
+ UTextureRenderTarget2D* Target = UKismetRenderingLibrary::CreateRenderTarget2D(World, Size.X, Size.Y, RTF_RGBA8_SRGB, FLinearColor::Black);
+ UCanvas* Canvas = nullptr;
+ FVector2D CanvasSize;
+ FDrawToRenderTargetContext Context;
+ UKismetRenderingLibrary::BeginDrawCanvasToRenderTarget(World, Target, Canvas, CanvasSize, Context);
+ Backdrop(Canvas, CanvasSize, 18);
+ FVerseHudFrame Frame;
+ Frame.Model = &Model;
+ Frame.Strings = &Ui->GetStrings();
+ Frame.Source = &Source;
+ Frame.Layout = Ui->ComputeLayout(CanvasSize);
+ Source.GetPawnState(Frame.Pawn);
+ Frame.bHasView = Source.GetView(Frame.View);
+ Frame.Now = Now + 0.05;
+ DrawFrame(Canvas, Frame, FVector2D::ZeroVector);
+ UKismetRenderingLibrary::EndDrawCanvasToRenderTarget(World, Context);
+ const FString Path = FPaths::Combine(Dir, FString::Printf(TEXT("hud_fight_%dx%d.png"), Size.X, Size.Y));
+ TestTrue(FString::Printf(TEXT("saved %s"), *Path), SavePng(World, Target, Path));
+ }
+
+ // Kill cam contact sheet: six moments of one replay. Each tile: the HUD in kill cam mode and a
+ // top-down plot of the server log (grey), the replayed killer (amber) and the camera (red).
+ FVerseKillCamBuffer Buffer;
+ auto PathAt = [](double T) { return FVector(600.0 * FMath::Cos(T * 1.1), 600.0 * FMath::Sin(T * 1.1), 90.0); };
+ for (int32 I = 0; I <= 300; ++I)
+ {
+ const double T = 50.0 + I / 60.0;
+ Buffer.AddPose(2, T, PathAt(T), FRotator(0.f, FMath::RadiansToDegrees(T * 1.1) + 90.f, 0.f));
+ }
+ FVerseDeathEvent Death;
+ Death.KillerId = 2;
+ Death.VictimId = 1;
+ Death.WeaponId = TEXT("graveline");
+ Death.ServerTime = 55.0;
+ Death.RespawnAt = 58.0;
+ FVerseKillCamPlayer Player;
+ TestTrue(TEXT("kill cam begins"), Player.Begin(Buffer, Death, 1, 0.0, 55.0, false));
+ FVerseHudModel CamModel;
+ CamModel.SetLocalPlayerId(1);
+ CamModel.OnDeath(Death, 0.0);
+
+ const FVector2D Tile(960, 540);
+ UTextureRenderTarget2D* Sheet = UKismetRenderingLibrary::CreateRenderTarget2D(World, 2880, 1080, RTF_RGBA8_SRGB, FLinearColor::Black);
+ UCanvas* Canvas = nullptr;
+ FVector2D CanvasSize;
+ FDrawToRenderTargetContext Context;
+ UKismetRenderingLibrary::BeginDrawCanvasToRenderTarget(World, Sheet, Canvas, CanvasSize, Context);
+ const double Length = Player.GetClipEnd() - Player.GetClipStart();
+ for (int32 K = 0; K < 6; ++K)
+ {
+ const double LocalT = Length * K / 5.0;
+ Player.Tick(LocalT);
+ const FVector2D Origin((K % 3) * Tile.X, (K / 3) * Tile.Y);
+ FCanvasTileItem Clear(Origin, Tile, FLinearColor(0.006f, 0.006f, 0.007f));
+ Canvas->Canvas->DrawItem(Clear);
+ FFakeVerseHudSource CamSource;
+ CamSource.LocalId = 1;
+ CamSource.Bots.Add(2);
+ CamSource.ServerTime = 55.0 + LocalT;
+ FVerseHudFrame Frame;
+ Frame.Model = &CamModel;
+ Frame.Strings = &Ui->GetStrings();
+ Frame.Source = &CamSource;
+ Frame.Layout = Ui->ComputeLayout(Tile);
+ Frame.ServerTime = CamSource.ServerTime;
+ Frame.bKillCam = Player.IsPlaying() || K == 5;
+ Frame.KillCamKillerId = 2;
+ Frame.SkipKeyName = Ui->GetKeyMap().GetKey(TEXT("skip_kill_cam")).GetDisplayName();
+ DrawFrame(Canvas, Frame, Origin);
+
+ // Top-down plot, 1 px = 4 cm, centred in the tile.
+ const FVector2D Centre = Origin + FVector2D(Tile.X * 0.5, Tile.Y * 0.56);
+ auto Map = [&Centre](const FVector& P) { return Centre + FVector2D(P.X, P.Y) / 4.0; };
+ for (double T = 51.0; T < 55.0; T += 1.0 / 30.0)
+ {
+ FCanvasLineItem Line(Map(PathAt(T)), Map(PathAt(T + 1.0 / 30.0)));
+ Line.SetColor(FLinearColor(0.35f, 0.33f, 0.30f));
+ Canvas->Canvas->DrawItem(Line);
+ }
+ FVector Killer;
+ FRotator Aim;
+ FVector Cam;
+ FRotator CamRot;
+ if (Player.GetKillerPose(Killer, Aim) && Player.GetCamera(Cam, CamRot))
+ {
+ FCanvasTileItem KillerDot(Map(Killer) - FVector2D(5, 5), FVector2D(10, 10), VerseUiTheme::Amber);
+ Canvas->Canvas->DrawItem(KillerDot);
+ FCanvasTileItem CamDot(Map(Cam) - FVector2D(4, 4), FVector2D(8, 8), VerseUiTheme::Red);
+ Canvas->Canvas->DrawItem(CamDot);
+ FCanvasLineItem Sight(Map(Cam), Map(Cam + CamRot.Vector() * 400.0));
+ Sight.SetColor(VerseUiTheme::Red);
+ Canvas->Canvas->DrawItem(Sight);
+ const double Err = FVector::Distance(Killer, PathAt(Player.GetReplayTime()));
+ FCanvasTextItem Info(Origin + FVector2D(16, Tile.Y - 30),
+ FText::AsCultureInvariant(FString::Printf(TEXT("t %.2f / %.2f s path error %.2f cm"), LocalT, Length, Err)),
+ FCoreStyle::GetDefaultFontStyle("Regular", 11), VerseUiTheme::TextDim);
+ Canvas->Canvas->DrawItem(Info);
+ }
+ FCanvasLineItem EdgeA(Origin, Origin + FVector2D(Tile.X, 0));
+ EdgeA.SetColor(VerseUiTheme::Edge);
+ Canvas->Canvas->DrawItem(EdgeA);
+ FCanvasLineItem EdgeB(Origin, Origin + FVector2D(0, Tile.Y));
+ EdgeB.SetColor(VerseUiTheme::Edge);
+ Canvas->Canvas->DrawItem(EdgeB);
+ }
+ UKismetRenderingLibrary::EndDrawCanvasToRenderTarget(World, Context);
+ TestTrue(TEXT("kill cam contact sheet saved"), SavePng(World, Sheet, FPaths::Combine(ProofDir(TEXT("18.5")), TEXT("kill_cam_contact_sheet.png"))));
+ return true;
+}
+
+// Evidence: one screenshot per locale of the armoury, the other screens, and the live HUD drawn
+// through the real AHUD post-render path, captured from the game viewport.
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiVisualMenusTest, "Verse.Visual.WP18.Menus", Flags)
+bool FVerseUiVisualMenusTest::RunTest(const FString&)
+{
+ if (SkipHeadless(*this))
+ {
+ return true;
+ }
+ UWorld* World = GameWorld();
+ UVerseUiSubsystem* Ui = World ? UVerseUiSubsystem::Get(World) : nullptr;
+ if (!Ui)
+ {
+ AddError(TEXT("needs a game world with a viewport and the UI subsystem (screenshot.py)"));
+ return false;
+ }
+ TSharedPtr<FFakeVerseHudSource> Source = MakeShared<FFakeVerseHudSource>();
+ TSharedPtr<FFakeVerseUiGamePort> Game = MakeShared<FFakeVerseUiGamePort>();
+ TSharedPtr<FFakeVerseUiBridgePort> Bridge = MakeShared<FFakeVerseUiBridgePort>();
+ Ui->SetHudSource(Source);
+ Ui->SetGamePort(Game);
+ Ui->SetBridgePort(Bridge);
+
+ TSharedRef<FSteps> Steps = MakeShared<FSteps>();
+ auto Shot = [Steps](const FString& Path, TFunction<void()> Setup)
+ {
+ TSharedRef<double> Started = MakeShared<double>(0.0);
+ Steps->Steps.Add([Setup, Path, Started]
+ {
+ Setup();
+ IFileManager::Get().Delete(*Path);
+ *Started = FPlatformTime::Seconds();
+ return true;
+ });
+ // Let Slate lay the screen out for a few frames, then capture.
+ Steps->Steps.Add([Started] { return FPlatformTime::Seconds() - *Started > 0.6; });
+ Steps->Steps.Add([Path] { FScreenshotRequest::RequestScreenshot(Path, true, false); return true; });
+ Steps->Steps.Add([Path, Started] { return IFileManager::Get().FileExists(*Path) || FPlatformTime::Seconds() - *Started > 10.0; });
+ };
+
+ const FString ArmouryDir = ProofDir(TEXT("18.6"));
+ for (const FString& Lang : FVerseUiStrings::SupportedLanguages())
+ {
+ Shot(FPaths::Combine(ArmouryDir, FString::Printf(TEXT("armoury_%s_1080p.png"), *Lang)), [Ui, Lang, Game]
+ {
+ Game->bDuel = false;
+ Ui->GetMutableStrings().SetLanguage(Lang);
+ Ui->GetArmoury().SelectTier(TEXT("adaptive"));
+ Ui->ShowScreen(EVerseUiScreen::Armoury);
+ });
+ }
+ Shot(FPaths::Combine(ProofDir(TEXT("18.7")), TEXT("verse_bar_en_1080p.png")), [Ui, Game]
+ {
+ Game->bDuel = false;
+ Ui->GetMutableStrings().SetLanguage(TEXT("en"));
+ Ui->ShowScreen(EVerseUiScreen::None);
+ });
+ Shot(FPaths::Combine(ProofDir(TEXT("18.8")), TEXT("esc_menu_en_1080p.png")), [Ui, Game]
+ {
+ Game->bDuel = true;
+ Ui->ShowScreen(EVerseUiScreen::EscMenu);
+ });
+ Shot(FPaths::Combine(ProofDir(TEXT("18.8")), TEXT("settings_de_1080p.png")), [Ui]
+ {
+ Ui->GetMutableStrings().SetLanguage(TEXT("de"));
+ Ui->ShowScreen(EVerseUiScreen::Settings);
+ });
+ Shot(FPaths::Combine(ProofDir(TEXT("18.9")), TEXT("end_of_set_en_1080p.png")), [Ui, Source]
+ {
+ Ui->GetMutableStrings().SetLanguage(TEXT("en"));
+ Source->Bots.Add(2);
+ Source->Skill = 0.62f;
+ FVerseSetSummary Summary;
+ Summary.SetIndex = 3;
+ Summary.BotTier = TEXT("adaptive");
+ Summary.Outcome = EVerseSetOutcome::Won;
+ Summary.Person = {};
+ Summary.Person.PlayerId = 1;
+ Summary.Person.Kills = 10;
+ Summary.Person.Deaths = 7;
+ Summary.Person.Headshots = 4;
+ Summary.Person.Finishers = 1;
+ Summary.Person.ShotsFired = 214;
+ Summary.Person.ShotsHit = 66;
+ Summary.Person.DamageDealt = 1342;
+ Summary.Person.WallsBreached = 3;
+ Summary.Person.BestStreak = 4;
+ Summary.Opponent.PlayerId = 2;
+ Summary.Opponent.bIsBot = true;
+ Summary.Opponent.Kills = 7;
+ Summary.Opponent.Deaths = 10;
+ Summary.Opponent.Headshots = 2;
+ Summary.Opponent.ShotsFired = 251;
+ Summary.Opponent.ShotsHit = 70;
+ Summary.Opponent.DamageDealt = 1012;
+ Summary.Opponent.WallsBreached = 2;
+ Summary.Opponent.BestStreak = 3;
+ UVerseEventHub::Get(Ui)->OnSetEnded.Broadcast(Summary);
+ });
+ Shot(FPaths::Combine(ProofDir(TEXT("18.1-18.4")), TEXT("hud_live_viewport_1080p.png")), [Ui, Source, Game]
+ {
+ Game->bDuel = true;
+ Ui->ShowScreen(EVerseUiScreen::None);
+ FightSource(*Source, Ui->GetMutableHudModel(), FPlatformTime::Seconds() + 0.5);
+ });
+ Steps->Steps.Add([this, Ui, ArmouryDir]
+ {
+ for (const FString& Lang : FVerseUiStrings::SupportedLanguages())
+ {
+ const FString Path = FPaths::Combine(ArmouryDir, FString::Printf(TEXT("armoury_%s_1080p.png"), *Lang));
+ TestTrue(FString::Printf(TEXT("armoury screenshot %s"), *Lang), IFileManager::Get().FileExists(*Path));
+ }
+ Ui->ShowScreen(EVerseUiScreen::None);
+ Ui->GetMutableStrings().SetLanguage(TEXT("en"));
+ Ui->SetHudSource(nullptr);
+ Ui->SetGamePort(nullptr);
+ Ui->SetBridgePort(nullptr);
+ return true;
+ });
+ ADD_LATENT_AUTOMATION_COMMAND(FFunctionLatentCommand([Steps] { return Steps->Update(); }));
+ return true;
+}
+
+// A18.3: HUD at most 0.3 ms game thread plus GPU, measured in the running game at 1080p.
+IMPLEMENT_SIMPLE_AUTOMATION_TEST(FVerseUiVisualCostTest, "Verse.Visual.WP18.Cost", Flags)
+bool FVerseUiVisualCostTest::RunTest(const FString&)
+{
+ if (SkipHeadless(*this))
+ {
+ return true;
+ }
+ UWorld* World = GameWorld();
+ UVerseUiSubsystem* Ui = World ? UVerseUiSubsystem::Get(World) : nullptr;
+ if (!Ui)
+ {
+ AddError(TEXT("needs a game world with a viewport and the UI subsystem (screenshot.py)"));
+ return false;
+ }
+ TSharedPtr<FFakeVerseHudSource> Source = MakeShared<FFakeVerseHudSource>();
+ TSharedPtr<FFakeVerseUiGamePort> Game = MakeShared<FFakeVerseUiGamePort>();
+ Game->bDuel = true;
+ Ui->SetHudSource(Source);
+ Ui->SetGamePort(Game);
+ Ui->ShowScreen(EVerseUiScreen::None);
+ FightSource(*Source, Ui->GetMutableHudModel(), FPlatformTime::Seconds() + 1000.0);
+
+ struct FState
+ {
+ int32 Frame = 0;
+ TArray<double> GpuOn;
+ TArray<double> GpuOff;
+ double GameThread = 0.0;
+ };
+ TSharedRef<FState> State = MakeShared<FState>();
+ ADD_LATENT_AUTOMATION_COMMAND(FFunctionLatentCommand([this, Ui, State]
+ {
+ // 8 alternating blocks of 60 frames, HUD on and off; the first 30 frames warm up.
+ const int32 Block = 60;
+ const int32 Warm = 30;
+ const int32 F = State->Frame++;
+ if (F < Warm)
+ {
+ return false;
+ }
+ const int32 Index = (F - Warm) / Block;
+ const bool bOn = Index % 2 == 0;
+ Ui->bDrawHudOnPostRender = bOn;
+ if ((F - Warm) % Block > 5)
+ {
+ const double GpuMs = FPlatformTime::ToMilliseconds(RHIGetGPUFrameCycles());
+ (bOn ? State->GpuOn : State->GpuOff).Add(GpuMs);
+ }
+ if (Index < 8)
+ {
+ return false;
+ }
+ Ui->bDrawHudOnPostRender = true;
+ auto Median = [](TArray<double> V) { V.Sort(); return V.Num() ? V[V.Num() / 2] : 0.0; };
+ const double On = Median(State->GpuOn);
+ const double Off = Median(State->GpuOff);
+ const double GameThread = Ui->GetHudCostMs();
+ const double Gpu = FMath::Max(0.0, On - Off);
+ const FString Json = FString::Printf(TEXT("{\"resolution\":\"1920x1080\",\"hud_game_thread_ms\":%.4f,\"gpu_frame_ms_hud_on\":%.4f,\"gpu_frame_ms_hud_off\":%.4f,\"hud_gpu_ms\":%.4f,\"total_ms\":%.4f,\"budget_ms\":0.3}"),
+ GameThread, On, Off, Gpu, GameThread + Gpu);
+ FFileHelper::SaveStringToFile(Json, *FPaths::Combine(ProofDir(TEXT("18.1-18.4")), TEXT("hud_cost.json")));
+ AddInfo(Json);
+ TestTrue(TEXT("HUD game thread measured"), GameThread > 0.0);
+ TestTrue(TEXT("HUD at most 0.3 ms game thread plus GPU"), GameThread + Gpu <= 0.3);
+ Ui->SetHudSource(nullptr);
+ Ui->SetGamePort(nullptr);
+ return true;
+ }));
+ return true;
+}
+
+#endif // WITH_DEV_AUTOMATION_TESTS
diff --git a/unreal/Verse/Source/VerseUI/Public/Core/VerseUiLayout.h b/unreal/Verse/Source/VerseUI/Public/Core/VerseUiLayout.h
new file mode 100644
index 0000000000..3b7ba0e565
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Public/Core/VerseUiLayout.h
@@ -0,0 +1,60 @@
+#pragma once
+
+#include "CoreMinimal.h"
+#include "Layout/Margin.h"
+
+/** Screen anchors for HUD blocks; offsets are in 1080p reference pixels. */
+enum class EVerseUiAnchor : uint8
+{
+ TopLeft,
+ Top,
+ TopRight,
+ Left,
+ Centre,
+ Right,
+ BottomLeft,
+ Bottom,
+ BottomRight,
+};
+
+/**
+ * Safe area and scale of one viewport (WP18.1). The HUD is authored at 1920 x 1080 and scales
+ * uniformly by the smaller axis ratio, so 1440p is x1.333 and 4K is x2. Blocks anchor to the
+ * safe rectangle (title-safe fraction or the platform padding, whichever is larger); the
+ * crosshair alone uses the whole viewport, because it sits on the projected bolt direction.
+ */
+struct VERSEUI_API FVerseUiLayout
+{
+ static constexpr float ReferenceWidth = 1920.f;
+ static constexpr float ReferenceHeight = 1080.f;
+
+ FVector2D Viewport = FVector2D(ReferenceWidth, ReferenceHeight);
+ /** Safe rectangle in viewport pixels. */
+ FVector2D SafeMin = FVector2D::ZeroVector;
+ FVector2D SafeMax = FVector2D(ReferenceWidth, ReferenceHeight);
+ /** Geometry scale relative to 1080p. */
+ float Scale = 1.f;
+ /** Geometry scale times the person's text size choice. */
+ float TextScale = 1.f;
+
+ /**
+ * @param SafeFraction Fraction of each axis kept free on every side (0.025 = action safe).
+ * @param PlatformPadding Pixels the platform reports as unsafe (FDisplayMetrics); larger wins.
+ * @param UserTextScale Accessibility text size, clamped to [0.8, 1.6].
+ */
+ static FVerseUiLayout Compute(const FVector2D& Viewport, float SafeFraction, const FMargin& PlatformPadding, float UserTextScale);
+
+ FVector2D SafeSize() const { return SafeMax - SafeMin; }
+
+ /** Reference pixels to viewport pixels. */
+ float Px(float ReferencePx) const { return ReferencePx * Scale; }
+
+ /** Font size in points for a 1080p reference size, after scale and text size. */
+ int32 FontSize(float ReferencePt) const;
+
+ /**
+ * Top-left corner of a block of Size (viewport px) at Anchor, moved inward by Offset
+ * (reference px). The block always ends up fully inside the safe rectangle.
+ */
+ FVector2D Place(EVerseUiAnchor Anchor, const FVector2D& Size, const FVector2D& Offset) const;
+};
diff --git a/unreal/Verse/Source/VerseUI/Public/Core/VerseUiPorts.h b/unreal/Verse/Source/VerseUI/Public/Core/VerseUiPorts.h
new file mode 100644
index 0000000000..c8b7d8b652
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Public/Core/VerseUiPorts.h
@@ -0,0 +1,138 @@
+#pragma once
+
+#include "Combat/VerseCombatTypes.h"
+#include "CoreMinimal.h"
+#include "Dom/JsonObject.h"
+
+// The UI's three seams to code it may not include or that has not landed yet. Each has a
+// default adapter in the UI subsystem and a fake in Private/Tests/UI/Fakes/.
+//
+// - IVerseUiBridgePort: the Verse -> app frames the UI sends (bridge-protocol 12, 14). WP17's
+// VerseBridge client implements it; until then the default logs the frame it would send.
+// - IVerseUiGamePort: start or leave the duel and change deck (WP11 switch, WP12 decks). The
+// default runs the registered Verse.QA.Duel.* commands, the only cross-module seam Core has.
+// - IVerseHudSource: what the HUD reads from the local pawn and the player states
+// (combat-state 2.1). The default reads the engine player states, the combat state
+// component and IVerseMovementQuery; magazine and gadget numbers need WP02's inventory.
+
+/** Verse -> app frames the UI sends. */
+class VERSEUI_API IVerseUiBridgePort
+{
+public:
+ virtual ~IVerseUiBridgePort() = default;
+
+ /** settings.set with any subset of welcome.settings (bridge-protocol 14). */
+ virtual void SendSettingsSet(const TSharedRef<FJsonObject>& Data) = 0;
+
+ /** focus.return_to_app {reason: return_key | station | esc_menu} (bridge-protocol 12). */
+ virtual void SendReturnToApp(const FString& Reason) = 0;
+};
+
+/** Duel and deck control. */
+class VERSEUI_API IVerseUiGamePort
+{
+public:
+ virtual ~IVerseUiGamePort() = default;
+
+ /** Tier normal, hard, elite or adaptive. */
+ virtual void StartDuel(FName Tier) = 0;
+ virtual void LeaveDuel() = 0;
+ virtual void TravelToDeck(FName Deck) = 0;
+ virtual bool IsDuelRunning() const = 0;
+ virtual FName GetCurrentDeck() const = 0;
+ /** Holds or releases the match while a menu covers it (parity D-09). */
+ virtual void SetPaused(bool bPaused) = 0;
+};
+
+struct VERSEUI_API FVerseHudGadgetState
+{
+ FName GadgetId;
+ int32 Charges = 0;
+ int32 MaxCharges = 0;
+ /** s; 0 = ready. */
+ float CooldownRemaining = 0.f;
+};
+
+/** The local pawn as the HUD shows it (bot.md 3.3: only what the person may know). */
+struct VERSEUI_API FVerseHudPawnState
+{
+ bool bValid = false;
+ /** False when the source cannot read health yet: the UI tracks it from own-hit events. */
+ bool bHealthKnown = true;
+ float Health = 100.f;
+ float MaxHealth = 100.f;
+ EVerseCombatPhase Phase = EVerseCombatPhase::Alive;
+ EVerseStance Stance = EVerseStance::Stand;
+ bool bSpawnProtected = false;
+ /** s left; 0 when not protected. */
+ float SpawnProtectionRemaining = 0.f;
+
+ /** False until a weapon state is known: the ammo block is hidden then. */
+ bool bHasWeapon = false;
+ FName WeaponId;
+ EVerseLoadoutSlot ActiveSlot = EVerseLoadoutSlot::Primary;
+ int32 Magazine = 0;
+ int32 MagazineSize = 0;
+ bool bChambered = false;
+ int32 Reserve = 0;
+ bool bReloading = false;
+ /** 0..1 */
+ float ReloadProgress = 0.f;
+ bool bTacticalReload = true;
+
+ TArray<FVerseHudGadgetState> Gadgets;
+};
+
+/** The camera the HUD projects through. */
+struct VERSEUI_API FVerseHudView
+{
+ FVector Location = FVector::ZeroVector;
+ FRotator Rotation = FRotator::ZeroRotator;
+ /** Horizontal field of view, degrees (aspect ratio keeps the horizontal FOV). */
+ float HorizontalFovDeg = 100.f;
+};
+
+/** One recorded pose for the kill cam. */
+struct VERSEUI_API FVersePawnPose
+{
+ int32 PlayerId = 0;
+ FVector Location = FVector::ZeroVector;
+ /** Control (view) rotation. */
+ FRotator Rotation = FRotator::ZeroRotator;
+ /**
+ * Server time of the state this pose shows, s; negative = the source's server time now.
+ * A source sets it when the pawn is drawn later than its replicated state (smoothing).
+ */
+ double ServerTime = -1.0;
+};
+
+/** What the HUD reads every frame. */
+class VERSEUI_API IVerseHudSource
+{
+public:
+ virtual ~IVerseHudSource() = default;
+
+ /** Player state id of the person; INDEX_NONE when there is no local player. */
+ virtual int32 GetLocalPlayerId() const = 0;
+ /** Server world time, s (the clock of every event's ServerTime and of RespawnAt). */
+ virtual double GetServerTime() const = 0;
+ virtual void GetPawnState(FVerseHudPawnState& Out) const = 0;
+ virtual bool GetView(FVerseHudView& Out) const = 0;
+
+ /**
+ * Direction the next own bolt leaves in (owner prediction: camera, recoil and sway; not the
+ * random spread, which is shown as the circle). False when no weapon aims: the crosshair
+ * then sits on the camera axis.
+ */
+ virtual bool GetPredictedBoltDirection(FVector& OutDirection, float& OutSpreadHalfAngleDeg) const = 0;
+
+ virtual FText GetDisplayName(int32 PlayerId) const = 0;
+ virtual bool IsBot(int32 PlayerId) const = 0;
+ /** AVersePlayerState::BotTier: normal, hard, elite, adaptive; None for a person. */
+ virtual FName GetBotTier(int32 PlayerId) const = 0;
+ /** AVersePlayerState::BotEffectiveSkill: adaptive s, -1 for a person. */
+ virtual float GetBotEffectiveSkill(int32 PlayerId) const = 0;
+
+ /** Current poses of every pawn the client sees (kill cam recording). */
+ virtual void GetPawnPoses(TArray<FVersePawnPose>& Out) const = 0;
+};
diff --git a/unreal/Verse/Source/VerseUI/Public/Core/VerseUiStrings.h b/unreal/Verse/Source/VerseUI/Public/Core/VerseUiStrings.h
new file mode 100644
index 0000000000..ddb6908fef
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Public/Core/VerseUiStrings.h
@@ -0,0 +1,67 @@
+#pragma once
+
+#include "CoreMinimal.h"
+#include "Dom/JsonObject.h"
+
+/**
+ * Every user-visible string of the Verse UI (WP18.1, A18.4). Code names keys only; text comes
+ * from the catalogue unreal/Verse/Data/ui/strings.<lang>.json (5 locales, a fallback) overlaid by the strings the
+ * bridge sends in welcome.locale and settings.changed (bridge-protocol 3.2, 12), so a string
+ * change needs no rebuild. Lookup order: bridge string, catalogue in the language, catalogue in
+ * the fallback language, English, the key itself (a visible bug, logged once).
+ */
+class VERSEUI_API FVerseUiStrings
+{
+public:
+ /** en, de, es, pt, zh: the 5 locales the web app bundles. */
+ static const TArray<FString>& SupportedLanguages();
+
+ /** <project>/Data/ui (strings.<lang>.json) */
+ static FString DefaultCatalogueDir();
+
+ /** Loads strings.<lang>.json of every supported language from Dir (replaces the catalogue). */
+ bool LoadCatalogue(const FString& Dir, FString* OutError = nullptr);
+ /** Merges one language file {lang, strings}. */
+ bool LoadCatalogueJson(const FString& Json, FString* OutError = nullptr);
+
+ /** Switches language; an unsupported code falls back to Fallback, then English. */
+ void SetLanguage(const FString& Lang, const FString& Fallback = TEXT("en"));
+
+ /** welcome.locale: {lang, fallback, strings}. Replaces earlier bridge strings. */
+ void ApplyBridgeLocale(const TSharedPtr<FJsonObject>& Locale);
+
+ /** settings.changed {lang?, strings?}: lang switches, strings merge over earlier ones. */
+ void ApplySettingsChanged(const TSharedPtr<FJsonObject>& Data);
+
+ FText Get(const FString& Key) const;
+
+ /** Named-argument format, for example "{kills} kills". */
+ FText Format(const FString& Key, const FFormatNamedArguments& Args) const;
+
+ /** Raw catalogue text of Key in Lang, empty when missing (tests). */
+ FString GetIn(const FString& Key, const FString& Lang) const;
+
+ TArray<FString> GetKeys() const;
+ const FString& GetLanguage() const { return Language; }
+
+ /** The culture of the Verse UI language (never the machine's culture), English as fallback. */
+ FCulturePtr GetCulture() const;
+ /** Numbers in the Verse UI language: fixed fraction digits, optional grouping. */
+ FText Number(double Value, int32 FractionDigits = 0, bool bGrouping = false) const;
+ /** Value 0..1 as a percent in the Verse UI language. */
+ FText Percent(double Value, int32 FractionDigits = 0) const;
+ int32 NumBridgeStrings() const { return BridgeStrings.Num(); }
+
+private:
+ FString Resolve(const FString& Key) const;
+
+ /** key -> lang -> text */
+ TMap<FString, TMap<FString, FString>> Catalogue;
+ /** Bridge strings for the current language. */
+ TMap<FString, FString> BridgeStrings;
+ FString Language = TEXT("en");
+ FString Fallback = TEXT("en");
+ mutable TSet<FString> ReportedMissing;
+ mutable FCulturePtr CachedCulture;
+ mutable FString CachedCultureLang;
+};
diff --git a/unreal/Verse/Source/VerseUI/Public/Core/VerseUiSubsystem.h b/unreal/Verse/Source/VerseUI/Public/Core/VerseUiSubsystem.h
new file mode 100644
index 0000000000..c0d6de7bb2
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Public/Core/VerseUiSubsystem.h
@@ -0,0 +1,240 @@
+#pragma once
+
+#include "Core/VerseUiPorts.h"
+#include "Core/VerseUiStrings.h"
+#include "CoreMinimal.h"
+#include "Hud/VerseHudModel.h"
+#include "Hud/VerseHudPainter.h"
+#include "KillCam/VerseKillCam.h"
+#include "Menus/VerseUiMenus.h"
+#include "Settings/VerseUiInputRemap.h"
+#include "Settings/VerseUiSettings.h"
+#include "Subsystems/WorldSubsystem.h"
+
+#include "VerseUiSubsystem.generated.h"
+
+class AActor;
+class AHUD;
+class ACameraActor;
+class APawn;
+class SVerseUiRoot;
+class UCanvas;
+class USkeletalMeshComponent;
+struct FActorSpawnParameters;
+class FVerseUiInputProcessor;
+class UVerseEventHub;
+
+DECLARE_MULTICAST_DELEGATE_OneParam(FOnVerseUiScreenChanged, EVerseUiScreen);
+
+/**
+ * The Verse UI of one game world (WP18): HUD model and painter, kill cam, armoury, Verse bar,
+ * menus, settings, end-of-set screen. It listens to the event hub, draws the HUD on every HUD's
+ * post-render (no game mode change needed), puts the Slate menus on the game viewport and
+ * routes UI keys through a Slate input pre-processor.
+ *
+ * WP17 feeds it the bridge (ApplyWelcome, ApplySettingsChanged) and sets the bridge port.
+ */
+UCLASS()
+class VERSEUI_API UVerseUiSubsystem : public UTickableWorldSubsystem
+{
+ GENERATED_BODY()
+
+public:
+ static UVerseUiSubsystem* Get(const UObject* WorldContextObject);
+
+ virtual bool ShouldCreateSubsystem(UObject* Outer) const override;
+ virtual void Initialize(FSubsystemCollectionBase& Collection) override;
+ virtual void OnWorldBeginPlay(UWorld& InWorld) override;
+ virtual void Deinitialize() override;
+ virtual void Tick(float DeltaTime) override;
+ virtual TStatId GetStatId() const override;
+
+ // Bridge (WP17 calls these with the frame's data object).
+ void ApplyWelcome(const TSharedPtr<FJsonObject>& Data);
+ void ApplySettingsChanged(const TSharedPtr<FJsonObject>& Data);
+ void SetBridgePort(TSharedPtr<IVerseUiBridgePort> Port);
+ void SetGamePort(TSharedPtr<IVerseUiGamePort> Port);
+ void SetHudSource(TSharedPtr<IVerseHudSource> Source);
+
+ // Settings actions (each app-backed change sends exactly one settings.set).
+ void SetGore(EVerseGoreLevel Level);
+ void SetReducedMotion(bool bReduced);
+ void SetReturnKey(const FKey& Key);
+ void SetAppSettings(const FVerseAppSettings& Next);
+ void RebindKey(FName Action, const FKey& Key);
+ void SetDuelFov(float Fov);
+ void SetScalability(int32 Level);
+ void SetTextScale(float Scale);
+ /** Settings reset (parity T-01): sensitivity 1, invert off, quality auto, FOV 70/85, volume 0.7, view third. */
+ void ResetSettings();
+
+ /** Applies a scalability level: 0..4, or -1 (auto) for the engine's default levels. */
+ static void ApplyScalabilityLevel(int32 Level);
+
+ /**
+ * Writes the gore level where VerseGore reads it: UVerseSettings::GoreLevel
+ * ([/Script/Verse.VerseSettings] in GameUserSettings, combat-state 8), on the class default
+ * object and in the ini, and asks a live UVerseGoreSubsystem to re-read it.
+ */
+ static void WriteGoreSetting(UWorld* World, EVerseGoreLevel Level);
+ /** The gore level stored for VerseGore, read back the way VerseGore reads it. */
+ static EVerseGoreLevel ReadGoreSetting();
+
+ // Screens and actions.
+ void ShowScreen(EVerseUiScreen InScreen);
+ EVerseUiScreen GetScreen() const { return Screen; }
+ void StartDuelFromArmoury();
+ void QuickStartDuel();
+ void LeaveDuel();
+ void ReturnToApp(const FString& Reason);
+ void TravelToDeck(FName Deck);
+ void SkipKillCam();
+ void ContinueAfterSet();
+ void ToggleBar();
+ bool IsBarOpen() const { return bBarOpen; }
+
+ /** Key routing; true when the UI used the key. */
+ bool HandleKey(const FKey& Key);
+ /** True while the controls page waits for the key of a rebind (mouse buttons count too). */
+ bool IsListeningForKey() const;
+
+ /** Bridge lifecycle (parity Q-01): booting until welcome, then WP17 sets visible, panel or dormant. */
+ void SetLifecycleState(FName State) { LifecycleState = State; }
+ FName GetLifecycleState() const { return LifecycleState; }
+
+ /** One replayed bolt the kill cam draws (WP18.5: fire events replayed). */
+ struct FReplayBolt
+ {
+ FVector Start = FVector::ZeroVector;
+ FVector End = FVector::ZeroVector;
+ double LocalTime = 0.0;
+ };
+ const TArray<FReplayBolt>& GetReplayBolts() const { return ReplayBolts; }
+ /** Seconds a replayed bolt stays drawn. */
+ static constexpr double ReplayBoltLife = 0.25;
+
+ /** Session totals for the summary shown on leave (parity D-10). */
+ const FVerseSessionSummary& GetSession() const { return Session; }
+ const FVerseEndScreen& GetSessionScreen() const { return SessionScreen; }
+
+ /** Rebinds the local player's Enhanced Input contexts to the current keys now (tests, possession). */
+ int32 ApplyKeyBindingsToInput();
+ FVerseUiInputRemap& GetInputRemap() { return InputRemap; }
+
+ /** The replayed killer: a scene root at the recorded capsule with a copy of the killer's mesh under it at the pawn's mesh offset. */
+ AActor* SpawnKillCamProxy(UWorld* World, const FActorSpawnParameters& Params, const APawn* Killer, USkeletalMeshComponent* KillerMesh);
+ bool IsPausedByUi() const { return bPausedByUi; }
+
+ // Read access.
+ const FVerseUiStrings& GetStrings() const { return Strings; }
+ FVerseUiStrings& GetMutableStrings() { return Strings; }
+ const FVerseHudModel& GetHudModel() const { return Hud; }
+ FVerseHudModel& GetMutableHudModel() { return Hud; }
+ const FVerseAppSettings& GetAppSettings() const { return AppSettings; }
+ UVerseUiUserSettings* GetUserSettings() const { return UserSettings; }
+ const FVerseKeyMap& GetKeyMap() const { return KeyMap; }
+ FVerseArmouryModel& GetArmoury() { return Armoury; }
+ const FVerseKillCamPlayer& GetKillCam() const { return KillCam; }
+ const FVerseKillCamBuffer& GetKillCamBuffer() const { return KillCamBuffer; }
+ const TArray<FName>& GetDecks() const { return Decks; }
+ IVerseHudSource& GetHudSource() const { return *HudSource; }
+ IVerseUiGamePort& GetGamePort() const { return *GamePort; }
+ const FVerseHudDrawList& GetLastDrawList() const { return LastDrawList; }
+ /** Mean HUD cost on the game thread (draw-list build plus canvas submit), ms, last 120 frames. */
+ double GetHudCostMs() const { return HudCostMs; }
+ FVerseUiLayout ComputeLayout(const FVector2D& Viewport) const;
+ const FVerseEndScreen& GetEndScreen() const { return EndScreen; }
+
+ /** Builds one HUD frame for a viewport size (the post-render draw and the captures use it). */
+ void BuildHudFrame(const FVector2D& Viewport, FVerseHudDrawList& Out) const;
+
+ FOnVerseUiScreenChanged OnScreenChanged;
+ /**
+ * Kill cam replay of fire and fracture events. The UI draws replayed bolts itself; the
+ * fracture hook is for the destruction client (destruction.md 4) once it binds it.
+ */
+ TFunction<void(const FVerseFireEvent&)> OnKillCamFire;
+ TFunction<void(const FVerseFractureEvent&)> OnKillCamFracture;
+
+ /** Draw the HUD from AHUD post-render (captures that draw it themselves turn it off). */
+ bool bDrawHudOnPostRender = true;
+
+ /** Local clock of the UI (real time seconds); tests may pin it. */
+ TFunction<double()> Clock;
+
+private:
+ void LoadData();
+ void BindHub();
+ void UnbindHub();
+ void AttachSlate();
+ void DetachSlate();
+ void RebuildScreen();
+ void ApplyInputMode();
+ void ApplyKillCamView(bool bStart);
+ void TickKillCam(double Now);
+ void OnHudPostRender(AHUD* InHud, UCanvas* Canvas);
+ void DrawReplayBolts(UCanvas* Canvas);
+ void AddReplayBolt(const FVerseFireEvent& Event);
+ void UpdatePause();
+ double LocalNow() const;
+ void PublishSettings();
+
+ void HandleHit(const FVerseHitEvent& Event);
+ void HandleDeath(const FVerseDeathEvent& Event);
+ void HandleSetEnded(const FVerseSetSummary& Summary);
+ void HandleFire(const FVerseFireEvent& Event);
+ void HandleFracture(const FVerseFractureEvent& Event);
+ void HandleStationUsed(const FVerseStationUsedEvent& Event);
+
+ FVerseUiStrings Strings;
+ FVerseHudModel Hud;
+ FVerseKillCamBuffer KillCamBuffer;
+ FVerseKillCamPlayer KillCam;
+ FVerseAppSettings AppSettings;
+ FVerseKeyMap KeyMap;
+ FVerseArmouryModel Armoury;
+ FVerseEndScreen EndScreen;
+ TArray<FName> Decks;
+ EVerseUiScreen Screen = EVerseUiScreen::None;
+ bool bBarOpen = false;
+ float SafeFraction = 0.025f;
+
+ UPROPERTY(Transient)
+ TObjectPtr<UVerseUiUserSettings> UserSettings;
+
+ UPROPERTY(Transient)
+ TObjectPtr<ACameraActor> KillCamCamera;
+
+ UPROPERTY(Transient)
+ TObjectPtr<AActor> KillCamProxy;
+
+ /** The live killer hidden in the local view only (PlayerController::HiddenActors, not replicated). */
+ TWeakObjectPtr<APawn> KillCamHiddenKiller;
+ TArray<FReplayBolt> ReplayBolts;
+ FVerseSessionSummary Session;
+ FVerseEndScreen SessionScreen;
+ FVerseUiInputRemap InputRemap;
+ double NextInputRemapAt = 0.0;
+ bool bPausedByUi = false;
+ FName LifecycleState = TEXT("booting");
+ /** Own health from own-hit events while the source cannot read it (WP02 attribute set). */
+ float TrackedHealth = 100.f;
+ bool bLastDuelRunning = false;
+ bool bOwnsGamePort = true;
+
+ TWeakObjectPtr<AActor> KillCamPreviousTarget;
+ TWeakObjectPtr<UVerseEventHub> BoundHub;
+ TArray<FDelegateHandle> HubHandles;
+ FDelegateHandle PostRenderHandle;
+
+ TSharedPtr<IVerseUiBridgePort> BridgePort;
+ TSharedPtr<IVerseUiGamePort> GamePort;
+ TSharedPtr<IVerseHudSource> HudSource;
+ TSharedPtr<SVerseUiRoot> SlateRoot;
+ TSharedPtr<FVerseUiInputProcessor> InputProcessor;
+
+ FVerseHudDrawList LastDrawList;
+ double HudCostMs = 0.0;
+ double HudCostAccum = 0.0;
+ int32 HudCostFrames = 0;
+};
diff --git a/unreal/Verse/Source/VerseUI/Public/Core/VerseUiTheme.h b/unreal/Verse/Source/VerseUI/Public/Core/VerseUiTheme.h
new file mode 100644
index 0000000000..d3b995ae85
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Public/Core/VerseUiTheme.h
@@ -0,0 +1,35 @@
+#pragma once
+
+#include "CoreMinimal.h"
+
+/**
+ * Colours and shapes of the Verse UI (README "Look": Military-Industrial Noir). Accents are
+ * sparse amber, red and gold on black steel; never cyan or violet. Every state that carries a
+ * colour also carries a shape (WP18.10), so nothing depends on colour alone.
+ */
+namespace VerseUiTheme
+{
+ /** Panels and plates. */
+ inline const FLinearColor Steel(0.010f, 0.010f, 0.011f, 0.86f);
+ inline const FLinearColor SteelLight(0.035f, 0.033f, 0.030f, 0.92f);
+ inline const FLinearColor Edge(0.20f, 0.17f, 0.12f, 1.f);
+ /** Body text: warm off-white. */
+ inline const FLinearColor Text(0.86f, 0.82f, 0.74f, 1.f);
+ inline const FLinearColor TextDim(0.48f, 0.45f, 0.40f, 1.f);
+ /** Own side: amber (own bolts are amber, README). */
+ inline const FLinearColor Amber(1.00f, 0.55f, 0.08f, 1.f);
+ /** Opponent and danger: red (the opponent's bolts are red). */
+ inline const FLinearColor Red(0.90f, 0.08f, 0.04f, 1.f);
+ /** Headshots, wins, rank: gold. */
+ inline const FLinearColor Gold(0.95f, 0.72f, 0.22f, 1.f);
+ /** Blocked (spawn protection): neutral grey-white. */
+ inline const FLinearColor Blocked(0.80f, 0.80f, 0.78f, 1.f);
+ /** Text shadow under the HUD. */
+ inline const FLinearColor Shadow(0.f, 0.f, 0.f, 0.75f);
+
+ /** True when a colour is in the forbidden cyan or violet band (hue 170-300 deg, saturated). */
+ VERSEUI_API bool IsForbiddenAccent(const FLinearColor& Colour);
+
+ /** Every accent this file defines, for the palette test. */
+ VERSEUI_API TArray<FLinearColor> AllColours();
+}
diff --git a/unreal/Verse/Source/VerseUI/Public/Hud/VerseCrosshair.h b/unreal/Verse/Source/VerseUI/Public/Hud/VerseCrosshair.h
new file mode 100644
index 0000000000..a0566f3fdb
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Public/Hud/VerseCrosshair.h
@@ -0,0 +1,25 @@
+#pragma once
+
+#include "Core/VerseUiPorts.h"
+#include "CoreMinimal.h"
+
+/**
+ * Crosshair placement (WP18.2, A18.1). The crosshair is drawn where the predicted bolt
+ * direction meets the screen, through the same projection the engine renders with
+ * (ULocalPlayer, aspect ratio keeps the horizontal FOV), so recoil, sway and lean move it
+ * exactly with the bolt. The spread circle radius is the spread half-angle on that projection.
+ */
+struct VERSEUI_API FVerseCrosshair
+{
+ /** The renderer's view-projection for View on a Viewport of that size (no translation). */
+ static FMatrix ViewProjection(const FVerseHudView& View, const FVector2D& Viewport);
+
+ /** Screen pixel of a world direction from the eye. False when it points behind the camera. */
+ static bool ProjectDirection(const FVerseHudView& View, const FVector2D& Viewport, const FVector& Direction, FVector2D& OutPixel);
+
+ /** Radius in pixels of a cone of HalfAngleDeg around the view axis. */
+ static float SpreadRadiusPx(const FVerseHudView& View, const FVector2D& Viewport, float HalfAngleDeg);
+
+ /** The pixel (integer cell) a sub-pixel position falls in. */
+ static FIntPoint PixelCell(const FVector2D& Position) { return FIntPoint(FMath::FloorToInt(Position.X), FMath::FloorToInt(Position.Y)); }
+};
diff --git a/unreal/Verse/Source/VerseUI/Public/Hud/VerseHudModel.h b/unreal/Verse/Source/VerseUI/Public/Hud/VerseHudModel.h
new file mode 100644
index 0000000000..c2523d6634
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Public/Hud/VerseHudModel.h
@@ -0,0 +1,127 @@
+#pragma once
+
+#include "Combat/VerseCombatTypes.h"
+#include "Core/VerseUiPorts.h"
+#include "CoreMinimal.h"
+
+/** Hit marker kinds (WP18.2). Each has its own shape (VerseHudPainter), never colour alone. */
+enum class EVerseHitMarkerKind : uint8
+{
+ Hit,
+ Headshot,
+ Kill,
+ Blocked,
+};
+
+struct VERSEUI_API FVerseHitMarker
+{
+ EVerseHitMarkerKind Kind = EVerseHitMarkerKind::Hit;
+ double StartTime = 0.0;
+ float Duration = 0.f;
+};
+
+/** Damage direction: where the bolt came from, in world space, so it turns with the view. */
+struct VERSEUI_API FVerseDamageIndicator
+{
+ /** Unit vector from the person toward the source. */
+ FVector FromDirection = FVector::ForwardVector;
+ double StartTime = 0.0;
+ float Duration = 0.f;
+ /** 0..1, from the damage. */
+ float Strength = 1.f;
+};
+
+enum class EVerseFeedKind : uint8
+{
+ Kill,
+ Respawn,
+ SetEnd,
+};
+
+struct VERSEUI_API FVerseKillFeedEntry
+{
+ EVerseFeedKind Kind = EVerseFeedKind::Kill;
+ int32 KillerId = INDEX_NONE;
+ int32 VictimId = INDEX_NONE;
+ EVerseDamageSource Cause = EVerseDamageSource::Bolt;
+ FName WeaponId;
+ bool bHeadshot = false;
+ /** The killing bolt went through at least one piece. */
+ bool bWallShot = false;
+ EVerseSetOutcome Outcome = EVerseSetOutcome::Unfinished;
+ double Time = 0.0;
+};
+
+/** Tuning of the HUD model (unreal/Verse/Data/ui/hud.json "timing"). */
+struct VERSEUI_API FVerseHudTiming
+{
+ float HitMarker = 0.30f;
+ float HeadshotMarker = 0.40f;
+ float KillMarker = 0.70f;
+ float BlockedMarker = 0.40f;
+ float DamageIndicator = 1.6f;
+ float FeedEntry = 6.f;
+ int32 FeedMax = 5;
+ int32 SetTarget = 10;
+};
+
+/**
+ * The HUD's view of the fight, fed by hub events and the HUD source (WP18.2-18.4). Pure C++:
+ * no world, no widgets, so every rule here is unit tested. "Now" is local real time in
+ * seconds; server times only drive the respawn countdown.
+ */
+class VERSEUI_API FVerseHudModel
+{
+public:
+ FVerseHudTiming Timing;
+
+ void Reset();
+ void SetLocalPlayerId(int32 Id) { LocalId = Id; }
+ int32 GetLocalPlayerId() const { return LocalId; }
+
+ void OnHit(const FVerseHitEvent& Event, double Now);
+ void OnDeath(const FVerseDeathEvent& Event, double Now);
+ void OnSetEnded(const FVerseSetSummary& Summary, double Now);
+ /** A finished set from the other side's view never arrives; this is the person's summary. */
+
+ /** Expires markers and feed lines; raises the respawn line when a dead player's RespawnAt passes. */
+ void Tick(double Now, double ServerTime);
+
+ const TArray<FVerseHitMarker>& GetHitMarkers() const { return HitMarkers; }
+ const TArray<FVerseDamageIndicator>& GetDamageIndicators() const { return DamageIndicators; }
+ /** Oldest first. */
+ const TArray<FVerseKillFeedEntry>& GetKillFeed() const { return Feed; }
+
+ int32 GetScoreSelf() const { return ScoreSelf; }
+ int32 GetScoreOpponent() const { return ScoreOpponent; }
+ int32 GetSetIndex() const { return SetIndex; }
+
+ bool IsLocalDead() const { return bLocalDead; }
+ /** Seconds until the person respawns (server clock), 0 when alive. */
+ float GetRespawnRemaining(double ServerTime) const;
+ /** Server time of the person's respawn. */
+ double GetLocalRespawnAt() const { return LocalRespawnAt; }
+
+ /** The last summary, for the end-of-set screen. */
+ const TOptional<FVerseSetSummary>& GetLastSummary() const { return LastSummary; }
+
+ static float MarkerAlpha(const FVerseHitMarker& Marker, double Now);
+
+private:
+ void PushFeed(const FVerseKillFeedEntry& Entry);
+
+ int32 LocalId = INDEX_NONE;
+ TArray<FVerseHitMarker> HitMarkers;
+ TArray<FVerseDamageIndicator> DamageIndicators;
+ TArray<FVerseKillFeedEntry> Feed;
+ /** Victim id -> the last hit on them (wall shot and headshot of the kill). */
+ TMap<int32, FVerseHitEvent> LastHitOn;
+ /** Dead player id -> RespawnAt (server time). */
+ TMap<int32, double> PendingRespawn;
+ int32 ScoreSelf = 0;
+ int32 ScoreOpponent = 0;
+ int32 SetIndex = 1;
+ bool bLocalDead = false;
+ double LocalRespawnAt = 0.0;
+ TOptional<FVerseSetSummary> LastSummary;
+};
diff --git a/unreal/Verse/Source/VerseUI/Public/Hud/VerseHudPainter.h b/unreal/Verse/Source/VerseUI/Public/Hud/VerseHudPainter.h
new file mode 100644
index 0000000000..714d5f5fdb
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Public/Hud/VerseHudPainter.h
@@ -0,0 +1,138 @@
+#pragma once
+
+#include "Core/VerseUiLayout.h"
+#include "Core/VerseUiPorts.h"
+#include "CoreMinimal.h"
+#include "Hud/VerseHudModel.h"
+
+class FVerseUiStrings;
+class UCanvas;
+class UFont;
+
+enum class EVerseTextAlign : uint8
+{
+ Left,
+ Centre,
+ Right,
+};
+
+/**
+ * A flat list of what the HUD draws this frame. The painter fills it from pure inputs (so tests
+ * read exactly what would be drawn); FVerseHudCanvasRenderer turns it into canvas items.
+ */
+struct VERSEUI_API FVerseHudDrawList
+{
+ struct FLine
+ {
+ FVector2D A, B;
+ float Thickness = 1.f;
+ FLinearColor Colour;
+ FName Tag;
+ };
+ struct FRect
+ {
+ FVector2D Min, Max;
+ FLinearColor Colour;
+ FName Tag;
+ };
+ struct FTri
+ {
+ FVector2D A, B, C;
+ FLinearColor Colour;
+ FName Tag;
+ };
+ struct FLabel
+ {
+ /** Anchor point; meaning depends on Align (left edge, centre or right edge of the top). */
+ FVector2D Position;
+ FText Text;
+ int32 FontSize = 12;
+ bool bBold = false;
+ FLinearColor Colour;
+ EVerseTextAlign Align = EVerseTextAlign::Left;
+ /** Width the layout reserved (0 = unbounded); A18.4 checks text fits it. */
+ float MaxWidth = 0.f;
+ /** Measured size, filled by the painter. */
+ FVector2D Size = FVector2D::ZeroVector;
+ FName Tag;
+ };
+
+ TArray<FLine> Lines;
+ TArray<FRect> Rects;
+ TArray<FTri> Tris;
+ TArray<FLabel> Labels;
+
+ /** Where the crosshair centre was drawn (A18.1). */
+ FVector2D CrosshairCentre = FVector2D::ZeroVector;
+ bool bCrosshairVisible = false;
+
+ void Reset();
+ int32 Num() const { return Lines.Num() + Rects.Num() + Tris.Num() + Labels.Num(); }
+ int32 CountTag(FName Tag) const;
+ const FLabel* FindLabel(FName Tag) const;
+};
+
+/** Text measure: text, point size, bold -> size in pixels. */
+using FVerseTextMeasure = TFunction<FVector2D(const FText&, int32, bool)>;
+
+/** Everything one HUD frame depends on. */
+struct VERSEUI_API FVerseHudFrame
+{
+ const FVerseHudModel* Model = nullptr;
+ const FVerseUiStrings* Strings = nullptr;
+ const IVerseHudSource* Source = nullptr;
+ FVerseUiLayout Layout;
+ FVerseHudPawnState Pawn;
+ FVerseHudView View;
+ bool bHasView = false;
+ double Now = 0.0;
+ double ServerTime = 0.0;
+ /** Kill cam running: crosshair and ammo hide, the banner shows. */
+ bool bKillCam = false;
+ int32 KillCamKillerId = INDEX_NONE;
+ /** Key name shown on the skip hint, for example "Space". */
+ FText SkipKeyName;
+ bool bReducedMotion = false;
+ /** Hide the duel blocks outside a duel (only the crosshair-free deck HUD stays). */
+ bool bInDuel = true;
+};
+
+/** Builds the HUD draw list (WP18.1-18.4, 18.10). */
+class VERSEUI_API FVerseHudPainter
+{
+public:
+ /** Slate font measure when Slate runs, else a monospace estimate. */
+ static FVerseTextMeasure DefaultMeasure();
+
+ static void Paint(const FVerseHudFrame& Frame, FVerseHudDrawList& Out, const FVerseTextMeasure& Measure);
+
+ /** Shape signature of a marker kind (line count, rect count, tri count), for WP18.10 tests. */
+ static FIntVector MarkerShape(EVerseHitMarkerKind Kind);
+
+ /** Point on screen a damage indicator points to, clockwise angle from straight ahead. */
+ static float IndicatorAngleDeg(const FVerseHudView& View, const FVector& FromDirection);
+
+private:
+ static void PaintCrosshair(const FVerseHudFrame& Frame, FVerseHudDrawList& Out);
+ static void PaintMarkers(const FVerseHudFrame& Frame, FVerseHudDrawList& Out);
+ static void PaintDamage(const FVerseHudFrame& Frame, FVerseHudDrawList& Out);
+ static void PaintVitals(const FVerseHudFrame& Frame, FVerseHudDrawList& Out, const FVerseTextMeasure& Measure);
+ static void PaintWeapon(const FVerseHudFrame& Frame, FVerseHudDrawList& Out, const FVerseTextMeasure& Measure);
+ static void PaintScore(const FVerseHudFrame& Frame, FVerseHudDrawList& Out, const FVerseTextMeasure& Measure);
+ static void PaintFeed(const FVerseHudFrame& Frame, FVerseHudDrawList& Out, const FVerseTextMeasure& Measure);
+ static void PaintCentre(const FVerseHudFrame& Frame, FVerseHudDrawList& Out, const FVerseTextMeasure& Measure);
+};
+
+/** Draws a list on a canvas (game HUD post-render, or a render target for captures). */
+class VERSEUI_API FVerseHudCanvasRenderer
+{
+public:
+ static void Render(UCanvas* Canvas, const FVerseHudDrawList& List);
+
+ /**
+ * The runtime-cache engine font every label item carries. A canvas text item built from a
+ * Slate font alone has no UFont and draws nothing (the engine's HasValidText checks the
+ * UFont); with this one set, the Slate font info still picks the face and size.
+ */
+ static const UFont* LabelFont();
+};
diff --git a/unreal/Verse/Source/VerseUI/Public/KillCam/VerseKillCam.h b/unreal/Verse/Source/VerseUI/Public/KillCam/VerseKillCam.h
new file mode 100644
index 0000000000..fc90f5c297
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Public/KillCam/VerseKillCam.h
@@ -0,0 +1,135 @@
+#pragma once
+
+#include "Combat/VerseCombatTypes.h"
+#include "Core/VerseUiPorts.h"
+#include "CoreMinimal.h"
+#include "Destruction/VerseDestructionTypes.h"
+
+/**
+ * Client ring buffer of the last seconds of the fight (WP18.5): every visible pawn's pose,
+ * fire events and fracture events, stamped with server time so they line up with
+ * FVerseDeathEvent::ServerTime. Pure C++.
+ */
+class VERSEUI_API FVerseKillCamBuffer
+{
+public:
+ struct FPoseSample
+ {
+ double Time = 0.0;
+ FVector Location = FVector::ZeroVector;
+ FRotator Rotation = FRotator::ZeroRotator;
+ };
+ struct FFireSample
+ {
+ double Time = 0.0;
+ FVerseFireEvent Event;
+ };
+ struct FFractureSample
+ {
+ double Time = 0.0;
+ FVerseFractureEvent Event;
+ };
+
+ /** Seconds kept (4 s, work-packages WP18.5). */
+ double Window = 4.0;
+
+ void Reset();
+ void AddPose(int32 PlayerId, double ServerTime, const FVector& Location, const FRotator& Rotation);
+ void AddFire(const FVerseFireEvent& Event, double ServerTime);
+ void AddFracture(const FVerseFractureEvent& Event, double ServerTime);
+ /** Drops everything older than Window before Now. */
+ void Trim(double ServerNow);
+
+ /** Interpolated pose at Time; false when the player has no samples around it. */
+ bool PoseAt(int32 PlayerId, double Time, FVector& OutLocation, FRotator& OutRotation) const;
+ /** Earliest time the player has a sample for, or +inf. */
+ double EarliestPose(int32 PlayerId) const;
+
+ const TArray<FFireSample>& GetFires() const { return Fires; }
+ const TArray<FFractureSample>& GetFractures() const { return Fractures; }
+ int32 NumPoses(int32 PlayerId) const;
+
+private:
+ TMap<int32, TArray<FPoseSample>> Poses;
+ TArray<FFireSample> Fires;
+ TArray<FFractureSample> Fractures;
+};
+
+enum class EVerseKillCamState : uint8
+{
+ Idle,
+ Playing,
+ Finished,
+ Skipped,
+};
+
+/** Tuning (unreal/Verse/Data/ui/hud.json "kill_cam"). */
+struct VERSEUI_API FVerseKillCamTuning
+{
+ /** End at least this long before respawn (A18.2 asks 200 ms; 250 leaves a frame of slack). */
+ float EndMarginS = 0.25f;
+ /** Shortest replay worth starting. */
+ float MinLengthS = 0.5f;
+ /** Third-person camera behind the killer, cm. */
+ float CameraBack = 260.f;
+ float CameraUp = 70.f;
+ float CameraRight = 45.f;
+ /** Finisher kills are cut before the takedown when gore is reduced (README Gore). */
+ float FinisherCutS = 2.5f;
+};
+
+/**
+ * Plays one kill cam: the killer's last seconds in third person while the person waits to
+ * respawn (A18.2: starts on the death event's frame, ends before respawn, killer path from the
+ * buffer). Replayed fire and fracture events go out through the callbacks so VFX and the
+ * destruction client can redraw them.
+ */
+class VERSEUI_API FVerseKillCamPlayer
+{
+public:
+ FVerseKillCamTuning Tuning;
+ TFunction<void(const FVerseFireEvent&)> OnReplayFire;
+ TFunction<void(const FVerseFractureEvent&)> OnReplayFracture;
+
+ /**
+ * Starts on a death of the local player. Copies the clip out of the buffer, so recording can
+ * go on. False (and Idle) for a suicide, a world kill, no killer samples, or no time left.
+ */
+ bool Begin(const FVerseKillCamBuffer& Buffer, const FVerseDeathEvent& Death, int32 LocalPlayerId,
+ double LocalNow, double ServerNow, bool bCutFinisher);
+
+ /** Advances; fires replayed events crossed since the last tick. */
+ void Tick(double LocalNow);
+ void Skip(double LocalNow);
+ void Stop();
+
+ EVerseKillCamState GetState() const { return State; }
+ bool IsPlaying() const { return State == EVerseKillCamState::Playing; }
+ int32 GetKillerId() const { return KillerId; }
+
+ /** Server time being shown. */
+ double GetReplayTime() const { return ReplayTime; }
+ double GetClipStart() const { return ClipStart; }
+ double GetClipEnd() const { return ClipEnd; }
+ /** Local time the replay started and ends (planned). */
+ double GetPlayStart() const { return PlayStart; }
+ double GetPlannedEnd() const { return PlayStart + (ClipEnd - ClipStart); }
+ double GetEndedAt() const { return EndedAt; }
+
+ /** The killer's pose at the replay time. */
+ bool GetKillerPose(FVector& OutLocation, FRotator& OutRotation) const;
+ /** Third-person camera looking past the killer at the replay time. */
+ bool GetCamera(FVector& OutLocation, FRotator& OutRotation) const;
+
+private:
+ FVerseKillCamBuffer Clip;
+ EVerseKillCamState State = EVerseKillCamState::Idle;
+ int32 KillerId = INDEX_NONE;
+ double ClipStart = 0.0;
+ double ClipEnd = 0.0;
+ double PlayStart = 0.0;
+ double ReplayTime = 0.0;
+ double EndedAt = 0.0;
+ int32 NextFire = 0;
+ int32 NextFracture = 0;
+};
diff --git a/unreal/Verse/Source/VerseUI/Public/Menus/VerseUiMenus.h b/unreal/Verse/Source/VerseUI/Public/Menus/VerseUiMenus.h
new file mode 100644
index 0000000000..6dc116f607
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Public/Menus/VerseUiMenus.h
@@ -0,0 +1,116 @@
+#pragma once
+
+#include "Combat/VerseCombatTypes.h"
+#include "CoreMinimal.h"
+
+/** One loadout line of the armoury (combat-state 2.2). */
+struct VERSEUI_API FVerseArmouryItem
+{
+ EVerseLoadoutSlot Slot = EVerseLoadoutSlot::Primary;
+ /** Item id; strings keys verse.item.<id>.name and verse.item.<id>.role. */
+ FName ItemId;
+ /** "firearm" | "melee" | "gadget" */
+ FString Kind;
+};
+
+/**
+ * Armoury (WP18.6): the loadout both duellists get, the bot tier, start duel. Data from
+ * unreal/Verse/Data/ui/armoury.json; the loadout follows UVerseRuleset::GetLoadout once WP11
+ * offers a choice.
+ */
+class VERSEUI_API FVerseArmouryModel
+{
+public:
+ static FString DefaultPath();
+ bool LoadJson(const FString& Json, FString* OutError = nullptr);
+ bool LoadFile(const FString& Path, FString* OutError = nullptr);
+
+ const TArray<FVerseArmouryItem>& GetLoadout() const { return Loadout; }
+ /** normal, hard, elite, adaptive */
+ const TArray<FName>& GetTiers() const { return Tiers; }
+ FName GetSelectedTier() const { return SelectedTier; }
+ bool SelectTier(FName Tier);
+ void CycleTier(int32 Direction);
+
+private:
+ TArray<FVerseArmouryItem> Loadout;
+ TArray<FName> Tiers;
+ FName SelectedTier = TEXT("hard");
+};
+
+enum class EVerseBarEntryKind : uint8
+{
+ QuickStartDuel,
+ Deck,
+ ReturnToApp,
+};
+
+struct VERSEUI_API FVerseBarEntry
+{
+ EVerseBarEntryKind Kind = EVerseBarEntryKind::Deck;
+ /** Deck id for Deck entries. */
+ FName Id;
+ FString LabelKey;
+ bool bActive = false;
+ bool bEnabled = true;
+};
+
+/** Verse bar (WP18.7, parity D-03): quick-start duel, the decks of welcome.decks, return to app. */
+struct VERSEUI_API FVerseBarModel
+{
+ static TArray<FVerseBarEntry> Build(const TArray<FName>& Decks, FName CurrentDeck, bool bDuelRunning);
+};
+
+struct VERSEUI_API FVerseEndScreenRow
+{
+ FString LabelKey;
+ FText Person;
+ FText Opponent;
+};
+
+/** End-of-set screen (WP18.9) from FVerseSetSummary and, for the adaptive tier, the bot's s. */
+struct VERSEUI_API FVerseEndScreen
+{
+ EVerseSetOutcome Outcome = EVerseSetOutcome::Unfinished;
+ FString TitleKey;
+ int32 SetIndex = 0;
+ int32 PersonKills = 0;
+ int32 OpponentKills = 0;
+ FName Tier;
+ bool bShowSkill = false;
+ /** Adaptive s in [0, 1] (bot.md 9.2). */
+ float Skill = -1.f;
+ TArray<FVerseEndScreenRow> Rows;
+
+ /** Numbers are formatted in Lang (the Verse UI language), never the machine's culture. */
+ static FVerseEndScreen Build(const FVerseSetSummary& Summary, float BotEffectiveSkill, const FString& Lang = TEXT("en"));
+};
+
+/** Totals of the duel session the summary shows on leave (parity D-10). */
+struct VERSEUI_API FVerseSessionSummary
+{
+ int32 SetsWon = 0;
+ int32 SetsLost = 0;
+ /** Summed lines of every finished set; BestStreak is the best of them. */
+ FVerseSetSummary Totals;
+ /** The person left while a set was running (verse.duel.notice.left). */
+ bool bLeftMidSet = false;
+
+ void Reset() { *this = FVerseSessionSummary(); }
+ void AddSet(const FVerseSetSummary& Set);
+ int32 NumSets() const { return SetsWon + SetsLost; }
+
+ /** Rows like the end-of-set screen, in Lang. */
+ FVerseEndScreen BuildScreen(const FString& Lang) const;
+};
+
+/** The screens the UI layer can show over the game. */
+enum class EVerseUiScreen : uint8
+{
+ None,
+ EscMenu,
+ Settings,
+ Armoury,
+ EndOfSet,
+ SessionSummary,
+};
diff --git a/unreal/Verse/Source/VerseUI/Public/Settings/VerseUiInputRemap.h b/unreal/Verse/Source/VerseUI/Public/Settings/VerseUiInputRemap.h
new file mode 100644
index 0000000000..0bc5c4cae7
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Public/Settings/VerseUiInputRemap.h
@@ -0,0 +1,33 @@
+#pragma once
+
+#include "CoreMinimal.h"
+#include "Settings/VerseUiSettings.h"
+
+class UInputMappingContext;
+class UEnhancedInputLocalPlayerSubsystem;
+
+/**
+ * Applies the person's gameplay key bindings (WP18.8) to the Enhanced Input mapping contexts
+ * the input owners add for the local player (WP01's IMC_VersePerson, later the weapon and
+ * station contexts). keys.json names per action the input action ("input_action", for
+ * example IA_Jump) and the default key: the first mapping of that action on that key is the
+ * one the binding moves, so gamepad mappings, second keyboard keys and modifiers stay.
+ */
+class VERSEUI_API FVerseUiInputRemap
+{
+public:
+ /** Sets Context's bound mappings to KeyMap's current keys; true when a key changed. */
+ bool Apply(UInputMappingContext* Context, const FVerseKeyMap& KeyMap);
+
+ /** Applies to every context applied to Subsystem's player; rebuilds its mappings on a change. */
+ int32 ApplyToPlayer(UEnhancedInputLocalPlayerSubsystem* Subsystem, const FVerseKeyMap& KeyMap);
+
+ /** Mapping indices this remap owns in Context (tests). */
+ int32 NumBound(const UInputMappingContext* Context) const;
+
+ void Reset() { Slots.Reset(); }
+
+private:
+ /** context -> (mapping index -> keys.json action), found once from the default keys. */
+ TMap<TWeakObjectPtr<UInputMappingContext>, TMap<int32, FName>> Slots;
+};
diff --git a/unreal/Verse/Source/VerseUI/Public/Settings/VerseUiSettings.h b/unreal/Verse/Source/VerseUI/Public/Settings/VerseUiSettings.h
new file mode 100644
index 0000000000..22bdff180b
--- /dev/null
+++ b/unreal/Verse/Source/VerseUI/Public/Settings/VerseUiSettings.h
@@ -0,0 +1,168 @@
+#pragma once
+
+#include "Combat/VerseCombatTypes.h"
+#include "CoreMinimal.h"
+#include "Dom/JsonObject.h"
+#include "InputCoreTypes.h"
+#include "UObject/Object.h"
+
+#include "VerseUiSettings.generated.h"
+
+/**
+ * App-backed Verse settings (bridge-protocol 3.2 welcome.settings). The app config is their
+ * truth: Verse reads them from welcome, applies settings.changed live and writes them with
+ * settings.set (bridge-protocol 14), so they survive a Verse restart in the app config.
+ */
+struct VERSEUI_API FVerseAppSettings
+{
+ EVerseGoreLevel Gore = EVerseGoreLevel::Full;
+ bool bReducedMotion = false;
+ FKey ReturnKey = EKeys::F10;
+ bool bUiSound = true;
+ bool bLevelSound = true;
+ FString Uniform = TEXT("standard");
+ /** "third" | "first" | "overview" */
+ FString ViewMode = TEXT("third");
+ float Sensitivity = 1.f;
+ bool bInvertY = false;
+ /** Deck view FOVs (parity V-09). */
+ float FovThird = 70.f;
+ float FovFirst = 85.f;
+ FString Quality = TEXT("auto");
+ float Volume = 0.7f;
+
+ /** Reads welcome.settings, or applies a settings.changed / settings.set subset over this. */
+ void ApplyJson(const TSharedPtr<FJsonObject>& Json);
+ /** The full welcome.settings object. */
+ TSharedRef<FJsonObject> ToJson() const;
+ /** The subset of fields where Other differs from this, in settings.set shape. */
+ TSharedRef<FJsonObject> Diff(const FVerseAppSettings& Other) const;
+
+ static FString GoreToString(EVerseGoreLevel Level);
+ static bool GoreFromString(const FString& Text, EVerseGoreLevel& Out);
+};
+
+USTRUCT()
+struct VERSEUI_API FVerseKeyBinding
+{
+ GENERATED_BODY()
+
+ UPROPERTY(Config)
+ FName Action;
+
+ UPROPERTY(Config)
+ FKey Key;
+};
+
+/**
+ * Unreal-only settings, in Unreal's user settings file (GameUserSettings.ini), so they survive
+ * a restart without the app (WP18.8): duel FOV, key bindings except the return key,
+ * scalability, text size, last tier.
+ */
+UCLASS(Config = GameUserSettings, ConfigDoNotCheckDefaults)
+class VERSEUI_API UVerseUiUserSettings : public UObject
+{
+ GENERATED_BODY()
+
+public:
+ static constexpr float DuelFovMin = 80.f;
+ static constexpr float DuelFovMax = 110.f;
+ /** bot.md 3.1 sizes the bot's view cone from this default. */
+ static constexpr float DuelFovDefault = 100.f;
+
+ /** Horizontal FOV in the duel, 80-110. */
+ UPROPERTY(Config)
+ float DuelFov = DuelFovDefault;
+
+ UPROPERTY(Config)
+ TArray<FVerseKeyBinding> KeyBindings;
+
+ /** -1 = auto (the engine's benchmark), 0..4 = low..cinematic. */
+ UPROPERTY(Config)
+ int32 Scalability = -1;
+
+ /** Accessibility text size, 0.8-1.6. */
+ UPROPERTY(Config)
+ float TextScale = 1.f;
+
+ /** Last tier chosen at the armoury: normal, hard, elite, adaptive. */
+ UPROPERTY(Config)
+ FName LastTier = TEXT("hard");
+
+ /** Bumped on each save (tests read it back). */
+ UPROPERTY(Config)
+ int32 SaveCount = 0;
+
+ void Clamp();
+ void SaveToDisk();
+ void ReloadFromDisk();
+};
+
+/** Commands keys can trigger in the UI layer. Gameplay actions belong to the input owners. */
+enum class EVerseUiCommand : uint8
+{
+ None,
+ ReturnToApp,
+ EscMenu,
+ SkipKillCam,
+ VerseBar,
+};
+
+/**
+ * The bindable actions and their default keys (unreal/Verse/Data/ui/keys.json), and the
+ * person's current choice. The return key is app-backed (welcome.settings.return_key); every
+ * other binding lives in UVerseUiUserSettings.
+ */
+class VERSEUI_API FVerseKeyMap
+{
+public:
+ struct FAction
+ {
+ FName Action;
+ FKey DefaultKey;
+ /** strings key of the label. */
+ FString LabelKey;
+ /** The UI handles it itself (return, Esc menu, skip, bar); others are gameplay input. */
+ EVerseUiCommand Command = EVerseUiCommand::None;
+ /**
+ * Gameplay input: the Enhanced Input action the input owner maps DefaultKey to (for
+ * example IA_Jump, WP01). The binding moves that one mapping (FVerseUiInputRemap).
+ */
+ FName InputAction;
+ };
+
+ static FName ReturnAction() { return TEXT("return_to_app"); }
+
+ /** <project>/Data/ui/keys.json */
+ static FString DefaultPath();
+ bool LoadJson(const FString& Json, FString* OutError = nullptr);
+ bool LoadFile(const FString& Path, FString* OutError = nullptr);
+
+ const TArray<FAction>& GetActions() const { return Actions; }
+ const FAction* FindAction(FName Action) const;
+
+ /** Current key (user choice, else default). The return key comes from the app settings. */
+ FKey GetKey(FName Action) const;
+
+ /** Takes the person's bindings; unknown actions are dropped. */
+ void SetBindings(const TArray<FVerseKeyBinding>& Bindings);
+ TArray<FVerseKeyBinding> GetBindings() const;
+ void SetReturnKey(const FKey& Key) { ReturnKey = Key; }
+
+ /**
+ * Binds Key to Action. When another action already has Key it gets Action's old key (swap),
+ * so no key is ever bound twice. Returns the action that was swapped, or NAME_None.
+ */
+ FName Rebind(FName Action, const FKey& Key);
+
+ /** Keys a binding may never take (Esc is the menu, the system keys stay the system's). */
+ static bool IsReserved(const FKey& Key);
+
+ /** What a key press does in the UI layer. */
+ EVerseUiCommand Route(const FKey& Key) const;
+
+private:
+ TArray<FAction> Actions;
+ TMap<FName, FKey> Overrides;
+ FKey ReturnKey = EKeys::F10;
+};
diff --git a/unreal/Verse/Source/VerseUI/VerseUI.Build.cs b/unreal/Verse/Source/VerseUI/VerseUI.Build.cs
index 6cc4046799..7f0f473e85 100644
--- a/unreal/Verse/Source/VerseUI/VerseUI.Build.cs
+++ b/unreal/Verse/Source/VerseUI/VerseUI.Build.cs
@@ -9,7 +9,9 @@ public class VerseUI : ModuleRules
PCHUsage = PCHUsageMode.UseExplicitOrSharedPCHs;
PublicDependencyModuleNames.AddRange(new string[] { "Core", "CoreUObject", "Engine" });
PublicDependencyModuleNames.AddRange(new string[] { "VerseCore", "VerseBridge", "VerseCombat", "VerseCrew", "VerseDecks" });
- // Json: station command data; Slate: the plain station overlay until WP18's UI root (WP16, request to the integration owner).
- PrivateDependencyModuleNames.AddRange(new string[] { "Json", "Slate", "SlateCore" });
+ // Engine modules only: Json and Slate for WP16's station overlay and command data; WP18's HUD,
+ // menus, key bindings into Enhanced Input, JSON data and render-target captures. Engine
+ // re-exports their headers but not their import libraries.
+ PrivateDependencyModuleNames.AddRange(new string[] { "InputCore", "EnhancedInput", "Json", "Slate", "SlateCore", "RenderCore", "RHI", "ImageCore" });
}
}