diff --git a/Content.Client/CartridgeLoader/Cartridges/LogProbeUi.cs b/Content.Client/CartridgeLoader/Cartridges/LogProbeUi.cs
index d28d3228c94d41..12b678d5d47b49 100644
--- a/Content.Client/CartridgeLoader/Cartridges/LogProbeUi.cs
+++ b/Content.Client/CartridgeLoader/Cartridges/LogProbeUi.cs
@@ -1,4 +1,5 @@
using Content.Client.UserInterface.Fragments;
+using Content.Shared.CartridgeLoader;
using Content.Shared.CartridgeLoader.Cartridges;
using Robust.Client.UserInterface;
@@ -13,16 +14,23 @@ public override Control GetUIFragmentRoot()
return _fragment!;
}
- public override void Setup(BoundUserInterface userInterface, EntityUid? fragmentOwner)
+ public override void Setup(BoundUserInterface ui, EntityUid? fragmentOwner)
{
_fragment = new LogProbeUiFragment();
+
+ _fragment.OnPrintPressed += () =>
+ {
+ var ev = new LogProbePrintMessage();
+ var message = new CartridgeUiMessage(ev);
+ ui.SendMessage(message);
+ };
}
public override void UpdateState(BoundUserInterfaceState state)
{
- if (state is not LogProbeUiState logProbeUiState)
+ if (state is not LogProbeUiState cast)
return;
- _fragment?.UpdateState(logProbeUiState.PulledLogs);
+ _fragment?.UpdateState(cast.EntityName, cast.PulledLogs);
}
}
diff --git a/Content.Client/CartridgeLoader/Cartridges/LogProbeUiFragment.xaml b/Content.Client/CartridgeLoader/Cartridges/LogProbeUiFragment.xaml
index d12fb55cdceff8..cdbaf7d6ee7d74 100644
--- a/Content.Client/CartridgeLoader/Cartridges/LogProbeUiFragment.xaml
+++ b/Content.Client/CartridgeLoader/Cartridges/LogProbeUiFragment.xaml
@@ -18,4 +18,9 @@
+
+
+
+
+
diff --git a/Content.Client/CartridgeLoader/Cartridges/LogProbeUiFragment.xaml.cs b/Content.Client/CartridgeLoader/Cartridges/LogProbeUiFragment.xaml.cs
index b22e0bc1964af2..d9569bd11d2a41 100644
--- a/Content.Client/CartridgeLoader/Cartridges/LogProbeUiFragment.xaml.cs
+++ b/Content.Client/CartridgeLoader/Cartridges/LogProbeUiFragment.xaml.cs
@@ -8,17 +8,24 @@ namespace Content.Client.CartridgeLoader.Cartridges;
[GenerateTypedNameReferences]
public sealed partial class LogProbeUiFragment : BoxContainer
{
+ ///
+ /// Action invoked when the print button gets pressed.
+ ///
+ public Action? OnPrintPressed;
+
public LogProbeUiFragment()
{
RobustXamlLoader.Load(this);
+
+ PrintButton.OnPressed += _ => OnPrintPressed?.Invoke();
}
- public void UpdateState(List logs)
+ public void UpdateState(string name, List logs)
{
- ProbedDeviceContainer.RemoveAllChildren();
+ EntityName.Text = name;
+ PrintButton.Disabled = string.IsNullOrEmpty(name);
- //Reverse the list so the oldest entries appear at the bottom
- logs.Reverse();
+ ProbedDeviceContainer.RemoveAllChildren();
var count = 1;
foreach (var log in logs)
diff --git a/Content.Server/CartridgeLoader/CartridgeLoaderSystem.cs b/Content.Server/CartridgeLoader/CartridgeLoaderSystem.cs
index 7caec6150ede0f..22d3e6d7d9ec55 100644
--- a/Content.Server/CartridgeLoader/CartridgeLoaderSystem.cs
+++ b/Content.Server/CartridgeLoader/CartridgeLoaderSystem.cs
@@ -427,6 +427,7 @@ private void OnLoaderUiMessage(EntityUid loaderUid, CartridgeLoaderComponent com
private void OnUiMessage(EntityUid uid, CartridgeLoaderComponent component, CartridgeUiMessage args)
{
var cartridgeEvent = args.MessageEvent;
+ cartridgeEvent.User = args.Actor;
cartridgeEvent.LoaderUid = GetNetEntity(uid);
RelayEvent(component, cartridgeEvent, true);
diff --git a/Content.Server/CartridgeLoader/Cartridges/LogProbeCartridgeComponent.cs b/Content.Server/CartridgeLoader/Cartridges/LogProbeCartridgeComponent.cs
index cfa92dd67f7be5..659433de364940 100644
--- a/Content.Server/CartridgeLoader/Cartridges/LogProbeCartridgeComponent.cs
+++ b/Content.Server/CartridgeLoader/Cartridges/LogProbeCartridgeComponent.cs
@@ -1,12 +1,21 @@
using Content.Shared.CartridgeLoader.Cartridges;
+using Content.Shared.Paper;
using Robust.Shared.Audio;
+using Robust.Shared.Prototypes;
+using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom;
namespace Content.Server.CartridgeLoader.Cartridges;
-[RegisterComponent]
-[Access(typeof(LogProbeCartridgeSystem))]
+[RegisterComponent, Access(typeof(LogProbeCartridgeSystem))]
+[AutoGenerateComponentPause]
public sealed partial class LogProbeCartridgeComponent : Component
{
+ ///
+ /// The name of the scanned entity, sent to clients when they open the UI.
+ ///
+ [DataField]
+ public string EntityName = string.Empty;
+
///
/// The list of pulled access logs
///
@@ -18,4 +27,25 @@ public sealed partial class LogProbeCartridgeComponent : Component
///
[DataField, ViewVariables(VVAccess.ReadWrite)]
public SoundSpecifier SoundScan = new SoundPathSpecifier("/Audio/Machines/scan_finish.ogg");
+
+ ///
+ /// Paper to spawn when printing logs.
+ ///
+ [DataField]
+ public EntProtoId PaperPrototype = "PaperAccessLogs";
+
+ [DataField]
+ public SoundSpecifier PrintSound = new SoundPathSpecifier("/Audio/Machines/diagnoser_printing.ogg");
+
+ ///
+ /// How long you have to wait before printing logs again.
+ ///
+ [DataField]
+ public TimeSpan PrintCooldown = TimeSpan.FromSeconds(5);
+
+ ///
+ /// When anyone is allowed to spawn another printout.
+ ///
+ [DataField(customTypeSerializer: typeof(TimeOffsetSerializer)), AutoPausedField]
+ public TimeSpan NextPrintAllowed = TimeSpan.Zero;
}
diff --git a/Content.Server/CartridgeLoader/Cartridges/LogProbeCartridgeSystem.cs b/Content.Server/CartridgeLoader/Cartridges/LogProbeCartridgeSystem.cs
index f5ccea95900ea7..ac5c0baa541e5b 100644
--- a/Content.Server/CartridgeLoader/Cartridges/LogProbeCartridgeSystem.cs
+++ b/Content.Server/CartridgeLoader/Cartridges/LogProbeCartridgeSystem.cs
@@ -1,25 +1,40 @@
using Content.Shared.Access.Components;
+using Content.Shared.Administration.Logs;
using Content.Shared.Audio;
using Content.Shared.CartridgeLoader;
using Content.Shared.CartridgeLoader.Cartridges;
+using Content.Shared.Database;
+using Content.Shared.Hands.EntitySystems;
+using Content.Shared.Labels.EntitySystems;
+using Content.Shared.Paper;
using Content.Shared.Popups;
using Robust.Shared.Audio.Systems;
using Robust.Shared.Random;
+using Robust.Shared.Timing;
+using System.Text;
namespace Content.Server.CartridgeLoader.Cartridges;
public sealed class LogProbeCartridgeSystem : EntitySystem
{
+ [Dependency] private readonly CartridgeLoaderSystem _cartridge = default!;
+ [Dependency] private readonly IGameTiming _timing = default!;
[Dependency] private readonly IRobustRandom _random = default!;
- [Dependency] private readonly CartridgeLoaderSystem? _cartridgeLoaderSystem = default!;
- [Dependency] private readonly SharedPopupSystem _popupSystem = default!;
- [Dependency] private readonly SharedAudioSystem _audioSystem = default!;
+ [Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
+ [Dependency] private readonly SharedAudioSystem _audio = default!;
+ [Dependency] private readonly SharedHandsSystem _hands = default!;
+ [Dependency] private readonly SharedLabelSystem _label = default!;
+ [Dependency] private readonly SharedPopupSystem _popup = default!;
+ [Dependency] private readonly SharedTransformSystem _transform = default!;
+ [Dependency] private readonly PaperSystem _paper = default!;
public override void Initialize()
{
base.Initialize();
+
SubscribeLocalEvent(OnUiReady);
SubscribeLocalEvent(AfterInteract);
+ SubscribeLocalEvent(OnMessage);
}
///
@@ -37,9 +52,10 @@ private void AfterInteract(Entity ent, ref Cartridge
return;
//Play scanning sound with slightly randomized pitch
- _audioSystem.PlayEntity(ent.Comp.SoundScan, args.InteractEvent.User, target, AudioHelpers.WithVariation(0.25f, _random));
- _popupSystem.PopupCursor(Loc.GetString("log-probe-scan", ("device", target)), args.InteractEvent.User);
+ _audio.PlayEntity(ent.Comp.SoundScan, args.InteractEvent.User, target, AudioHelpers.WithVariation(0.25f, _random));
+ _popup.PopupCursor(Loc.GetString("log-probe-scan", ("device", target)), args.InteractEvent.User);
+ ent.Comp.EntityName = Name(target);
ent.Comp.PulledAccessLogs.Clear();
foreach (var accessRecord in accessReaderComponent.AccessLog)
@@ -52,6 +68,9 @@ private void AfterInteract(Entity ent, ref Cartridge
ent.Comp.PulledAccessLogs.Add(log);
}
+ // Reverse the list so the oldest is at the bottom
+ ent.Comp.PulledAccessLogs.Reverse();
+
UpdateUiState(ent, args.Loader);
}
@@ -63,9 +82,49 @@ private void OnUiReady(Entity ent, ref CartridgeUiRe
UpdateUiState(ent, args.Loader);
}
+ private void OnMessage(Entity ent, ref CartridgeMessageEvent args)
+ {
+ if (args is LogProbePrintMessage cast)
+ PrintLogs(ent, cast.User);
+ }
+
+ private void PrintLogs(Entity ent, EntityUid user)
+ {
+ if (string.IsNullOrEmpty(ent.Comp.EntityName))
+ return;
+
+ if (_timing.CurTime < ent.Comp.NextPrintAllowed)
+ return;
+
+ ent.Comp.NextPrintAllowed = _timing.CurTime + ent.Comp.PrintCooldown;
+
+ var paper = Spawn(ent.Comp.PaperPrototype, _transform.GetMapCoordinates(user));
+ _label.Label(paper, ent.Comp.EntityName); // label it for easy identification
+
+ _audio.PlayEntity(ent.Comp.PrintSound, user, paper);
+ _hands.PickupOrDrop(user, paper, checkActionBlocker: false);
+
+ // generate the actual printout text
+ var builder = new StringBuilder();
+ builder.AppendLine(Loc.GetString("log-probe-printout-device", ("name", ent.Comp.EntityName)));
+ builder.AppendLine(Loc.GetString("log-probe-printout-header"));
+ var number = 1;
+ foreach (var log in ent.Comp.PulledAccessLogs)
+ {
+ var time = TimeSpan.FromSeconds(Math.Truncate(log.Time.TotalSeconds)).ToString();
+ builder.AppendLine(Loc.GetString("log-probe-printout-entry", ("number", number), ("time", time), ("accessor", log.Accessor)));
+ number++;
+ }
+
+ var paperComp = Comp(paper);
+ _paper.SetContent((paper, paperComp), builder.ToString());
+
+ _adminLogger.Add(LogType.EntitySpawn, LogImpact.Low, $"{ToPrettyString(user):user} printed out LogProbe logs ({paper}) of {ent.Comp.EntityName}");
+ }
+
private void UpdateUiState(Entity ent, EntityUid loaderUid)
{
- var state = new LogProbeUiState(ent.Comp.PulledAccessLogs);
- _cartridgeLoaderSystem?.UpdateCartridgeUiState(loaderUid, state);
+ var state = new LogProbeUiState(ent.Comp.EntityName, ent.Comp.PulledAccessLogs);
+ _cartridge.UpdateCartridgeUiState(loaderUid, state);
}
}
diff --git a/Content.Shared/CartridgeLoader/CartridgeUiMessage.cs b/Content.Shared/CartridgeLoader/CartridgeUiMessage.cs
index 1155030f93882d..d86e1c9338c407 100644
--- a/Content.Shared/CartridgeLoader/CartridgeUiMessage.cs
+++ b/Content.Shared/CartridgeLoader/CartridgeUiMessage.cs
@@ -16,5 +16,7 @@ public CartridgeUiMessage(CartridgeMessageEvent messageEvent)
[Serializable, NetSerializable]
public abstract class CartridgeMessageEvent : EntityEventArgs
{
+ [NonSerialized]
+ public EntityUid User;
public NetEntity LoaderUid;
}
diff --git a/Content.Shared/CartridgeLoader/Cartridges/LogProbePrintMessage.cs b/Content.Shared/CartridgeLoader/Cartridges/LogProbePrintMessage.cs
new file mode 100644
index 00000000000000..50097422fb5616
--- /dev/null
+++ b/Content.Shared/CartridgeLoader/Cartridges/LogProbePrintMessage.cs
@@ -0,0 +1,6 @@
+using Robust.Shared.Serialization;
+
+namespace Content.Shared.CartridgeLoader.Cartridges;
+
+[Serializable, NetSerializable]
+public sealed class LogProbePrintMessage : CartridgeMessageEvent;
diff --git a/Content.Shared/CartridgeLoader/Cartridges/LogProbeUiState.cs b/Content.Shared/CartridgeLoader/Cartridges/LogProbeUiState.cs
index 9dc507b7e513e1..fa760582582cc1 100644
--- a/Content.Shared/CartridgeLoader/Cartridges/LogProbeUiState.cs
+++ b/Content.Shared/CartridgeLoader/Cartridges/LogProbeUiState.cs
@@ -5,13 +5,19 @@ namespace Content.Shared.CartridgeLoader.Cartridges;
[Serializable, NetSerializable]
public sealed class LogProbeUiState : BoundUserInterfaceState
{
+ ///
+ /// The name of the scanned entity.
+ ///
+ public string EntityName;
+
///
/// The list of probed network devices
///
public List PulledLogs;
- public LogProbeUiState(List pulledLogs)
+ public LogProbeUiState(string entityName, List pulledLogs)
{
+ EntityName = entityName;
PulledLogs = pulledLogs;
}
}
diff --git a/Resources/Locale/en-US/cartridge-loader/cartridges.ftl b/Resources/Locale/en-US/cartridge-loader/cartridges.ftl
index 2db27f5be09aec..4d8bf55529c707 100644
--- a/Resources/Locale/en-US/cartridge-loader/cartridges.ftl
+++ b/Resources/Locale/en-US/cartridge-loader/cartridges.ftl
@@ -19,6 +19,10 @@ log-probe-scan = Downloaded logs from {$device}!
log-probe-label-time = Time
log-probe-label-accessor = Accessed by
log-probe-label-number = #
+log-probe-print-button = Print Logs
+log-probe-printout-device = Scanned Device: {$name}
+log-probe-printout-header = Latest logs:
+log-probe-printout-entry = #{$number} / {$time} / {$accessor}
# Wanted list cartridge
wanted-list-program-name = Wanted list
diff --git a/Resources/Prototypes/Entities/Objects/Devices/forensic_scanner.yml b/Resources/Prototypes/Entities/Objects/Devices/forensic_scanner.yml
index fbb477de64b8be..46735247c364f4 100644
--- a/Resources/Prototypes/Entities/Objects/Devices/forensic_scanner.yml
+++ b/Resources/Prototypes/Entities/Objects/Devices/forensic_scanner.yml
@@ -57,3 +57,13 @@
- type: GuideHelp
guides:
- Forensics
+
+- type: entity
+ parent: ForensicReportPaper
+ id: PaperAccessLogs
+ name: access logs
+ description: A printout from the detective's trusty LogProbe.
+ components:
+ - type: PaperVisuals
+ headerImagePath: null
+ headerMargin: 0.0, 0.0, 0.0, 0.0