Fix lobby container

This commit is contained in:
Aviu00
2024-01-26 09:07:51 +03:00
parent 767b61d551
commit 251751d1c3
3 changed files with 28 additions and 151 deletions

View File

@@ -1,101 +0,0 @@
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<IUriOpener>();
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;
}
}
}

View File

@@ -1,4 +1,5 @@
using Robust.Client;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.Utility;
@@ -8,26 +9,27 @@ namespace Content.Client.Info
{
private IGameController _gameController;
private List<Button> _connectButtons = new();
private IUriOpener _uriOpener;
public ServerListBox()
{
_gameController = IoCManager.Resolve<IGameController>();
_uriOpener = IoCManager.Resolve<IUriOpener>();
Orientation = LayoutOrientation.Vertical;
AddServers();
}
private void AddServers()
{
AddServerInfo("Грид", "Сервер с постоянным безумием");
AddServerInfo("Мэйд", "Сервер с лучшим сервисом");
AddServerInfo("Енги", "Сервер с расслабленным геймплеем");
AddServerInfo("Амур", "Сервер для любителей ЕРП");
AddServerInfo("Инфинити️", "Сервер без правил");
AddServerInfo("Гласио", "Сервер с лучшим отыгрышем");
AddServerInfo("Атараксия", "Для любителей ролевой игры");
AddServerInfo("Grid", "Сервер с постоянным безумием", "ss14://s0.ss14.su:3333", null);
AddServerInfo("Maid", "Сервер с лучшим сервисом", "ss14://s5.ss14.su:6666", null);
AddServerInfo("Engi", "Сервер с расслабленным геймплеем", "ss14://s5.ss14.su:7777", null);
AddServerInfo("Amour", "Сервер для любителей ЕРП", "ss14://s0.ss14.su:8888", "https://discord.gg/vxHPsZ3Qyr");
AddServerInfo("Glasio", "Сервер с лучшим отыгрышем", "ss14://s0.ss14.su:4444", "https://discord.gg/TGzZep96cR");
AddServerInfo("Ataraxia", "Для любителей ролевой игры", "ss14://s0.ss14.su:10101", "https://discord.gg/BCPkP3TcDT");
}
private void AddServerInfo(string serverName, string description)
private void AddServerInfo(string serverName, string description, string serverUrl, string ?discord)
{
var serverBox = new BoxContainer
{
@@ -53,21 +55,36 @@ namespace Content.Client.Info
var buttonBox = new BoxContainer
{
Orientation = LayoutOrientation.Vertical,
Orientation = LayoutOrientation.Horizontal,
HorizontalExpand = true,
HorizontalAlignment = HAlignment.Right
};
var connectButton = new Button
{
Text = "Connect"
Text = "Подключиться"
};
if (discord != null)
{
var discordButton = new Button
{
Text = "Discord"
};
discordButton.OnPressed += _ =>
{
_uriOpener.OpenUri(discord);
};
buttonBox.AddChild(discordButton);
}
_connectButtons.Add(connectButton);
connectButton.OnPressed += _ =>
{
ConnectToServer(serverName);
_gameController.Redial(serverUrl, "Connecting to another server...");
foreach (var connectButton in _connectButtons)
{
@@ -85,36 +102,5 @@ namespace Content.Client.Info
AddChild(serverBox);
}
private void ConnectToServer(string serverName)
{
var url = "";
switch (serverName)
{
case "Грид":
url = "ss14://s0.ss14.su:3333";
break;
case "Мэйд":
url = "ss14://s5.ss14.su:6666";
break;
case "Енги":
url = "ss14://s5.ss14.su:7777";
break;
case "Амур":
url = "ss14://s0.ss14.su:8888";
break;
case "Инфинити️":
url = "ss14://s0.ss14.su:5555";
break;
case "Гласио":
url = "ss14://s0.ss14.su:4444";
break;
case "Атараксия":
url = "ss14://s0.ss14.su:10101";
break;
}
_gameController.Redial(url, "Connecting to another server...");
}
}
}

View File

@@ -45,14 +45,6 @@
</PanelContainer>
<BoxContainer Orientation="Horizontal" HorizontalAlignment="Stretch" VerticalAlignment="Top">
<PanelContainer Name="TopLeftContainer" MinHeight="350" MinWidth="469" StyleClasses="LobbyGayBackground">
<info:DiscordListBox Name="DiscordListBox" Access="Public" MinSize="0 30" VerticalExpand="True" HorizontalExpand="True" Margin="3 3 3 3" HorizontalAlignment="Stretch"/>
</PanelContainer>
<BoxContainer HorizontalAlignment="Stretch" HorizontalExpand="True">
<!-- Empty container to create spacing -->
</BoxContainer>
<PanelContainer Name="TopRightContainer" MinHeight="350" MinWidth="469" StyleClasses="LobbyGayBackground">
<info:ServerListBox Name="ServerListBox" Access="Public" MinSize="0 30" VerticalExpand="True" HorizontalExpand="True" Margin="3 3 3 3" HorizontalAlignment="Stretch"/>
</PanelContainer>