2020-08-13 14:40:27 +02:00
|
|
|
using System.Linq;
|
2023-07-08 14:08:32 +10:00
|
|
|
using System.Numerics;
|
2021-06-09 22:19:39 +02:00
|
|
|
using Content.Client.Message;
|
2021-06-20 10:09:24 +02:00
|
|
|
using Content.Shared.GameTicking;
|
2020-04-08 06:07:54 -05:00
|
|
|
using Robust.Client.UserInterface.Controls;
|
|
|
|
|
using Robust.Client.UserInterface.CustomControls;
|
2022-04-14 11:40:26 -07:00
|
|
|
using Robust.Shared.Utility;
|
2021-07-18 18:39:31 +02:00
|
|
|
using static Robust.Client.UserInterface.Controls.BoxContainer;
|
2020-04-08 06:07:54 -05:00
|
|
|
|
2021-06-09 22:19:39 +02:00
|
|
|
namespace Content.Client.RoundEnd
|
2020-04-08 06:07:54 -05:00
|
|
|
{
|
2022-01-21 01:38:35 -08:00
|
|
|
public sealed class RoundEndSummaryWindow : DefaultWindow
|
2020-04-08 06:07:54 -05:00
|
|
|
{
|
2022-06-23 16:32:06 +07:00
|
|
|
private readonly IEntityManager _entityManager;
|
2023-06-05 16:33:49 +12:00
|
|
|
public int RoundId;
|
2020-04-08 06:07:54 -05:00
|
|
|
|
2022-04-14 11:40:26 -07:00
|
|
|
public RoundEndSummaryWindow(string gm, string roundEnd, TimeSpan roundTimeSpan, int roundId,
|
2022-06-23 16:32:06 +07:00
|
|
|
RoundEndMessageEvent.RoundEndPlayerInfo[] info, IEntityManager entityManager)
|
2020-04-08 06:07:54 -05:00
|
|
|
{
|
2022-06-23 16:32:06 +07:00
|
|
|
_entityManager = entityManager;
|
|
|
|
|
|
2023-07-08 14:08:32 +10:00
|
|
|
MinSize = SetSize = new Vector2(520, 580);
|
2020-04-12 00:59:44 -05:00
|
|
|
|
2021-06-21 02:13:54 +02:00
|
|
|
Title = Loc.GetString("round-end-summary-window-title");
|
2020-04-12 00:59:44 -05:00
|
|
|
|
2021-12-12 05:09:47 -08:00
|
|
|
// The round end window is split into two tabs, one about the round stats
|
|
|
|
|
// and the other is a list of RoundEndPlayerInfo for each player.
|
|
|
|
|
// This tab would be a good place for things like: "x many people died.",
|
|
|
|
|
// "clown slipped the crew x times.", "x shots were fired this round.", etc.
|
|
|
|
|
// Also good for serious info.
|
|
|
|
|
|
2023-06-05 16:33:49 +12:00
|
|
|
RoundId = roundId;
|
2021-12-12 05:09:47 -08:00
|
|
|
var roundEndTabs = new TabContainer();
|
2022-04-14 11:40:26 -07:00
|
|
|
roundEndTabs.AddChild(MakeRoundEndSummaryTab(gm, roundEnd, roundTimeSpan, roundId));
|
2023-08-17 01:20:09 +03:00
|
|
|
roundEndTabs.AddChild(MakePlayerManifestTab(info));
|
2021-12-12 05:09:47 -08:00
|
|
|
|
|
|
|
|
Contents.AddChild(roundEndTabs);
|
|
|
|
|
|
2024-02-01 05:49:48 -07:00
|
|
|
OpenCenteredRight();
|
2021-12-12 05:09:47 -08:00
|
|
|
MoveToFront();
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-14 11:40:26 -07:00
|
|
|
private BoxContainer MakeRoundEndSummaryTab(string gamemode, string roundEnd, TimeSpan roundDuration, int roundId)
|
2021-12-12 05:09:47 -08:00
|
|
|
{
|
|
|
|
|
var roundEndSummaryTab = new BoxContainer
|
2020-04-12 00:59:44 -05:00
|
|
|
{
|
2021-07-18 18:39:31 +02:00
|
|
|
Orientation = LayoutOrientation.Vertical,
|
2021-06-21 02:13:54 +02:00
|
|
|
Name = Loc.GetString("round-end-summary-window-round-end-summary-tab-title")
|
2020-04-12 00:59:44 -05:00
|
|
|
};
|
|
|
|
|
|
2021-12-12 05:09:47 -08:00
|
|
|
var roundEndSummaryContainerScrollbox = new ScrollContainer
|
2020-04-12 00:59:44 -05:00
|
|
|
{
|
2023-03-05 23:30:07 -05:00
|
|
|
VerticalExpand = true,
|
|
|
|
|
Margin = new Thickness(10)
|
2021-12-12 05:09:47 -08:00
|
|
|
};
|
|
|
|
|
var roundEndSummaryContainer = new BoxContainer
|
|
|
|
|
{
|
|
|
|
|
Orientation = LayoutOrientation.Vertical
|
2020-04-12 00:59:44 -05:00
|
|
|
};
|
|
|
|
|
|
2020-04-08 06:07:54 -05:00
|
|
|
//Gamemode Name
|
|
|
|
|
var gamemodeLabel = new RichTextLabel();
|
2022-04-14 11:40:26 -07:00
|
|
|
var gamemodeMessage = new FormattedMessage();
|
2024-09-01 14:00:53 +03:00
|
|
|
gamemodeMessage.AddMarkupOrThrow(Loc.GetString("round-end-summary-window-round-id-label", ("roundId", roundId)));
|
2022-04-14 11:40:26 -07:00
|
|
|
gamemodeMessage.AddText(" ");
|
2024-09-01 14:00:53 +03:00
|
|
|
gamemodeMessage.AddMarkupOrThrow(Loc.GetString("round-end-summary-window-gamemode-name-label", ("gamemode", gamemode)));
|
2022-04-14 11:40:26 -07:00
|
|
|
gamemodeLabel.SetMessage(gamemodeMessage);
|
2021-12-12 05:09:47 -08:00
|
|
|
roundEndSummaryContainer.AddChild(gamemodeLabel);
|
|
|
|
|
|
|
|
|
|
//Duration
|
|
|
|
|
var roundTimeLabel = new RichTextLabel();
|
|
|
|
|
roundTimeLabel.SetMarkup(Loc.GetString("round-end-summary-window-duration-label",
|
|
|
|
|
("hours", roundDuration.Hours),
|
|
|
|
|
("minutes", roundDuration.Minutes),
|
|
|
|
|
("seconds", roundDuration.Seconds)));
|
|
|
|
|
roundEndSummaryContainer.AddChild(roundTimeLabel);
|
2020-04-08 06:07:54 -05:00
|
|
|
|
2020-08-20 18:09:29 +02:00
|
|
|
//Round end text
|
|
|
|
|
if (!string.IsNullOrEmpty(roundEnd))
|
|
|
|
|
{
|
2020-09-13 14:23:52 +02:00
|
|
|
var roundEndLabel = new RichTextLabel();
|
2021-12-12 05:09:47 -08:00
|
|
|
roundEndLabel.SetMarkup(roundEnd);
|
|
|
|
|
roundEndSummaryContainer.AddChild(roundEndLabel);
|
2020-08-20 18:09:29 +02:00
|
|
|
}
|
|
|
|
|
|
2021-12-12 05:09:47 -08:00
|
|
|
roundEndSummaryContainerScrollbox.AddChild(roundEndSummaryContainer);
|
|
|
|
|
roundEndSummaryTab.AddChild(roundEndSummaryContainerScrollbox);
|
|
|
|
|
|
|
|
|
|
return roundEndSummaryTab;
|
|
|
|
|
}
|
2020-04-08 23:51:49 -05:00
|
|
|
|
2023-08-17 01:20:09 +03:00
|
|
|
private BoxContainer MakePlayerManifestTab(RoundEndMessageEvent.RoundEndPlayerInfo[] playersInfo)
|
2021-12-12 05:09:47 -08:00
|
|
|
{
|
|
|
|
|
var playerManifestTab = new BoxContainer
|
|
|
|
|
{
|
|
|
|
|
Orientation = LayoutOrientation.Vertical,
|
2023-08-17 01:20:09 +03:00
|
|
|
Name = Loc.GetString("round-end-summary-window-player-manifest-tab-title")
|
2021-12-12 05:09:47 -08:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var playerInfoContainerScrollbox = new ScrollContainer
|
2021-06-21 02:13:54 +02:00
|
|
|
{
|
2023-03-05 23:30:07 -05:00
|
|
|
VerticalExpand = true,
|
|
|
|
|
Margin = new Thickness(10)
|
2021-06-21 02:13:54 +02:00
|
|
|
};
|
2021-12-12 05:09:47 -08:00
|
|
|
var playerInfoContainer = new BoxContainer
|
2021-07-18 18:39:31 +02:00
|
|
|
{
|
|
|
|
|
Orientation = LayoutOrientation.Vertical
|
|
|
|
|
};
|
2020-04-08 23:51:49 -05:00
|
|
|
|
2020-08-22 12:45:49 +02:00
|
|
|
//Put observers at the bottom of the list. Put antags on top.
|
2021-12-12 05:09:47 -08:00
|
|
|
var sortedPlayersInfo = playersInfo.OrderBy(p => p.Observer).ThenBy(p => !p.Antag);
|
|
|
|
|
|
2020-04-11 10:31:44 -05:00
|
|
|
//Create labels for each player info.
|
2021-12-12 05:09:47 -08:00
|
|
|
foreach (var playerInfo in sortedPlayersInfo)
|
2020-04-08 23:51:49 -05:00
|
|
|
{
|
2022-06-23 16:32:06 +07:00
|
|
|
var hBox = new BoxContainer
|
|
|
|
|
{
|
|
|
|
|
Orientation = LayoutOrientation.Horizontal,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var playerInfoText = new RichTextLabel
|
|
|
|
|
{
|
|
|
|
|
VerticalAlignment = VAlignment.Center,
|
|
|
|
|
VerticalExpand = true,
|
|
|
|
|
};
|
|
|
|
|
|
2023-12-27 17:41:58 -05:00
|
|
|
if (playerInfo.PlayerNetEntity != null)
|
2022-06-23 16:32:06 +07:00
|
|
|
{
|
2023-12-27 17:41:58 -05:00
|
|
|
hBox.AddChild(new SpriteView(playerInfo.PlayerNetEntity.Value, _entityManager)
|
|
|
|
|
{
|
|
|
|
|
OverrideDirection = Direction.South,
|
|
|
|
|
VerticalAlignment = VAlignment.Center,
|
|
|
|
|
SetSize = new Vector2(32, 32),
|
|
|
|
|
VerticalExpand = true,
|
|
|
|
|
});
|
2022-06-23 16:32:06 +07:00
|
|
|
}
|
2020-04-12 00:59:44 -05:00
|
|
|
|
2021-03-16 15:50:20 +01:00
|
|
|
if (playerInfo.PlayerICName != null)
|
2020-08-22 12:45:49 +02:00
|
|
|
{
|
2021-03-16 15:50:20 +01:00
|
|
|
if (playerInfo.Observer)
|
|
|
|
|
{
|
|
|
|
|
playerInfoText.SetMarkup(
|
2021-06-21 02:13:54 +02:00
|
|
|
Loc.GetString("round-end-summary-window-player-info-if-observer-text",
|
2021-12-12 05:09:47 -08:00
|
|
|
("playerOOCName", playerInfo.PlayerOOCName),
|
2021-06-21 02:13:54 +02:00
|
|
|
("playerICName", playerInfo.PlayerICName)));
|
2021-03-16 15:50:20 +01:00
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//TODO: On Hover display a popup detailing more play info.
|
|
|
|
|
//For example: their antag goals and if they completed them sucessfully.
|
|
|
|
|
var icNameColor = playerInfo.Antag ? "red" : "white";
|
|
|
|
|
playerInfoText.SetMarkup(
|
2021-06-21 02:13:54 +02:00
|
|
|
Loc.GetString("round-end-summary-window-player-info-if-not-observer-text",
|
|
|
|
|
("playerOOCName", playerInfo.PlayerOOCName),
|
|
|
|
|
("icNameColor", icNameColor),
|
2021-12-12 05:09:47 -08:00
|
|
|
("playerICName", playerInfo.PlayerICName),
|
2021-06-21 02:13:54 +02:00
|
|
|
("playerRole", Loc.GetString(playerInfo.Role))));
|
2021-03-16 15:50:20 +01:00
|
|
|
}
|
2020-08-22 12:45:49 +02:00
|
|
|
}
|
2022-06-23 16:32:06 +07:00
|
|
|
hBox.AddChild(playerInfoText);
|
|
|
|
|
playerInfoContainer.AddChild(hBox);
|
2020-04-08 23:51:49 -05:00
|
|
|
}
|
2020-04-10 01:37:14 -05:00
|
|
|
|
2021-12-12 05:09:47 -08:00
|
|
|
playerInfoContainerScrollbox.AddChild(playerInfoContainer);
|
|
|
|
|
playerManifestTab.AddChild(playerInfoContainerScrollbox);
|
2020-04-11 10:31:44 -05:00
|
|
|
|
2021-12-12 05:09:47 -08:00
|
|
|
return playerManifestTab;
|
2020-04-08 06:07:54 -05:00
|
|
|
}
|
|
|
|
|
}
|
2020-04-08 23:51:49 -05:00
|
|
|
|
2020-04-08 06:07:54 -05:00
|
|
|
}
|