Lobby Refactor (#7077)
This commit is contained in:
@@ -2,6 +2,7 @@ using System.Linq;
|
||||
using Content.Client.HUD.UI;
|
||||
using Content.Client.Inventory;
|
||||
using Content.Client.Preferences;
|
||||
using Content.Client.UserInterface.Controls;
|
||||
using Content.Shared.CharacterAppearance.Systems;
|
||||
using Content.Shared.GameTicking;
|
||||
using Content.Shared.Inventory;
|
||||
@@ -23,23 +24,20 @@ namespace Content.Client.Lobby.UI
|
||||
{
|
||||
public sealed class LobbyCharacterPreviewPanel : Control
|
||||
{
|
||||
private readonly IEntityManager _entMan;
|
||||
private readonly IClientPreferencesManager _preferencesManager;
|
||||
private readonly IPrototypeManager _prototypeManager;
|
||||
[Dependency] private readonly IEntityManager _entityManager = default!;
|
||||
[Dependency] private readonly IClientPreferencesManager _preferencesManager = default!;
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
|
||||
|
||||
private EntityUid? _previewDummy;
|
||||
private readonly Label _summaryLabel;
|
||||
private readonly BoxContainer _loaded;
|
||||
private readonly BoxContainer _viewBox;
|
||||
private readonly Label _unloaded;
|
||||
|
||||
public LobbyCharacterPreviewPanel(IEntityManager entityManager,
|
||||
IClientPreferencesManager preferencesManager,
|
||||
IPrototypeManager prototypeManager)
|
||||
public LobbyCharacterPreviewPanel()
|
||||
{
|
||||
_entMan = entityManager;
|
||||
_preferencesManager = preferencesManager;
|
||||
_prototypeManager = prototypeManager;
|
||||
|
||||
IoCManager.InjectDependencies(this);
|
||||
var header = new NanoHeading
|
||||
{
|
||||
Text = Loc.GetString("lobby-character-preview-panel-header")
|
||||
@@ -57,9 +55,6 @@ namespace Content.Client.Lobby.UI
|
||||
{
|
||||
Orientation = LayoutOrientation.Vertical
|
||||
};
|
||||
|
||||
vBox.AddChild(header);
|
||||
|
||||
_unloaded = new Label { Text = Loc.GetString("lobby-character-preview-panel-unloaded-preferences-label") };
|
||||
|
||||
_loaded = new BoxContainer
|
||||
@@ -67,17 +62,18 @@ namespace Content.Client.Lobby.UI
|
||||
Orientation = LayoutOrientation.Vertical,
|
||||
Visible = false
|
||||
};
|
||||
|
||||
_loaded.AddChild(CharacterSetupButton);
|
||||
_loaded.AddChild(_summaryLabel);
|
||||
|
||||
_viewBox = new BoxContainer
|
||||
{
|
||||
Orientation = LayoutOrientation.Horizontal
|
||||
};
|
||||
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);
|
||||
@@ -95,7 +91,7 @@ namespace Content.Client.Lobby.UI
|
||||
_preferencesManager.OnServerDataLoaded -= UpdateUI;
|
||||
|
||||
if (!disposing) return;
|
||||
if (_previewDummy != null) _entMan.DeleteEntity(_previewDummy.Value);
|
||||
if (_previewDummy != null) _entityManager.DeleteEntity(_previewDummy.Value);
|
||||
_previewDummy = default;
|
||||
}
|
||||
|
||||
@@ -103,7 +99,7 @@ namespace Content.Client.Lobby.UI
|
||||
{
|
||||
return new()
|
||||
{
|
||||
Sprite = _entMan.GetComponent<ISpriteComponent>(entity),
|
||||
Sprite = _entityManager.GetComponent<ISpriteComponent>(entity),
|
||||
OverrideDirection = direction,
|
||||
Scale = (2, 2)
|
||||
};
|
||||
@@ -126,7 +122,7 @@ namespace Content.Client.Lobby.UI
|
||||
}
|
||||
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 viewNorth = MakeSpriteView(_previewDummy.Value, Direction.North);
|
||||
var viewWest = MakeSpriteView(_previewDummy.Value, Direction.West);
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
<Control xmlns="https://spacestation14.io"
|
||||
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:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
|
||||
xmlns:ui="clr-namespace:Content.Client.UserInterface.Controls"
|
||||
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:hudUi="clr-namespace:Content.Client.HUD.UI"
|
||||
xmlns:chatUi="clr-namespace:Content.Client.Chat.UI"
|
||||
@@ -13,29 +13,12 @@
|
||||
<Control>
|
||||
<!-- Parallax background -->
|
||||
<parallax:ParallaxControl />
|
||||
|
||||
<Control Margin="20 20 20 20">
|
||||
<PanelContainer StyleClasses="AngleRect" />
|
||||
<BoxContainer Orientation="Vertical">
|
||||
<!-- Top row -->
|
||||
<BoxContainer Orientation="Horizontal" MinSize="0 40">
|
||||
<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">
|
||||
<TextureRect Access="Public" Name = "Background" Stretch="Scale"/>
|
||||
<Control Margin="10 10 10 10" >
|
||||
<!-- Left Top Panel -->
|
||||
<PanelContainer StyleClasses="AngleRect" HorizontalAlignment="Left" Name = "LeftSideTop" VerticalExpand="True" VerticalAlignment="Top" >
|
||||
<BoxContainer Orientation="Vertical" HorizontalAlignment="Center" MaxWidth="620">
|
||||
<info:LinkBanner Name="LinkBanner" VerticalExpand="false" HorizontalAlignment="Center" Margin="3 3 3 3"/>
|
||||
<hudUi:StripeBack>
|
||||
<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}"/>
|
||||
@@ -46,41 +29,45 @@
|
||||
StyleClasses="LabelBig" HorizontalExpand="True" />
|
||||
<Button Name="ReadyButton" Access="Public" ToggleMode="True" Text="{Loc 'ui-lobby-ready-up-button'}"
|
||||
StyleClasses="ButtonBig" />
|
||||
</BoxContainer>
|
||||
</hudUi:StripeBack>
|
||||
<chatUi:ChatBox Name="Chat" Access="Public" VerticalExpand="True" Margin="3 3 3 3"/>
|
||||
</BoxContainer></hudUi:StripeBack>
|
||||
</BoxContainer>
|
||||
<!-- Gold line -->
|
||||
<PanelContainer MinSize="2 0">
|
||||
<PanelContainer.PanelOverride>
|
||||
<gfx:StyleBoxFlat BackgroundColor="{x:Static style:StyleNano.NanoGold}" />
|
||||
</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>
|
||||
</PanelContainer>
|
||||
<!-- Left Bot Panel -->
|
||||
<BoxContainer Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Bottom" MaxWidth="620">
|
||||
<info:DevInfoBanner Name="DevInfoBanner" VerticalExpand="false" Margin="3 3 3 3"/>
|
||||
</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>
|
||||
|
||||
@@ -17,108 +17,12 @@ namespace Content.Client.Lobby.UI
|
||||
[GenerateTypedNameReferences]
|
||||
internal sealed partial class LobbyGui : Control
|
||||
{
|
||||
public LobbyCharacterPreviewPanel CharacterPreview { get; }
|
||||
|
||||
public LobbyGui(IEntityManager entityManager,
|
||||
IClientPreferencesManager preferencesManager)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
ServerName.HorizontalExpand = true;
|
||||
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();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user