Enable nullability in Content.Client (#3257)

* Enable nullability in Content.Client

* Remove #nullable enable

* Merge fixes

* Remove Debug.Assert

* Merge fixes

* Fix build

* Fix build
This commit is contained in:
DrSmugleaf
2021-03-10 14:48:29 +01:00
committed by GitHub
parent 4f9bd4e802
commit 902aa128c2
270 changed files with 1774 additions and 1550 deletions

View File

@@ -39,8 +39,8 @@ namespace Content.Client.State
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IVoteManager _voteManager = default!;
[ViewVariables] private CharacterSetupGui _characterSetup;
[ViewVariables] private LobbyGui _lobby;
[ViewVariables] private CharacterSetupGui _characterSetup = default!;
[ViewVariables] private LobbyGui _lobby = default!;
public override void Startup()
{
@@ -48,16 +48,16 @@ namespace Content.Client.State
_prototypeManager);
LayoutContainer.SetAnchorPreset(_characterSetup, LayoutContainer.LayoutPreset.Wide);
_characterSetup.CloseButton.OnPressed += args =>
_characterSetup.CloseButton.OnPressed += _ =>
{
_userInterfaceManager.StateRoot.AddChild(_lobby);
_userInterfaceManager.StateRoot.RemoveChild(_characterSetup);
};
_characterSetup.SaveButton.OnPressed += args =>
_characterSetup.SaveButton.OnPressed += _ =>
{
_characterSetup.Save();
_lobby.CharacterPreview.UpdateUI();
_lobby?.CharacterPreview.UpdateUI();
};
_lobby = new LobbyGui(_entityManager, _preferencesManager);
@@ -70,28 +70,28 @@ namespace Content.Client.State
_lobby.Chat.DefaultChatFormat = "ooc \"{0}\"";
_lobby.ServerName.Text = _baseClient.GameInfo.ServerName;
_lobby.ServerName.Text = _baseClient.GameInfo?.ServerName;
_inputManager.SetInputCommand(ContentKeyFunctions.FocusChat,
InputCmdHandler.FromDelegate(s => GameScreen.FocusChat(_lobby.Chat)));
InputCmdHandler.FromDelegate(_ => GameScreen.FocusChat(_lobby.Chat)));
_inputManager.SetInputCommand(ContentKeyFunctions.FocusOOC,
InputCmdHandler.FromDelegate(s => GameScreen.FocusOOC(_lobby.Chat)));
InputCmdHandler.FromDelegate(_ => GameScreen.FocusOOC(_lobby.Chat)));
_inputManager.SetInputCommand(ContentKeyFunctions.FocusAdminChat,
InputCmdHandler.FromDelegate(s => GameScreen.FocusAdminChat(_lobby.Chat)));
InputCmdHandler.FromDelegate(_ => GameScreen.FocusAdminChat(_lobby.Chat)));
UpdateLobbyUi();
_lobby.CharacterPreview.CharacterSetupButton.OnPressed += args =>
_lobby.CharacterPreview.CharacterSetupButton.OnPressed += _ =>
{
SetReady(false);
_userInterfaceManager.StateRoot.RemoveChild(_lobby);
_userInterfaceManager.StateRoot.AddChild(_characterSetup);
};
_lobby.ObserveButton.OnPressed += args => _consoleHost.ExecuteCommand("observe");
_lobby.ReadyButton.OnPressed += args =>
_lobby.ObserveButton.OnPressed += _ => _consoleHost.ExecuteCommand("observe");
_lobby.ReadyButton.OnPressed += _ =>
{
if (!_clientGameTicker.IsGameStarted)
{
@@ -99,7 +99,6 @@ namespace Content.Client.State
}
new LateJoinGui().OpenCentered();
return;
};
_lobby.ReadyButton.OnToggled += args =>
@@ -107,8 +106,8 @@ namespace Content.Client.State
SetReady(args.Pressed);
};
_lobby.LeaveButton.OnPressed += args => _consoleHost.ExecuteCommand("disconnect");
_lobby.OptionsButton.OnPressed += args => new OptionsMenu().Open();
_lobby.LeaveButton.OnPressed += _ => _consoleHost.ExecuteCommand("disconnect");
_lobby.OptionsButton.OnPressed += _ => new OptionsMenu().Open();
UpdatePlayerList();
@@ -153,14 +152,7 @@ namespace Content.Client.State
var seconds = difference.TotalSeconds;
if (seconds < 0)
{
if (seconds < -5)
{
text = Loc.GetString("Right Now?");
}
else
{
text = Loc.GetString("Right Now");
}
text = Loc.GetString(seconds < -5 ? "Right Now?" : "Right Now");
}
else
{
@@ -171,7 +163,7 @@ namespace Content.Client.State
_lobby.StartTime.Text = Loc.GetString("Round Starts In: {0}", text);
}
private void PlayerManagerOnPlayerListUpdated(object sender, EventArgs e)
private void PlayerManagerOnPlayerListUpdated(object? sender, EventArgs e)
{
// Remove disconnected sessions from the Ready Dict
foreach (var p in _clientGameTicker.Status)
@@ -223,7 +215,10 @@ namespace Content.Client.State
_lobby.ReadyButton.Pressed = _clientGameTicker.AreWeReady;
}
_lobby.ServerInfo.SetInfoBlob(_clientGameTicker.ServerInfoBlob);
if (_clientGameTicker.ServerInfoBlob != null)
{
_lobby.ServerInfo.SetInfoBlob(_clientGameTicker.ServerInfoBlob);
}
}
private void UpdatePlayerList()
@@ -236,8 +231,8 @@ namespace Content.Client.State
// Don't show ready state if we're ingame
if (!_clientGameTicker.IsGameStarted)
{
var status = PlayerStatus.NotReady;
if (session.UserId == _playerManager.LocalPlayer.UserId)
PlayerStatus status;
if (session.UserId == _playerManager.LocalPlayer?.UserId)
status = _clientGameTicker.AreWeReady ? PlayerStatus.Ready : PlayerStatus.NotReady;
else
_clientGameTicker.Status.TryGetValue(session.UserId, out status);