Transition lobby from tscn to C#, localization support for lobby.

This commit is contained in:
Pieter-Jan Briers
2019-05-14 00:23:58 +02:00
parent 331cfaa1c5
commit 88c29abe5e
3 changed files with 84 additions and 344 deletions

View File

@@ -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});
}
}
}