MainMenuControl to XAML (#4642)
This commit is contained in:
44
Content.Client/MainMenu/UI/MainMenuControl.xaml
Normal file
44
Content.Client/MainMenu/UI/MainMenuControl.xaml
Normal 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>
|
||||
51
Content.Client/MainMenu/UI/MainMenuControl.xaml.cs
Normal file
51
Content.Client/MainMenu/UI/MainMenuControl.xaml.cs
Normal 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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user