From 11cd6c7ac43ff95a309f25ba32c16fc0be54de46 Mon Sep 17 00:00:00 2001 From: rhailrake <49613070+rhailrake@users.noreply.github.com> Date: Sat, 19 Aug 2023 00:32:14 +0600 Subject: [PATCH] Lobby Containers (#320) --- Content.Client/Info/DiscordListBox.cs | 101 ++++++++++++++++++++++ Content.Client/Info/ServerListBox.cs | 120 ++++++++++++++++++++++++++ Content.Client/Lobby/UI/LobbyGui.xaml | 16 ++++ 3 files changed, 237 insertions(+) create mode 100644 Content.Client/Info/DiscordListBox.cs create mode 100644 Content.Client/Info/ServerListBox.cs diff --git a/Content.Client/Info/DiscordListBox.cs b/Content.Client/Info/DiscordListBox.cs new file mode 100644 index 0000000000..11112f215d --- /dev/null +++ b/Content.Client/Info/DiscordListBox.cs @@ -0,0 +1,101 @@ +using Robust.Client.UserInterface; +using Robust.Client.UserInterface.Controls; +using Robust.Shared.Utility; + +namespace Content.Client.Info +{ + public sealed class DiscordListBox : BoxContainer + { + + private IUriOpener _uriOpener; + + public DiscordListBox() + { + _uriOpener = IoCManager.Resolve(); + Orientation = LayoutOrientation.Vertical; + AddDiscordServers(); + } + + private void AddDiscordServers() + { + AddDiscordServerInfo("Атараксия", "Проект для заинтересованных в отыгрыше."); + AddDiscordServerInfo("Гласио", "Ролевой сервер для разумных эскапистов."); + AddDiscordServerInfo("Амур", "Проект с ЕРП направленностью."); + } + + private void AddDiscordServerInfo(string serverName, string description) + { + var serverBox = new BoxContainer + { + Orientation = LayoutOrientation.Horizontal, + }; + + var nameAndDescriptionBox = new BoxContainer + { + Orientation = LayoutOrientation.Vertical, + }; + + var serverNameLabel = new Label + { + Text = serverName, + MinWidth = 200 + }; + + var descriptionLabel = new RichTextLabel + { + MaxWidth = 500 + }; + descriptionLabel.SetMessage(FormattedMessage.FromMarkup(description)); + + var buttonBox = new BoxContainer + { + Orientation = LayoutOrientation.Vertical, + HorizontalExpand = true, + HorizontalAlignment = HAlignment.Right + }; + + var connectButton = new Button + { + Text = "Discord" + }; + + connectButton.OnPressed += _ => + { + OpenUrl(serverName, connectButton); + }; + + buttonBox.AddChild(connectButton); + + nameAndDescriptionBox.AddChild(serverNameLabel); + nameAndDescriptionBox.AddChild(descriptionLabel); + + serverBox.AddChild(nameAndDescriptionBox); + serverBox.AddChild(buttonBox); + + AddChild(serverBox); + } + + private void OpenUrl(string serverName, Button button) + { + button.Disabled = true; + + var url = ""; + + switch (serverName) + { + case "Атараксия": + url = "https://discord.gg/BCPkP3TcDT"; + break; + case "Гласио": + url = "https://discord.gg/TGzZep96cR"; + break; + case "Амур": + url = "https://discord.gg/vxHPsZ3Qyr"; + break; + } + _uriOpener.OpenUri(url); + + button.Disabled = false; + } + } +} diff --git a/Content.Client/Info/ServerListBox.cs b/Content.Client/Info/ServerListBox.cs new file mode 100644 index 0000000000..2581f0d877 --- /dev/null +++ b/Content.Client/Info/ServerListBox.cs @@ -0,0 +1,120 @@ +using Robust.Client; +using Robust.Client.UserInterface.Controls; +using Robust.Shared.Utility; + +namespace Content.Client.Info +{ + public sealed class ServerListBox : BoxContainer + { + private IGameController _gameController; + private List