Skip to content

Commit

Permalink
fax stamp protection
Browse files Browse the repository at this point in the history
  • Loading branch information
whatston3 committed Jan 19, 2025
1 parent 30ac7d8 commit 41735eb
Show file tree
Hide file tree
Showing 12 changed files with 50 additions and 13 deletions.
2 changes: 1 addition & 1 deletion Content.Client/Fax/AdminUI/AdminFaxEui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ public AdminFaxEui()
_window.OnClose += () => SendMessage(new AdminFaxEuiMsg.Close());
_window.OnFollowFax += entity => SendMessage(new AdminFaxEuiMsg.Follow(entity));
_window.OnMessageSend += args => SendMessage(new AdminFaxEuiMsg.Send(args.entity, args.title,
args.stampedBy, args.message, args.stampSprite, args.stampColor, args.locked));
args.stampedBy, args.message, args.stampSprite, args.stampColor, args.locked, args.stampProtected)); // Frontier
}

public override void Opened()
Expand Down
3 changes: 3 additions & 0 deletions Content.Client/Fax/AdminUI/AdminFaxWindow.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,9 @@
<Label Text="{Loc admin-fax-stamp-color}" />
<ColorSelectorSliders Margin="12 0 0 0" Name="StampColorSelector" Color="#BB3232"/>
<CheckBox Name="LockPageCheckbox" Text="{Loc admin-fax-lock-page}" ToolTip="{Loc admin-fax-lock-page-tooltip}"/>
<!-- Frontier: stamp protection -->
<CheckBox Name="StampProtectPageCheckbox" Text="{Loc admin-fax-stamp-protect-page}" ToolTip="{Loc admin-fax-stamp-protect-page-tooltip}"/>
<!-- End Frontier: stamp protection -->
<Button Name="SendButton" Text="{Loc admin-fax-send}" Margin="0 10 0 0" />
</BoxContainer>
</DefaultWindow>
5 changes: 3 additions & 2 deletions Content.Client/Fax/AdminUI/AdminFaxWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ public sealed partial class AdminFaxWindow : DefaultWindow
{
private const string StampsRsiPath = "/Textures/Objects/Misc/bureaucracy.rsi";

public Action<(NetEntity entity, string title, string stampedBy, string message, string stampSprite, Color stampColor, bool locked)>? OnMessageSend;
public Action<(NetEntity entity, string title, string stampedBy, string message, string stampSprite, Color stampColor, bool locked, bool stampProtected)>? OnMessageSend; // Frontier: add stampProtected
public Action<NetEntity>? OnFollowFax;

[Dependency] private readonly IResourceCache _resCache = default!;
Expand Down Expand Up @@ -99,6 +99,7 @@ private void SendMessage(BaseButton.ButtonEventArgs obj)
var from = FromEdit.Text;
var stampColor = StampColorSelector.Color;
var locked = LockPageCheckbox.Pressed;
OnMessageSend?.Invoke((faxEntity.Value, title, from, message, stamp, stampColor, locked));
var stampProtected = StampProtectPageCheckbox.Pressed; // Frontier
OnMessageSend?.Invoke((faxEntity.Value, title, from, message, stamp, stampColor, locked, stampProtected)); // Frontier: add stampProtected
}
}
2 changes: 1 addition & 1 deletion Content.Server/Fax/AdminUI/AdminFaxEui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public override void HandleMessage(EuiMessageBase msg)
{
var printout = new FaxPrintout(sendData.Content, sendData.Title, null, null, sendData.StampState,
new() { new StampDisplayInfo { StampedName = sendData.From, StampedColor = sendData.StampColor } },
locked: sendData.Locked);
locked: sendData.Locked, stampProtected: sendData.StampProtected); // Frontier: add StampProtected
_faxSystem.Receive(_entityManager.GetEntity(sendData.Target), printout);
break;
}
Expand Down
1 change: 1 addition & 0 deletions Content.Server/Fax/FaxConstants.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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 FaxPaperStampProtectedData = "fax_data_stamp_protected"; // Frontier: stamp protection
}
16 changes: 14 additions & 2 deletions Content.Server/Fax/FaxSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,7 @@
using Robust.Shared.Prototypes;
using Content.Shared.NameModifier.Components;
using Content.Shared.Power;
using Content.Shared.Tag; // Frontier

namespace Content.Server.Fax;

Expand All @@ -52,6 +53,7 @@ public sealed class FaxSystem : EntitySystem
[Dependency] private readonly ISharedAdminLogManager _adminLogger = default!;
[Dependency] private readonly MetaDataSystem _metaData = default!;
[Dependency] private readonly FaxecuteSystem _faxecute = default!;
[Dependency] private readonly TagSystem _tag = default!; // Frontier

private const string PaperSlotId = "Paper";

Expand Down Expand Up @@ -298,8 +300,9 @@ private void OnPacketReceived(EntityUid uid, FaxMachineComponent component, Devi
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.FaxPaperStampProtectedData, out bool? stampProtected); // Frontier

var printout = new FaxPrintout(content, name, label, prototypeId, stampState, stampedBy, locked ?? false);
var printout = new FaxPrintout(content, name, label, prototypeId, stampState, stampedBy, locked ?? false, stampProtected ?? false); // Frontier: add stampProtected
Receive(uid, printout, args.SenderAddress);

break;
Expand Down Expand Up @@ -469,7 +472,8 @@ public void Copy(EntityUid uid, FaxMachineComponent? component, FaxCopyMessage a
metadata.EntityPrototype?.ID ?? component.PrintPaperId,
paper.StampState,
paper.StampedBy,
paper.EditingDisabled);
paper.EditingDisabled,
_tag.HasTag(sendEntity.Value, "NFPaperStampProtected")); // Frontier: add stamp protection

