MainMenuControl to XAML (#4642)

This commit is contained in:
Visne
2021-09-19 19:34:46 +02:00
committed by GitHub
parent 4f125f9c4a
commit 9e5628ab5e
3 changed files with 96 additions and 134 deletions

View File

@@ -0,0 +1,44 @@
<Control xmlns="https://spacestation14.io"
xmlns:pllax="clr-namespace:Content.Client.Parallax"
xmlns:clog="clr-namespace:Content.Client.Changelog">
<pllax:ParallaxControl />
<LayoutContainer>
<BoxContainer Name="VBox"
Orientation="Vertical"
StyleIdentifier="mainMenuVBox">
<TextureRect Name="Logo"
Stretch="KeepCentered" />
<BoxContainer Orientation="Horizontal"
SeparationOverride="4">
<Label Text="{Loc 'main-menu-username-label'}" />
<LineEdit Name="UsernameBoxProtected"
PlaceHolder="{Loc 'main-menu-username-text'}"
HorizontalExpand="True" />
</BoxContainer>
<Button Name="JoinPublicServerButtonProtected"
Text="{Loc 'main-menu-join-public-server-button'}"
StyleIdentifier="mainMenu"
TextAlign="Center" />
<Control MinSize="0 2" />
<LineEdit Name="AddressBoxProtected"
Text="localhost"
PlaceHolder="server address:port"
HorizontalExpand="True" />
<Button Name="DirectConnectButtonProtected"
Text="{Loc 'main-menu-direct-connect-button'}"
TextAlign="Center"
StyleIdentifier="mainMenu" />
<Control MinSize="0 2" />
<Button Name="OptionsButtonProtected"
Text="{Loc 'main-menu-options-button'}"
TextAlign="Center"
StyleIdentifier="mainMenu" />
<Button Name="QuitButtonProtected"
Text="{Loc 'main-menu-quit-button'}"
TextAlign="Center"
StyleIdentifier="mainMenu" />
<clog:ChangelogButton />
</BoxContainer>
<Label Name="VersionLabel" Text="v0.1" />
</LayoutContainer>
</Control>

View File

@@ -0,0 +1,51 @@
using Content.Client.Changelog;
using Content.Client.Parallax;
using Robust.Client.AutoGenerated;
using Robust.Client.ResourceManagement;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared;
using Robust.Shared.Configuration;
using Robust.Shared.Localization;
namespace Content.Client.MainMenu.UI
{
[GenerateTypedNameReferences]
public partial class MainMenuControl : Control
{
public LineEdit UserNameBox => UsernameBoxProtected;
public Button JoinPublicServerButton => JoinPublicServerButtonProtected;
public LineEdit AddressBox => AddressBoxProtected;
public Button DirectConnectButton => DirectConnectButtonProtected;
public Button OptionsButton => OptionsButtonProtected;
public Button QuitButton => QuitButtonProtected;
public MainMenuControl(IResourceCache resCache, IConfigurationManager configMan)
{
RobustXamlLoader.Load(this);
LayoutContainer.SetAnchorPreset(this, LayoutContainer.LayoutPreset.Wide);
LayoutContainer.SetAnchorPreset(VBox, LayoutContainer.LayoutPreset.TopRight);
LayoutContainer.SetMarginRight(VBox, -25);
LayoutContainer.SetMarginTop(VBox, 30);
LayoutContainer.SetGrowHorizontal(VBox, LayoutContainer.GrowDirection.Begin);
var logoTexture = resCache.GetResource<TextureResource>("/Textures/Logo/logo.png");
Logo.Texture = logoTexture;
var currentUserName = configMan.GetCVar(CVars.PlayerName);
UserNameBox.Text = currentUserName;
#if !FULL_RELEASE
JoinPublicServerButton.Disabled = true;
JoinPublicServerButton.ToolTip = Loc.GetString("main-menu-join-public-server-button-tooltip");
#endif
LayoutContainer.SetAnchorPreset(VersionLabel, LayoutContainer.LayoutPreset.BottomRight);
LayoutContainer.SetGrowHorizontal(VersionLabel, LayoutContainer.GrowDirection.Begin);
LayoutContainer.SetGrowVertical(VersionLabel, LayoutContainer.GrowDirection.Begin);
}
}
}