* attempt at moving MainViewport to UIWidget

* oldchat (prototype)

* separate oldchat and default ss14 HUD into their own files

* restores original default game screen logic and adds that logic into separated chat game screen

* hand reloading, several tweaks to port oldchat to main ss14 branch

oldchat is currently not selectable

* screen type cvar, gameplay state screen reloading/loading

* reload screen on ui layout cvar change

* fixes up basic reloading (HUD switching is still very bad)

* some UI widget reloading for main UI screen switching

* alert sync on screen change

* inventory reload

* hotbar margin fix

* chat bubbles above viewport

* whoops

* fixes ordering of speech bubble root

* should fix the chat focus issue (at least in-game, not lobby yet)

* should fix up the lobby/game chat focus

* fixes chat for lobby, turns lobby into a UI state

* viewport UI controller

* viewport ratio selection

* whoops

* adds the /tg/ widescreen ratio

* removes warning from inventory UI controller, adds background to separated chat game screen's chat portion

* menu button reload

* unload menu buttons only from gameplay state shutdown

* bugfix

* character button fix

* adds config options for viewport width/UI layout

* variable naming changes, get or null instead of get to avoid exceptions

* moves entity system get into controller
This commit is contained in:
Flipp Syder
2022-10-17 15:13:41 -07:00
committed by GitHub
parent 730eddf0ab
commit a3dafd88dc
37 changed files with 910 additions and 208 deletions

View File

@@ -4,6 +4,7 @@ using Content.Client.LateJoin;
using Content.Client.Lobby.UI;
using Content.Client.Preferences;
using Content.Client.Preferences.UI;
using Content.Client.UserInterface.Systems.Chat;
using Content.Client.Voting;
using Robust.Client;
using Robust.Client.Console;
@@ -34,45 +35,47 @@ namespace Content.Client.Lobby
[Dependency] private readonly IConfigurationManager _configurationManager = default!;
[ViewVariables] private CharacterSetupGui? _characterSetup;
[ViewVariables] private LobbyGui? _lobby;
private ClientGameTicker _gameTicker = default!;
protected override Type? LinkedScreenType { get; } = typeof(LobbyGui);
private LobbyGui Lobby => (LobbyGui) _userInterfaceManager.ActiveScreen!;
protected override void Startup()
{
var chatController = _userInterfaceManager.GetUIController<ChatUIController>();
_gameTicker = _entityManager.System<ClientGameTicker>();
_characterSetup = new CharacterSetupGui(_entityManager, _resourceCache, _preferencesManager,
_prototypeManager, _configurationManager);
LayoutContainer.SetAnchorPreset(_characterSetup, LayoutContainer.LayoutPreset.Wide);
_lobby = new LobbyGui(_entityManager, _preferencesManager);
_userInterfaceManager.StateRoot.AddChild(_lobby);
chatController.SetMainChat(true);
_characterSetup.CloseButton.OnPressed += _ =>
{
_userInterfaceManager.StateRoot.AddChild(_lobby);
_userInterfaceManager.StateRoot.AddChild(Lobby);
_userInterfaceManager.StateRoot.RemoveChild(_characterSetup);
};
_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 += _ =>
Lobby.CharacterPreview.CharacterSetupButton.OnPressed += _ =>
{
SetReady(false);
_userInterfaceManager.StateRoot.RemoveChild(_lobby);
_userInterfaceManager.StateRoot.RemoveChild(Lobby);
_userInterfaceManager.StateRoot.AddChild(_characterSetup);
};
_lobby.ReadyButton.OnPressed += _ =>
Lobby.ReadyButton.OnPressed += _ =>
{
if (!_gameTicker.IsGameStarted)
{
@@ -82,13 +85,13 @@ namespace Content.Client.Lobby
new LateJoinGui().OpenCentered();
};
_lobby.ReadyButton.OnToggled += args =>
Lobby.ReadyButton.OnToggled += args =>
{
SetReady(args.Pressed);
};
_lobby.LeaveButton.OnPressed += _ => _consoleHost.ExecuteCommand("disconnect");
_lobby.OptionsButton.OnPressed += _ => _userInterfaceManager.GetUIController<OptionsUIController>().ToggleWindow();
Lobby.LeaveButton.OnPressed += _ => _consoleHost.ExecuteCommand("disconnect");
Lobby.OptionsButton.OnPressed += _ => _userInterfaceManager.GetUIController<OptionsUIController>().ToggleWindow();
_gameTicker.InfoBlobUpdated += UpdateLobbyUi;
@@ -98,25 +101,22 @@ namespace Content.Client.Lobby
protected override void Shutdown()
{
var chatController = _userInterfaceManager.GetUIController<ChatUIController>();
chatController.SetMainChat(false);
_gameTicker.InfoBlobUpdated -= UpdateLobbyUi;
_gameTicker.LobbyStatusUpdated -= LobbyStatusUpdated;
_gameTicker.LobbyLateJoinStatusUpdated -= LobbyLateJoinStatusUpdated;
_lobby?.Dispose();
_characterSetup?.Dispose();
_lobby = null;
_characterSetup = null;
}
public override void FrameUpdate(FrameEventArgs e)
{
if (_lobby == null)
return;
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 +140,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,50 +152,43 @@ namespace Content.Client.Lobby
private void LobbyLateJoinStatusUpdated()
{
if (_lobby == null) return;
_lobby.ReadyButton.Disabled = _gameTicker.DisallowedLateJoin;
Lobby.ReadyButton.Disabled = _gameTicker.DisallowedLateJoin;
}
private void UpdateLobbyUi()
{
if (_lobby == null)
return;
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);
}
}
private void UpdateLobbyBackground()
{
if (_lobby == null)
return;
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;
}
}

