Fax machines can print from text file (#23262)
* added * checks tweaking * fixed what sloth wanted * fixed? * dialog diposing fix * checks tweaking * more changes * dispose streamreader * Update Content.Client/Fax/UI/FaxBoundUi.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * Update Content.Server/Fax/FaxSystem.cs Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> * fix minor typo --------- Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com>
This commit is contained in:
@@ -51,6 +51,9 @@ public sealed class FaxSystem : EntitySystem
|
||||
/// </summary>
|
||||
[ValidatePrototypeId<EntityPrototype>]
|
||||
private const string DefaultPaperPrototypeId = "Paper";
|
||||
|
||||
[ValidatePrototypeId<EntityPrototype>]
|
||||
private const string OfficePaperPrototypeId = "PaperOffice";
|
||||
|
||||
public override void Initialize()
|
||||
{
|
||||
@@ -72,6 +75,7 @@ public sealed class FaxSystem : EntitySystem
|
||||
|
||||
// UI
|
||||
SubscribeLocalEvent<FaxMachineComponent, AfterActivatableUIOpenEvent>(OnToggleInterface);
|
||||
SubscribeLocalEvent<FaxMachineComponent, FaxFileMessage>(OnFileButtonPressed);
|
||||
SubscribeLocalEvent<FaxMachineComponent, FaxCopyMessage>(OnCopyButtonPressed);
|
||||
SubscribeLocalEvent<FaxMachineComponent, FaxSendMessage>(OnSendButtonPressed);
|
||||
SubscribeLocalEvent<FaxMachineComponent, FaxRefreshMessage>(OnRefreshButtonPressed);
|
||||
@@ -301,6 +305,12 @@ public sealed class FaxSystem : EntitySystem
|
||||
UpdateUserInterface(uid, component);
|
||||
}
|
||||
|
||||
private void OnFileButtonPressed(EntityUid uid, FaxMachineComponent component, FaxFileMessage args)
|
||||
{
|
||||
args.Content = args.Content[..Math.Min(args.Content.Length, FaxFileMessageValidation.MaxContentSize)];
|
||||
PrintFile(uid, component, args);
|
||||
}
|
||||
|
||||
private void OnCopyButtonPressed(EntityUid uid, FaxMachineComponent component, FaxCopyMessage args)
|
||||
{
|
||||
Copy(uid, component);
|
||||
@@ -387,6 +397,27 @@ public sealed class FaxSystem : EntitySystem
|
||||
_deviceNetworkSystem.QueuePacket(uid, null, payload);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Makes fax print from a file from the computer. A timeout is set after copying,
|
||||
/// which is shared by the send button.
|
||||
/// </summary>
|
||||
public void PrintFile(EntityUid uid, FaxMachineComponent component, FaxFileMessage args)
|
||||
{
|
||||
string prototype;
|
||||
if (args.OfficePaper)
|
||||
prototype = OfficePaperPrototypeId;
|
||||
else
|
||||
prototype = DefaultPaperPrototypeId;
|
||||
|
||||
var name = Loc.GetString("fax-machine-printed-paper-name");
|
||||
|
||||
var printout = new FaxPrintout(args.Content, name, prototype);
|
||||
component.PrintingQueue.Enqueue(printout);
|
||||
component.SendTimeoutRemaining += component.SendTimeout;
|
||||
|
||||
UpdateUserInterface(uid, component);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Copies the paper in the fax. A timeout is set after copying,
|
||||
/// which is shared by the send button.
|
||||
|
||||
Reference in New Issue
Block a user