Replay client (#15001)

This commit is contained in:
Leon Friedrich
2023-06-05 16:44:09 +12:00
committed by GitHub
parent a8eee5878a
commit 2ef95a3225
28 changed files with 1474 additions and 1 deletions

View File

@@ -0,0 +1,51 @@
using Robust.Client.ResourceManagement;
using Robust.Client.State;
using Robust.Client.UserInterface;
using Robust.Shared.CPUJob.JobQueues;
using Robust.Shared.Timing;
namespace Content.Client.Replay.UI.Loading;
[Virtual]
public class LoadingScreen<TResult> : State
{
[Dependency] private readonly IResourceCache _resourceCache = default!;
[Dependency] private readonly IUserInterfaceManager _userInterfaceManager = default!;
public event Action<TResult?, Exception?>? OnJobFinished;
private LoadingScreenControl _screen = default!;
public Job<TResult>? Job;
public override void FrameUpdate(FrameEventArgs e)
{
base.FrameUpdate(e);
if (Job == null)
return;
Job.Run();
if (Job.Status != JobStatus.Finished)
return;
OnJobFinished?.Invoke(Job.Result, Job.Exception);
Job = null;
}
protected override void Startup()
{
_screen = new(_resourceCache);
_userInterfaceManager.StateRoot.AddChild(_screen);
}
protected override void Shutdown()
{
_screen.Dispose();
}
public void UpdateProgress(float value, float maxValue, string header, string subtext = "")
{
_screen.Bar.Value = value;
_screen.Bar.MaxValue = maxValue;
_screen.Header.Text = header;
_screen.Subtext.Text = subtext;
}
}

View File

@@ -0,0 +1,38 @@
<Control xmlns="https://spacestation14.io"
xmlns:pllax="clr-namespace:Content.Client.Parallax">
<pllax:ParallaxControl />
<PanelContainer Name="Background"
HorizontalAlignment="Center"
VerticalAlignment="Center">
<BoxContainer Orientation="Vertical"
Align="Center">
<BoxContainer
Orientation="Horizontal"
Align="Center"
Margin="12">
<AnimatedTextureRect Name="SpriteLeft"
SetSize="64 64"
Margin="16 0"/>
<Label Name="Header"
Margin="5"
Access="Public"/>
<AnimatedTextureRect Name="SpriteRight"
SetSize="64 64"
Margin="16 0"/>
</BoxContainer>
<ProgressBar Name="Bar"
MaxValue="1.0"
MinWidth="400"
MinHeight="25"
Margin="12 6"
Access="Public"/>
<BoxContainer
Orientation="Horizontal"
Align="Center">
<Label Name="Subtext"
Margin="6"
Access="Public"/>
</BoxContainer>
</BoxContainer>
</PanelContainer>
</Control>

View File

@@ -0,0 +1,39 @@
using Content.Client.Resources;
using Robust.Client.AutoGenerated;
using Robust.Client.Graphics;
using Robust.Client.ResourceManagement;
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 LoadingScreenControl : Control
{
public static SpriteSpecifier Sprite = new SpriteSpecifier.Rsi(new ("/Textures/Mobs/Silicon/Bots/mommi.rsi"), "wiggle");
public LoadingScreenControl(IResourceCache resCache)
{
RobustXamlLoader.Load(this);
LayoutContainer.SetAnchorPreset(this, LayoutContainer.LayoutPreset.Wide);
Header.FontOverride = resCache.GetFont("/Fonts/NotoSansDisplay/NotoSansDisplay-Bold.ttf", 24);
Subtext.FontOverride = resCache.GetFont("/Fonts/NotoSansDisplay/NotoSansDisplay-Bold.ttf", 12);
SpriteLeft.SetFromSpriteSpecifier(Sprite);
SpriteRight.SetFromSpriteSpecifier(Sprite);
SpriteLeft.HorizontalAlignment = HAlignment.Stretch;
SpriteLeft.VerticalAlignment = VAlignment.Stretch;
SpriteLeft.DisplayRect.Stretch = TextureRect.StretchMode.KeepAspectCentered;
SpriteRight.DisplayRect.Stretch = TextureRect.StretchMode.KeepAspectCentered;
Background.PanelOverride = new StyleBoxFlat()
{
BackgroundColor = Color.FromHex("#303033"),
BorderColor = Color.FromHex("#5a5a5a"),
BorderThickness = new Thickness(4)
};
}
}