View File

@@ -1,4 +1,4 @@
<Control 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"
@@ -10,7 +10,7 @@
xmlns:widgets="clr-namespace:Content.Client.UserInterface.Systems.Chat.Widgets">
<!-- Background -->
<TextureRect Access="Public" Name = "Background" Stretch="KeepAspectCovered"/>
<BoxContainer Orientation="Horizontal" Margin="10 10 10 10" SeparationOverride="2">
<BoxContainer Name="MainContainer" Orientation="Horizontal" Margin="10 10 10 10" SeparationOverride="2">
<SplitContainer State="Auto" HorizontalExpand="True">
<!-- LHS Controls -->
<BoxContainer Orientation="Vertical" SeparationOverride="4" HorizontalExpand="True">
@@ -47,7 +47,7 @@
<!-- Top row -->
<BoxContainer Orientation="Horizontal" MinSize="0 40" Name="HeaderContainer" Access="Public" SeparationOverride="4">
<Label Margin="8 0 0 0" StyleClasses="LabelHeadingBigger" VAlign="Center" Text="{Loc 'ui-lobby-title'}" />
<Label Name="ServerName" Access="Public" StyleClasses="LabelHeadingBigger" VAlign="Center" />
<Label Name="ServerName" Access="Public" StyleClasses="LabelHeadingBigger" VAlign="Center" HorizontalExpand="True" HorizontalAlignment="Center" />
</BoxContainer>
<!-- Gold line -->
<controls:HLine Color="{x:Static style:StyleNano.NanoGold}" Thickness="2"/>
@@ -71,9 +71,9 @@
<!-- Gold line -->
<controls:HLine Color="{x:Static style:StyleNano.NanoGold}" Thickness="2" Access="Public"/>
<controls:HSpacer Spacing="10"/>
<widgets:ChatBox Name="Chat" Access="Public" VerticalExpand="True" Margin="3 3 3 3" MinHeight="50" Main="True"/>
<widgets:ChatBox Name="Chat" Access="Public" VerticalExpand="True" Margin="3 3 3 3" MinHeight="50" />
</BoxContainer>
</PanelContainer>
</SplitContainer>
</BoxContainer>
</Control>
</lobbyUi:LobbyGui>

View File

@@ -15,14 +15,12 @@ using static Robust.Client.UserInterface.Controls.BoxContainer;
namespace Content.Client.Lobby.UI
{
[GenerateTypedNameReferences]
internal sealed partial class LobbyGui : Control
internal sealed partial class LobbyGui : UIScreen
{
public LobbyGui(IEntityManager entityManager,
IClientPreferencesManager preferencesManager)
public LobbyGui()
{
RobustXamlLoader.Load(this);
ServerName.HorizontalExpand = true;
ServerName.HorizontalAlignment = HAlignment.Center;
SetAnchorPreset(MainContainer, LayoutPreset.Wide);
}
}
}