]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add an option to the admin fax menu to lock papers such that they can't be edited...
authordffdff2423 <dffdff2423@gmail.com>
Wed, 10 Jul 2024 05:28:36 +0000 (00:28 -0500)
committerGitHub <noreply@github.com>
Wed, 10 Jul 2024 05:28:36 +0000 (15:28 +1000)
* Add option to adminfax for locking papers.

* Replace dummy control with margin

12 files changed:
Content.Client/Fax/AdminUI/AdminFaxEui.cs
Content.Client/Fax/AdminUI/AdminFaxWindow.xaml
Content.Client/Fax/AdminUI/AdminFaxWindow.xaml.cs
Content.Server/Fax/AdminUI/AdminFaxEui.cs
Content.Server/Fax/FaxConstants.cs
Content.Server/Fax/FaxSystem.cs
Content.Server/Paper/PaperComponent.cs
Content.Server/Paper/PaperSystem.cs
Content.Shared/Fax/AdminFaxEui.cs
Content.Shared/Fax/Components/FaxMachineComponent.cs
Resources/Locale/en-US/fax/fax-admin.ftl
Resources/Locale/en-US/paper/paper-component.ftl

index ace3f3eb7b358e8e45fda0cf8311962c108968b7..452c54eb7972a2acaa2698db9ae59823a1472e1b 100644 (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()
index d469a0e9d3837879664d608f71ba4f8b7685060b..dc4092a3b53460944fcf1e681745008e911d78e1 100644 (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>
index c1fba48309456b868527a9a7f05363c7e4928e3c..698b3114b7da1f5a92652f37a205362db0c6cffb 100644 (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));
     }
 }
index 452fc593d9571642fcb11f441b8d7c3f9ec2b830..fe6b03fab7ba5b2d8a2f3b3f6bd95029231a3a93 100644 (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;
             }
index 24ed7cbcf32f63a0c37921763378eff3988c20b4..4b0ff7853eb04b020fd8364ce6ffdb1d8b09d929 100644 (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";
 }
index 82acb3c60c36ea6bb32abab56788fc8928b6f56e..2b059b4b802f6eb6c8bfb99e91cacff587bf249f 100644 (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);
index 6c379eea2bc565a09d0702b357c1035c952ef1a7..7b04a77d579f25ca8e7e33c0bd6dba9eda429285 100644 (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;
 }
index 4a7828c78c8fe545ff9bde445f150b01ac54fe27..3935df83701e0cc1715904462b24ea4ba3a33c61 100644 (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);
 
index 7b3e1fae8d338e398c21c46dd05d8c85f39a3c30..613a13d0124de9cf794d19cf030267669ff36893 100644 (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;
         }
     }
 }
index 6664ce023ddab1ae231406e2d25376b4f9184f19..1c089865088f0d405ed5fa3e9d24efba6b865cdb 100644 (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;
     }
 }
index eff7e15fe8b63091dda7261b164a1eea1f735ca9..8a8f37809e16fab1c5e0440e05268398e29ec031 100644 (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.
index a62616631f4abd5ba9c31468b429dfbb1dcdf1b1..c2d9d5712bf67e25f42b9e97d935d8e43c3343d5 100644 (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.