Displaying of player characters in the round end statistics (#9006)

* All in one

* using fix

* Update GameTicker.RoundFlow.cs

Co-authored-by: Paul Ritter <ritter.paul1@googlemail.com>
This commit is contained in:
KIBORG04
2022-06-23 16:32:06 +07:00
committed by GitHub
parent bdc656200a
commit 58da937259
6 changed files with 67 additions and 5 deletions

View File

@@ -18,6 +18,8 @@ namespace Content.Client.GameTicking.Managers
public sealed class ClientGameTicker : SharedGameTicker public sealed class ClientGameTicker : SharedGameTicker
{ {
[Dependency] private readonly IStateManager _stateManager = default!; [Dependency] private readonly IStateManager _stateManager = default!;
[Dependency] private readonly IEntityManager _entityManager = default!;
[ViewVariables] private bool _initialized; [ViewVariables] private bool _initialized;
private Dictionary<EntityUid, Dictionary<string, uint?>> _jobsAvailable = new(); private Dictionary<EntityUid, Dictionary<string, uint?>> _jobsAvailable = new();
private Dictionary<EntityUid, string> _stationNames = new(); private Dictionary<EntityUid, string> _stationNames = new();
@@ -135,7 +137,7 @@ namespace Content.Client.GameTicking.Managers
RestartSound = message.RestartSound; RestartSound = message.RestartSound;
//This is not ideal at all, but I don't see an immediately better fit anywhere else. //This is not ideal at all, but I don't see an immediately better fit anywhere else.
var roundEnd = new RoundEndSummaryWindow(message.GamemodeTitle, message.RoundEndText, message.RoundDuration, message.RoundId, message.AllPlayersEndInfo); var roundEnd = new RoundEndSummaryWindow(message.GamemodeTitle, message.RoundEndText, message.RoundDuration, message.RoundId, message.AllPlayersEndInfo, _entityManager);
} }
private void RoundRestartCleanup(RoundRestartCleanupEvent ev) private void RoundRestartCleanup(RoundRestartCleanupEvent ev)

View File

@@ -1,6 +1,7 @@
using System.Linq; using System.Linq;
using Content.Client.Message; using Content.Client.Message;
using Content.Shared.GameTicking; using Content.Shared.GameTicking;
using Robust.Client.GameObjects;
using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.CustomControls; using Robust.Client.UserInterface.CustomControls;
using Robust.Shared.Utility; using Robust.Shared.Utility;
@@ -10,10 +11,13 @@ namespace Content.Client.RoundEnd
{ {
public sealed class RoundEndSummaryWindow : DefaultWindow public sealed class RoundEndSummaryWindow : DefaultWindow
{ {
private readonly IEntityManager _entityManager;
public RoundEndSummaryWindow(string gm, string roundEnd, TimeSpan roundTimeSpan, int roundId, public RoundEndSummaryWindow(string gm, string roundEnd, TimeSpan roundTimeSpan, int roundId,
RoundEndMessageEvent.RoundEndPlayerInfo[] info) RoundEndMessageEvent.RoundEndPlayerInfo[] info, IEntityManager entityManager)
{ {
_entityManager = entityManager;
MinSize = SetSize = (520, 580); MinSize = SetSize = (520, 580);
Title = Loc.GetString("round-end-summary-window-title"); Title = Loc.GetString("round-end-summary-window-title");
@@ -105,7 +109,27 @@ namespace Content.Client.RoundEnd
//Create labels for each player info. //Create labels for each player info.
foreach (var playerInfo in sortedPlayersInfo) foreach (var playerInfo in sortedPlayersInfo)
{ {
var playerInfoText = new RichTextLabel(); var hBox = new BoxContainer
{
Orientation = LayoutOrientation.Horizontal,
};
var playerInfoText = new RichTextLabel
{
VerticalAlignment = VAlignment.Center,
VerticalExpand = true,
};
if (_entityManager.TryGetComponent(playerInfo.PlayerEntityUid, out ISpriteComponent? sprite))
{
hBox.AddChild(new SpriteView
{
Sprite = sprite,
OverrideDirection = Direction.South,
VerticalAlignment = VAlignment.Center,
VerticalExpand = true,
});
}
if (playerInfo.PlayerICName != null) if (playerInfo.PlayerICName != null)
{ {
@@ -129,7 +153,8 @@ namespace Content.Client.RoundEnd
("playerRole", Loc.GetString(playerInfo.Role)))); ("playerRole", Loc.GetString(playerInfo.Role))));
} }
} }
playerInfoContainer.AddChild(playerInfoText); hBox.AddChild(playerInfoText);
playerInfoContainer.AddChild(hBox);
} }
playerInfoContainerScrollbox.AddChild(playerInfoContainer); playerInfoContainerScrollbox.AddChild(playerInfoContainer);

View File

@@ -0,0 +1,25 @@
using Content.Server.GameTicking;
using Content.Shared.Administration;
using Robust.Shared.Console;
namespace Content.Server.Administration.Commands;
[AdminCommand(AdminFlags.VarEdit)]
public sealed class ThrowScoreboardCommand : IConsoleCommand
{
public string Command => "throwscoreboard";
public string Description => Loc.GetString("throw-scoreboard-command-description");
public string Help => Loc.GetString("throw-scoreboard-command-help-text");
public void Execute(IConsoleShell shell, string argStr, string[] args)
{
if (args.Length > 0)
{
shell.WriteLine(Help);
return;
}
EntitySystem.Get<GameTicker>().ShowRoundEndScoreboard();
}
}

View File

@@ -262,6 +262,11 @@ namespace Content.Server.GameTicking
RunLevel = GameRunLevel.PostRound; RunLevel = GameRunLevel.PostRound;
ShowRoundEndScoreboard(text);
}
public void ShowRoundEndScoreboard(string text = "")
{
//Tell every client the round has ended. //Tell every client the round has ended.
var gamemodeTitle = Preset != null ? Loc.GetString(Preset.ModeTitle) : string.Empty; var gamemodeTitle = Preset != null ? Loc.GetString(Preset.ModeTitle) : string.Empty;
@@ -314,6 +319,7 @@ namespace Content.Server.GameTicking
PlayerOOCName = contentPlayerData?.Name ?? "(IMPOSSIBLE: REGISTERED MIND WITH NO OWNER)", PlayerOOCName = contentPlayerData?.Name ?? "(IMPOSSIBLE: REGISTERED MIND WITH NO OWNER)",
// Character name takes precedence over current entity name // Character name takes precedence over current entity name
PlayerICName = playerIcName, PlayerICName = playerIcName,
PlayerEntityUid = mind.OwnedEntity,
Role = antag Role = antag
? mind.AllRoles.First(role => role.Antagonist).Name ? mind.AllRoles.First(role => role.Antagonist).Name
: mind.AllRoles.FirstOrDefault()?.Name ?? Loc.GetString("game-ticker-unknown-role"), : mind.AllRoles.FirstOrDefault()?.Name ?? Loc.GetString("game-ticker-unknown-role"),

View File

@@ -1,5 +1,6 @@
using Robust.Shared.Network; using Robust.Shared.Network;
using Robust.Shared.Serialization; using Robust.Shared.Serialization;
using Robust.Shared.Utility;
namespace Content.Shared.GameTicking namespace Content.Shared.GameTicking
{ {
@@ -127,6 +128,7 @@ namespace Content.Shared.GameTicking
public string PlayerOOCName; public string PlayerOOCName;
public string? PlayerICName; public string? PlayerICName;
public string Role; public string Role;
public EntityUid? PlayerEntityUid;
public bool Antag; public bool Antag;
public bool Observer; public bool Observer;
public bool Connected; public bool Connected;

View File

@@ -0,0 +1,2 @@
throw-scoreboard-command-description = Show round-end scoreboard for all players, but not finish the round
throw-scoreboard-command-help-text = Usage: throwscoreboard