move criminal records console component to shared (#24957)

* move criminal records console component to shared

* todone

---------

Co-authored-by: deltanedas <@deltanedas:kde.org>
This commit is contained in:
deltanedas
2024-02-05 12:55:39 +00:00
committed by GitHub
parent 9deaf67521
commit 9b1c88b78b
7 changed files with 38 additions and 13 deletions

View File

@@ -15,13 +15,16 @@ public sealed partial class CrimeHistoryWindow : FancyWindow
public Action<string>? OnAddHistory; public Action<string>? OnAddHistory;
public Action<uint>? OnDeleteHistory; public Action<uint>? OnDeleteHistory;
private uint _maxLength;
private uint? _index; private uint? _index;
private DialogWindow? _dialog; private DialogWindow? _dialog;
public CrimeHistoryWindow() public CrimeHistoryWindow(uint maxLength)
{ {
RobustXamlLoader.Load(this); RobustXamlLoader.Load(this);
_maxLength = maxLength;
OnClose += () => OnClose += () =>
{ {
_dialog?.Close(); _dialog?.Close();
@@ -47,8 +50,7 @@ public sealed partial class CrimeHistoryWindow : FancyWindow
_dialog.OnConfirmed += responses => _dialog.OnConfirmed += responses =>
{ {
var line = responses[field]; var line = responses[field];
// TODO: whenever the console is moved to shared unhardcode this if (line.Length < 1 || line.Length > _maxLength)
if (line.Length < 1 || line.Length > 256)
return; return;
OnAddHistory?.Invoke(line); OnAddHistory?.Invoke(line);

View File

@@ -1,5 +1,6 @@
using Content.Shared.Access.Systems; using Content.Shared.Access.Systems;
using Content.Shared.CriminalRecords; using Content.Shared.CriminalRecords;
using Content.Shared.CriminalRecords.Components;
using Content.Shared.Security; using Content.Shared.Security;
using Content.Shared.StationRecords; using Content.Shared.StationRecords;
using Robust.Client.Player; using Robust.Client.Player;
@@ -27,7 +28,9 @@ public sealed class CriminalRecordsConsoleBoundUserInterface : BoundUserInterfac
{ {
base.Open(); 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 => _window.OnKeySelected += key =>
SendMessage(new SelectStationRecord(key)); SendMessage(new SelectStationRecord(key));
_window.OnFiltersChanged += (type, filterValue) => _window.OnFiltersChanged += (type, filterValue) =>
@@ -40,7 +43,7 @@ public sealed class CriminalRecordsConsoleBoundUserInterface : BoundUserInterfac
_window.OnHistoryClosed += () => _historyWindow?.Close(); _window.OnHistoryClosed += () => _historyWindow?.Close();
_window.OnClose += Close; _window.OnClose += Close;
_historyWindow = new(); _historyWindow = new(comp.MaxStringLength);
_historyWindow.OnAddHistory += line => SendMessage(new CriminalRecordAddHistory(line)); _historyWindow.OnAddHistory += line => SendMessage(new CriminalRecordAddHistory(line));
_historyWindow.OnDeleteHistory += index => SendMessage(new CriminalRecordDeleteHistory(index)); _historyWindow.OnDeleteHistory += index => SendMessage(new CriminalRecordDeleteHistory(index));

View File

@@ -35,6 +35,7 @@ public sealed partial class CriminalRecordsConsoleWindow : FancyWindow
public Action? OnHistoryClosed; public Action? OnHistoryClosed;
public Action<SecurityStatus, string>? OnDialogConfirmed; public Action<SecurityStatus, string>? OnDialogConfirmed;
private uint _maxLength;
private bool _isPopulating; private bool _isPopulating;
private bool _access; private bool _access;
private uint? _selectedKey; private uint? _selectedKey;
@@ -44,7 +45,7 @@ public sealed partial class CriminalRecordsConsoleWindow : FancyWindow
private StationRecordFilterType _currentFilterType; 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); RobustXamlLoader.Load(this);
@@ -54,6 +55,7 @@ public sealed partial class CriminalRecordsConsoleWindow : FancyWindow
_random = robustRandom; _random = robustRandom;
_accessReader = accessReader; _accessReader = accessReader;
_maxLength = maxLength;
_currentFilterType = StationRecordFilterType.Name; _currentFilterType = StationRecordFilterType.Name;
OpenCentered(); OpenCentered();
@@ -246,8 +248,7 @@ public sealed partial class CriminalRecordsConsoleWindow : FancyWindow
_reasonDialog.OnConfirmed += responses => _reasonDialog.OnConfirmed += responses =>
{ {
var reason = responses[field]; var reason = responses[field];
// TODO: same as history unhardcode if (reason.Length < 1 || reason.Length > _maxLength)
if (reason.Length < 1 || reason.Length > 256)
return; return;
OnDialogConfirmed?.Invoke(SecurityStatus.Wanted, reason); OnDialogConfirmed?.Invoke(SecurityStatus.Wanted, reason);

View File

@@ -0,0 +1,7 @@
using Content.Shared.CriminalRecords.Systems;
namespace Content.Client.CriminalRecords.Systems;
public sealed class CriminalRecordsConsoleSystem : SharedCriminalRecordsConsoleSystem
{
}

View File

@@ -1,4 +1,3 @@
using Content.Server.CriminalRecords.Components;
using Content.Server.Popups; using Content.Server.Popups;
using Content.Server.Radio.EntitySystems; using Content.Server.Radio.EntitySystems;
using Content.Server.Station.Systems; using Content.Server.Station.Systems;
@@ -6,6 +5,8 @@ using Content.Server.StationRecords;
using Content.Server.StationRecords.Systems; using Content.Server.StationRecords.Systems;
using Content.Shared.Access.Systems; using Content.Shared.Access.Systems;
using Content.Shared.CriminalRecords; using Content.Shared.CriminalRecords;
using Content.Shared.CriminalRecords.Components;
using Content.Shared.CriminalRecords.Systems;
using Content.Shared.Security; using Content.Shared.Security;
using Content.Shared.StationRecords; using Content.Shared.StationRecords;
using Robust.Server.GameObjects; using Robust.Server.GameObjects;
@@ -14,7 +15,10 @@ using System.Diagnostics.CodeAnalysis;
namespace Content.Server.CriminalRecords.Systems; 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 AccessReaderSystem _access = default!;
[Dependency] private readonly CriminalRecordsSystem _criminalRecords = default!; [Dependency] private readonly CriminalRecordsSystem _criminalRecords = default!;

View File

@@ -1,15 +1,15 @@
using Content.Server.CriminalRecords.Systems; using Content.Shared.CriminalRecords.Systems;
using Content.Shared.Radio; using Content.Shared.Radio;
using Content.Shared.StationRecords; using Content.Shared.StationRecords;
using Robust.Shared.Prototypes; using Robust.Shared.Prototypes;
namespace Content.Server.CriminalRecords.Components; namespace Content.Shared.CriminalRecords.Components;
/// <summary> /// <summary>
/// A component for Criminal Record Console storing an active station record key and a currently applied filter /// A component for Criminal Record Console storing an active station record key and a currently applied filter
/// </summary> /// </summary>
[RegisterComponent] [RegisterComponent]
[Access(typeof(CriminalRecordsConsoleSystem))] [Access(typeof(SharedCriminalRecordsConsoleSystem))]
public sealed partial class CriminalRecordsConsoleComponent : Component public sealed partial class CriminalRecordsConsoleComponent : Component
{ {
/// <summary> /// <summary>

View File

@@ -0,0 +1,8 @@
namespace Content.Shared.CriminalRecords.Systems;
/// <summary>
/// Nothing is predicted just exists for access.
/// </summary>
public abstract class SharedCriminalRecordsConsoleSystem : EntitySystem
{
}