Character setup in Lobby UI (#12007)
This commit is contained in:
@@ -76,7 +76,7 @@ namespace Content.Client.Gameplay
|
||||
UserInterfaceManager.PopupRoot.AddChild(_fpsCounter);
|
||||
_fpsCounter.Visible = _configurationManager.GetCVar(CCVars.HudFpsCounterVisible);
|
||||
_configurationManager.OnValueChanged(CCVars.HudFpsCounterVisible, (show) => { _fpsCounter.Visible = show; });
|
||||
_configurationManager.OnValueChanged(CCVars.UILayout, _ => ReloadMainScreen());
|
||||
_configurationManager.OnValueChanged(CCVars.UILayout, ReloadMainScreenValueChange);
|
||||
}
|
||||
|
||||
protected override void Shutdown()
|
||||
@@ -88,12 +88,18 @@ namespace Content.Client.Gameplay
|
||||
_eyeManager.MainViewport = UserInterfaceManager.MainViewport;
|
||||
_fpsCounter.Dispose();
|
||||
_uiManager.ClearWindows();
|
||||
_configurationManager.UnsubValueChanged(CCVars.UILayout, ReloadMainScreenValueChange);
|
||||
UnloadMainScreen();
|
||||
}
|
||||
|
||||
private void ReloadMainScreenValueChange(string _)
|
||||
{
|
||||
ReloadMainScreen();
|
||||
}
|
||||
|
||||
public void ReloadMainScreen()
|
||||
{
|
||||
if (_uiManager.ActiveScreen == null)
|
||||
if (_uiManager.ActiveScreen?.GetWidget<MainViewport>() == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -39,60 +39,45 @@ namespace Content.Client.Lobby
|
||||
private ClientGameTicker _gameTicker = default!;
|
||||
|
||||
protected override Type? LinkedScreenType { get; } = typeof(LobbyGui);
|
||||
private LobbyGui Lobby => (LobbyGui) _userInterfaceManager.ActiveScreen!;
|
||||
private LobbyGui? _lobby;
|
||||
|
||||
protected override void Startup()
|
||||
{
|
||||
if (_userInterfaceManager.ActiveScreen == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
_lobby = (LobbyGui) _userInterfaceManager.ActiveScreen;
|
||||
|
||||
var chatController = _userInterfaceManager.GetUIController<ChatUIController>();
|
||||
_gameTicker = _entityManager.System<ClientGameTicker>();
|
||||
_characterSetup = new CharacterSetupGui(_entityManager, _resourceCache, _preferencesManager,
|
||||
_prototypeManager, _configurationManager);
|
||||
LayoutContainer.SetAnchorPreset(_characterSetup, LayoutContainer.LayoutPreset.Wide);
|
||||
|
||||
_lobby.CharacterSetupState.AddChild(_characterSetup);
|
||||
chatController.SetMainChat(true);
|
||||
|
||||
_characterSetup.CloseButton.OnPressed += _ =>
|
||||
{
|
||||
_userInterfaceManager.StateRoot.AddChild(Lobby);
|
||||
_userInterfaceManager.StateRoot.RemoveChild(_characterSetup);
|
||||
_lobby.SwitchState(LobbyGui.LobbyGuiState.Default);
|
||||
};
|
||||
|
||||
_characterSetup.SaveButton.OnPressed += _ =>
|
||||
{
|
||||
_characterSetup.Save();
|
||||
Lobby?.CharacterPreview.UpdateUI();
|
||||
_lobby.CharacterPreview.UpdateUI();
|
||||
};
|
||||
|
||||
LayoutContainer.SetAnchorPreset(Lobby, LayoutContainer.LayoutPreset.Wide);
|
||||
_voteManager.SetPopupContainer(Lobby.VoteContainer);
|
||||
Lobby.ServerName.Text = _baseClient.GameInfo?.ServerName; //The eye of refactor gazes upon you...
|
||||
LayoutContainer.SetAnchorPreset(_lobby, LayoutContainer.LayoutPreset.Wide);
|
||||
_voteManager.SetPopupContainer(_lobby.VoteContainer);
|
||||
_lobby.ServerName.Text = _baseClient.GameInfo?.ServerName; //The eye of refactor gazes upon you...
|
||||
UpdateLobbyUi();
|
||||
|
||||
Lobby.CharacterPreview.CharacterSetupButton.OnPressed += _ =>
|
||||
{
|
||||
SetReady(false);
|
||||
_userInterfaceManager.StateRoot.RemoveChild(Lobby);
|
||||
_userInterfaceManager.StateRoot.AddChild(_characterSetup);
|
||||
};
|
||||
|
||||
Lobby.ReadyButton.OnPressed += _ =>
|
||||
{
|
||||
if (!_gameTicker.IsGameStarted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
new LateJoinGui().OpenCentered();
|
||||
};
|
||||
|
||||
Lobby.ReadyButton.OnToggled += args =>
|
||||
{
|
||||
SetReady(args.Pressed);
|
||||
};
|
||||
|
||||
Lobby.LeaveButton.OnPressed += _ => _consoleHost.ExecuteCommand("disconnect");
|
||||
Lobby.OptionsButton.OnPressed += _ => _userInterfaceManager.GetUIController<OptionsUIController>().ToggleWindow();
|
||||
|
||||
_lobby.CharacterPreview.CharacterSetupButton.OnPressed += OnSetupPressed;
|
||||
_lobby.ReadyButton.OnPressed += OnReadyPressed;
|
||||
_lobby.ReadyButton.OnToggled += OnReadyToggled;
|
||||
|
||||
_gameTicker.InfoBlobUpdated += UpdateLobbyUi;
|
||||
_gameTicker.LobbyStatusUpdated += LobbyStatusUpdated;
|
||||
@@ -107,16 +92,43 @@ namespace Content.Client.Lobby
|
||||
_gameTicker.LobbyStatusUpdated -= LobbyStatusUpdated;
|
||||
_gameTicker.LobbyLateJoinStatusUpdated -= LobbyLateJoinStatusUpdated;
|
||||
|
||||
_lobby!.CharacterPreview.CharacterSetupButton.OnPressed -= OnSetupPressed;
|
||||
_lobby!.ReadyButton.OnPressed -= OnReadyPressed;
|
||||
_lobby!.ReadyButton.OnToggled -= OnReadyToggled;
|
||||
|
||||
_lobby = null;
|
||||
|
||||
_characterSetup?.Dispose();
|
||||
_characterSetup = null;
|
||||
}
|
||||
|
||||
private void OnSetupPressed(BaseButton.ButtonEventArgs args)
|
||||
{
|
||||
SetReady(false);
|
||||
_lobby!.SwitchState(LobbyGui.LobbyGuiState.CharacterSetup);
|
||||
}
|
||||
|
||||
private void OnReadyPressed(BaseButton.ButtonEventArgs args)
|
||||
{
|
||||
if (!_gameTicker.IsGameStarted)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
new LateJoinGui().OpenCentered();
|
||||
}
|
||||
|
||||
private void OnReadyToggled(BaseButton.ButtonToggledEventArgs args)
|
||||
{
|
||||
SetReady(args.Pressed);
|
||||
}
|
||||
|
||||
public override void FrameUpdate(FrameEventArgs e)
|
||||
{
|
||||
if (_gameTicker.IsGameStarted)
|
||||
{
|
||||
Lobby.StartTime.Text = string.Empty;
|
||||
Lobby.StationTime.Text = Loc.GetString("lobby-state-player-status-station-time", ("stationTime", _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan).ToString("hh\\:mm")));
|
||||
_lobby!.StartTime.Text = string.Empty;
|
||||
_lobby!.StationTime.Text = Loc.GetString("lobby-state-player-status-station-time", ("stationTime", _gameTiming.CurTime.Subtract(_gameTicker.RoundStartTimeSpan).ToString("hh\\:mm")));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -140,8 +152,8 @@ namespace Content.Client.Lobby
|
||||
}
|
||||
}
|
||||
|
||||
Lobby.StationTime.Text = Loc.GetString("lobby-state-player-status-station-time", ("stationTime", TimeSpan.Zero.ToString("hh\\:mm")));
|
||||
Lobby.StartTime.Text = Loc.GetString("lobby-state-round-start-countdown-text", ("timeLeft", text));
|
||||
_lobby!.StationTime.Text = Loc.GetString("lobby-state-player-status-station-time", ("stationTime", TimeSpan.Zero.ToString("hh\\:mm")));
|
||||
_lobby!.StartTime.Text = Loc.GetString("lobby-state-round-start-countdown-text", ("timeLeft", text));
|
||||
}
|
||||
|
||||
private void LobbyStatusUpdated()
|
||||
@@ -152,31 +164,31 @@ namespace Content.Client.Lobby
|
||||
|
||||
private void LobbyLateJoinStatusUpdated()
|
||||
{
|
||||
Lobby.ReadyButton.Disabled = _gameTicker.DisallowedLateJoin;
|
||||
_lobby!.ReadyButton.Disabled = _gameTicker.DisallowedLateJoin;
|
||||
}
|
||||
|
||||
private void UpdateLobbyUi()
|
||||
{
|
||||
if (_gameTicker.IsGameStarted)
|
||||
{
|
||||
Lobby.ReadyButton.Text = Loc.GetString("lobby-state-ready-button-join-state");
|
||||
Lobby.ReadyButton.ToggleMode = false;
|
||||
Lobby.ReadyButton.Pressed = false;
|
||||
Lobby.ObserveButton.Disabled = false;
|
||||
_lobby!.ReadyButton.Text = Loc.GetString("lobby-state-ready-button-join-state");
|
||||
_lobby!.ReadyButton.ToggleMode = false;
|
||||
_lobby!.ReadyButton.Pressed = false;
|
||||
_lobby!.ObserveButton.Disabled = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
Lobby.StartTime.Text = string.Empty;
|
||||
Lobby.ReadyButton.Text = Loc.GetString("lobby-state-ready-button-ready-up-state");
|
||||
Lobby.ReadyButton.ToggleMode = true;
|
||||
Lobby.ReadyButton.Disabled = false;
|
||||
Lobby.ReadyButton.Pressed = _gameTicker.AreWeReady;
|
||||
Lobby.ObserveButton.Disabled = true;
|
||||
_lobby!.StartTime.Text = string.Empty;
|
||||
_lobby!.ReadyButton.Text = Loc.GetString("lobby-state-ready-button-ready-up-state");
|
||||
_lobby!.ReadyButton.ToggleMode = true;
|
||||
_lobby!.ReadyButton.Disabled = false;
|
||||
_lobby!.ReadyButton.Pressed = _gameTicker.AreWeReady;
|
||||
_lobby!.ObserveButton.Disabled = true;
|
||||
}
|
||||
|
||||
if (_gameTicker.ServerInfoBlob != null)
|
||||
{
|
||||
Lobby.ServerInfo.SetInfoBlob(_gameTicker.ServerInfoBlob);
|
||||
_lobby!.ServerInfo.SetInfoBlob(_gameTicker.ServerInfoBlob);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -184,11 +196,11 @@ namespace Content.Client.Lobby
|
||||
{
|
||||
if (_gameTicker.LobbyBackground != null)
|
||||
{
|
||||
Lobby.Background.Texture = _resourceCache.GetResource<TextureResource>(_gameTicker.LobbyBackground );
|
||||
_lobby!.Background.Texture = _resourceCache.GetResource<TextureResource>(_gameTicker.LobbyBackground );
|
||||
}
|
||||
else
|
||||
{
|
||||
Lobby.Background.Texture = null;
|
||||
_lobby!.Background.Texture = null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
<lobbyUi:LobbyGui xmlns="https://spacestation14.io"
|
||||
<lobbyUi:LobbyGui xmlns="https://spacestation14.io"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:maths="clr-namespace:Robust.Shared.Maths;assembly=Robust.Shared.Maths"
|
||||
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
|
||||
@@ -9,37 +9,42 @@
|
||||
xmlns:info="clr-namespace:Content.Client.Info"
|
||||
xmlns:widgets="clr-namespace:Content.Client.UserInterface.Systems.Chat.Widgets">
|
||||
<!-- Background -->
|
||||
<TextureRect Access="Public" Name = "Background" Stretch="KeepAspectCovered"/>
|
||||
<BoxContainer Name="MainContainer" Orientation="Horizontal" Margin="10 10 10 10" SeparationOverride="2">
|
||||
<TextureRect Access="Public" VerticalExpand="True" HorizontalExpand="True" Name = "Background" Stretch="KeepAspectCovered"/>
|
||||
<BoxContainer Name="MainContainer" VerticalExpand="True" HorizontalExpand="True" Orientation="Horizontal" Margin="10 10 10 10" SeparationOverride="2">
|
||||
<SplitContainer State="Auto" HorizontalExpand="True">
|
||||
<!-- LHS Controls -->
|
||||
<BoxContainer Orientation="Vertical" SeparationOverride="4" HorizontalExpand="True">
|
||||
<!-- Left Top Panel -->
|
||||
<PanelContainer StyleClasses="AngleRect" HorizontalAlignment="Left" Name = "LeftSideTop" VerticalAlignment="Top" >
|
||||
<BoxContainer Orientation="Vertical" HorizontalAlignment="Center" MaxWidth="620">
|
||||
<info:LinkBanner Name="LinkBanner" VerticalExpand="false" HorizontalAlignment="Center" Margin="3 3 3 3"/>
|
||||
<controls: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}"/>
|
||||
<Label Name="StartTime"
|
||||
Access="Public"
|
||||
Align="Right"
|
||||
FontColorOverride="{x:Static maths:Color.DarkGray}"
|
||||
StyleClasses="LabelBig" HorizontalExpand="True" />
|
||||
<Button Name="ReadyButton" Access="Public" ToggleMode="True" Text="{Loc 'ui-lobby-ready-up-button'}"
|
||||
StyleClasses="ButtonBig" />
|
||||
</BoxContainer>
|
||||
</controls:StripeBack>
|
||||
<BoxContainer Name="LeftSide" Orientation="Vertical" SeparationOverride="4" HorizontalExpand="True">
|
||||
<Control Name="DefaultState" VerticalExpand="True">
|
||||
<!-- Left Top Panel -->
|
||||
<PanelContainer StyleClasses="AngleRect" HorizontalAlignment="Left" Name = "LeftSideTop" VerticalAlignment="Top" >
|
||||
<BoxContainer Orientation="Vertical" HorizontalAlignment="Center" MaxWidth="620">
|
||||
<info:LinkBanner Name="LinkBanner" VerticalExpand="false" HorizontalAlignment="Center" Margin="3 3 3 3"/>
|
||||
<controls: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}"/>
|
||||
<Label Name="StartTime"
|
||||
Access="Public"
|
||||
Align="Right"
|
||||
FontColorOverride="{x:Static maths:Color.DarkGray}"
|
||||
StyleClasses="LabelBig" HorizontalExpand="True" />
|
||||
<Button Name="ReadyButton" Access="Public" ToggleMode="True" Text="{Loc 'ui-lobby-ready-up-button'}"
|
||||
StyleClasses="ButtonBig" />
|
||||
</BoxContainer>
|
||||
</controls:StripeBack>
|
||||
</BoxContainer>
|
||||
</PanelContainer>
|
||||
<!-- Voting Popups -->
|
||||
<BoxContainer Orientation="Vertical" SeparationOverride="4" Name="VoteContainer" Access="Public" HorizontalAlignment="Left" VerticalAlignment="Top"/>
|
||||
<!-- Vertical Padding-->
|
||||
<Control VerticalExpand="True"/>
|
||||
<!-- Left Bot Panel -->
|
||||
<BoxContainer Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Bottom" MaxWidth="620">
|
||||
<info:DevInfoBanner Name="DevInfoBanner" VerticalExpand="false" Margin="3 3 3 3"/>
|
||||
</BoxContainer>
|
||||
</PanelContainer>
|
||||
<!-- Voting Popups -->
|
||||
<BoxContainer Orientation="Vertical" SeparationOverride="4" Name="VoteContainer" Access="Public" HorizontalAlignment="Left" VerticalAlignment="Top"/>
|
||||
<!-- Vertical Padding-->
|
||||
<Control VerticalExpand="True"/>
|
||||
<!-- Left Bot Panel -->
|
||||
<BoxContainer Orientation="Vertical" HorizontalAlignment="Left" VerticalAlignment="Bottom" MaxWidth="620">
|
||||
<info:DevInfoBanner Name="DevInfoBanner" VerticalExpand="false" Margin="3 3 3 3"/>
|
||||
</BoxContainer>
|
||||
</Control>
|
||||
<!-- Character setup state -->
|
||||
<!-- This is injected on startup. Funky! -->
|
||||
<Control Access="Public" Visible="False" Name="CharacterSetupState" VerticalExpand="True" />
|
||||
</BoxContainer>
|
||||
<!-- Right Panel -->
|
||||
<PanelContainer Name="RightSide" StyleClasses="AngleRect" HorizontalAlignment= "Right" VerticalExpand="True" VerticalAlignment="Stretch">
|
||||
|
||||
@@ -1,8 +1,12 @@
|
||||
using Content.Client.Chat.UI;
|
||||
using Content.Client.Info;
|
||||
using Content.Client.Preferences;
|
||||
using Content.Client.Preferences.UI;
|
||||
using Content.Client.UserInterface.Systems.EscapeMenu;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.State;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
@@ -17,10 +21,55 @@ namespace Content.Client.Lobby.UI
|
||||
[GenerateTypedNameReferences]
|
||||
internal sealed partial class LobbyGui : UIScreen
|
||||
{
|
||||
[Dependency] private readonly IClientConsoleHost _consoleHost = default!;
|
||||
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
|
||||
|
||||
public LobbyGui()
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
SetAnchorPreset(MainContainer, LayoutPreset.Wide);
|
||||
SetAnchorPreset(Background, LayoutPreset.Wide);
|
||||
|
||||
LeaveButton.OnPressed += _ => _consoleHost.ExecuteCommand("disconnect");
|
||||
OptionsButton.OnPressed += _ => _userInterfaceManager.GetUIController<OptionsUIController>().ToggleWindow();
|
||||
}
|
||||
|
||||
public void SwitchState(LobbyGuiState state)
|
||||
{
|
||||
DefaultState.Visible = false;
|
||||
CharacterSetupState.Visible = false;
|
||||
|
||||
switch (state)
|
||||
{
|
||||
case LobbyGuiState.Default:
|
||||
DefaultState.Visible = true;
|
||||
RightSide.Visible = true;
|
||||
break;
|
||||
case LobbyGuiState.CharacterSetup:
|
||||
CharacterSetupState.Visible = true;
|
||||
|
||||
var actualWidth = (float) _userInterfaceManager.RootControl.PixelWidth;
|
||||
var setupWidth = (float) LeftSide.PixelWidth;
|
||||
|
||||
if (1 - (setupWidth / actualWidth) > 0.30)
|
||||
{
|
||||
RightSide.Visible = false;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
public enum LobbyGuiState : byte
|
||||
{
|
||||
/// <summary>
|
||||
/// The default state, i.e., what's seen on launch.
|
||||
/// </summary>
|
||||
Default,
|
||||
/// <summary>
|
||||
/// The character setup state.
|
||||
/// </summary>
|
||||
CharacterSetup
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,9 +2,9 @@
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
|
||||
xmlns:parallax="clr-namespace:Content.Client.Parallax"
|
||||
xmlns:style="clr-namespace:Content.Client.Stylesheets">
|
||||
<parallax:ParallaxControl />
|
||||
<Control Margin="20 20 20 20">
|
||||
xmlns:style="clr-namespace:Content.Client.Stylesheets"
|
||||
VerticalExpand="True">
|
||||
<Control>
|
||||
<PanelContainer Name="BackgroundPanel" />
|
||||
<BoxContainer Orientation="Vertical" SeparationOverride="0">
|
||||
<BoxContainer Orientation="Horizontal" MinSize="0 40">
|
||||
|
||||
@@ -13,6 +13,7 @@ using Robust.Client.Graphics;
|
||||
using Robust.Client.ResourceManagement;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
Reference in New Issue
Block a user