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:
@@ -32,7 +32,7 @@ namespace Content.Server.Cargo.Components
|
||||
/// The paper-type prototype to spawn with the order information.
|
||||
/// </summary>
|
||||
[DataField("printerOutput", customTypeSerializer: typeof(PrototypeIdSerializer<EntityPrototype>))]
|
||||
public string PrinterOutput = "Paper";
|
||||
public string PrinterOutput = "PaperCargoInvoice";
|
||||
|
||||
[DataField("receiverPort", customTypeSerializer: typeof(PrototypeIdSerializer<ReceiverPortPrototype>))]
|
||||
public string ReceiverPort = "OrderReceiver";
|
||||
|
||||
@@ -465,7 +465,7 @@ public sealed partial class CargoSystem
|
||||
return;
|
||||
|
||||
// spawn a piece of paper.
|
||||
var printed = EntityManager.SpawnEntity("Paper", coordinates);
|
||||
var printed = EntityManager.SpawnEntity(component.PrinterOutput, coordinates);
|
||||
|
||||
if (!TryComp<PaperComponent>(printed, out var paper))
|
||||
return;
|
||||
|
||||
@@ -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))
|
||||
{
|
||||
|
||||
@@ -57,6 +57,7 @@ namespace Content.Server.Nuke
|
||||
var printout = new FaxPrintout(
|
||||
paperContent,
|
||||
Loc.GetString("nuke-codes-fax-paper-name"),
|
||||
null,
|
||||
"paper_stamp-cent",
|
||||
new() { Loc.GetString("stamp-component-stamped-name-centcom") });
|
||||
_faxSystem.Receive(fax.Owner, printout, null, fax);
|
||||
@@ -84,9 +85,9 @@ namespace Content.Server.Nuke
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
var owningStation = station ?? _station.GetOwningStation(uid);
|
||||
|
||||
|
||||
// Find the first nuke that matches the passed location.
|
||||
foreach (var nuke in EntityQuery<NukeComponent>())
|
||||
{
|
||||
|
||||
@@ -166,7 +166,7 @@ namespace Content.Server.Paper
|
||||
if (!Resolve(uid, ref paperComp))
|
||||
return;
|
||||
|
||||
_uiSystem.GetUiOrNull(uid, PaperUiKey.Key)?.SetState(new PaperBoundUserInterfaceState(paperComp.Content, paperComp.Mode));
|
||||
_uiSystem.GetUiOrNull(uid, PaperUiKey.Key)?.SetState(new PaperBoundUserInterfaceState(paperComp.Content, paperComp.StampedBy, paperComp.Mode));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user