From 06da8d4b7fce9fb697e0b9ae4efaa01f44f2cd6b Mon Sep 17 00:00:00 2001 From: Stefano Pigozzi Date: Fri, 17 Jul 2026 18:33:56 +0200 Subject: [PATCH] Update Space Villain's UI (#40963) * Rewrite `SpaceVillainArcadeMenu`'s layout code * Rewrite `SpaceVillainArcadeMenu` to use XAML * Run "Format document" on the XAML * Make `SpaceVillainGame` strings more specific * Update Space Villain's localization Potentially breaking: All strings related to Space Villain now share the `space-villain` prefix, instead of mixing `spacevillain` and `space-villain`. * Use `StyleClasses` to make the action buttons display as a single line * Capitalize the Space Villain action button text * Tweak Space Villain colors a bit * Capitalize Space Villain's name in action messages * Capitalize slime enemy last name * Fix accidentaly find-and-replaced comment * Revert consistency changes to localization keys * Remove unnecessary expand and stretch properties * Rewrite Space Villain's info grid into a series of nested `BoxContainer` * Make HP and MP labels start with a space so that the spacer keeps a fixed size * Change spacers into plain `Control`s * fix --------- Co-authored-by: Pok245 <113675512+Pok27@users.noreply.github.com> --- .../Arcade/SpaceVillainArcadeMenu.cs | 114 ------------------ .../Arcade/SpaceVillainArcadeMenu.xaml | 98 +++++++++++++++ .../Arcade/SpaceVillainArcadeMenu.xaml.cs | 45 +++++++ .../space-villain-game-component.ftl | 20 +-- .../Locale/en-US/arcade/spacevillain.ftl | 12 +- .../Locale/en-US/datasets/arcade_villain.ftl | 2 +- 6 files changed, 163 insertions(+), 128 deletions(-) delete mode 100644 Content.Client/Arcade/SpaceVillainArcadeMenu.cs create mode 100644 Content.Client/Arcade/SpaceVillainArcadeMenu.xaml create mode 100644 Content.Client/Arcade/SpaceVillainArcadeMenu.xaml.cs diff --git a/Content.Client/Arcade/SpaceVillainArcadeMenu.cs b/Content.Client/Arcade/SpaceVillainArcadeMenu.cs deleted file mode 100644 index 3d25d2208d..0000000000 --- a/Content.Client/Arcade/SpaceVillainArcadeMenu.cs +++ /dev/null @@ -1,114 +0,0 @@ -using System.Numerics; -using Content.Client.Arcade.UI; -using Content.Shared.Arcade; -using Robust.Client.UserInterface.Controls; -using Robust.Client.UserInterface.CustomControls; - -namespace Content.Client.Arcade -{ - public sealed class SpaceVillainArcadeMenu : DefaultWindow - { - private readonly Label _enemyNameLabel; - private readonly Label _playerInfoLabel; - private readonly Label _enemyInfoLabel; - private readonly Label _playerActionLabel; - private readonly Label _enemyActionLabel; - - private readonly Button[] _gameButtons = new Button[3]; //used to disable/enable all game buttons - - public event Action? OnPlayerAction; - - public SpaceVillainArcadeMenu() - { - MinSize = SetSize = new Vector2(300, 225); - Title = Loc.GetString("spacevillain-menu-title"); - - var grid = new GridContainer { Columns = 1 }; - - var infoGrid = new GridContainer { Columns = 3 }; - infoGrid.AddChild(new Label { Text = Loc.GetString("spacevillain-menu-label-player"), Align = Label.AlignMode.Center }); - infoGrid.AddChild(new Label { Text = "|", Align = Label.AlignMode.Center }); - _enemyNameLabel = new Label { Align = Label.AlignMode.Center }; - infoGrid.AddChild(_enemyNameLabel); - - _playerInfoLabel = new Label { Align = Label.AlignMode.Center }; - infoGrid.AddChild(_playerInfoLabel); - infoGrid.AddChild(new Label { Text = "|", Align = Label.AlignMode.Center }); - _enemyInfoLabel = new Label { Align = Label.AlignMode.Center }; - infoGrid.AddChild(_enemyInfoLabel); - var centerContainer = new CenterContainer(); - centerContainer.AddChild(infoGrid); - grid.AddChild(centerContainer); - - _playerActionLabel = new Label { Align = Label.AlignMode.Center }; - grid.AddChild(_playerActionLabel); - - _enemyActionLabel = new Label { Align = Label.AlignMode.Center }; - grid.AddChild(_enemyActionLabel); - - var buttonGrid = new GridContainer { Columns = 3 }; - _gameButtons[0] = new Button() - { - Text = Loc.GetString("spacevillain-menu-button-attack") - }; - - _gameButtons[0].OnPressed += - _ => OnPlayerAction?.Invoke(SharedSpaceVillainArcadeComponent.PlayerAction.Attack); - buttonGrid.AddChild(_gameButtons[0]); - - _gameButtons[1] = new Button() - { - Text = Loc.GetString("spacevillain-menu-button-heal") - }; - - _gameButtons[1].OnPressed += - _ => OnPlayerAction?.Invoke(SharedSpaceVillainArcadeComponent.PlayerAction.Heal); - buttonGrid.AddChild(_gameButtons[1]); - - _gameButtons[2] = new Button() - { - Text = Loc.GetString("spacevillain-menu-button-recharge") - }; - - _gameButtons[2].OnPressed += - _ => OnPlayerAction?.Invoke(SharedSpaceVillainArcadeComponent.PlayerAction.Recharge); - buttonGrid.AddChild(_gameButtons[2]); - - centerContainer = new CenterContainer(); - centerContainer.AddChild(buttonGrid); - grid.AddChild(centerContainer); - - var newGame = new Button() - { - Text = Loc.GetString("spacevillain-menu-button-new-game") - }; - - newGame.OnPressed += _ => OnPlayerAction?.Invoke(SharedSpaceVillainArcadeComponent.PlayerAction.NewGame); - grid.AddChild(newGame); - - ContentsContainer.AddChild(grid); - } - - private void UpdateMetadata(SharedSpaceVillainArcadeComponent.SpaceVillainArcadeMetaDataUpdateMessage message) - { - Title = message.GameTitle; - _enemyNameLabel.Text = message.EnemyName; - - foreach (var gameButton in _gameButtons) - { - gameButton.Disabled = message.ButtonsDisabled; - } - } - - public void UpdateInfo(SharedSpaceVillainArcadeComponent.SpaceVillainArcadeDataUpdateMessage message) - { - if (message is SharedSpaceVillainArcadeComponent.SpaceVillainArcadeMetaDataUpdateMessage metaMessage) - UpdateMetadata(metaMessage); - - _playerInfoLabel.Text = $"HP: {message.PlayerHP} MP: {message.PlayerMP}"; - _enemyInfoLabel.Text = $"HP: {message.EnemyHP} MP: {message.EnemyMP}"; - _playerActionLabel.Text = message.PlayerActionMessage; - _enemyActionLabel.Text = message.EnemyActionMessage; - } - } -} diff --git a/Content.Client/Arcade/SpaceVillainArcadeMenu.xaml b/Content.Client/Arcade/SpaceVillainArcadeMenu.xaml new file mode 100644 index 0000000000..bc40fdb1c9 --- /dev/null +++ b/Content.Client/Arcade/SpaceVillainArcadeMenu.xaml @@ -0,0 +1,98 @@ + + + + + + + + + + + + + + + + + + +