diff --git a/Content.Client/Lobby/LobbyUIController.cs b/Content.Client/Lobby/LobbyUIController.cs index acbcceeb565e2f..19f43e05752bbf 100644 --- a/Content.Client/Lobby/LobbyUIController.cs +++ b/Content.Client/Lobby/LobbyUIController.cs @@ -11,6 +11,7 @@ using Content.Shared.Preferences.Loadouts; using Content.Shared.Preferences.Loadouts.Effects; using Content.Shared.Roles; +using Robust.Client.State; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controllers; using Robust.Shared.Map; @@ -21,6 +22,7 @@ namespace Content.Client.Lobby; public sealed class LobbyUIController : UIController, IOnStateEntered, IOnStateExited { [Dependency] private readonly IClientPreferencesManager _preferencesManager = default!; + [Dependency] private readonly IStateManager _stateManager = default!; [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [UISystemDependency] private readonly HumanoidAppearanceSystem _humanoid = default!; [UISystemDependency] private readonly ClientInventorySystem _inventory = default!; @@ -73,7 +75,7 @@ public void SetPreviewPanel(LobbyCharacterPreviewPanel? panel) UpdateCharacterUI(); } - public void SetDummyJob(JobPrototype? job, RoleLoadout? loadout) + public void SetDummyJob(JobPrototype? job) { _dummyJob = job; UpdateCharacterUI(); @@ -81,6 +83,10 @@ public void SetDummyJob(JobPrototype? job, RoleLoadout? loadout) public void UpdateCharacterUI() { + // Test moment + if (_stateManager.CurrentState is not LobbyState) + return; + if (!_preferencesManager.ServerDataLoaded) { _previewPanel?.SetLoaded(false); diff --git a/Content.Client/Lobby/UI/LobbyCharacterPreviewPanel.cs b/Content.Client/Lobby/UI/LobbyCharacterPreviewPanel.cs deleted file mode 100644 index e017dddbe0afdc..00000000000000 --- a/Content.Client/Lobby/UI/LobbyCharacterPreviewPanel.cs +++ /dev/null @@ -1,97 +0,0 @@ -using System.Numerics; -using Content.Client.UserInterface.Controls; -using Robust.Client.UserInterface; -using Robust.Client.UserInterface.Controls; -using static Robust.Client.UserInterface.Controls.BoxContainer; - -namespace Content.Client.Lobby.UI; - -/// -/// Handles the entity preview for a character in a particular role. -/// -public sealed class LobbyCharacterPreviewPanel : Control -{ - private readonly Label _summaryLabel; - private readonly BoxContainer _loaded; - private readonly BoxContainer _viewBox; - private readonly Label _unloaded; - - public LobbyCharacterPreviewPanel() - { - IoCManager.InjectDependencies(this); - var header = new NanoHeading - { - Text = Loc.GetString("lobby-character-preview-panel-header") - }; - - CharacterSetupButton = new Button - { - Text = Loc.GetString("lobby-character-preview-panel-character-setup-button"), - HorizontalAlignment = HAlignment.Center, - Margin = new Thickness(0, 5, 0, 0), - }; - - _summaryLabel = new Label - { - HorizontalAlignment = HAlignment.Center, - Margin = new Thickness(3, 3), - }; - - var vBox = new BoxContainer - { - Orientation = LayoutOrientation.Vertical - }; - _unloaded = new Label { Text = Loc.GetString("lobby-character-preview-panel-unloaded-preferences-label") }; - - _loaded = new BoxContainer - { - Orientation = LayoutOrientation.Vertical, - Visible = false - }; - _viewBox = new BoxContainer - { - Orientation = LayoutOrientation.Horizontal, - HorizontalAlignment = HAlignment.Center, - }; - var vSpacer = new VSpacer(); - - _loaded.AddChild(_summaryLabel); - _loaded.AddChild(_viewBox); - _loaded.AddChild(vSpacer); - _loaded.AddChild(CharacterSetupButton); - - vBox.AddChild(header); - vBox.AddChild(_loaded); - vBox.AddChild(_unloaded); - AddChild(vBox); - - UserInterfaceManager.GetUIController().SetPreviewPanel(this); - } - - public void SetLoaded(bool value) - { - _loaded.Visible = value; - _unloaded.Visible = !value; - } - - public void SetSummaryText(string value) - { - _summaryLabel.Text = string.Empty; - } - - public void SetSprite(EntityUid uid) - { - _viewBox.DisposeAllChildren(); - var spriteView = new SpriteView - { - OverrideDirection = Direction.South, - Scale = new Vector2(4f, 4f), - MaxSize = new Vector2(112, 112), - Stretch = SpriteView.StretchMode.Fill, - }; - spriteView.SetEntity(uid); - _viewBox.AddChild(spriteView); - } - - public Button CharacterSetupButton { get; } -} diff --git a/Content.Client/Lobby/UI/LobbyCharacterPreviewPanel.xaml b/Content.Client/Lobby/UI/LobbyCharacterPreviewPanel.xaml new file mode 100644 index 00000000000000..997507414cd750 --- /dev/null +++ b/Content.Client/Lobby/UI/LobbyCharacterPreviewPanel.xaml @@ -0,0 +1,22 @@ + + + + + + +