Lobby Refactor (#7077)

This commit is contained in:
Jesse Rougeau
2022-03-13 19:33:19 -07:00
committed by GitHub
parent 8470e83af4
commit 8418098dd8
17 changed files with 278 additions and 250 deletions

View File

@@ -9,6 +9,7 @@ using Content.Shared.Station;
using JetBrains.Annotations; using JetBrains.Annotations;
using Robust.Client.Graphics; using Robust.Client.Graphics;
using Robust.Client.State; using Robust.Client.State;
using Robust.Shared.ContentPack;
using Robust.Shared.IoC; using Robust.Shared.IoC;
using Robust.Shared.Log; using Robust.Shared.Log;
using Robust.Shared.Network; using Robust.Shared.Network;
@@ -21,7 +22,6 @@ namespace Content.Client.GameTicking.Managers
public sealed class ClientGameTicker : SharedGameTicker public sealed class ClientGameTicker : SharedGameTicker
{ {
[Dependency] private readonly IStateManager _stateManager = default!; [Dependency] private readonly IStateManager _stateManager = default!;
[ViewVariables] private bool _initialized; [ViewVariables] private bool _initialized;
private Dictionary<StationId, Dictionary<string, int>> _jobsAvailable = new(); private Dictionary<StationId, Dictionary<string, int>> _jobsAvailable = new();
private Dictionary<StationId, string> _stationNames = new(); private Dictionary<StationId, string> _stationNames = new();
@@ -29,6 +29,7 @@ namespace Content.Client.GameTicking.Managers
[ViewVariables] public bool AreWeReady { get; private set; } [ViewVariables] public bool AreWeReady { get; private set; }
[ViewVariables] public bool IsGameStarted { get; private set; } [ViewVariables] public bool IsGameStarted { get; private set; }
[ViewVariables] public string? LobbySong { get; private set; } [ViewVariables] public string? LobbySong { get; private set; }
[ViewVariables] public string? LobbyBackground { get; private set; }
[ViewVariables] public bool DisallowedLateJoin { get; private set; } [ViewVariables] public bool DisallowedLateJoin { get; private set; }
[ViewVariables] public string? ServerInfoBlob { get; private set; } [ViewVariables] public string? ServerInfoBlob { get; private set; }
[ViewVariables] public TimeSpan StartTime { get; private set; } [ViewVariables] public TimeSpan StartTime { get; private set; }
@@ -89,6 +90,7 @@ namespace Content.Client.GameTicking.Managers
IsGameStarted = message.IsRoundStarted; IsGameStarted = message.IsRoundStarted;
AreWeReady = message.YouAreReady; AreWeReady = message.YouAreReady;
LobbySong = message.LobbySong; LobbySong = message.LobbySong;
LobbyBackground = message.LobbyBackground;
Paused = message.Paused; Paused = message.Paused;
if (IsGameStarted) if (IsGameStarted)
Status.Clear(); Status.Clear();

View File

@@ -0,0 +1,32 @@
using Content.Client.Changelog;
using Content.Client.Credits;
using Content.Client.Links;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Utility;
namespace Content.Client.Info
{
public sealed class DevInfoBanner : BoxContainer
{
public DevInfoBanner() {
var buttons = new BoxContainer
{
Orientation = LayoutOrientation.Horizontal
};
AddChild(buttons);
var uriOpener = IoCManager.Resolve<IUriOpener>();
var reportButton = new Button {Text = Loc.GetString("server-info-report-button")};
reportButton.OnPressed += args => uriOpener.OpenUri(UILinks.BugReport);
var creditsButton = new Button {Text = Loc.GetString("server-info-credits-button")};
creditsButton.OnPressed += args => new CreditsWindow().Open();
buttons.AddChild(reportButton);
buttons.AddChild(creditsButton);
}
}
}

View File

@@ -0,0 +1,43 @@
using Content.Client.Changelog;
using Content.Client.Credits;
using Content.Client.Links;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.IoC;
using Robust.Shared.Localization;
using Robust.Shared.Utility;
namespace Content.Client.Info
{
public sealed class LinkBanner : BoxContainer
{
public LinkBanner()
{
var buttons = new BoxContainer
{
Orientation = LayoutOrientation.Horizontal
};
AddChild(buttons);
var uriOpener = IoCManager.Resolve<IUriOpener>();
var rulesButton = new Button() {Text = Loc.GetString("server-info-rules-button")};
rulesButton.OnPressed += args => new RulesAndInfoWindow().Open();
var discordButton = new Button {Text = Loc.GetString("server-info-discord-button")};
discordButton.OnPressed += args => uriOpener.OpenUri(UILinks.Discord);
var websiteButton = new Button {Text = Loc.GetString("server-info-website-button")};
websiteButton.OnPressed += args => uriOpener.OpenUri(UILinks.Website);
var wikiButton = new Button {Text = Loc.GetString("server-info-wiki-button")};
wikiButton.OnPressed += args => uriOpener.OpenUri(UILinks.Wiki);
var changelogButton = new ChangelogButton();
buttons.AddChild(changelogButton);
buttons.AddChild(rulesButton);
buttons.AddChild(discordButton);
buttons.AddChild(websiteButton);
buttons.AddChild(wikiButton);
}
}
}

View File

@@ -22,48 +22,7 @@ namespace Content.Client.Info
VerticalExpand = true VerticalExpand = true
}; };
AddChild(_richTextLabel); AddChild(_richTextLabel);
var buttons = new BoxContainer
{
Orientation = LayoutOrientation.Horizontal
};
AddChild(buttons);
var uriOpener = IoCManager.Resolve<IUriOpener>();
var rulesButton = new Button() { Text = Loc.GetString("server-info-rules-button") };
rulesButton.OnPressed += args => new RulesAndInfoWindow().Open();
var discordButton = new Button {Text = Loc.GetString("server-info-discord-button") };
discordButton.OnPressed += args => uriOpener.OpenUri(UILinks.Discord);
var websiteButton = new Button {Text = Loc.GetString("server-info-website-button") };
websiteButton.OnPressed += args => uriOpener.OpenUri(UILinks.Website);
var wikiButton = new Button {Text = Loc.GetString("server-info-wiki-button") };
wikiButton.OnPressed += args => uriOpener.OpenUri(UILinks.Wiki);
var reportButton = new Button { Text = Loc.GetString("server-info-report-button") };
reportButton.OnPressed += args => uriOpener.OpenUri(UILinks.BugReport);
var creditsButton = new Button { Text = Loc.GetString("server-info-credits-button") };
creditsButton.OnPressed += args => new CreditsWindow().Open();
var changelogButton = new ChangelogButton
{
HorizontalExpand = true,
HorizontalAlignment = HAlignment.Right
};
buttons.AddChild(rulesButton);
buttons.AddChild(discordButton);
buttons.AddChild(websiteButton);
buttons.AddChild(wikiButton);
buttons.AddChild(reportButton);
buttons.AddChild(creditsButton);
buttons.AddChild(changelogButton);
} }
public void SetInfoBlob(string markup) public void SetInfoBlob(string markup)
{ {
_richTextLabel.SetMessage(FormattedMessage.FromMarkup(markup)); _richTextLabel.SetMessage(FormattedMessage.FromMarkup(markup));

View File

@@ -8,6 +8,7 @@ using Content.Client.LateJoin;
using Content.Client.Lobby.UI; using Content.Client.Lobby.UI;
using Content.Client.Preferences; using Content.Client.Preferences;
using Content.Client.Preferences.UI; using Content.Client.Preferences.UI;
using Content.Client.Resources;
using Content.Client.Voting; using Content.Client.Voting;
using Content.Shared.GameTicking; using Content.Shared.GameTicking;
using Robust.Client; using Robust.Client;
@@ -22,6 +23,7 @@ using Robust.Shared.IoC;
using Robust.Shared.Localization; using Robust.Shared.Localization;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
using Robust.Shared.Timing; using Robust.Shared.Timing;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables; using Robust.Shared.ViewVariables;
namespace Content.Client.Lobby namespace Content.Client.Lobby
@@ -104,12 +106,10 @@ namespace Content.Client.Lobby
_lobby.LeaveButton.OnPressed += _ => _consoleHost.ExecuteCommand("disconnect"); _lobby.LeaveButton.OnPressed += _ => _consoleHost.ExecuteCommand("disconnect");
_lobby.OptionsButton.OnPressed += _ => new OptionsMenu().Open(); _lobby.OptionsButton.OnPressed += _ => new OptionsMenu().Open();
UpdatePlayerList();
_playerManager.PlayerListUpdated += PlayerManagerOnPlayerListUpdated; _playerManager.PlayerListUpdated += PlayerManagerOnPlayerListUpdated;
_gameTicker.InfoBlobUpdated += UpdateLobbyUi; _gameTicker.InfoBlobUpdated += UpdateLobbyUi;
_gameTicker.LobbyStatusUpdated += LobbyStatusUpdated; _gameTicker.LobbyStatusUpdated += LobbyStatusUpdated;
_gameTicker.LobbyReadyUpdated += LobbyReadyUpdated;
_gameTicker.LobbyLateJoinStatusUpdated += LobbyLateJoinStatusUpdated; _gameTicker.LobbyLateJoinStatusUpdated += LobbyLateJoinStatusUpdated;
} }
@@ -118,7 +118,6 @@ namespace Content.Client.Lobby
_playerManager.PlayerListUpdated -= PlayerManagerOnPlayerListUpdated; _playerManager.PlayerListUpdated -= PlayerManagerOnPlayerListUpdated;
_gameTicker.InfoBlobUpdated -= UpdateLobbyUi; _gameTicker.InfoBlobUpdated -= UpdateLobbyUi;
_gameTicker.LobbyStatusUpdated -= LobbyStatusUpdated; _gameTicker.LobbyStatusUpdated -= LobbyStatusUpdated;
_gameTicker.LobbyReadyUpdated -= LobbyReadyUpdated;
_gameTicker.LobbyLateJoinStatusUpdated -= LobbyLateJoinStatusUpdated; _gameTicker.LobbyLateJoinStatusUpdated -= LobbyLateJoinStatusUpdated;
_lobby?.Dispose(); _lobby?.Dispose();
@@ -176,14 +175,12 @@ namespace Content.Client.Lobby
} }
} }
UpdatePlayerList();
} }
private void LobbyReadyUpdated() => UpdatePlayerList();
private void LobbyStatusUpdated() private void LobbyStatusUpdated()
{ {
UpdatePlayerList(); UpdateLobbyBackground();
UpdateLobbyUi(); UpdateLobbyUi();
} }
@@ -222,35 +219,18 @@ namespace Content.Client.Lobby
} }
} }
private void UpdatePlayerList() private void UpdateLobbyBackground()
{ {
if (_lobby == null) return; if (_lobby == null) return;
_lobby.OnlinePlayerList.Clear(); if (_gameTicker.LobbyBackground != null)
var gameTicker = EntitySystem.Get<ClientGameTicker>();
foreach (var session in _playerManager.Sessions.OrderBy(s => s.Name))
{ {
var readyState = string.Empty; _lobby.Background.Texture = _resourceCache.GetResource<TextureResource>(_gameTicker.LobbyBackground );
// Don't show ready state if we're ingame
if (!gameTicker.IsGameStarted)
{
LobbyPlayerStatus status;
if (session.UserId == _playerManager.LocalPlayer?.UserId)
status = gameTicker.AreWeReady ? LobbyPlayerStatus.Ready : LobbyPlayerStatus.NotReady;
else
gameTicker.Status.TryGetValue(session.UserId, out status);
readyState = status switch
{
LobbyPlayerStatus.NotReady => Loc.GetString("lobby-state-player-status-not-ready"),
LobbyPlayerStatus.Ready => Loc.GetString("lobby-state-player-status-ready"),
LobbyPlayerStatus.Observer => Loc.GetString("lobby-state-player-status-observer"),
_ => string.Empty,
};
}
_lobby.OnlinePlayerList.AddItem(session.Name, readyState);
} }
else
{
_lobby.Background.Texture = null;
}
} }
private void SetReady(bool newReady) private void SetReady(bool newReady)
@@ -261,7 +241,6 @@ namespace Content.Client.Lobby
} }
_consoleHost.ExecuteCommand($"toggleready {newReady}"); _consoleHost.ExecuteCommand($"toggleready {newReady}");
UpdatePlayerList();
} }
} }
} }

