Improve Paper UI, allow an to entity configure how it's UI looks (#13494)
Co-authored-by: Eoin Mcloughlin <helloworld@eoinrul.es>
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
namespace Content.Server.Fax;
|
||||
namespace Content.Server.Fax;
|
||||
|
||||
public static class FaxConstants
|
||||
{
|
||||
@@ -23,6 +23,7 @@ public static class FaxConstants
|
||||
|
||||
public const string FaxNameData = "fax_data_name";
|
||||
public const string FaxPaperNameData = "fax_data_title";
|
||||
public const string FaxPaperPrototypeData = "fax_data_prototype";
|
||||
public const string FaxPaperContentData = "fax_data_content";
|
||||
public const string FaxPaperStampStateData = "fax_data_stamp_state";
|
||||
public const string FaxPaperStampedByData = "fax_data_stamped_by";
|
||||
|
||||
@@ -1,5 +1,7 @@
|
||||
using Content.Shared.Containers.ItemSlots;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype;
|
||||
|
||||
namespace Content.Server.Fax;
|
||||
|
||||
@@ -33,21 +35,21 @@ public sealed class FaxMachineComponent : Component
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("responsePings")]
|
||||
public bool ResponsePings { get; set; } = true;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Should admins be notified on message receive
|
||||
/// </summary>
|
||||
[ViewVariables(VVAccess.ReadWrite)]
|
||||
[DataField("notifyAdmins")]
|
||||
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("receiveNukeCodes")]
|
||||
public bool ReceiveNukeCodes { get; set; } = false;
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Is fax was emaaged
|
||||
/// </summary>
|
||||
@@ -134,16 +136,20 @@ public sealed class FaxPrintout
|
||||
[DataField("content")]
|
||||
public string Content { get; }
|
||||
|
||||
[DataField("prototypeId", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string PrototypeId { get; }
|
||||
|
||||
[DataField("stampState")]
|
||||
public string? StampState { get; }
|
||||
|
||||
[DataField("stampedBy")]
|
||||
public List<string> StampedBy { get; }
|
||||
|
||||
public FaxPrintout(string content, string name, string? stampState = null, List<string>? stampedBy = null)
|
||||
public FaxPrintout(string content, string name, string? prototypeId, string? stampState = null, List<string>? stampedBy = null)
|
||||
{
|
||||
Content = content;
|
||||
Name = name;
|
||||
PrototypeId = prototypeId ?? "";
|
||||
StampState = stampState;
|
||||
StampedBy = stampedBy ?? new List<string>();
|
||||
}
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Administration;
|
||||
using Content.Server.Administration.Managers;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.DeviceNetwork;
|
||||
@@ -275,8 +275,9 @@ public sealed class FaxSystem : EntitySystem
|
||||
|
||||
args.Data.TryGetValue(FaxConstants.FaxPaperStampStateData, out string? stampState);
|
||||
args.Data.TryGetValue(FaxConstants.FaxPaperStampedByData, out List<string>? stampedBy);
|
||||
args.Data.TryGetValue(FaxConstants.FaxPaperPrototypeData, out string? prototypeId);
|
||||
|
||||
var printout = new FaxPrintout(content, name, stampState, stampedBy);
|
||||
var printout = new FaxPrintout(content, name, prototypeId, stampState, stampedBy);
|
||||
Receive(uid, printout, args.SenderAddress);
|
||||
|
||||
break;
|
||||
@@ -397,12 +398,21 @@ public sealed class FaxSystem : EntitySystem
|
||||
{ FaxConstants.FaxPaperContentData, paper.Content },
|
||||
};
|
||||
|
||||
if (metadata.EntityPrototype != null)
|
||||
{
|
||||
/// todo: Ideally, we could just make a copy of the whole entity when it's
|
||||
/// faxed, in order to preserve visuals, etc.. This functionality isn't
|
||||
/// available yet, so we'll pass along the originating prototypeId and fall
|
||||
/// back to "Paper" in SpawnPaperFromQueue if we can't find one here.
|
||||
payload[FaxConstants.FaxPaperPrototypeData] = metadata.EntityPrototype.ID;
|
||||
}
|
||||
|
||||
if (paper.StampState != null)
|
||||
{
|
||||
payload[FaxConstants.FaxPaperStampStateData] = paper.StampState;
|
||||
payload[FaxConstants.FaxPaperStampedByData] = paper.StampedBy;
|
||||
}
|
||||
|
||||
|
||||
_deviceNetworkSystem.QueuePacket(uid, component.DestinationFaxAddress, payload);
|
||||
|
||||
_adminLogger.Add(LogType.Action, LogImpact.Low, $"{(sender != null ? ToPrettyString(sender.Value) : "Unknown"):user} sent fax from \"{component.FaxName}\" {ToPrettyString(uid)} to {faxName} ({component.DestinationFaxAddress}): {paper.Content}");
|
||||
@@ -442,7 +452,9 @@ public sealed class FaxSystem : EntitySystem
|
||||
return;
|
||||
|
||||
var printout = component.PrintingQueue.Dequeue();
|
||||
var printed = EntityManager.SpawnEntity("Paper", Transform(uid).Coordinates);
|
||||
|
||||
var entityToSpawn = printout.PrototypeId.Length == 0 ? "Paper" : printout.PrototypeId;
|
||||
var printed = EntityManager.SpawnEntity(entityToSpawn, Transform(uid).Coordinates);
|
||||
|
||||
if (TryComp<PaperComponent>(printed, out var paper))
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user