Add an option to the admin fax menu to lock papers such that they can't be edited by cybersun pens (#28972)

* Add option to adminfax for locking papers.

* Replace dummy control with margin
This commit is contained in:
dffdff2423
2024-07-10 00:28:36 -05:00
committed by GitHub
parent 8d48096c57
commit e8b3042a38
12 changed files with 40 additions and 11 deletions

View File

@@ -16,7 +16,7 @@ public sealed class AdminFaxEui : BaseEui
_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.stampedBy, args.message, args.stampSprite, args.stampColor, args.locked));
}
public override void Opened()

View File

@@ -23,7 +23,7 @@
</BoxContainer>
<Label Text="{Loc admin-fax-stamp-color}" />
<ColorSelectorSliders Margin="12 0 0 0" Name="StampColorSelector" Color="#BB3232"/>
<Control MinHeight="10" />
<Button Name="SendButton" Text="{Loc admin-fax-send}"></Button>
<CheckBox Name="LockPageCheckbox" Text="{Loc admin-fax-lock-page}" ToolTip="{Loc admin-fax-lock-page-tooltip}"/>
<Button Name="SendButton" Text="{Loc admin-fax-send}" Margin="0 10 0 0" />
</BoxContainer>
</DefaultWindow>

View File

@@ -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)>? OnMessageSend;
public Action<(NetEntity entity, string title, string stampedBy, string message, string stampSprite, Color stampColor, bool locked)>? OnMessageSend;
public Action<NetEntity>? OnFollowFax;
[Dependency] private readonly IResourceCache _resCache = default!;
@@ -98,6 +98,7 @@ public sealed partial class AdminFaxWindow : DefaultWindow
var from = FromEdit.Text;
var stampColor = StampColorSelector.Color;
OnMessageSend?.Invoke((faxEntity.Value, title, from, message, stamp, stampColor));
var locked = LockPageCheckbox.Pressed;
OnMessageSend?.Invoke((faxEntity.Value, title, from, message, stamp, stampColor, locked));
}
}

View File

@@ -1,3 +1,4 @@
using Content.Server.Construction.Conditions;
using Content.Server.DeviceNetwork.Components;
using Content.Server.EUI;
using Content.Shared.Eui;
@@ -56,7 +57,8 @@ public sealed class AdminFaxEui : BaseEui
case AdminFaxEuiMsg.Send sendData:
{
var printout = new FaxPrintout(sendData.Content, sendData.Title, null, null, sendData.StampState,
new() { new StampDisplayInfo { StampedName = sendData.From, StampedColor = sendData.StampColor } });
new() { new StampDisplayInfo { StampedName = sendData.From, StampedColor = sendData.StampColor } },
locked: sendData.Locked);
_faxSystem.Receive(_entityManager.GetEntity(sendData.Target), printout);
break;
}

View File

@@ -29,4 +29,5 @@ public static class FaxConstants
public const string FaxPaperStampStateData = "fax_data_stamp_state";
public const string FaxPaperStampedByData = "fax_data_stamped_by";
public const string FaxSyndicateData = "fax_data_i_am_syndicate";
public const string FaxPaperLockedData = "fax_data_locked";
}

View File

