- add: new tiles and another ui tweaks (#11)
* - fix: audio crash * - tweak: main menu * connect gui * some shaders here * tiles
This commit is contained in:
@@ -1,70 +1,96 @@
|
||||
<Control xmlns="https://spacestation14.io"
|
||||
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
|
||||
xmlns:gfx="clr-namespace:Robust.Client.Graphics;assembly=Robust.Client"
|
||||
xmlns:parallax="clr-namespace:Content.Client.Parallax"
|
||||
xmlns:controls="clr-namespace:Content.Client.UserInterface.Controls">
|
||||
<parallax:ParallaxControl />
|
||||
|
||||
<TextureRect Access="Public" TexturePath="/Textures/Ohio/ohfuck.png" VerticalExpand="True" HorizontalExpand="True" Name="Background" Stretch="KeepAspectCovered"/>
|
||||
|
||||
<Control HorizontalAlignment="Center" VerticalAlignment="Center">
|
||||
|
||||
<PanelContainer StyleClasses="AngleRect" />
|
||||
|
||||
<BoxContainer Orientation="Vertical" MinSize="300 200">
|
||||
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
|
||||
<Label Margin="8 0 0 0" Text="{Loc 'connecting-title'}"
|
||||
StyleClasses="LabelHeading" VAlign="Center" />
|
||||
|
||||
<Button Name="ExitButton" Text="{Loc 'connecting-exit'}"
|
||||
HorizontalAlignment="Right" HorizontalExpand="True" />
|
||||
|
||||
</BoxContainer>
|
||||
|
||||
<controls:HighDivider />
|
||||
|
||||
<BoxContainer Orientation="Vertical" VerticalExpand="True" Margin="4 4 4 0">
|
||||
|
||||
<Control VerticalExpand="True" Margin="0 0 0 8">
|
||||
|
||||
<BoxContainer Orientation="Vertical" Name="ConnectingStatus">
|
||||
|
||||
<Label Text="{Loc 'connecting-in-progress'}" Align="Center" />
|
||||
|
||||
<!-- Who the fuck named these cont- oh wait I did -->
|
||||
|
||||
<Label Name="ConnectStatus" StyleClasses="LabelSubText" Align="Center" />
|
||||
|
||||
</BoxContainer>
|
||||
|
||||
<BoxContainer Orientation="Vertical" Name="ConnectFail" Visible="False">
|
||||
|
||||
<RichTextLabel Name="ConnectFailReason" VerticalAlignment="Stretch"/>
|
||||
|
||||
<Button Name="RetryButton" Text="{Loc 'connecting-retry'}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalExpand="True" VerticalAlignment="Bottom" />
|
||||
|
||||
</BoxContainer>
|
||||
|
||||
<BoxContainer Orientation="Vertical" Name="Disconnected">
|
||||
|
||||
<Label Text="{Loc 'connecting-disconnected'}" Align="Center" />
|
||||
|
||||
<Label Name="DisconnectReason" Align="Center" />
|
||||
|
||||
<Button Name="ReconnectButton" Text="{Loc 'connecting-reconnect'}"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalExpand="True" VerticalAlignment="Bottom" />
|
||||
|
||||
<Button Name="RedialButton" Text="{Loc 'connecting-redial'}"
|
||||
Disabled="True"
|
||||
HorizontalAlignment="Center"
|
||||
VerticalExpand="True" VerticalAlignment="Bottom" />
|
||||
|
||||
</BoxContainer>
|
||||
|
||||
</Control>
|
||||
|
||||
<Label Name="ConnectingAddress" StyleClasses="LabelSubText" HorizontalAlignment="Center" />
|
||||
|
||||
</BoxContainer>
|
||||
|
||||
<PanelContainer>
|
||||
|
||||
<PanelContainer.PanelOverride>
|
||||
|
||||
<gfx:StyleBoxFlat BackgroundColor="#444" ContentMarginTopOverride="2" />
|
||||
|
||||
</PanelContainer.PanelOverride>
|
||||
|
||||
</PanelContainer>
|
||||
|
||||
<BoxContainer Orientation="Horizontal" Margin="12 0 4 0" VerticalAlignment="Bottom">
|
||||
|
||||
<Label Text="{Loc 'connecting-tip'}" StyleClasses="LabelSubText" />
|
||||
|
||||
<Label Text="{Loc 'connecting-version'}" StyleClasses="LabelSubText"
|
||||
HorizontalAlignment="Right" HorizontalExpand="True" />
|
||||
|
||||
</BoxContainer>
|
||||
|
||||
</BoxContainer>
|
||||
|
||||
</Control>
|
||||
<!-- Bottom window for tips -->
|
||||
<PanelContainer Name="LoginTips" StyleClasses="AngleRect" Margin="0 10" MaxWidth="600" VerticalExpand="True" VerticalAlignment="Bottom">
|
||||
<BoxContainer Orientation="Vertical" VerticalExpand="True">
|
||||
<controls:StripeBack>
|
||||
<BoxContainer Orientation="Horizontal" HorizontalAlignment="Center">
|
||||
<Label Name="LoginTipTitle" Text="Tip" StyleClasses="LabelHeading" Align="Center"/>
|
||||
</BoxContainer>
|
||||
</controls:StripeBack>
|
||||
<BoxContainer Orientation="Vertical" Margin="5 5 5 5" >
|
||||
<RichTextLabel Name="LoginTip" VerticalExpand="True" />
|
||||
</BoxContainer>
|
||||
</BoxContainer>
|
||||
</PanelContainer>
|
||||
|
||||
</Control>
|
||||
|
||||
@@ -1,4 +1,3 @@
|
||||
using System.Linq;
|
||||
using Content.Client.Stylesheets;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Dataset;
|
||||
@@ -7,133 +6,130 @@ using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Configuration;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Random;
|
||||
|
||||
namespace Content.Client.Launcher
|
||||
namespace Content.Client.Launcher;
|
||||
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class LauncherConnectingGui : Control
|
||||
{
|
||||
[GenerateTypedNameReferences]
|
||||
public sealed partial class LauncherConnectingGui : Control
|
||||
private const float RedialWaitTimeSeconds = 15f;
|
||||
private readonly LauncherConnecting _state;
|
||||
private readonly IRobustRandom _random;
|
||||
private readonly IPrototypeManager _prototype;
|
||||
private readonly IConfigurationManager _cfg;
|
||||
|
||||
private float _redialWaitTime = RedialWaitTimeSeconds;
|
||||
|
||||
public LauncherConnectingGui(LauncherConnecting state, IRobustRandom random,
|
||||
IPrototypeManager prototype, IConfigurationManager config)
|
||||
{
|
||||
private const float RedialWaitTimeSeconds = 15f;
|
||||
private readonly LauncherConnecting _state;
|
||||
private readonly IRobustRandom _random;
|
||||
private readonly IPrototypeManager _prototype;
|
||||
private readonly IConfigurationManager _cfg;
|
||||
_state = state;
|
||||
_random = random;
|
||||
_prototype = prototype;
|
||||
_cfg = config;
|
||||
|
||||
private float _redialWaitTime = RedialWaitTimeSeconds;
|
||||
RobustXamlLoader.Load(this);
|
||||
|
||||
public LauncherConnectingGui(LauncherConnecting state, IRobustRandom random,
|
||||
IPrototypeManager prototype, IConfigurationManager config)
|
||||
LayoutContainer.SetAnchorPreset(this, LayoutContainer.LayoutPreset.Wide);
|
||||
|
||||
Stylesheet = IoCManager.Resolve<IStylesheetManager>().SheetSpace;
|
||||
|
||||
ChangeLoginTip();
|
||||
ReconnectButton.OnPressed += _ => _state.RetryConnect();
|
||||
// Redial shouldn't fail, but if it does, try a reconnect (maybe we're being run from debug)
|
||||
RedialButton.OnPressed += _ =>
|
||||
{
|
||||
_state = state;
|
||||
_random = random;
|
||||
_prototype = prototype;
|
||||
_cfg = config;
|
||||
if (!_state.Redial())
|
||||
_state.RetryConnect();
|
||||
};
|
||||
RetryButton.OnPressed += _ => _state.RetryConnect();
|
||||
ExitButton.OnPressed += _ => _state.Exit();
|
||||
|
||||
RobustXamlLoader.Load(this);
|
||||
var addr = state.Address;
|
||||
if (addr != null)
|
||||
ConnectingAddress.Text = addr;
|
||||
|
||||
LayoutContainer.SetAnchorPreset(this, LayoutContainer.LayoutPreset.Wide);
|
||||
state.PageChanged += OnPageChanged;
|
||||
state.ConnectFailReasonChanged += ConnectFailReasonChanged;
|
||||
state.ConnectionStateChanged += ConnectionStateChanged;
|
||||
|
||||
Stylesheet = IoCManager.Resolve<IStylesheetManager>().SheetSpace;
|
||||
ConnectionStateChanged(state.ConnectionState);
|
||||
|
||||
ChangeLoginTip();
|
||||
ReconnectButton.OnPressed += _ => _state.RetryConnect();
|
||||
// Redial shouldn't fail, but if it does, try a reconnect (maybe we're being run from debug)
|
||||
RedialButton.OnPressed += _ =>
|
||||
{
|
||||
if (!_state.Redial())
|
||||
_state.RetryConnect();
|
||||
};
|
||||
RetryButton.OnPressed += _ => _state.RetryConnect();
|
||||
ExitButton.OnPressed += _ => _state.Exit();
|
||||
// Redial flag setup
|
||||
var edim = IoCManager.Resolve<ExtendedDisconnectInformationManager>();
|
||||
edim.LastNetDisconnectedArgsChanged += LastNetDisconnectedArgsChanged;
|
||||
LastNetDisconnectedArgsChanged(edim.LastNetDisconnectedArgs);
|
||||
}
|
||||
|
||||
var addr = state.Address;
|
||||
if (addr != null)
|
||||
ConnectingAddress.Text = addr;
|
||||
private void ConnectFailReasonChanged(string? reason)
|
||||
{
|
||||
ConnectFailReason.SetMessage(reason == null
|
||||
? ""
|
||||
: Loc.GetString("connecting-fail-reason", ("reason", reason)));
|
||||
}
|
||||
|
||||
state.PageChanged += OnPageChanged;
|
||||
state.ConnectFailReasonChanged += ConnectFailReasonChanged;
|
||||
state.ConnectionStateChanged += ConnectionStateChanged;
|
||||
private void LastNetDisconnectedArgsChanged(NetDisconnectedArgs? args)
|
||||
{
|
||||
var redialFlag = args?.RedialFlag ?? false;
|
||||
RedialButton.Visible = redialFlag;
|
||||
ReconnectButton.Visible = !redialFlag;
|
||||
}
|
||||
|
||||
ConnectionStateChanged(state.ConnectionState);
|
||||
private void ChangeLoginTip()
|
||||
{
|
||||
var tipsDataset = _cfg.GetCVar(CCVars.LoginTipsDataset);
|
||||
var loginTipsEnabled = _prototype.TryIndex<DatasetPrototype>(tipsDataset, out var tips);
|
||||
|
||||
// Redial flag setup
|
||||
var edim = IoCManager.Resolve<ExtendedDisconnectInformationManager>();
|
||||
edim.LastNetDisconnectedArgsChanged += LastNetDisconnectedArgsChanged;
|
||||
LastNetDisconnectedArgsChanged(edim.LastNetDisconnectedArgs);
|
||||
//LoginTips.Visible = loginTipsEnabled;
|
||||
if (!loginTipsEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
private void ConnectFailReasonChanged(string? reason)
|
||||
var tipList = tips!.Values;
|
||||
|
||||
if (tipList.Count == 0)
|
||||
return;
|
||||
|
||||
var randomIndex = _random.Next(tipList.Count);
|
||||
var tip = tipList[randomIndex];
|
||||
//LoginTip.SetMessage(tip);
|
||||
|
||||
//LoginTipTitle.Text = Loc.GetString("connecting-window-tip", ("numberTip", randomIndex));
|
||||
}
|
||||
|
||||
protected override void FrameUpdate(FrameEventArgs args)
|
||||
{
|
||||
base.FrameUpdate(args);
|
||||
_redialWaitTime -= args.DeltaSeconds;
|
||||
if (_redialWaitTime <= 0)
|
||||
{
|
||||
ConnectFailReason.SetMessage(reason == null
|
||||
? ""
|
||||
: Loc.GetString("connecting-fail-reason", ("reason", reason)));
|
||||
RedialButton.Disabled = false;
|
||||
RedialButton.Text = Loc.GetString("connecting-redial");
|
||||
}
|
||||
|
||||
private void LastNetDisconnectedArgsChanged(NetDisconnectedArgs? args)
|
||||
else
|
||||
{
|
||||
var redialFlag = args?.RedialFlag ?? false;
|
||||
RedialButton.Visible = redialFlag;
|
||||
ReconnectButton.Visible = !redialFlag;
|
||||
}
|
||||
|
||||
private void ChangeLoginTip()
|
||||
{
|
||||
var tipsDataset = _cfg.GetCVar(CCVars.LoginTipsDataset);
|
||||
var loginTipsEnabled = _prototype.TryIndex<DatasetPrototype>(tipsDataset, out var tips);
|
||||
|
||||
LoginTips.Visible = loginTipsEnabled;
|
||||
if (!loginTipsEnabled)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
var tipList = tips!.Values;
|
||||
|
||||
if (tipList.Count == 0)
|
||||
return;
|
||||
|
||||
var randomIndex = _random.Next(tipList.Count);
|
||||
var tip = tipList[randomIndex];
|
||||
LoginTip.SetMessage(tip);
|
||||
|
||||
LoginTipTitle.Text = Loc.GetString("connecting-window-tip", ("numberTip", randomIndex));
|
||||
}
|
||||
|
||||
protected override void FrameUpdate(FrameEventArgs args)
|
||||
{
|
||||
base.FrameUpdate(args);
|
||||
_redialWaitTime -= args.DeltaSeconds;
|
||||
if (_redialWaitTime <= 0)
|
||||
{
|
||||
RedialButton.Disabled = false;
|
||||
RedialButton.Text = Loc.GetString("connecting-redial");
|
||||
}
|
||||
else
|
||||
{
|
||||
RedialButton.Disabled = true;
|
||||
RedialButton.Text = Loc.GetString("connecting-redial-wait", ("time", _redialWaitTime.ToString("00.000")));
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPageChanged(LauncherConnecting.Page page)
|
||||
{
|
||||
ConnectingStatus.Visible = page == LauncherConnecting.Page.Connecting;
|
||||
ConnectFail.Visible = page == LauncherConnecting.Page.ConnectFailed;
|
||||
Disconnected.Visible = page == LauncherConnecting.Page.Disconnected;
|
||||
|
||||
if (page == LauncherConnecting.Page.Disconnected)
|
||||
DisconnectReason.Text = _state.LastDisconnectReason;
|
||||
}
|
||||
|
||||
private void ConnectionStateChanged(ClientConnectionState state)
|
||||
{
|
||||
ConnectStatus.Text = Loc.GetString($"connecting-state-{state}");
|
||||
RedialButton.Disabled = true;
|
||||
RedialButton.Text = Loc.GetString("connecting-redial-wait", ("time", _redialWaitTime.ToString("00.000")));
|
||||
}
|
||||
}
|
||||
|
||||
private void OnPageChanged(LauncherConnecting.Page page)
|
||||
{
|
||||
ConnectingStatus.Visible = page == LauncherConnecting.Page.Connecting;
|
||||
ConnectFail.Visible = page == LauncherConnecting.Page.ConnectFailed;
|
||||
Disconnected.Visible = page == LauncherConnecting.Page.Disconnected;
|
||||
|
||||
if (page == LauncherConnecting.Page.Disconnected)
|
||||
DisconnectReason.Text = _state.LastDisconnectReason;
|
||||
}
|
||||
|
||||
private void ConnectionStateChanged(ClientConnectionState state)
|
||||
{
|
||||
ConnectStatus.Text = Loc.GetString($"connecting-state-{state}");
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user