View File

@@ -2,6 +2,7 @@ using System.Linq;
using Content.Client.HUD.UI; using Content.Client.HUD.UI;
using Content.Client.Inventory; using Content.Client.Inventory;
using Content.Client.Preferences; using Content.Client.Preferences;
using Content.Client.UserInterface.Controls;
using Content.Shared.CharacterAppearance.Systems; using Content.Shared.CharacterAppearance.Systems;
using Content.Shared.GameTicking; using Content.Shared.GameTicking;
using Content.Shared.Inventory; using Content.Shared.Inventory;
@@ -23,23 +24,20 @@ namespace Content.Client.Lobby.UI
{ {
public sealed class LobbyCharacterPreviewPanel : Control public sealed class LobbyCharacterPreviewPanel : Control
{ {
private readonly IEntityManager _entMan; [Dependency] private readonly IEntityManager _entityManager = default!;
private readonly IClientPreferencesManager _preferencesManager; [Dependency] private readonly IClientPreferencesManager _preferencesManager = default!;
private readonly IPrototypeManager _prototypeManager; [Dependency] private readonly IPrototypeManager _prototypeManager = default!;
private EntityUid? _previewDummy; private EntityUid? _previewDummy;
private readonly Label _summaryLabel; private readonly Label _summaryLabel;
private readonly BoxContainer _loaded; private readonly BoxContainer _loaded;
private readonly BoxContainer _viewBox; private readonly BoxContainer _viewBox;
private readonly Label _unloaded; private readonly Label _unloaded;
public LobbyCharacterPreviewPanel(IEntityManager entityManager, public LobbyCharacterPreviewPanel()
IClientPreferencesManager preferencesManager,
IPrototypeManager prototypeManager)
{ {
_entMan = entityManager; IoCManager.InjectDependencies(this);
_preferencesManager = preferencesManager;
_prototypeManager = prototypeManager;
var header = new NanoHeading var header = new NanoHeading
{ {
Text = Loc.GetString("lobby-character-preview-panel-header") Text = Loc.GetString("lobby-character-preview-panel-header")
@@ -57,9 +55,6 @@ namespace Content.Client.Lobby.UI
{ {
Orientation = LayoutOrientation.Vertical Orientation = LayoutOrientation.Vertical
}; };
vBox.AddChild(header);
_unloaded = new Label { Text = Loc.GetString("lobby-character-preview-panel-unloaded-preferences-label") }; _unloaded = new Label { Text = Loc.GetString("lobby-character-preview-panel-unloaded-preferences-label") };
_loaded = new BoxContainer _loaded = new BoxContainer
@@ -67,17 +62,18 @@ namespace Content.Client.Lobby.UI
Orientation = LayoutOrientation.Vertical, Orientation = LayoutOrientation.Vertical,
Visible = false Visible = false
}; };
_loaded.AddChild(CharacterSetupButton);
_loaded.AddChild(_summaryLabel);
_viewBox = new BoxContainer _viewBox = new BoxContainer
{ {
Orientation = LayoutOrientation.Horizontal Orientation = LayoutOrientation.Horizontal
}; };
var _vSpacer = new VSpacer();
_loaded.AddChild(_summaryLabel);
_loaded.AddChild(_viewBox); _loaded.AddChild(_viewBox);
_loaded.AddChild(_vSpacer);
_loaded.AddChild(CharacterSetupButton);
vBox.AddChild(header);
vBox.AddChild(_loaded); vBox.AddChild(_loaded);
vBox.AddChild(_unloaded); vBox.AddChild(_unloaded);
AddChild(vBox); AddChild(vBox);
@@ -95,7 +91,7 @@ namespace Content.Client.Lobby.UI
_preferencesManager.OnServerDataLoaded -= UpdateUI; _preferencesManager.OnServerDataLoaded -= UpdateUI;
if (!disposing) return; if (!disposing) return;
if (_previewDummy != null) _entMan.DeleteEntity(_previewDummy.Value); if (_previewDummy != null) _entityManager.DeleteEntity(_previewDummy.Value);
_previewDummy = default; _previewDummy = default;
} }
@@ -103,7 +99,7 @@ namespace Content.Client.Lobby.UI
{ {
return new() return new()
{ {
Sprite = _entMan.GetComponent<ISpriteComponent>(entity), Sprite = _entityManager.GetComponent<ISpriteComponent>(entity),
OverrideDirection = direction, OverrideDirection = direction,
Scale = (2, 2) Scale = (2, 2)
}; };
@@ -126,7 +122,7 @@ namespace Content.Client.Lobby.UI
} }
else else
{ {
_previewDummy = _entMan.SpawnEntity(_prototypeManager.Index<SpeciesPrototype>(selectedCharacter.Species).DollPrototype, MapCoordinates.Nullspace); _previewDummy = _entityManager.SpawnEntity(_prototypeManager.Index<SpeciesPrototype>(selectedCharacter.Species).DollPrototype, MapCoordinates.Nullspace);
var viewSouth = MakeSpriteView(_previewDummy.Value, Direction.South); var viewSouth = MakeSpriteView(_previewDummy.Value, Direction.South);
var viewNorth = MakeSpriteView(_previewDummy.Value, Direction.North); var viewNorth = MakeSpriteView(_previewDummy.Value, Direction.North);
var viewWest = MakeSpriteView(_previewDummy.Value, Direction.West); var viewWest = MakeSpriteView(_previewDummy.Value, Direction.West);

View File

@@ -1,10 +1,10 @@
<Control xmlns="https://spacestation14.io" <Control xmlns="https://spacestation14.io"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
xmlns:maths="clr-namespace:Robust.Shared.Maths;assembly=Robust.Shared.Maths" xmlns:maths="clr-namespace:Robust.Shared.Maths;assembly=Robust.Shared.Maths"
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls" xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
xmlns:ui="clr-namespace:Content.Client.UserInterface.Controls"
xmlns:parallax="clr-namespace:Content.Client.Parallax" xmlns:parallax="clr-namespace:Content.Client.Parallax"
xmlns:ui="clr-namespace:Content.Client.Voting.UI" xmlns:vote="clr-namespace:Content.Client.Voting.UI"
xmlns:style="clr-namespace:Content.Client.Stylesheets" xmlns:style="clr-namespace:Content.Client.Stylesheets"
xmlns:hudUi="clr-namespace:Content.Client.HUD.UI" xmlns:hudUi="clr-namespace:Content.Client.HUD.UI"
xmlns:chatUi="clr-namespace:Content.Client.Chat.UI" xmlns:chatUi="clr-namespace:Content.Client.Chat.UI"
@@ -13,29 +13,12 @@
<Control> <Control>
<!-- Parallax background --> <!-- Parallax background -->
<parallax:ParallaxControl /> <parallax:ParallaxControl />
<TextureRect Access="Public" Name = "Background" Stretch="Scale"/>
<Control Margin="20 20 20 20"> <Control Margin="10 10 10 10" >
<PanelContainer StyleClasses="AngleRect" /> <!-- Left Top Panel -->
<BoxContainer Orientation="Vertical"> <PanelContainer StyleClasses="AngleRect" HorizontalAlignment="Left" Name = "LeftSideTop" VerticalExpand="True" VerticalAlignment="Top" >
<!-- Top row --> <BoxContainer Orientation="Vertical" HorizontalAlignment="Center" MaxWidth="620">
<BoxContainer Orientation="Horizontal" MinSize="0 40"> <info:LinkBanner Name="LinkBanner" VerticalExpand="false" HorizontalAlignment="Center" Margin="3 3 3 3"/>
<Label Margin="8 0 0 0" StyleClasses="LabelHeadingBigger" VAlign="Center" Text="{Loc 'ui-lobby-title'}" />
<Label Name="ServerName" Access="Public" StyleClasses="LabelHeadingBigger" VAlign="Center" />
<ui:VoteCallMenuButton Name="CallVoteButton" StyleClasses="ButtonBig" />
<Button Name="OptionsButton" Access="Public" StyleClasses="ButtonBig" Text="{Loc 'ui-lobby-options-button'}" />
<Button Name="LeaveButton" Access="Public" StyleClasses="ButtonBig" Text="{Loc 'ui-lobby-leave-button'}" />
</BoxContainer>
<!-- Gold line -->
<PanelContainer>
<PanelContainer.PanelOverride>
<gfx:StyleBoxFlat BackgroundColor="{x:Static style:StyleNano.NanoGold}"
ContentMarginTopOverride="2" />
</PanelContainer.PanelOverride>
</PanelContainer>
<!-- Middle section with the two vertical panels -->
<BoxContainer Orientation="Horizontal" VerticalExpand="True">
<!-- Left panel -->
<BoxContainer Orientation="Vertical" Name="LeftPanelContainer" HorizontalExpand="True">
<hudUi:StripeBack> <hudUi:StripeBack>
<BoxContainer Orientation="Horizontal" SeparationOverride="6" Margin="3 3 3 3"> <BoxContainer Orientation="Horizontal" SeparationOverride="6" Margin="3 3 3 3">
<cc:UICommandButton Command="observe" Name="ObserveButton" Access="Public" Text="{Loc 'ui-lobby-observe-button'}" StyleClasses="ButtonBig" WindowType="{x:Type lobbyUi:ObserveWarningWindow}"/> <cc:UICommandButton Command="observe" Name="ObserveButton" Access="Public" Text="{Loc 'ui-lobby-observe-button'}" StyleClasses="ButtonBig" WindowType="{x:Type lobbyUi:ObserveWarningWindow}"/>
@@ -46,41 +29,45 @@
StyleClasses="LabelBig" HorizontalExpand="True" /> StyleClasses="LabelBig" HorizontalExpand="True" />
<Button Name="ReadyButton" Access="Public" ToggleMode="True" Text="{Loc 'ui-lobby-ready-up-button'}" <Button Name="ReadyButton" Access="Public" ToggleMode="True" Text="{Loc 'ui-lobby-ready-up-button'}"
StyleClasses="ButtonBig" /> StyleClasses="ButtonBig" />
</BoxContainer> </BoxContainer></hudUi:StripeBack>
</hudUi:StripeBack>
<chatUi:ChatBox Name="Chat" Access="Public" VerticalExpand="True" Margin="3 3 3 3"/>
</BoxContainer> </BoxContainer>
<!-- Gold line --> </PanelContainer>
<PanelContainer MinSize="2 0"> <!-- Left Bot Panel -->
<PanelContainer.PanelOverride> <BoxContainer Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Bottom" MaxWidth="620">
<gfx:StyleBoxFlat BackgroundColor="{x:Static style:StyleNano.NanoGold}" /> <info:DevInfoBanner Name="DevInfoBanner" VerticalExpand="false" Margin="3 3 3 3"/>
</PanelContainer.PanelOverride>
</PanelContainer>
<!-- Right panel -->
<Control HorizontalExpand="True">
<BoxContainer Orientation="Vertical">
<!-- Player list -->
<hudUi:NanoHeading Text="{Loc 'ui-lobby-online-players-block'}" />
<lobbyUi:LobbyPlayerList Name="OnlinePlayerList"
Access="Public"
HorizontalExpand="True"
VerticalExpand="True"
Margin="3 3 3 3" />
<!-- Server info -->
<hudUi:NanoHeading Text="{Loc 'ui-lobby-server-info-block'}" />
<info:ServerInfo Name="ServerInfo"
Access="Public"
VerticalExpand="True"
Margin="3 3 3 3"/>
</BoxContainer>
<BoxContainer Orientation="Vertical"
Name="VoteContainer"
Access="Public"
HorizontalAlignment="Right"
Margin="0 8 8 0" />
</Control>
</BoxContainer>
</BoxContainer> </BoxContainer>
<!-- RightPanel Panel -->
<PanelContainer Name="RightSide" StyleClasses="AngleRect" HorizontalAlignment= "Right" VerticalExpand="True" VerticalAlignment="Stretch">
<BoxContainer Orientation="Vertical">
<!-- Top row -->
<BoxContainer Orientation="Horizontal" MinSize="0 40" Name="HeaderContainer" Access="Public">
<Label Margin="8 0 0 0" StyleClasses="LabelHeadingBigger" VAlign="Center" Text="{Loc 'ui-lobby-title'}" />
<Label Name="ServerName" Access="Public" StyleClasses="LabelHeadingBigger" VAlign="Center" />
</BoxContainer>
<!-- Gold line -->
<ui:HLine Color="{x:Static style:StyleNano.NanoGold}" Thickness="2"/>
<ui:HSpacer Spacing="10"/>
<!-- Voting bar -->
<BoxContainer Orientation="Horizontal" MinSize="0 40" Name="VoteContainer" Access="Public" HorizontalAlignment="Right">
<cc:CommandButton Name = "AHelpButton" Command="openahelp" Access="Public" Text = "{Loc 'ui-lobby-ahelp-button'}" StyleClasses="ButtonBig"/>
<vote:VoteCallMenuButton Name="CallVoteButton" StyleClasses="ButtonBig" />
<Button Name="OptionsButton" Access="Public" StyleClasses="ButtonBig" Text="{Loc 'ui-lobby-options-button'}" />
<Button Name="LeaveButton" Access="Public" StyleClasses="ButtonBig" Text="{Loc 'ui-lobby-leave-button'}" />
</BoxContainer>
<ui:HSpacer Spacing="10"/>
<!-- Server info -->
<hudUi:NanoHeading Text="{Loc 'ui-lobby-server-info-block'}" />
<info:ServerInfo Name="ServerInfo" Access="Public" MinSize="0 30" VerticalExpand="false" Margin="3 3 3 3" MaxWidth="400"/>
<ui:HSpacer Spacing="5"/>
<lobbyUi:LobbyCharacterPreviewPanel Name="CharacterPreview" Access="Public"></lobbyUi:LobbyCharacterPreviewPanel>
<ui:HSpacer Spacing="5"/>
<BoxContainer MinHeight="10"/>
<!-- Gold line -->
<ui:HLine Color="{x:Static style:StyleNano.NanoGold}" Thickness="2" Access="Public"/>
<ui:HSpacer Spacing="10"/>
<chatUi:ChatBox Name="Chat" Access="Public" VerticalExpand="True" Margin="3 3 3 3" MinHeight="50"/>
</BoxContainer>
</PanelContainer>
</Control> </Control>
</Control> </Control>
</Control> </Control>

View File

@@ -17,108 +17,12 @@ namespace Content.Client.Lobby.UI
[GenerateTypedNameReferences] [GenerateTypedNameReferences]
internal sealed partial class LobbyGui : Control internal sealed partial class LobbyGui : Control
{ {
public LobbyCharacterPreviewPanel CharacterPreview { get; }
public LobbyGui(IEntityManager entityManager, public LobbyGui(IEntityManager entityManager,
IClientPreferencesManager preferencesManager) IClientPreferencesManager preferencesManager)
{ {
RobustXamlLoader.Load(this); RobustXamlLoader.Load(this);
ServerName.HorizontalExpand = true; ServerName.HorizontalExpand = true;
ServerName.HorizontalAlignment = HAlignment.Center; ServerName.HorizontalAlignment = HAlignment.Center;
CharacterPreview = new LobbyCharacterPreviewPanel(
entityManager,
preferencesManager,
IoCManager.Resolve<IPrototypeManager>())
{
HorizontalAlignment = HAlignment.Left
};
LeftPanelContainer.AddChild(CharacterPreview);
CharacterPreview.SetPositionFirst();
}
}
public sealed class LobbyPlayerList : Control
{
private readonly ScrollContainer _scroll;
private readonly BoxContainer _vBox;
public LobbyPlayerList()
{
var panel = new PanelContainer()
{
PanelOverride = new StyleBoxFlat { BackgroundColor = Color.FromHex("#202028") },
};
_vBox = new BoxContainer
{
Orientation = LayoutOrientation.Vertical
};
_scroll = new ScrollContainer();
_scroll.AddChild(_vBox);
panel.AddChild(_scroll);
AddChild(panel);
}
// Adds a row
public void AddItem(string name, string status)
{
var hbox = new BoxContainer
{
Orientation = LayoutOrientation.Horizontal,
HorizontalExpand = true,
};
// Player Name
hbox.AddChild(new PanelContainer()
{
PanelOverride = new StyleBoxFlat
{
BackgroundColor = Color.FromHex("#373744"),
ContentMarginBottomOverride = 2,
ContentMarginLeftOverride = 4,
ContentMarginRightOverride = 4,
ContentMarginTopOverride = 2
},
Children =
{
new Label
{
Text = name
}
},
HorizontalExpand = true
});
// Status
hbox.AddChild(new PanelContainer()
{
PanelOverride = new StyleBoxFlat
{
BackgroundColor = Color.FromHex("#373744"),
ContentMarginBottomOverride = 2,
ContentMarginLeftOverride = 4,
ContentMarginRightOverride = 4,
ContentMarginTopOverride = 2
},
Children =
{
new Label
{
Text = status
}
},
HorizontalExpand = true,
SizeFlagsStretchRatio = 0.2f,
});
_vBox.AddChild(hbox);
}
// Deletes all rows
public void Clear()
{
_vBox.RemoveAllChildren();
} }
} }
} }

View File

@@ -0,0 +1,46 @@
using Content.Client.Stylesheets;
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Maths;
namespace Content.Client.UserInterface.Controls;
public sealed class HLine : Container
{
public Color? Color
{
get
{
if (_line.PanelOverride is StyleBoxFlat styleBox) return styleBox.BackgroundColor;
return null;
}
set
{
if (_line.PanelOverride is StyleBoxFlat styleBox) styleBox.BackgroundColor = value!.Value;
}
}
public float? Thickness {
get
{
if (_line.PanelOverride is StyleBoxFlat styleBox) return styleBox.ContentMarginTopOverride;
return null;
}
set
{
if (_line.PanelOverride is StyleBoxFlat styleBox) styleBox.ContentMarginTopOverride = value!.Value;
}
}
private readonly PanelContainer _line;
public HLine()
{
_line = new PanelContainer();
_line.PanelOverride = new StyleBoxFlat();
_line.PanelOverride.ContentMarginTopOverride = Thickness;
AddChild(_line);
}
}

View File

@@ -0,0 +1,21 @@
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Maths;
using TerraFX.Interop.Windows;
namespace Content.Client.UserInterface.Controls;
public sealed class HSpacer : Control
{
public float Spacing { get => MinHeight; set => MinHeight = value; }
public HSpacer()
{
MinHeight = Spacing;
}
public HSpacer(float height = 5)
{
Spacing = height;
MinHeight = height;
}
}

View File

@@ -0,0 +1,20 @@
using Robust.Client.Graphics;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Maths;
namespace Content.Client.UserInterface.Controls;
public sealed class VSpacer : Control
{
public float Spacing{ get => MinWidth; set => MinWidth = value; }
public VSpacer()
{
MinWidth = Spacing;
}
public VSpacer(float width = 5)
{
Spacing = width;
MinWidth = width;
}
}

View File

@@ -71,7 +71,7 @@ namespace Content.Server.GameTicking
private TickerLobbyStatusEvent GetStatusMsg(IPlayerSession session) private TickerLobbyStatusEvent GetStatusMsg(IPlayerSession session)
{ {
_playersInLobby.TryGetValue(session, out var status); _playersInLobby.TryGetValue(session, out var status);
return new TickerLobbyStatusEvent(RunLevel != GameRunLevel.PreRoundLobby, LobbySong, status == LobbyPlayerStatus.Ready, _roundStartTime, Paused); return new TickerLobbyStatusEvent(RunLevel != GameRunLevel.PreRoundLobby, LobbySong, LobbyBackground,status == LobbyPlayerStatus.Ready, _roundStartTime, Paused);
} }
private void SendStatusToAll() private void SendStatusToAll()

View File

@@ -0,0 +1,33 @@
using System.IO;
using System.Linq;
using Content.Shared.Audio;
using Robust.Shared.ContentPack;
using Robust.Shared.Random;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
namespace Content.Server.GameTicking;
public sealed partial class GameTicker
{
[Dependency] private readonly IResourceManager _resourceManager = default!;
[ViewVariables]
public string? LobbyBackground { get; private set; }
[ViewVariables]
private List<ResourcePath>? _lobbyBackgrounds;
private static readonly string[] WhitelistedBackgroundExtensions = new string[] {"png", "jpg", "jpeg"};
private const string LobbyScreenPath = "/Textures/LobbyScreens";
private void InitializeLobbyBackground()
{
_lobbyBackgrounds = _resourceManager.ContentFindFiles(new ResourcePath(LobbyScreenPath)).ToList();
_lobbyBackgrounds = _lobbyBackgrounds.FindAll(path => WhitelistedBackgroundExtensions.Contains((path.Extension)));
LobbyBackground = _lobbyBackgrounds.Any() ? _robustRandom.Pick(_lobbyBackgrounds).ToString() : null;
}
}

View File

@@ -50,6 +50,7 @@ namespace Content.Server.GameTicking
InitializeCVars(); InitializeCVars();
InitializePlayer(); InitializePlayer();
InitializeLobbyMusic(); InitializeLobbyMusic();
InitializeLobbyBackground();
InitializeGamePreset(); InitializeGamePreset();
InitializeJobController(); InitializeJobController();
InitializeUpdates(); InitializeUpdates();

View File

@@ -44,15 +44,17 @@ namespace Content.Shared.GameTicking
{ {
public bool IsRoundStarted { get; } public bool IsRoundStarted { get; }
public string? LobbySong { get; } public string? LobbySong { get; }
public string? LobbyBackground { get; }
public bool YouAreReady { get; } public bool YouAreReady { get; }
// UTC. // UTC.
public TimeSpan StartTime { get; } public TimeSpan StartTime { get; }
public bool Paused { get; } public bool Paused { get; }
public TickerLobbyStatusEvent(bool isRoundStarted, string? lobbySong, bool youAreReady, TimeSpan startTime, bool paused) public TickerLobbyStatusEvent(bool isRoundStarted, string? lobbySong, string? lobbyBackground, bool youAreReady, TimeSpan startTime, bool paused)
{ {
IsRoundStarted = isRoundStarted; IsRoundStarted = isRoundStarted;
LobbySong = lobbySong; LobbySong = lobbySong;
LobbyBackground = lobbyBackground;
YouAreReady = youAreReady; YouAreReady = youAreReady;
StartTime = startTime; StartTime = startTime;
Paused = paused; Paused = paused;

View File

@@ -1,4 +1,5 @@
ui-lobby-title = Lobby ui-lobby-title = Lobby
ui-lobby-ahelp-button = AHelp
ui-lobby-options-button = Options ui-lobby-options-button = Options
ui-lobby-leave-button = Leave ui-lobby-leave-button = Leave
ui-lobby-observe-button = Observe ui-lobby-observe-button = Observe

View File

@@ -0,0 +1,2 @@
Note:
Only png and jpgs files are supported