Sent fax now tells where it was sent from (#41108)

* Make fax tell where the fax is from

* make the line shorter

* localization

* fix fax machine not knowing where the fax is from

* fix popup saying PeerSelector

* name is now get from the known fax list

* shorter to fit in more papers

* send the sender not the destination

* add time to info displayed

* nuke [ViewVariables(VVAccess.ReadWrite)]

* update submodule

* use RoundDuration() instead

* ops, this was needed
This commit is contained in:
Samuka
2026-02-01 14:57:18 -03:00
committed by GitHub
parent 9a47e0f61d
commit 728f3eac2a
7 changed files with 66 additions and 16 deletions

View File

@@ -25,13 +25,13 @@ public sealed partial class FaxWindow : DefaultWindow
PaperButtonPressed += OnPaperButtonPressed;
FileButton.OnPressed += _ => FileButtonPressed?.Invoke();
PaperButton.OnPressed += _ => PaperButtonPressed?.Invoke();
FileButton.OnPressed += _ => FileButtonPressed?.Invoke();
PaperButton.OnPressed += _ => PaperButtonPressed?.Invoke();
CopyButton.OnPressed += _ => CopyButtonPressed?.Invoke();
SendButton.OnPressed += _ => SendButtonPressed?.Invoke();
RefreshButton.OnPressed += _ => RefreshButtonPressed?.Invoke();
PeerSelector.OnItemSelected += args =>
PeerSelected?.Invoke((string) args.Button.GetItemMetadata(args.Id)!);
PeerSelected?.Invoke((string)args.Button.GetItemMetadata(args.Id)!);
}
public void UpdateState(FaxUiState state)

View File

@@ -30,4 +30,5 @@ public static class FaxConstants
public const string FaxPaperStampedByData = "fax_data_stamped_by";
public const string FaxSyndicateData = "fax_data_i_am_syndicate";
public const string FaxPaperLockedData = "fax_data_locked";
public const string FaxPaperSenderFaxNameData = "fax_data_sender_fax_name";
}

View File

@@ -15,6 +15,7 @@ using Content.Shared.Emag.Systems;
using Content.Shared.Fax;
using Content.Shared.Fax.Components;
using Content.Shared.Fax.Systems;
using Content.Shared.GameTicking;
using Content.Shared.Interaction;
using Content.Shared.Labels.Components;
using Content.Shared.Labels.EntitySystems;
@@ -30,6 +31,7 @@ using Robust.Shared.Audio.Systems;
using Robust.Shared.Containers;
using Robust.Shared.Player;
using Robust.Shared.Prototypes;
using Robust.Shared.Timing;
namespace Content.Server.Fax;
@@ -39,6 +41,7 @@ public sealed class FaxSystem : EntitySystem
[Dependency] private readonly IAdminManager _adminManager = default!;
[Dependency] private readonly ItemSlotsSystem _itemSlotsSystem = default!;
[Dependency] private readonly SharedAppearanceSystem _appearanceSystem = default!;
[Dependency] private readonly SharedGameTicker _gameTicker = default!;
[Dependency] private readonly PopupSystem _popupSystem = default!;
[Dependency] private readonly DeviceNetworkSystem _deviceNetworkSystem = default!;
[Dependency] private readonly PaperSystem _paperSystem = default!;
@@ -300,8 +303,9 @@ public sealed class FaxSystem : EntitySystem
args.Data.TryGetValue(FaxConstants.FaxPaperStampedByData, out List<StampDisplayInfo>? stampedBy);
args.Data.TryGetValue(FaxConstants.FaxPaperPrototypeData, out string? prototypeId);
args.Data.TryGetValue(FaxConstants.FaxPaperLockedData, out bool? locked);
args.Data.TryGetValue(FaxConstants.FaxPaperSenderFaxNameData, out string? senderFaxName);
var printout = new FaxPrintout(content, name, label, prototypeId, stampState, stampedBy, locked ?? false);
var printout = new FaxPrintout(content, name, label, prototypeId, stampState, stampedBy, locked ?? false, senderFaxName);
Receive(uid, printout, args.SenderAddress);
break;
@@ -392,6 +396,7 @@ public sealed class FaxSystem : EntitySystem
return;
component.DestinationFaxAddress = destAddress;
component.DestinationFaxName = component.KnownFaxes[destAddress];
UpdateUserInterface(uid, component);
}
@@ -521,13 +526,35 @@ public sealed class FaxSystem : EntitySystem
TryComp<LabelComponent>(sendEntity, out var labelComponent);
var content = paper.Content;
if (component.AddSenderInfo)
{
var faxMachineAddress = TryComp<DeviceNetworkComponent>(uid, out var deviceNetworkComponent)
? deviceNetworkComponent.Address
: Loc.GetString("device-address-unknown");
var time = _gameTicker.RoundDuration();
var timeString = TimeSpan.FromSeconds(Math.Truncate(time.TotalSeconds)).ToString();
content += "\n";
content += Loc.GetString(component.SenderInfo,
("sender_name", component.FaxName),
("sender_addr", faxMachineAddress),
("recipient_name", component.DestinationFaxName ?? Loc.GetString("fax-machine-popup-source-unknown")),
("recipient_addr", component.DestinationFaxAddress),
("time", timeString)
);
}
var payload = new NetworkPayload()
{
{ DeviceNetworkConstants.Command, FaxConstants.FaxPrintCommand },
{ FaxConstants.FaxPaperNameData, nameMod?.BaseName ?? metadata.EntityName },
{ FaxConstants.FaxPaperLabelData, labelComponent?.CurrentLabel },
{ FaxConstants.FaxPaperContentData, paper.Content },
{ FaxConstants.FaxPaperContentData, content },
{ FaxConstants.FaxPaperLockedData, paper.EditingDisabled },
{ FaxConstants.FaxPaperSenderFaxNameData, component.FaxName ?? Loc.GetString("fax-machine-popup-source-unknown") }
};
if (metadata.EntityPrototype != null)
@@ -570,9 +597,7 @@ public sealed class FaxSystem : EntitySystem
if (!Resolve(uid, ref component))
return;
var faxName = Loc.GetString("fax-machine-popup-source-unknown");
if (fromAddress != null && component.KnownFaxes.TryGetValue(fromAddress, out var fax)) // If message received from unknown fax address
faxName = fax;
var faxName = printout.SenderFaxName ?? Loc.GetString("fax-machine-popup-source-unknown");
_popupSystem.PopupEntity(Loc.GetString("fax-machine-popup-received", ("from", faxName)), uid);
_appearanceSystem.SetData(uid, FaxMachineVisuals.VisualState, FaxMachineVisualState.Printing);

