mirror of
https://github.com/WWhiteDreamProject/wwdpublic.git
synced 2026-04-18 05:59:03 +03:00
* add tape recorder * add filled tape recorder to trinkets * :trollface: * :trollface: --------- Co-authored-by: deltanedas <@deltanedas:kde.org>
50 lines
1.2 KiB
C#
50 lines
1.2 KiB
C#
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<TapeRecorderWindow>();
|
|
_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);
|
|
}
|
|
}
|