mirror of
https://github.com/wega-team/ss14-wega.git
synced 2026-02-14 19:30:01 +01:00
67 lines
2.3 KiB
C#
67 lines
2.3 KiB
C#
using Content.Shared.StationRecords;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Shared.Player; // Corvax-Wega-Record
|
|
using static Robust.Client.UserInterface.Controls.BaseButton; // Corvax-Wega-Record
|
|
|
|
namespace Content.Client.StationRecords;
|
|
|
|
public sealed class GeneralStationRecordConsoleBoundUserInterface : BoundUserInterface
|
|
{
|
|
[ViewVariables]
|
|
private GeneralStationRecordConsoleWindow? _window = default!;
|
|
|
|
public GeneralStationRecordConsoleBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
|
{
|
|
}
|
|
|
|
[Dependency] private readonly IEntityManager _entityManager = default!; // Corvax-Wega-Record
|
|
[Dependency] private readonly ISharedPlayerManager _playerManager = default!; // Corvax-Wega-Record
|
|
|
|
protected override void Open()
|
|
{
|
|
base.Open();
|
|
|
|
_window = this.CreateWindow<GeneralStationRecordConsoleWindow>();
|
|
_window.OnKeySelected += key =>
|
|
SendMessage(new SelectStationRecord(key));
|
|
_window.OnFiltersChanged += (type, filterValue) =>
|
|
SendMessage(new SetStationRecordFilter(type, filterValue));
|
|
_window.OnDeleted += id => SendMessage(new DeleteStationRecord(id));
|
|
|
|
_window.OnJobAdd += OnJobsAdd; // Corvax-Wega-Record
|
|
_window.OnJobSubtract += OnJobsSubtract; // Corvax-Wega-Record
|
|
}
|
|
|
|
// Corvax-Wega-Record-start
|
|
private void OnJobsAdd(ButtonEventArgs args)
|
|
{
|
|
if (args.Button.Parent?.Parent is not JobRow row || row.Job == null)
|
|
return;
|
|
|
|
var netEntity = _entityManager.GetNetEntity(_playerManager.LocalSession?.AttachedEntity ?? EntityUid.Invalid);
|
|
AdjustStationJobMsg msg = new(netEntity, row.Job, 1);
|
|
SendMessage(msg);
|
|
}
|
|
|
|
private void OnJobsSubtract(ButtonEventArgs args)
|
|
{
|
|
if (args.Button.Parent?.Parent is not JobRow row || row.Job == null)
|
|
return;
|
|
|
|
var netEntity = _entityManager.GetNetEntity(_playerManager.LocalSession?.AttachedEntity ?? EntityUid.Invalid);
|
|
AdjustStationJobMsg msg = new(netEntity, row.Job, -1);
|
|
SendMessage(msg);
|
|
}
|
|
// Corvax-Wega-Record-end
|
|
|
|
protected override void UpdateState(BoundUserInterfaceState state)
|
|
{
|
|
base.UpdateState(state);
|
|
|
|
if (state is not GeneralStationRecordConsoleState cast)
|
|
return;
|
|
|
|
_window?.UpdateState(cast);
|
|
}
|
|
}
|