Files
tbd-station-14/Content.Client/CriminalRecords/CriminalRecordsConsoleBoundUserInterface.cs
James Simonson b9424386c7 Criminal Records Computer Better UX + Filtering (#32352)
* First pass at new Criminal Records Computer

need buttons to highlight.

* Filter status tabs/buttons now activate correctly via UpdateState

* Removed unneeded Directives

* Fix typo + undo VSCode changes

* Implement Emo Feedback

Loc NA and use inject deps
Cannot use inject deps on sprite system.

* try to undo vscode launch.json change

* Added requests + Filter dropdown list + jobs

Fixed maintainer fix requests,
Added Job to announcement channel output
Removed toggle buttons in-place of a dropdown list

* Fixed missed merge conflict

+ fixed an bug with filterstatus not showing on re-open ui

* Update criminal-records.ftl

Fixed lint error. whoops.

* Update Content.Server/CriminalRecords/Systems/CriminalRecordsConsoleSystem.cs

typo

Co-authored-by: chromiumboy <50505512+chromiumboy@users.noreply.github.com>

* impliment chromiumboy feedback

hopefully this will do it....

---------

Co-authored-by: chromiumboy <50505512+chromiumboy@users.noreply.github.com>
2025-01-29 13:34:49 +03:00

84 lines
2.9 KiB
C#

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;
using Robust.Shared.Prototypes;
using Robust.Shared.Random;
namespace Content.Client.CriminalRecords;
public sealed class CriminalRecordsConsoleBoundUserInterface : BoundUserInterface
{
[Dependency] private readonly IPrototypeManager _proto = default!;
[Dependency] private readonly IRobustRandom _random = default!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
private readonly AccessReaderSystem _accessReader;
private CriminalRecordsConsoleWindow? _window;
private CrimeHistoryWindow? _historyWindow;
public CriminalRecordsConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
{
_accessReader = EntMan.System<AccessReaderSystem>();
}
protected override void Open()
{
base.Open();
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) =>
SendMessage(new SetStationRecordFilter(type, filterValue));
_window.OnStatusSelected += status =>
SendMessage(new CriminalRecordChangeStatus(status, null));
_window.OnDialogConfirmed += (status, reason) =>
SendMessage(new CriminalRecordChangeStatus(status, reason));
_window.OnStatusFilterPressed += (statusFilter) =>
SendMessage(new CriminalRecordSetStatusFilter(statusFilter));
_window.OnHistoryUpdated += UpdateHistory;
_window.OnHistoryClosed += () => _historyWindow?.Close();
_window.OnClose += Close;
_historyWindow = new(comp.MaxStringLength);
_historyWindow.OnAddHistory += line => SendMessage(new CriminalRecordAddHistory(line));
_historyWindow.OnDeleteHistory += index => SendMessage(new CriminalRecordDeleteHistory(index));
_historyWindow.Close(); // leave closed until user opens it
}
/// <summary>
/// Updates or opens a new history window.
/// </summary>
private void UpdateHistory(CriminalRecord record, bool access, bool open)
{
_historyWindow!.UpdateHistory(record, access);
if (open)
_historyWindow.OpenCentered();
}
protected override void UpdateState(BoundUserInterfaceState state)
{
base.UpdateState(state);
if (state is not CriminalRecordsConsoleState cast)
return;
_window?.UpdateState(cast);
}
protected override void Dispose(bool disposing)
{
base.Dispose(disposing);
_window?.Close();
_historyWindow?.Close();
}
}