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:
@@ -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);
|
||||
|
||||
@@ -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));
|
||||
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -0,0 +1,7 @@
|
||||
using Content.Shared.CriminalRecords.Systems;
|
||||
|
||||
namespace Content.Client.CriminalRecords.Systems;
|
||||
|
||||
public sealed class CriminalRecordsConsoleSystem : SharedCriminalRecordsConsoleSystem
|
||||
{
|
||||
}
|
||||
@@ -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!;
|
||||
|
||||
@@ -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>
|
||||
@@ -0,0 +1,8 @@
|
||||
namespace Content.Shared.CriminalRecords.Systems;
|
||||
|
||||
/// <summary>
|
||||
/// Nothing is predicted just exists for access.
|
||||
/// </summary>
|
||||
public abstract class SharedCriminalRecordsConsoleSystem : EntitySystem
|
||||
{
|
||||
}
|
||||
Reference in New Issue
Block a user