View File

@@ -13,24 +13,27 @@ public sealed partial class FaxMachineComponent : Component
/// <summary>
/// Name with which the fax will be visible to others on the network
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("name")]
public string FaxName { get; set; } = "Unknown";
/// <summary>
/// Sprite to use when inserting an object.
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField, AutoNetworkedField]
public string InsertingState = "inserting";
/// <summary>
/// Device address of fax in network to which data will be send
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField("destinationAddress")]
public string? DestinationFaxAddress { get; set; }
/// <summary>
/// Name of fax in network to which data will be send
/// </summary>
[DataField("destinationName")]
public string? DestinationFaxName { get; set; }
/// <summary>
/// Contains the item to be sent, assumes it's paper...
/// </summary>
@@ -41,21 +44,18 @@ public sealed partial class FaxMachineComponent : Component
/// Is fax machine should respond to pings in network
/// This will make it visible to others on the network
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField]
public bool ResponsePings { get; set; } = true;
/// <summary>
/// Should admins be notified on message receive
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField]
public bool NotifyAdmins { get; set; } = false;
/// <summary>
/// Should that fax receive nuke codes send by admins. Probably should be captain fax only
/// </summary>
[ViewVariables(VVAccess.ReadWrite)]
[DataField]
public bool ReceiveNukeCodes { get; set; } = false;
@@ -135,6 +135,18 @@ public sealed partial class FaxMachineComponent : Component
/// </summary>
[DataField]
public EntProtoId PrintOfficePaperId = "PaperOffice";
/// <summary>
/// If the fax machine should add a bit of text in the end of the fax that specifies from where and to where the fax is for
/// </summary>
[DataField]
public bool AddSenderInfo = true;
/// <summary>
/// The text that is sent along with the paper's content if <see cref="AddSenderInfo"/> is true
/// </summary>
[DataField]
public LocId SenderInfo = "fax-machine-sender-info";
}
[DataDefinition]
@@ -161,11 +173,14 @@ public sealed partial class FaxPrintout
[DataField]
public bool Locked { get; private set; }
[DataField]
public string? SenderFaxName { get; private set; } = default!;
private FaxPrintout()
{
}
public FaxPrintout(string content, string name, string? label = null, string? prototypeId = null, string? stampState = null, List<StampDisplayInfo>? stampedBy = null, bool locked = false)
public FaxPrintout(string content, string name, string? label = null, string? prototypeId = null, string? stampState = null, List<StampDisplayInfo>? stampedBy = null, bool locked = false, string? senderFaxName = null)
{
Content = content;
Name = name;
@@ -174,5 +189,6 @@ public sealed partial class FaxPrintout
StampState = stampState;
StampedBy = stampedBy ?? new List<StampDisplayInfo>();
Locked = locked;
SenderFaxName = senderFaxName;
}
}

View File

@@ -74,7 +74,6 @@ public sealed class FaxRefreshMessage : BoundUserInterfaceMessage
public sealed class FaxDestinationMessage : BoundUserInterfaceMessage
{
public string Address { get; }
public FaxDestinationMessage(string address)
{
Address = address;

View File

@@ -55,3 +55,5 @@ device-net-id-apc = Apc
device-net-id-atmos-devices = Atmos Devices
device-net-id-reserved = Reserved
# Unknown
device-address-unknown = ????-????

View File

@@ -26,3 +26,10 @@ fax-machine-ui-paper-not-inserted = No paper
fax-machine-chat-notify = Received new fax message from "{$fax}" fax
fax-machine-printed-paper-name = printed paper
fax-machine-sender-info =
─────────────────────────────────────
Fax sent
from: {$sender_name} [address: {$sender_addr}]
to: {$recipient_name} [address: {$recipient_addr}]
at: {$time}