]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
move criminal records console component to shared (#24957)
authordeltanedas <39013340+deltanedas@users.noreply.github.com>
Mon, 5 Feb 2024 12:55:39 +0000 (12:55 +0000)
committerGitHub <noreply@github.com>
Mon, 5 Feb 2024 12:55:39 +0000 (23:55 +1100)
* move criminal records console component to shared

* todone

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
Content.Client/CriminalRecords/CrimeHistoryWindow.xaml.cs
Content.Client/CriminalRecords/CriminalRecordsConsoleBoundUserInterface.cs
Content.Client/CriminalRecords/CriminalRecordsConsoleWindow.xaml.cs
Content.Client/CriminalRecords/Systems/CriminalRecordsConsoleSystem.cs [new file with mode: 0644]
Content.Server/CriminalRecords/Systems/CriminalRecordsConsoleSystem.cs
Content.Shared/CriminalRecords/Components/CriminalRecordsConsoleComponent.cs [moved from Content.Server/CriminalRecords/Components/CriminalRecordsConsoleComponent.cs with 90% similarity]
Content.Shared/CriminalRecords/Systems/SharedCriminalRecordsConsoleSystem.cs [new file with mode: 0644]

index bccf501d9c5539475e2ffd3c033f5bb5f0cc0ae3..1c6e83a359f3a2db2632f13ec6d978a148453b2c 100644 (file)
@@ -15,13 +15,16 @@ public sealed partial class CrimeHistoryWindow : FancyWindow
     public Action<string>? OnAddHistory;
     public Action<uint>? OnDeleteHistory;
 
+    private uint _maxLength;
     private uint? _index;
     private DialogWindow? _dialog;
 
-    public CrimeHistoryWindow()
+    public CrimeHistoryWindow(uint maxLength)
     {
         RobustXamlLoader.Load(this);
 
+        _maxLength = maxLength;
+
         OnClose += () =>
         {
             _dialog?.Close();
@@ -47,8 +50,7 @@ public sealed partial class CrimeHistoryWindow : FancyWindow
             _dialog.OnConfirmed += responses =>
             {
                 var line = responses[field];
-                // TODO: whenever the console is moved to shared unhardcode this
-                if (line.Length < 1 || line.Length > 256)
+                if (line.Length < 1 || line.Length > _maxLength)
                     return;
 
                 OnAddHistory?.Invoke(line);
index f6c9080a2dbc1f3f13d618afe85f7cd418a16178..88b9c90c2ff13bab0fd7984742010ab195257c26 100644 (file)
@@ -1,5 +1,6 @@
 using Content.Shared.Access.Systems;
 using Content.Shared.CriminalRecords;
+using Content.Shared.CriminalRecords.Components;
 using Content.Shared.Security;
 using Content.Shared.StationRecords;
 using Robust.Client.Player;
@@ -27,7 +28,9 @@ public sealed class CriminalRecordsConsoleBoundUserInterface : BoundUserInterfac
     {
         base.Open();
 
-        _window = new(Owner, _playerManager, _proto, _random, _accessReader);
+        var comp = EntMan.GetComponent<CriminalRecordsConsoleComponent>(Owner);
+
+        _window = new(Owner, comp.MaxStringLength, _playerManager, _proto, _random, _accessReader);
         _window.OnKeySelected += key =>
             SendMessage(new SelectStationRecord(key));
         _window.OnFiltersChanged += (type, filterValue) =>
@@ -40,7 +43,7 @@ public sealed class CriminalRecordsConsoleBoundUserInterface : BoundUserInterfac
         _window.OnHistoryClosed += () => _historyWindow?.Close();
         _window.OnClose += Close;
 
-        _historyWindow = new();
+        _historyWindow = new(comp.MaxStringLength);
         _historyWindow.OnAddHistory += line => SendMessage(new CriminalRecordAddHistory(line));
         _historyWindow.OnDeleteHistory += index => SendMessage(new CriminalRecordDeleteHistory(index));
 
index f5c631ea0bca5353224bedb62b926311e7a69b0c..61b5c3833158cc48b1cba8abb35ceb9dc374adfc 100644 (file)
@@ -35,6 +35,7 @@ public sealed partial class CriminalRecordsConsoleWindow : FancyWindow
     public Action? OnHistoryClosed;
     public Action<SecurityStatus, string>? OnDialogConfirmed;
 
+    private uint _maxLength;
     private bool _isPopulating;
     private bool _access;
     private uint? _selectedKey;
@@ -44,7 +45,7 @@ public sealed partial class CriminalRecordsConsoleWindow : FancyWindow
 
     private StationRecordFilterType _currentFilterType;
 
-    public CriminalRecordsConsoleWindow(EntityUid console, IPlayerManager playerManager, IPrototypeManager prototypeManager, IRobustRandom robustRandom, AccessReaderSystem accessReader)
+    public CriminalRecordsConsoleWindow(EntityUid console, uint maxLength, IPlayerManager playerManager, IPrototypeManager prototypeManager, IRobustRandom robustRandom, AccessReaderSystem accessReader)
     {
         RobustXamlLoader.Load(this);
 
@@ -54,6 +55,7 @@ public sealed partial class CriminalRecordsConsoleWindow : FancyWindow
         _random = robustRandom;
         _accessReader = accessReader;
 
+        _maxLength = maxLength;
         _currentFilterType = StationRecordFilterType.Name;
 
         OpenCentered();
@@ -246,8 +248,7 @@ public sealed partial class CriminalRecordsConsoleWindow : FancyWindow
         _reasonDialog.OnConfirmed += responses =>
         {
             var reason = responses[field];
-            // TODO: same as history unhardcode
-            if (reason.Length < 1 || reason.Length > 256)
+            if (reason.Length < 1 || reason.Length > _maxLength)
                 return;
 
             OnDialogConfirmed?.Invoke(SecurityStatus.Wanted, reason);
diff --git a/Content.Client/CriminalRecords/Systems/CriminalRecordsConsoleSystem.cs b/Content.Client/CriminalRecords/Systems/CriminalRecordsConsoleSystem.cs
new file mode 100644 (file)
index 0000000..2a34376
--- /dev/null
@@ -0,0 +1,7 @@
+using Content.Shared.CriminalRecords.Systems;
+
+namespace Content.Client.CriminalRecords.Systems;
+
+public sealed class CriminalRecordsConsoleSystem : SharedCriminalRecordsConsoleSystem
+{
+}
index f0a4f96152aa6d3187c387bae7359e7da97f3cf7..84f8ffc2e50669bcd0516d58c72487b3bb3b6769 100644 (file)
@@ -1,4 +1,3 @@
-using Content.Server.CriminalRecords.Components;
 using Content.Server.Popups;
 using Content.Server.Radio.EntitySystems;
 using Content.Server.Station.Systems;
@@ -6,6 +5,8 @@ using Content.Server.StationRecords;
 using Content.Server.StationRecords.Systems;
 using Content.Shared.Access.Systems;
 using Content.Shared.CriminalRecords;
+using Content.Shared.CriminalRecords.Components;
+using Content.Shared.CriminalRecords.Systems;
 using Content.Shared.Security;
 using Content.Shared.StationRecords;
 using Robust.Server.GameObjects;
@@ -14,7 +15,10 @@ using System.Diagnostics.CodeAnalysis;
 
 namespace Content.Server.CriminalRecords.Systems;
 
-public sealed class CriminalRecordsConsoleSystem : EntitySystem
+/// <summary>
+/// Handles all UI for criminal records console
+/// </summary>
+public sealed class CriminalRecordsConsoleSystem : SharedCriminalRecordsConsoleSystem
 {
     [Dependency] private readonly AccessReaderSystem _access = default!;
     [Dependency] private readonly CriminalRecordsSystem _criminalRecords = default!;
similarity index 90%
rename from Content.Server/CriminalRecords/Components/CriminalRecordsConsoleComponent.cs
rename to Content.Shared/CriminalRecords/Components/CriminalRecordsConsoleComponent.cs
index de9ada8f8c79f031e73c76f1de8c830d60ebfd9a..70e927e3cb8492b0c72d55126dc283a4a025b249 100644 (file)
@@ -1,15 +1,15 @@
-using Content.Server.CriminalRecords.Systems;
+using Content.Shared.CriminalRecords.Systems;
 using Content.Shared.Radio;
 using Content.Shared.StationRecords;
 using Robust.Shared.Prototypes;
 
-namespace Content.Server.CriminalRecords.Components;
+namespace Content.Shared.CriminalRecords.Components;
 
 /// <summary>
 /// A component for Criminal Record Console storing an active station record key and a currently applied filter
 /// </summary>
 [RegisterComponent]
-[Access(typeof(CriminalRecordsConsoleSystem))]
+[Access(typeof(SharedCriminalRecordsConsoleSystem))]
 public sealed partial class CriminalRecordsConsoleComponent : Component
 {
     /// <summary>
diff --git a/Content.Shared/CriminalRecords/Systems/SharedCriminalRecordsConsoleSystem.cs b/Content.Shared/CriminalRecords/Systems/SharedCriminalRecordsConsoleSystem.cs
new file mode 100644 (file)
index 0000000..f9fc67c
--- /dev/null
@@ -0,0 +1,8 @@
+namespace Content.Shared.CriminalRecords.Systems;
+
+/// <summary>
+/// Nothing is predicted just exists for access.
+/// </summary>
+public abstract class SharedCriminalRecordsConsoleSystem : EntitySystem
+{
+}