diff --git a/Content.Client/GameTicking/ClientGameTicker.cs b/Content.Client/GameTicking/ClientGameTicker.cs index 77ca609371..ad8bc976c8 100644 --- a/Content.Client/GameTicking/ClientGameTicker.cs +++ b/Content.Client/GameTicking/ClientGameTicker.cs @@ -1,6 +1,7 @@ using System; using Content.Client.Interfaces; using Content.Client.State; +using Content.Client.UserInterface; using Content.Shared; using Robust.Client.Interfaces.State; using Robust.Shared.Interfaces.Network; @@ -35,10 +36,13 @@ namespace Content.Client.GameTicking _netManager.RegisterNetMessage(nameof(MsgTickerJoinGame), JoinGame); _netManager.RegisterNetMessage(nameof(MsgTickerLobbyStatus), LobbyStatus); _netManager.RegisterNetMessage(nameof(MsgTickerLobbyInfo), LobbyInfo); + _netManager.RegisterNetMessage(nameof(MsgRoundEndMessage), RoundEnd); _initialized = true; } + + private void JoinLobby(MsgTickerJoinLobby message) { _stateManager.RequestStateChange(); @@ -64,5 +68,13 @@ namespace Content.Client.GameTicking { _stateManager.RequestStateChange(); } + + 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.DurationInHours); + + } } } diff --git a/Content.Client/UserInterface/RoundEndSummaryWindow.cs b/Content.Client/UserInterface/RoundEndSummaryWindow.cs new file mode 100644 index 0000000000..b3abe84b69 --- /dev/null +++ b/Content.Client/UserInterface/RoundEndSummaryWindow.cs @@ -0,0 +1,56 @@ +using Robust.Client.Graphics; +using Robust.Client.Interfaces.Input; +using Robust.Client.Interfaces.ResourceManagement; +using Robust.Client.ResourceManagement; +using Robust.Client.UserInterface.Controls; +using Robust.Client.UserInterface.CustomControls; +using Robust.Shared.IoC; +using Robust.Shared.Localization; +using Robust.Shared.Maths; +using Content.Client.Utility; + +namespace Content.Client.UserInterface +{ + public sealed class RoundEndSummaryWindow : SS14Window + { + private readonly int _headerFontSize = 14; + private VBoxContainer VBox { get; } + + protected override Vector2? CustomSize => (520, 580); + +#pragma warning disable 649 + [Dependency] private readonly IResourceCache _resourceCache; + [Dependency] private readonly ILocalizationManager _loc; + [Dependency] private readonly IInputManager _inputManager; +#pragma warning restore 649 + + public RoundEndSummaryWindow(string gm, uint duration) + { + Title = "Round End Summary"; + + //Get section header font + _loc = IoCManager.Resolve(); + var cache = IoCManager.Resolve(); + var inputManager = IoCManager.Resolve(); + Font headerFont = new VectorFont(cache.GetResource("/Nano/NotoSans/NotoSans-Regular.ttf"), _headerFontSize); + + var scrollContainer = new ScrollContainer(); + scrollContainer.AddChild(VBox = new VBoxContainer()); + Contents.AddChild(scrollContainer); + + //Gamemode Name + var gamemodeLabel = new RichTextLabel(); + gamemodeLabel.SetMarkup(_loc.GetString("Round of: [color=white]{0}[/color] has ended.", gm)); + VBox.AddChild(gamemodeLabel); + + //Duration + var roundDurationInfo = new RichTextLabel(); + roundDurationInfo.SetMarkup(_loc.GetString("The round lasted for [color=yellow]{0}[/color] hours.", duration)); + VBox.AddChild(roundDurationInfo); + + OpenCentered(); + MoveToFront(); + + } + } +} diff --git a/Content.Server/GameTicking/GamePreset.cs b/Content.Server/GameTicking/GamePreset.cs index cf7981b725..b880b162a0 100644 --- a/Content.Server/GameTicking/GamePreset.cs +++ b/Content.Server/GameTicking/GamePreset.cs @@ -1,4 +1,4 @@ -namespace Content.Server.GameTicking +namespace Content.Server.GameTicking { /// /// A round-start setup preset, such as which antagonists to spawn. @@ -6,6 +6,7 @@ namespace Content.Server.GameTicking public abstract class GamePreset { public abstract void Start(); + public virtual string ModeTitle => "Sandbox"; public virtual string Description => "Secret!"; } } diff --git a/Content.Server/GameTicking/GamePresets/PresetDeathMatch.cs b/Content.Server/GameTicking/GamePresets/PresetDeathMatch.cs index 11c716442d..5b866dc8fa 100644 --- a/Content.Server/GameTicking/GamePresets/PresetDeathMatch.cs +++ b/Content.Server/GameTicking/GamePresets/PresetDeathMatch.cs @@ -1,4 +1,4 @@ -using Content.Server.GameTicking.GameRules; +using Content.Server.GameTicking.GameRules; using Content.Server.Interfaces.GameTicking; using Robust.Shared.IoC; @@ -15,6 +15,7 @@ namespace Content.Server.GameTicking.GamePresets _gameTicker.AddGameRule(); } - public override string Description => "Deathmatch, go and kill everybody else to win!"; + public override string ModeTitle => "Deathmatch"; + public override string Description => "Kill anything that moves!"; } } diff --git a/Content.Server/GameTicking/GamePresets/PresetSandbox.cs b/Content.Server/GameTicking/GamePresets/PresetSandbox.cs index f80b41ebd0..05f15c6972 100644 --- a/Content.Server/GameTicking/GamePresets/PresetSandbox.cs +++ b/Content.Server/GameTicking/GamePresets/PresetSandbox.cs @@ -1,4 +1,4 @@ -using Content.Server.Sandbox; +using Content.Server.Sandbox; using Robust.Shared.IoC; namespace Content.Server.GameTicking.GamePresets @@ -14,6 +14,7 @@ namespace Content.Server.GameTicking.GamePresets _sandboxManager.IsSandboxEnabled = true; } - public override string Description => "Sandbox, go and build something!"; + public override string ModeTitle => "Sandbox"; + public override string Description => "No stress, build something!"; } } diff --git a/Content.Server/GameTicking/GameTicker.cs b/Content.Server/GameTicking/GameTicker.cs index e8c654b2c3..3df9f50c4a 100644 --- a/Content.Server/GameTicking/GameTicker.cs +++ b/Content.Server/GameTicking/GameTicker.cs @@ -100,6 +100,7 @@ namespace Content.Server.GameTicking _netManager.RegisterNetMessage(nameof(MsgTickerJoinGame)); _netManager.RegisterNetMessage(nameof(MsgTickerLobbyStatus)); _netManager.RegisterNetMessage(nameof(MsgTickerLobbyInfo)); + _netManager.RegisterNetMessage(nameof(MsgRoundEndMessage)); SetStartPreset(_configurationManager.GetCVar("game.defaultpreset")); @@ -200,6 +201,13 @@ namespace Content.Server.GameTicking Logger.InfoS("ticker", "Ending round!"); RunLevel = GameRunLevel.PostRound; + + //Tell every client the round has ended. + var roundEndMessage = _netManager.CreateNetMessage(); + roundEndMessage.GamemodeTitle = MakeGamePreset().ModeTitle; + //TODO:Grab actual timespan of round. + roundEndMessage.DurationInHours = 1337; + _netManager.ServerSendToAll(roundEndMessage); } public void Respawn(IPlayerSession targetPlayer) @@ -559,10 +567,12 @@ namespace Content.Server.GameTicking private string GetInfoText() { - var gameMode = MakeGamePreset().Description; + var gmTitle = MakeGamePreset().ModeTitle; + var desc = MakeGamePreset().Description; return _localization.GetString(@"Hi and welcome to [color=white]Space Station 14![/color] -The current game mode is [color=white]{0}[/color]", gameMode); +The current game mode is: [color=white]{0}[/color]. +[color=yellow]{1}[/color]", gmTitle, desc ); } private void UpdateInfoText() diff --git a/Content.Shared/SharedGameTicker.cs b/Content.Shared/SharedGameTicker.cs index 126a44e0e9..616e53ef1c 100644 --- a/Content.Shared/SharedGameTicker.cs +++ b/Content.Shared/SharedGameTicker.cs @@ -1,4 +1,4 @@ -using System; +using System; using Lidgren.Network; using Robust.Shared.Interfaces.Network; using Robust.Shared.Network; @@ -114,5 +114,36 @@ namespace Content.Shared buffer.Write(TextBlob); } } + + protected class MsgRoundEndMessage : NetMessage + { + + #region REQUIRED + + public const MsgGroups GROUP = MsgGroups.Command; + public const string NAME = nameof(MsgRoundEndMessage); + public MsgRoundEndMessage(INetChannel channel) : base(NAME, GROUP) { } + + #endregion + + public string GamemodeTitle; + //TODO: Change to a more detailed measurement of time. + public uint DurationInHours; + + public override void ReadFromBuffer(NetIncomingMessage buffer) + { + GamemodeTitle = buffer.ReadString(); + DurationInHours = buffer.ReadUInt32(); + } + + public override void WriteToBuffer(NetOutgoingMessage buffer) + { + buffer.Write(GamemodeTitle); + buffer.Write(DurationInHours); + + } + + } } } +