Transition lobby from tscn to C#, localization support for lobby.
This commit is contained in:
@@ -10,9 +10,11 @@ using Robust.Client.Console;
|
||||
using Robust.Client.Interfaces;
|
||||
using Robust.Client.Interfaces.Input;
|
||||
using Robust.Client.Interfaces.UserInterface;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Shared.Input;
|
||||
using Robust.Shared.Interfaces.Network;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.ViewVariables;
|
||||
|
||||
@@ -27,6 +29,7 @@ namespace Content.Client.GameTicking
|
||||
[Dependency] private IBaseClient _baseClient;
|
||||
[Dependency] private IChatManager _chatManager;
|
||||
[Dependency] private IClientConsole _console;
|
||||
[Dependency] private ILocalizationManager _localization;
|
||||
#pragma warning restore 649
|
||||
|
||||
[ViewVariables] private bool _areWeReady;
|
||||
@@ -83,11 +86,11 @@ namespace Content.Client.GameTicking
|
||||
{
|
||||
if (difference.TotalSeconds < -5)
|
||||
{
|
||||
text = "Right Now?";
|
||||
text = _localization.GetString("Right Now?");
|
||||
}
|
||||
else
|
||||
{
|
||||
text = "Right Now";
|
||||
text = _localization.GetString("Right Now");
|
||||
}
|
||||
}
|
||||
else
|
||||
@@ -95,7 +98,7 @@ namespace Content.Client.GameTicking
|
||||
text = $"{(int) Math.Floor(difference.TotalMinutes)}:{difference.Seconds:D2}";
|
||||
}
|
||||
|
||||
_lobby.StartTime.Text = "Round Starts In: " + text;
|
||||
_lobby.StartTime.Text = _localization.GetString("Round Starts In: {0}", text);
|
||||
}
|
||||
|
||||
private void _lobbyStatus(MsgTickerLobbyStatus message)
|
||||
@@ -116,14 +119,14 @@ namespace Content.Client.GameTicking
|
||||
|
||||
if (_gameStarted)
|
||||
{
|
||||
_lobby.ReadyButton.Text = "Join";
|
||||
_lobby.ReadyButton.Text = _localization.GetString("Join");
|
||||
_lobby.ReadyButton.ToggleMode = false;
|
||||
_lobby.ReadyButton.Pressed = false;
|
||||
}
|
||||
else
|
||||
{
|
||||
_lobby.StartTime.Text = "";
|
||||
_lobby.ReadyButton.Text = "Ready Up";
|
||||
_lobby.ReadyButton.Text = _localization.GetString("Ready Up");
|
||||
_lobby.ReadyButton.ToggleMode = true;
|
||||
_lobby.ReadyButton.Pressed = _areWeReady;
|
||||
}
|
||||
@@ -144,9 +147,11 @@ namespace Content.Client.GameTicking
|
||||
|
||||
_tickerState = TickerState.InLobby;
|
||||
|
||||
_lobby = new LobbyGui();
|
||||
_lobby = new LobbyGui(_localization);
|
||||
_userInterfaceManager.StateRoot.AddChild(_lobby);
|
||||
|
||||
_lobby.SetAnchorAndMarginPreset(Control.LayoutPreset.Wide, margin: 20);
|
||||
|
||||
_chatManager.SetChatBox(_lobby.Chat);
|
||||
_lobby.Chat.DefaultChatFormat = "ooc \"{0}\"";
|
||||
|
||||
|
||||
@@ -1,36 +1,86 @@
|
||||
using Content.Client.Chat;
|
||||
using Robust.Client.Graphics.Drawing;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
|
||||
namespace Content.Client.UserInterface
|
||||
{
|
||||
public class LobbyGui : Control
|
||||
internal sealed class LobbyGui : PanelContainer
|
||||
{
|
||||
protected override ResourcePath ScenePath => new ResourcePath("/Scenes/Lobby/Lobby.tscn");
|
||||
public Label ServerName { get; }
|
||||
public Label StartTime { get; }
|
||||
public Button ReadyButton { get; }
|
||||
public Button ObserveButton { get; }
|
||||
public Button LeaveButton { get; }
|
||||
public ChatBox Chat { get; set; }
|
||||
|
||||
public Label ServerName => GetChild<Label>("Panel/VBoxContainer/TitleContainer/ServerName");
|
||||
public Label StartTime => GetChild<Label>("Panel/VBoxContainer/HBoxContainer/LeftVBox/ReadyButtons/RoundStartText");
|
||||
|
||||
public Button ReadyButton =>
|
||||
GetChild<Button>("Panel/VBoxContainer/HBoxContainer/LeftVBox/ReadyButtons/ReadyButton");
|
||||
|
||||
public Button ObserveButton =>
|
||||
GetChild<Button>("Panel/VBoxContainer/HBoxContainer/LeftVBox/ReadyButtons/ObserveButton");
|
||||
|
||||
public Button LeaveButton => GetChild<Button>("Panel/VBoxContainer/TitleContainer/LeaveButton");
|
||||
|
||||
public ChatBox Chat { get; private set; }
|
||||
|
||||
protected override void Initialize()
|
||||
public LobbyGui(ILocalizationManager localization)
|
||||
{
|
||||
base.Initialize();
|
||||
PanelOverride = new StyleBoxFlat { BackgroundColor = new Color(37, 37, 45)};
|
||||
|
||||
var chatContainer = GetChild("Panel/VBoxContainer/HBoxContainer/LeftVBox");
|
||||
Chat = new ChatBox {ReleaseFocusOnEnter = false};
|
||||
chatContainer.AddChild(Chat);
|
||||
Chat.SizeFlagsVertical = SizeFlags.FillExpand;
|
||||
var vBox = new VBoxContainer();
|
||||
AddChild(vBox);
|
||||
|
||||
{
|
||||
// Title bar.
|
||||
var titleContainer = new HBoxContainer();
|
||||
vBox.AddChild(titleContainer);
|
||||
|
||||
titleContainer.AddChild(new Label
|
||||
{
|
||||
Text = localization.GetString("Lobby"),
|
||||
SizeFlagsHorizontal = SizeFlags.None
|
||||
});
|
||||
|
||||
titleContainer.AddChild(ServerName = new Label
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.ShrinkCenter | SizeFlags.Expand
|
||||
});
|
||||
|
||||
titleContainer.AddChild(LeaveButton = new Button
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.ShrinkEnd,
|
||||
Text = localization.GetString("Leave")
|
||||
});
|
||||
}
|
||||
|
||||
var hBox = new HBoxContainer {SizeFlagsVertical = SizeFlags.FillExpand};
|
||||
vBox.AddChild(hBox);
|
||||
|
||||
{
|
||||
var leftVBox = new VBoxContainer {SizeFlagsHorizontal = SizeFlags.FillExpand};
|
||||
hBox.AddChild(leftVBox);
|
||||
|
||||
// Placeholder.
|
||||
leftVBox.AddChild(new Control {SizeFlagsVertical = SizeFlags.FillExpand});
|
||||
|
||||
var readyButtons = new HBoxContainer();
|
||||
|
||||
leftVBox.AddChild(readyButtons);
|
||||
readyButtons.AddChild(ObserveButton = new Button
|
||||
{
|
||||
Text = localization.GetString("Observe")
|
||||
});
|
||||
|
||||
readyButtons.AddChild(StartTime = new Label
|
||||
{
|
||||
SizeFlagsHorizontal = SizeFlags.FillExpand,
|
||||
Align = Label.AlignMode.Right
|
||||
});
|
||||
|
||||
readyButtons.AddChild(ReadyButton = new Button
|
||||
{
|
||||
ToggleMode = true,
|
||||
Text = localization.GetString("Ready Up")
|
||||
});
|
||||
|
||||
leftVBox.AddChild(Chat = new ChatBox {SizeFlagsVertical = SizeFlags.FillExpand});
|
||||
}
|
||||
|
||||
// Placeholder.
|
||||
hBox.AddChild(new Control {SizeFlagsHorizontal = SizeFlags.FillExpand});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user