Add foundation for Round End Summary Screen.
Adjust GamePreset class, added title alongside description.
This commit is contained in:
@@ -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<MsgTickerJoinGame>(nameof(MsgTickerJoinGame), JoinGame);
|
||||
_netManager.RegisterNetMessage<MsgTickerLobbyStatus>(nameof(MsgTickerLobbyStatus), LobbyStatus);
|
||||
_netManager.RegisterNetMessage<MsgTickerLobbyInfo>(nameof(MsgTickerLobbyInfo), LobbyInfo);
|
||||
_netManager.RegisterNetMessage<MsgRoundEndMessage>(nameof(MsgRoundEndMessage), RoundEnd);
|
||||
|
||||
_initialized = true;
|
||||
}
|
||||
|
||||
|
||||
|
||||
private void JoinLobby(MsgTickerJoinLobby message)
|
||||
{
|
||||
_stateManager.RequestStateChange<LobbyState>();
|
||||
@@ -64,5 +68,13 @@ namespace Content.Client.GameTicking
|
||||
{
|
||||
_stateManager.RequestStateChange<GameScreen>();
|
||||
}
|
||||
|
||||
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);
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
56
Content.Client/UserInterface/RoundEndSummaryWindow.cs
Normal file
56
Content.Client/UserInterface/RoundEndSummaryWindow.cs
Normal file
@@ -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<ILocalizationManager>();
|
||||
var cache = IoCManager.Resolve<IResourceCache>();
|
||||
var inputManager = IoCManager.Resolve<IInputManager>();
|
||||
Font headerFont = new VectorFont(cache.GetResource<FontResource>("/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();
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,4 +1,4 @@
|
||||
namespace Content.Server.GameTicking
|
||||
namespace Content.Server.GameTicking
|
||||
{
|
||||
/// <summary>
|
||||
/// 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!";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<RuleDeathMatch>();
|
||||
}
|
||||
|
||||
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!";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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!";
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,6 +100,7 @@ namespace Content.Server.GameTicking
|
||||
_netManager.RegisterNetMessage<MsgTickerJoinGame>(nameof(MsgTickerJoinGame));
|
||||
_netManager.RegisterNetMessage<MsgTickerLobbyStatus>(nameof(MsgTickerLobbyStatus));
|
||||
_netManager.RegisterNetMessage<MsgTickerLobbyInfo>(nameof(MsgTickerLobbyInfo));
|
||||
_netManager.RegisterNetMessage<MsgRoundEndMessage>(nameof(MsgRoundEndMessage));
|
||||
|
||||
SetStartPreset(_configurationManager.GetCVar<string>("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<MsgRoundEndMessage>();
|
||||
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()
|
||||
|
||||
@@ -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);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user