@@ -300,8 +300,9 @@ public sealed class FaxSystem : EntitySystem
args.Data.TryGetValue(FaxConstants.FaxPaperStampStateData, out string? stampState);
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);
var printout = new FaxPrintout(content, name, label, prototypeId, stampState, stampedBy);
var printout = new FaxPrintout(content, name, label, prototypeId, stampState, stampedBy, locked ?? false);
Receive(uid, printout, args.SenderAddress);
break;
@@ -473,7 +474,8 @@ public sealed class FaxSystem : EntitySystem
labelComponent?.CurrentLabel,
metadata.EntityPrototype?.ID ?? DefaultPaperPrototypeId,
paper.StampState,
paper.StampedBy);
paper.StampedBy,
paper.EditingDisabled);
component.PrintingQueue.Enqueue(printout);
component.SendTimeoutRemaining += component.SendTimeout;
@@ -522,6 +524,7 @@ public sealed class FaxSystem : EntitySystem
{ FaxConstants.FaxPaperNameData, nameMod?.BaseName ?? metadata.EntityName },
{ FaxConstants.FaxPaperLabelData, labelComponent?.CurrentLabel },
{ FaxConstants.FaxPaperContentData, paper.Content },
{ FaxConstants.FaxPaperLockedData, paper.EditingDisabled },
};
if (metadata.EntityPrototype != null)
@@ -598,6 +601,8 @@ public sealed class FaxSystem : EntitySystem
_paperSystem.TryStamp(printed, stamp, printout.StampState);
}
}
paper.EditingDisabled = printout.Locked;
}
_metaData.SetEntityName(printed, printout.Name);

View File

@@ -1,5 +1,4 @@
using Content.Shared.Paper;
using Robust.Shared.GameStates;
namespace Content.Server.Paper;
@@ -21,4 +20,7 @@ public sealed partial class PaperComponent : SharedPaperComponent
/// </summary>
[DataField("stampState")]
public string? StampState { get; set; }
[DataField]
public bool EditingDisabled = false;
}

View File

@@ -102,6 +102,14 @@ namespace Content.Server.Paper
var editable = paperComp.StampedBy.Count == 0 || _tagSystem.HasTag(args.Used, "WriteIgnoreStamps");
if (_tagSystem.HasTag(args.Used, "Write") && editable)
{
if (paperComp.EditingDisabled)
{
var paperEditingDisabledMessage = Loc.GetString("paper-tamper-proof-modified-message");
_popupSystem.PopupEntity(paperEditingDisabledMessage, uid, args.User);
args.Handled = true;
return;
}
var writeEvent = new PaperWriteEvent(uid, args.User);
RaiseLocalEvent(args.Used, ref writeEvent);

View File

@@ -56,8 +56,9 @@ public static class AdminFaxEuiMsg
public string Content { get; }
public string StampState { get; }
public Color StampColor { get; }
public bool Locked { get; }
public Send(NetEntity target, string title, string from, string content, string stamp, Color stampColor)
public Send(NetEntity target, string title, string from, string content, string stamp, Color stampColor, bool locked)
{
Target = target;
Title = title;
@@ -65,6 +66,7 @@ public static class AdminFaxEuiMsg
Content = content;
StampState = stamp;
StampColor = stampColor;
Locked = locked;
}
}
}

View File

@@ -150,11 +150,14 @@ public sealed partial class FaxPrintout
[DataField("stampedBy")]
public List<StampDisplayInfo> StampedBy { get; private set; } = new();
[DataField]
public bool Locked { get; private set; }
private FaxPrintout()
{
}
public FaxPrintout(string content, string name, string? label = null, string? prototypeId = null, string? stampState = null, List<StampDisplayInfo>? stampedBy = null)
public FaxPrintout(string content, string name, string? label = null, string? prototypeId = null, string? stampState = null, List<StampDisplayInfo>? stampedBy = null, bool locked = false)
{
Content = content;
Name = name;
@@ -162,5 +165,6 @@ public sealed partial class FaxPrintout
PrototypeId = prototypeId ?? "";
StampState = stampState;
StampedBy = stampedBy ?? new List<StampDisplayInfo>();
Locked = locked;
}
}

View File

@@ -12,3 +12,5 @@ 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.

View File

@@ -12,3 +12,5 @@ paper-component-action-stamp-paper-other = {CAPITALIZE(THE($user))} stamps {THE(
paper-component-action-stamp-paper-self = You stamp {THE($target)} with {THE($stamp)}.
paper-ui-save-button = Save ({$keybind})
paper-tamper-proof-modified-message = This page was written using tamper-proof ink.