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});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,315 +0,0 @@
|
||||
[gd_scene format=2]
|
||||
|
||||
[node name="Control" type="Control" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
|
||||
[node name="Panel" type="Panel" parent="." index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 20.0
|
||||
margin_top = 20.0
|
||||
margin_right = -20.0
|
||||
margin_bottom = -20.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
|
||||
[node name="VBoxContainer" type="VBoxContainer" parent="Panel" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
margin_left = 3.0
|
||||
margin_top = 3.0
|
||||
margin_right = -3.0
|
||||
margin_bottom = -3.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 1
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
alignment = 0
|
||||
|
||||
[node name="TitleContainer" type="MarginContainer" parent="Panel/VBoxContainer" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 978.0
|
||||
margin_bottom = 20.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
custom_constants/margin_right = 0
|
||||
custom_constants/margin_top = 0
|
||||
custom_constants/margin_left = 0
|
||||
custom_constants/margin_bottom = 0
|
||||
_sections_unfolded = [ "custom_constants", "custom_styles" ]
|
||||
|
||||
[node name="LobbyLabel" type="Label" parent="Panel/VBoxContainer/TitleContainer" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 3.0
|
||||
margin_right = 43.0
|
||||
margin_bottom = 17.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 2
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 0
|
||||
size_flags_vertical = 4
|
||||
text = "LOBBY"
|
||||
percent_visible = 1.0
|
||||
lines_skipped = 0
|
||||
max_lines_visible = -1
|
||||
_sections_unfolded = [ "Size Flags" ]
|
||||
|
||||
[node name="ServerName" type="Label" parent="Panel/VBoxContainer/TitleContainer" index="1"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 3.0
|
||||
margin_right = 978.0
|
||||
margin_bottom = 17.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 2
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 4
|
||||
text = "Space Station 14"
|
||||
align = 1
|
||||
percent_visible = 1.0
|
||||
lines_skipped = 0
|
||||
max_lines_visible = -1
|
||||
|
||||
[node name="LeaveButton" type="Button" parent="Panel/VBoxContainer/TitleContainer" index="2"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 929.0
|
||||
margin_right = 978.0
|
||||
margin_bottom = 20.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
focus_mode = 2
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 8
|
||||
size_flags_vertical = 1
|
||||
toggle_mode = false
|
||||
enabled_focus_mode = 2
|
||||
shortcut = null
|
||||
group = null
|
||||
text = "Leave"
|
||||
flat = false
|
||||
align = 1
|
||||
_sections_unfolded = [ "Size Flags" ]
|
||||
|
||||
[node name="HBoxContainer" type="HBoxContainer" parent="Panel/VBoxContainer" index="1"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 24.0
|
||||
margin_right = 978.0
|
||||
margin_bottom = 554.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 1
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 3
|
||||
alignment = 0
|
||||
|
||||
[node name="LeftVBox" type="VBoxContainer" parent="Panel/VBoxContainer/HBoxContainer" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 487.0
|
||||
margin_bottom = 530.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 1
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
alignment = 0
|
||||
|
||||
[node name="LeftPanel" type="Container" parent="Panel/VBoxContainer/HBoxContainer/LeftVBox" index="0"]
|
||||
|
||||
editor/display_folded = true
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 487.0
|
||||
margin_bottom = 506.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 3
|
||||
|
||||
[node name="RichTextLabel" type="RichTextLabel" parent="Panel/VBoxContainer/HBoxContainer/LeftVBox/LeftPanel" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 1.0
|
||||
anchor_bottom = 1.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = true
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
bbcode_enabled = false
|
||||
bbcode_text = ""
|
||||
visible_characters = -1
|
||||
percent_visible = 1.0
|
||||
meta_underlined = true
|
||||
tab_size = 4
|
||||
text = "Welcome to the server!
|
||||
|
||||
Player count: 0"
|
||||
scroll_active = true
|
||||
scroll_following = false
|
||||
selection_enabled = false
|
||||
override_selected_font_color = false
|
||||
|
||||
[node name="ReadyButtons" type="HBoxContainer" parent="Panel/VBoxContainer/HBoxContainer/LeftVBox" index="1"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_top = 510.0
|
||||
margin_right = 487.0
|
||||
margin_bottom = 530.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 1
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
alignment = 0
|
||||
|
||||
[node name="ObserveButton" type="Button" parent="Panel/VBoxContainer/HBoxContainer/LeftVBox/ReadyButtons" index="0"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_right = 66.0
|
||||
margin_bottom = 20.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
focus_mode = 2
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
toggle_mode = false
|
||||
enabled_focus_mode = 2
|
||||
shortcut = null
|
||||
group = null
|
||||
text = "Observe"
|
||||
flat = false
|
||||
align = 1
|
||||
|
||||
[node name="RoundStartText" type="Label" parent="Panel/VBoxContainer/HBoxContainer/LeftVBox/ReadyButtons" index="1"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 70.0
|
||||
margin_top = 3.0
|
||||
margin_right = 411.0
|
||||
margin_bottom = 17.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 2
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 4
|
||||
text = "Round Starts In:"
|
||||
align = 2
|
||||
percent_visible = 1.0
|
||||
lines_skipped = 0
|
||||
max_lines_visible = -1
|
||||
|
||||
[node name="ReadyButton" type="Button" parent="Panel/VBoxContainer/HBoxContainer/LeftVBox/ReadyButtons" index="2"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 415.0
|
||||
margin_right = 487.0
|
||||
margin_bottom = 20.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
focus_mode = 2
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 1
|
||||
size_flags_vertical = 1
|
||||
toggle_mode = true
|
||||
enabled_focus_mode = 2
|
||||
shortcut = null
|
||||
group = null
|
||||
text = "Ready Up"
|
||||
flat = false
|
||||
align = 1
|
||||
|
||||
[node name="RightPanel" type="Container" parent="Panel/VBoxContainer/HBoxContainer" index="1"]
|
||||
|
||||
anchor_left = 0.0
|
||||
anchor_top = 0.0
|
||||
anchor_right = 0.0
|
||||
anchor_bottom = 0.0
|
||||
margin_left = 491.0
|
||||
margin_right = 978.0
|
||||
margin_bottom = 530.0
|
||||
rect_pivot_offset = Vector2( 0, 0 )
|
||||
rect_clip_content = false
|
||||
mouse_filter = 0
|
||||
mouse_default_cursor_shape = 0
|
||||
size_flags_horizontal = 3
|
||||
size_flags_vertical = 1
|
||||
|
||||
|
||||
Reference in New Issue
Block a user