fixed dumb shit that nobody cares (#772)

This commit is contained in:
Valtos
2024-11-05 23:04:51 +03:00
committed by Jabak
parent 6e07aed4b8
commit 7d657aa818
5 changed files with 101 additions and 28 deletions

View File

@@ -0,0 +1,30 @@
using Content.Client.Stylesheets;
using Robust.Client.State;
using Robust.Client.UserInterface;
using Robust.Shared.Utility;
namespace Content.Client.Replay.UI.Loading;
/// <summary>
/// State used to display an error message if a replay failed to load.
/// </summary>
/// <seealso cref="ReplayLoadingFailedControl"/>
/// <seealso cref="ContentReplayPlaybackManager"/>
public sealed class ReplayLoadingFailed : State
{
[Dependency] private readonly IStylesheetManager _stylesheetManager = default!;
[Dependency] private readonly IUserInterfaceManager _userInterface = default!;
private ReplayLoadingFailedControl? _control;
public void SetData(Exception exception, Action? cancelPressed, Action? retryPressed)
{
DebugTools.Assert(_control != null);
_control.SetData(exception, cancelPressed, retryPressed);
}
protected override void Startup()
{
_control = new ReplayLoadingFailedControl(_stylesheetManager);
_userInterface.StateRoot.AddChild(_control);
}
protected override void Shutdown()
{
_control?.Orphan();
}
}

View File

@@ -0,0 +1,14 @@
<Control xmlns="https://spacestation14.io"
xmlns:pllax="clr-namespace:Content.Client.Parallax">
<pllax:ParallaxControl />
<Control HorizontalAlignment="Center" VerticalAlignment="Center">
<PanelContainer StyleClasses="AngleRect" />
<BoxContainer Orientation="Vertical" SetSize="800 600" Margin="2">
<ScrollContainer Name="what" VerticalExpand="True" HScrollEnabled="False" Margin="0 0 0 2" ReturnMeasure="True">
<RichTextLabel Name="ReasonLabel" VerticalAlignment="Top" />
</ScrollContainer>
<Button Name="RetryButton" StyleClasses="Caution" Text="{Loc 'replay-loading-retry'}" Visible="False" />
<Button Name="CancelButton" Text="{Loc 'replay-loading-cancel'}" Visible="False" />
</BoxContainer>
</Control>
</Control>

View File

@@ -0,0 +1,38 @@
using Content.Client.Stylesheets;
using Robust.Client.AutoGenerated;
using Robust.Client.UserInterface;
using Robust.Client.UserInterface.Controls;
using Robust.Client.UserInterface.XAML;
using Robust.Shared.Utility;
namespace Content.Client.Replay.UI.Loading;
[GenerateTypedNameReferences]
public sealed partial class ReplayLoadingFailedControl : Control
{
public ReplayLoadingFailedControl(IStylesheetManager stylesheet)
{
RobustXamlLoader.Load(this);
Stylesheet = stylesheet.SheetSpace;
LayoutContainer.SetAnchorPreset(this, LayoutContainer.LayoutPreset.Wide);
}
public void SetData(Exception exception, Action? cancelPressed, Action? retryPressed)
{
ReasonLabel.SetMessage(
FormattedMessage.FromUnformatted(Loc.GetString("replay-loading-failed", ("reason", exception))));
if (cancelPressed != null)
{
CancelButton.Visible = true;
CancelButton.OnPressed += _ =>
{
cancelPressed();
};
}
if (retryPressed != null)
{
RetryButton.Visible = true;
RetryButton.OnPressed += _ =>
{
retryPressed();
};
}
}
}