6
StarHorizon_Public/Content.Client/Replay/UI/Loading/ReplayLoadingFailedControl.xaml.cs
2026-01-24 12:49:55 +03:00

45 lines
1.2 KiB
C#

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();
};
}
}
}