Ready Indicator in the lobby (#1771)

* Ready Indicator in the lobby

* Use SessionID instead of Name

* Don't show ready state when game is already running

* Make Ready List not selectable

* -Remove disconnected sessions from Ready
-Fix showing ReadyStatus when staying in lobby
This commit is contained in:
Exp
2020-08-18 14:52:59 +02:00
committed by GitHub
parent 6fb2a335b1
commit 5de57d6cd2
6 changed files with 157 additions and 5 deletions

View File

@@ -1,4 +1,5 @@
using System;
using System.Collections.Generic;
using Content.Client.Interfaces;
using Content.Client.State;
using Content.Client.UserInterface;
@@ -8,6 +9,7 @@ using Robust.Client.Interfaces.Graphics;
using Robust.Client.Interfaces.State;
using Robust.Shared.Interfaces.Network;
using Robust.Shared.IoC;
using Robust.Shared.Network;
using Robust.Shared.Utility;
using Robust.Shared.ViewVariables;
@@ -27,9 +29,11 @@ namespace Content.Client.GameTicking
[ViewVariables] public string ServerInfoBlob { get; private set; }
[ViewVariables] public DateTime StartTime { get; private set; }
[ViewVariables] public bool Paused { get; private set; }
[ViewVariables] public Dictionary<NetSessionId, bool> Ready { get; private set; }
public event Action InfoBlobUpdated;
public event Action LobbyStatusUpdated;
public event Action LobbyReadyUpdated;
public void Initialize()
{
@@ -40,12 +44,14 @@ namespace Content.Client.GameTicking
_netManager.RegisterNetMessage<MsgTickerLobbyStatus>(nameof(MsgTickerLobbyStatus), LobbyStatus);
_netManager.RegisterNetMessage<MsgTickerLobbyInfo>(nameof(MsgTickerLobbyInfo), LobbyInfo);
_netManager.RegisterNetMessage<MsgTickerLobbyCountdown>(nameof(MsgTickerLobbyCountdown), LobbyCountdown);
_netManager.RegisterNetMessage<MsgTickerLobbyReady>(nameof(MsgTickerLobbyReady), LobbyReady);
_netManager.RegisterNetMessage<MsgRoundEndMessage>(nameof(MsgRoundEndMessage), RoundEnd);
_netManager.RegisterNetMessage<MsgRequestWindowAttention>(nameof(MsgRequestWindowAttention), msg =>
{
IoCManager.Resolve<IClyde>().RequestWindowAttention();
});
Ready = new Dictionary<NetSessionId, bool>();
_initialized = true;
}
@@ -62,6 +68,8 @@ namespace Content.Client.GameTicking
IsGameStarted = message.IsRoundStarted;
AreWeReady = message.YouAreReady;
Paused = message.Paused;
if (IsGameStarted)
Ready.Clear();
LobbyStatusUpdated?.Invoke();
}
@@ -84,9 +92,18 @@ namespace Content.Client.GameTicking
Paused = message.Paused;
}
private void LobbyReady(MsgTickerLobbyReady message)
{
// Merge the Dictionaries
foreach (var p in message.PlayerReady)
{
Ready[p.Key] = p.Value;
}
LobbyReadyUpdated?.Invoke();
}
private void RoundEnd(MsgRoundEndMessage message)
{
//This is not ideal at all, but I don't see an immediately better fit anywhere else.
var roundEnd = new RoundEndSummaryWindow(message.GamemodeTitle, message.RoundDuration, message.AllPlayersEndInfo);