From 306bd79503c50f423a4b7a913b699420aff96fc2 Mon Sep 17 00:00:00 2001 From: Kill_Me_I_Noobs <118206719+Vonsant@users.noreply.github.com> Date: Fri, 6 Dec 2024 17:43:52 +0300 Subject: [PATCH] Port TapeRecorder (#129) --- .../TapeRecorder/TapeRecorderSystem.cs | 24 + .../Ui/TapeRecorderBoundUserInterface.cs | 64 +++ .../TapeRecorder/Ui/TapeRecorderWindow.xaml | 23 + .../Ui/TapeRecorderWindow.xaml.cs | 133 ++++++ .../TapeRecorder/TapeRecorderSystem.cs | 132 ++++++ .../Components/ActiveTapeRecorderComponent.cs | 9 + .../Components/TapeCassetteComponent.cs | 72 +++ .../Components/TapeRecorderComponent.cs | 124 +++++ .../TapeRecorder/Events/TapeRecorderEvents.cs | 50 +++ .../TapeRecorder/SharedTapeRecorderSystem.cs | 422 ++++++++++++++++++ .../TapeCassetteRecordedMessage.cs | 51 +++ .../Audio/Items/Taperecorder/attributions.yml | 17 + .../Items/Taperecorder/taperecorder_play.ogg | Bin 0 -> 11670 bytes .../Taperecorder/taperecorder_rewind.ogg | Bin 0 -> 13159 bytes .../Items/Taperecorder/taperecorder_stop.ogg | Bin 0 -> 7395 bytes .../en-US/taperecorder/taperecorder.ftl | 26 ++ .../catalog/fills/boxes/security.ftl | 2 + .../objects/devices/tape_recorder.ftl | 4 + .../entities/objects/misc/paper.ftl | 1 + .../ru-RU/taperecorder/taperecorder.ftl | 26 ++ .../Catalog/Fills/Boxes/security.yml | 23 + .../Catalog/Fills/Lockers/security.yml | 1 + .../Objects/Devices/tape_recorder.yml | 88 ++++ .../Entities/Objects/Misc/paper.yml | 6 + .../Entities/Structures/Machines/lathe.yml | 2 + Resources/Prototypes/Recipes/Lathes/misc.yml | 18 + .../Roles/Jobs/Wildcards/reporter.yml | 8 +- .../Devices/cassette_tapes.rsi/meta.json | 17 + .../cassette_tapes.rsi/tape_greyscale.png | Bin 0 -> 423 bytes .../cassette_tapes.rsi/tape_ribbonoverlay.png | Bin 0 -> 449 bytes .../Devices/tape_recorder.rsi/inhand-left.png | Bin 0 -> 491 bytes .../tape_recorder.rsi/inhand-right.png | Bin 0 -> 487 bytes .../Devices/tape_recorder.rsi/meta.json | 58 +++ .../tape_recorder.rsi/taperecorder_empty.png | Bin 0 -> 581 bytes .../tape_recorder.rsi/taperecorder_idle.png | Bin 0 -> 597 bytes .../taperecorder_playing.png | Bin 0 -> 955 bytes .../taperecorder_recording.png | Bin 0 -> 934 bytes .../taperecorder_rewinding.png | Bin 0 -> 887 bytes .../Objects/Storage/boxes.rsi/meta.json | 3 + .../Objects/Storage/boxes.rsi/recorder.png | Bin 0 -> 189 bytes 40 files changed, 1401 insertions(+), 3 deletions(-) create mode 100644 Content.Client/TapeRecorder/TapeRecorderSystem.cs create mode 100644 Content.Client/TapeRecorder/Ui/TapeRecorderBoundUserInterface.cs create mode 100644 Content.Client/TapeRecorder/Ui/TapeRecorderWindow.xaml create mode 100644 Content.Client/TapeRecorder/Ui/TapeRecorderWindow.xaml.cs create mode 100644 Content.Server/TapeRecorder/TapeRecorderSystem.cs create mode 100644 Content.Shared/TapeRecorder/Components/ActiveTapeRecorderComponent.cs create mode 100644 Content.Shared/TapeRecorder/Components/TapeCassetteComponent.cs create mode 100644 Content.Shared/TapeRecorder/Components/TapeRecorderComponent.cs create mode 100644 Content.Shared/TapeRecorder/Events/TapeRecorderEvents.cs create mode 100644 Content.Shared/TapeRecorder/SharedTapeRecorderSystem.cs create mode 100644 Content.Shared/TapeRecorder/TapeCassetteRecordedMessage.cs create mode 100644 Resources/Audio/Items/Taperecorder/attributions.yml create mode 100644 Resources/Audio/Items/Taperecorder/taperecorder_play.ogg create mode 100644 Resources/Audio/Items/Taperecorder/taperecorder_rewind.ogg create mode 100644 Resources/Audio/Items/Taperecorder/taperecorder_stop.ogg create mode 100644 Resources/Locale/en-US/taperecorder/taperecorder.ftl create mode 100644 Resources/Locale/ru-RU/ss14-ru/prototypes/entities/objects/devices/tape_recorder.ftl create mode 100644 Resources/Locale/ru-RU/taperecorder/taperecorder.ftl create mode 100644 Resources/Prototypes/Entities/Objects/Devices/tape_recorder.yml create mode 100644 Resources/Textures/Objects/Devices/cassette_tapes.rsi/meta.json create mode 100644 Resources/Textures/Objects/Devices/cassette_tapes.rsi/tape_greyscale.png create mode 100644 Resources/Textures/Objects/Devices/cassette_tapes.rsi/tape_ribbonoverlay.png create mode 100644 Resources/Textures/Objects/Devices/tape_recorder.rsi/inhand-left.png create mode 100644 Resources/Textures/Objects/Devices/tape_recorder.rsi/inhand-right.png create mode 100644 Resources/Textures/Objects/Devices/tape_recorder.rsi/meta.json create mode 100644 Resources/Textures/Objects/Devices/tape_recorder.rsi/taperecorder_empty.png create mode 100644 Resources/Textures/Objects/Devices/tape_recorder.rsi/taperecorder_idle.png create mode 100644 Resources/Textures/Objects/Devices/tape_recorder.rsi/taperecorder_playing.png create mode 100644 Resources/Textures/Objects/Devices/tape_recorder.rsi/taperecorder_recording.png create mode 100644 Resources/Textures/Objects/Devices/tape_recorder.rsi/taperecorder_rewinding.png create mode 100644 Resources/Textures/Objects/Storage/boxes.rsi/recorder.png diff --git a/Content.Client/TapeRecorder/TapeRecorderSystem.cs b/Content.Client/TapeRecorder/TapeRecorderSystem.cs new file mode 100644 index 00000000000..c228ea356c2 --- /dev/null +++ b/Content.Client/TapeRecorder/TapeRecorderSystem.cs @@ -0,0 +1,24 @@ +using Content.Shared.TapeRecorder; + +namespace Content.Client.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); + } +} \ No newline at end of file diff --git a/Content.Client/TapeRecorder/Ui/TapeRecorderBoundUserInterface.cs b/Content.Client/TapeRecorder/Ui/TapeRecorderBoundUserInterface.cs new file mode 100644 index 00000000000..33df6267480 --- /dev/null +++ b/Content.Client/TapeRecorder/Ui/TapeRecorderBoundUserInterface.cs @@ -0,0 +1,64 @@ +using Content.Shared.TapeRecorder.Components; +using Content.Shared.TapeRecorder.Events; +using Robust.Shared.Prototypes; +using Robust.Shared.Timing; + +namespace Content.Client.TapeRecorder.Ui; + +public sealed class TapeRecorderBoundUserInterface(EntityUid owner, Enum uiKey) : BoundUserInterface(owner, uiKey) +{ + [Dependency] private readonly IEntityManager _entMan = default!; + + [ViewVariables] + private TapeRecorderWindow? _window; + + [ViewVariables] + private TimeSpan _printCooldown; + + protected override void Open() + { + base.Open(); + + _window = new(_entMan, Owner); + _window.OnClose += Close; + _window.OnModeChanged += ChangeMode; + _window.OnPrintTranscript += PrintTranscript; + _window.OpenCentered(); + } + + private void ChangeMode(TapeRecorderMode mode) + { + SendMessage(new ChangeModeTapeRecorderMessage(mode)); + } + + 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); + } + + protected override void Dispose(bool disposing) + { + base.Dispose(disposing); + if (disposing) + _window?.Dispose(); + } +} diff --git a/Content.Client/TapeRecorder/Ui/TapeRecorderWindow.xaml b/Content.Client/TapeRecorder/Ui/TapeRecorderWindow.xaml new file mode 100644 index 00000000000..0e22a7815fe --- /dev/null +++ b/Content.Client/TapeRecorder/Ui/TapeRecorderWindow.xaml @@ -0,0 +1,23 @@ + + + + + + + + +