CatStation/Content.Client/Arcade/SpaceVillainArcadeMenu.xaml.cs
Stefano Pigozzi 06da8d4b7f
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>
2026-07-17 16:33:56 +00:00

45 lines
2.1 KiB
C#

using Content.Shared.Arcade;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface.CustomControls;
using Robust.Client.UserInterface.XAML;
namespace Content.Client.Arcade;
[GenerateTypedNameReferences]
public sealed partial class SpaceVillainArcadeMenu : DefaultWindow
{
public event Action<SharedSpaceVillainArcadeComponent.PlayerAction>? OnPlayerAction;
public SpaceVillainArcadeMenu()
{
RobustXamlLoader.Load(this);
AttackButton.OnPressed += _ => OnPlayerAction?.Invoke(SharedSpaceVillainArcadeComponent.PlayerAction.Attack);
HealButton.OnPressed += _ => OnPlayerAction?.Invoke(SharedSpaceVillainArcadeComponent.PlayerAction.Heal);
RechargeButton.OnPressed += _ => OnPlayerAction?.Invoke(SharedSpaceVillainArcadeComponent.PlayerAction.Recharge);
NewGameButton.OnPressed += _ => OnPlayerAction?.Invoke(SharedSpaceVillainArcadeComponent.PlayerAction.NewGame);
}
private void UpdateMetadata(SharedSpaceVillainArcadeComponent.SpaceVillainArcadeMetaDataUpdateMessage message)
{
Title = message.GameTitle;
EnemyNameLabel.Text = message.EnemyName;
AttackButton.Disabled = message.ButtonsDisabled;
HealButton.Disabled = message.ButtonsDisabled;
RechargeButton.Disabled = message.ButtonsDisabled;
NewGameButton.Disabled = message.ButtonsDisabled;
}
public void UpdateInfo(SharedSpaceVillainArcadeComponent.SpaceVillainArcadeDataUpdateMessage message)
{
if (message is SharedSpaceVillainArcadeComponent.SpaceVillainArcadeMetaDataUpdateMessage metaMessage)
UpdateMetadata(metaMessage);
PlayerHpLabel.Text = Loc.GetString("spacevillain-menu-label-health", ("amount", message.PlayerHP));
PlayerMpLabel.Text = Loc.GetString("spacevillain-menu-label-magic", ("amount", message.PlayerMP));
EnemyHpLabel.Text = Loc.GetString("spacevillain-menu-label-health", ("amount", message.EnemyHP));
EnemyMpLabel.Text = Loc.GetString("spacevillain-menu-label-magic", ("amount", message.EnemyMP));
PlayerActionLabel.Text = message.PlayerActionMessage;
EnemyActionLabel.Text = message.EnemyActionMessage;
}
}