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:
@@ -99,7 +99,8 @@ namespace Content.Client.State
|
||||
|
||||
_playerManager.PlayerListUpdated += PlayerManagerOnPlayerListUpdated;
|
||||
_clientGameTicker.InfoBlobUpdated += UpdateLobbyUi;
|
||||
_clientGameTicker.LobbyStatusUpdated += UpdateLobbyUi;
|
||||
_clientGameTicker.LobbyStatusUpdated += LobbyStatusUpdated;
|
||||
_clientGameTicker.LobbyReadyUpdated += LobbyReadyUpdated;
|
||||
}
|
||||
|
||||
public override void Shutdown()
|
||||
@@ -149,7 +150,25 @@ namespace Content.Client.State
|
||||
_lobby.StartTime.Text = Loc.GetString("Round Starts In: {0}", text);
|
||||
}
|
||||
|
||||
private void PlayerManagerOnPlayerListUpdated(object sender, EventArgs e) => UpdatePlayerList();
|
||||
private void PlayerManagerOnPlayerListUpdated(object sender, EventArgs e)
|
||||
{
|
||||
// Remove disconnected sessions from the Ready Dict
|
||||
foreach (var p in _clientGameTicker.Ready)
|
||||
{
|
||||
if (!_playerManager.SessionsDict.TryGetValue(p.Key, out _))
|
||||
{
|
||||
_clientGameTicker.Ready.Remove(p.Key);
|
||||
}
|
||||
}
|
||||
UpdatePlayerList();
|
||||
}
|
||||
private void LobbyReadyUpdated() => UpdatePlayerList();
|
||||
|
||||
private void LobbyStatusUpdated()
|
||||
{
|
||||
UpdatePlayerList();
|
||||
UpdateLobbyUi();
|
||||
}
|
||||
|
||||
private void UpdateLobbyUi()
|
||||
{
|
||||
@@ -178,10 +197,24 @@ namespace Content.Client.State
|
||||
private void UpdatePlayerList()
|
||||
{
|
||||
_lobby.OnlinePlayerItemList.Clear();
|
||||
_lobby.PlayerReadyList.Clear();
|
||||
|
||||
foreach (var session in _playerManager.Sessions.OrderBy(s => s.Name))
|
||||
{
|
||||
_lobby.OnlinePlayerItemList.AddItem(session.Name);
|
||||
|
||||
var readyState = "";
|
||||
// Don't show ready state if we're ingame
|
||||
if (!_clientGameTicker.IsGameStarted)
|
||||
{
|
||||
var ready = false;
|
||||
if (session.SessionId == _playerManager.LocalPlayer.SessionId)
|
||||
ready = _clientGameTicker.AreWeReady;
|
||||
else
|
||||
_clientGameTicker.Ready.TryGetValue(session.SessionId, out ready);
|
||||
readyState = ready ? Loc.GetString("Ready") : Loc.GetString("Not Ready");
|
||||
}
|
||||
_lobby.PlayerReadyList.AddItem(readyState, null, false);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -193,6 +226,7 @@ namespace Content.Client.State
|
||||
}
|
||||
|
||||
_console.ProcessCommand($"toggleready {newReady}");
|
||||
UpdatePlayerList();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user