diff --git a/Content.Client/DeltaV/TapeRecorder/TapeRecorderSystem.cs b/Content.Client/DeltaV/TapeRecorder/TapeRecorderSystem.cs new file mode 100644 index 00000000000..7b8ed6663ca --- /dev/null +++ b/Content.Client/DeltaV/TapeRecorder/TapeRecorderSystem.cs @@ -0,0 +1,24 @@ +using Content.Shared.DeltaV.TapeRecorder.Systems; + +namespace Content.Client.DeltaV.TapeRecorder; + +/// +/// Required for client side prediction stuff +/// +public sealed class TapeRecorderSystem : SharedTapeRecorderSystem +{ + private TimeSpan _lastTickTime = TimeSpan.Zero; + + public override void Update(float frameTime) + { + if (!Timing.IsFirstTimePredicted) + return; + + //We need to know the exact time period that has passed since the last update to ensure the tape position is sync'd with the server + //Since the client can skip frames when lagging, we cannot use frameTime + var realTime = (float) (Timing.CurTime - _lastTickTime).TotalSeconds; + _lastTickTime = Timing.CurTime; + + base.Update(realTime); + } +} diff --git a/Content.Client/DeltaV/TapeRecorder/UI/TapeRecorderBoundUserInterface.cs b/Content.Client/DeltaV/TapeRecorder/UI/TapeRecorderBoundUserInterface.cs new file mode 100644 index 00000000000..521fbb96247 --- /dev/null +++ b/Content.Client/DeltaV/TapeRecorder/UI/TapeRecorderBoundUserInterface.cs @@ -0,0 +1,49 @@ +using Content.Shared.DeltaV.TapeRecorder; +using Robust.Client.UserInterface; +using Robust.Shared.Prototypes; +using Robust.Shared.Timing; + +namespace Content.Client.DeltaV.TapeRecorder.UI; + +public sealed class TapeRecorderBoundUserInterface(EntityUid owner, Enum uiKey) : BoundUserInterface(owner, uiKey) +{ + [ViewVariables] + private TapeRecorderWindow? _window; + + [ViewVariables] + private TimeSpan _printCooldown; + + protected override void Open() + { + base.Open(); + + _window = this.CreateWindow(); + _window.Owner = Owner; + _window.OnModeChanged += mode => SendMessage(new ChangeModeTapeRecorderMessage(mode)); + _window.OnPrintTranscript += PrintTranscript; + } + + private void PrintTranscript() + { + SendMessage(new PrintTapeRecorderMessage()); + + _window?.UpdatePrint(true); + + Timer.Spawn(_printCooldown, () => + { + _window?.UpdatePrint(false); + }); + } + + protected override void UpdateState(BoundUserInterfaceState state) + { + base.UpdateState(state); + + if (state is not TapeRecorderState cast) + return; + + _printCooldown = cast.PrintCooldown; + + _window?.UpdateState(cast); + } +} diff --git a/Content.Client/DeltaV/TapeRecorder/UI/TapeRecorderWindow.xaml b/Content.Client/DeltaV/TapeRecorder/UI/TapeRecorderWindow.xaml new file mode 100644 index 00000000000..c6dc577d264 --- /dev/null +++ b/Content.Client/DeltaV/TapeRecorder/UI/TapeRecorderWindow.xaml @@ -0,0 +1,23 @@ + + + + + + + + +