component.PrintingQueue.Enqueue(printout);
component.SendTimeoutRemaining += component.SendTimeout;
Expand Down Expand Up @@ -527,6 +531,7 @@ public void Send(EntityUid uid, FaxMachineComponent? component, FaxSendMessage a
{ FaxConstants.FaxPaperLabelData, labelComponent?.CurrentLabel },
{ FaxConstants.FaxPaperContentData, paper.Content },
{ FaxConstants.FaxPaperLockedData, paper.EditingDisabled },
{ FaxConstants.FaxPaperStampProtectedData, _tag.HasTag(sendEntity.Value, "NFPaperStampProtected") }, // Frontier
};

if (metadata.EntityPrototype != null)
Expand Down Expand Up @@ -613,6 +618,13 @@ private void SpawnPaperFromQueue(EntityUid uid, FaxMachineComponent? component =
}

paper.EditingDisabled = printout.Locked;

// Frontier: stamp protection
if (printout.StampProtected)
{
_tag.AddTag(printed, "NFPaperStampProtected");
}
// End Frontier
}

_metaData.SetEntityName(printed, printout.Name);
Expand Down
3 changes: 2 additions & 1 deletion Content.Server/Nuke/NukeCodePaperSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,8 @@ public bool SendNukeCodes(EntityUid station)
new List<StampDisplayInfo>
{
new StampDisplayInfo { StampedName = Loc.GetString("stamp-component-stamped-name-centcom"), StampedColor = Color.FromHex("#BB3232") },
}
},
stampProtected: true // Frontier: centcom signed, should be protected
);
_faxSystem.Receive(faxEnt, printout, null, fax);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@ public sealed partial class RandomFaxRuleComponent : Component
[DataField]
public bool Locked { get; private set; }

[DataField]
public bool StampProtected { get; private set; }

/// <summary>
/// The localized string
/// </summary>
Expand Down Expand Up @@ -101,4 +104,5 @@ public sealed partial class EditableFaxPrintout
public string? StampState;
public List<StampDisplayInfo> StampedBy = new();
public bool Locked;
public bool StampProtected;
}
6 changes: 4 additions & 2 deletions Content.Server/_NF/StationEvents/Events/RandomFaxRule.cs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,8 @@ protected override void Started(EntityUid uid, RandomFaxRuleComponent component,
PrototypeId = component.PrototypeId,
StampState = component.StampState,
StampedBy = component.StampedBy ?? new(),
Locked = component.Locked
Locked = component.Locked,
StampProtected = component.StampProtected, // Frontier
};
string? localAddress = component.FromAddress;
if (component.PreFaxActions != null)
Expand Down Expand Up @@ -113,7 +114,8 @@ protected override void Started(EntityUid uid, RandomFaxRuleComponent component,
prototypeId: recipientPrintout.PrototypeId,
stampState: recipientPrintout.StampState,
stampedBy: recipientPrintout.StampedBy,
locked: recipientPrintout.Locked
locked: recipientPrintout.Locked,
stampProtected: recipientPrintout.StampProtected
);
_faxSystem.Receive(faxUid, printout, recipientAddress, faxComp);
break;
Expand Down
4 changes: 3 additions & 1 deletion Content.Shared/Fax/AdminFaxEui.cs
Original file line number Diff line number Diff line change
Expand Up @@ -57,8 +57,9 @@ public sealed class Send : EuiMessageBase
public string StampState { get; }
public Color StampColor { get; }
public bool Locked { get; }
public bool StampProtected { get; } // Frontier

public Send(NetEntity target, string title, string from, string content, string stamp, Color stampColor, bool locked)
public Send(NetEntity target, string title, string from, string content, string stamp, Color stampColor, bool locked, bool stampProtected) // Frontier: stampProtected
{
Target = target;
Title = title;
Expand All @@ -67,6 +68,7 @@ public Send(NetEntity target, string title, string from, string content, string
StampState = stamp;
StampColor = stampColor;
Locked = locked;
StampProtected = stampProtected; // Frontier
}
}
}
6 changes: 5 additions & 1 deletion Content.Shared/Fax/Components/FaxMachineComponent.cs
Original file line number Diff line number Diff line change
Expand Up @@ -202,11 +202,14 @@ public sealed partial class FaxPrintout
[DataField]
public bool Locked { get; private set; }

[DataField] // Frontier
public bool StampProtected { get; private set; } // Frontier

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, bool stampProtected = false) // Frontier: add stampProtected
{
Content = content;
Name = name;
Expand All @@ -215,5 +218,6 @@ public FaxPrintout(string content, string name, string? label = null, string? pr
StampState = stampState;
StampedBy = stampedBy ?? new List<StampDisplayInfo>();
Locked = locked;
StampProtected = stampProtected; // Frontier
}
}
11 changes: 9 additions & 2 deletions Resources/Locale/en-US/fax/fax-admin.ftl
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,12 @@ admin-fax-message-placeholder = Your message here...
admin-fax-stamp = Stamp icon:
admin-fax-stamp-color = Stamp color:
admin-fax-send = Send
admin-fax-lock-page = Lock Page
admin-fax-lock-page-tooltip = Lock the paper such that it cannot be edited even by things such as cybersun pens.
# Frontier: edit lock page
admin-fax-lock-page = Lock Page (uneditable)
admin-fax-lock-page-tooltip = Lock the paper such that it cannot be edited at all.
# End Frontier

# Frontier: stamp protection
admin-fax-stamp-protect-page = Block Cybersun Pen
admin-fax-stamp-protect-page-tooltip = Prevent the paper from being edited by Cybersun pens.
# End Frontier: stamp protection

0 comments on commit 41735eb

Please sign in to comment.