[Feat] Обновление для визора СБ (#274)
* add: security hud update * access & fix names * translates * fix
121
Content.Client/_White/SecurityHud/SecurityHudBUI.cs
Normal file
@@ -0,0 +1,121 @@
|
||||
using System.Linq;
|
||||
using Content.Client._White.UserInterface.Radial;
|
||||
using Content.Shared._White.SecurityHud;
|
||||
using Content.Shared.Security;
|
||||
using Content.Shared.StatusIcon;
|
||||
using Robust.Shared.Prototypes;
|
||||
|
||||
namespace Content.Client._White.SecurityHud;
|
||||
|
||||
public sealed class SecurityHudBUI : BoundUserInterface
|
||||
{
|
||||
[Dependency] private readonly IPrototypeManager _prototypeManager = default!;
|
||||
private RadialContainer? _radialContainer;
|
||||
|
||||
private bool _updated;
|
||||
|
||||
private readonly Dictionary<string, string> _names = new()
|
||||
{
|
||||
{ "SecurityIconDischarged", Loc.GetString("criminal-records-status-released")},
|
||||
{ "SecurityIconSuspected", Loc.GetString("criminal-records-status-suspected")},
|
||||
{ "SecurityIconWanted", Loc.GetString("criminal-records-status-wanted")},
|
||||
{ "SecurityIconIncarcerated", Loc.GetString("criminal-records-status-detained")},
|
||||
{ "CriminalRecordIconRemove", Loc.GetString("security-hud-remove-status") }
|
||||
};
|
||||
|
||||
private readonly Dictionary<string, string> _icons = new()
|
||||
{
|
||||
{ "SecurityIconDischarged", "/Textures/White/Interface/securityhud.rsi/released.png" },
|
||||
{ "SecurityIconSuspected", "/Textures/White/Interface/securityhud.rsi/suspected.png" },
|
||||
{ "SecurityIconWanted", "/Textures/White/Interface/securityhud.rsi/wanted.png" },
|
||||
{ "SecurityIconIncarcerated", "/Textures/White/Interface/securityhud.rsi/incarcerated.png" },
|
||||
{ "CriminalRecordIconRemove", "/Textures/White/Interface/securityhud.rsi/remove.png" }
|
||||
};
|
||||
|
||||
private readonly Dictionary<string, SecurityStatus> _status = new()
|
||||
{
|
||||
{ "SecurityIconDischarged", SecurityStatus.Discharged },
|
||||
{ "SecurityIconSuspected", SecurityStatus.Suspected },
|
||||
{ "SecurityIconWanted", SecurityStatus.Wanted },
|
||||
{ "SecurityIconIncarcerated", SecurityStatus.Detained },
|
||||
{ "CriminalRecordIconRemove", SecurityStatus.None }
|
||||
};
|
||||
|
||||
|
||||
public SecurityHudBUI(EntityUid owner, Enum uiKey) : base(owner, uiKey)
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
}
|
||||
|
||||
protected override void Open()
|
||||
{
|
||||
base.Open();
|
||||
|
||||
if (_radialContainer != null)
|
||||
UIReset();
|
||||
|
||||
_radialContainer = new RadialContainer();
|
||||
|
||||
_radialContainer.Closed += Close;
|
||||
|
||||
if (State != null)
|
||||
UpdateState(State);
|
||||
}
|
||||
|
||||
private void UIReset()
|
||||
{
|
||||
_radialContainer?.Close();
|
||||
_radialContainer = null;
|
||||
_updated = false;
|
||||
}
|
||||
|
||||
private void PopulateRadial(IReadOnlyCollection<string> ids, NetEntity user, NetEntity target)
|
||||
{
|
||||
foreach (var id in ids)
|
||||
{
|
||||
if (_radialContainer == null)
|
||||
continue;
|
||||
|
||||
if(!_names.TryGetValue(id, out var name) || !_icons.TryGetValue(id, out var icon) || !_status.TryGetValue(id, out var status))
|
||||
return;
|
||||
|
||||
var button = _radialContainer.AddButton(name, icon);
|
||||
button.Controller.OnPressed += _ =>
|
||||
{
|
||||
Select(status, user, target);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
private void Select(SecurityStatus status, NetEntity user, NetEntity target)
|
||||
{
|
||||
SendMessage(new SecurityHudStatusSelectedMessage(status, user, target));
|
||||
UIReset();
|
||||
Close();
|
||||
}
|
||||
|
||||
protected override void Dispose(bool disposing)
|
||||
{
|
||||
base.Dispose(disposing);
|
||||
UIReset();
|
||||
}
|
||||
|
||||
protected override void UpdateState(BoundUserInterfaceState state)
|
||||
{
|
||||
base.UpdateState(state);
|
||||
|
||||
if (_updated)
|
||||
return;
|
||||
|
||||
if (state is SecurityHudBUIState newState)
|
||||
{
|
||||
PopulateRadial(newState.Ids, newState.User, newState.Target);
|
||||
}
|
||||
|
||||
if (_radialContainer == null)
|
||||
return;
|
||||
|
||||
_radialContainer?.OpenAttachedLocalPlayer();
|
||||
_updated = true;
|
||||
}
|
||||
}
|
||||
20
Content.Server/_White/SecurityHud/SecurityHudComponent.cs
Normal file
@@ -0,0 +1,20 @@
|
||||
using Content.Shared.Radio;
|
||||
using Content.Shared.StatusIcon;
|
||||
using Robust.Shared.Prototypes;
|
||||
using Robust.Shared.Serialization.TypeSerializers.Implementations.Custom.Prototype.List;
|
||||
|
||||
namespace Content.Server._White.SecurityHud;
|
||||
|
||||
[RegisterComponent]
|
||||
public sealed partial class SecurityHudComponent : Component
|
||||
{
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
[DataField("criminalrecords", customTypeSerializer: typeof(PrototypeIdListSerializer<StatusIconPrototype>))]
|
||||
public IReadOnlyCollection<string> Status = ArraySegment<string>.Empty;
|
||||
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
public ProtoId<RadioChannelPrototype> SecurityChannel = "Security";
|
||||
|
||||
[ViewVariables(VVAccess.ReadOnly)]
|
||||
public string Reason = "Изменено с помощью визора";
|
||||
}
|
||||
162
Content.Server/_White/SecurityHud/SecurityHudSystem.cs
Normal file
@@ -0,0 +1,162 @@
|
||||
using Content.Server.Access.Systems;
|
||||
using Content.Server.CriminalRecords.Systems;
|
||||
using Content.Server.Popups;
|
||||
using Content.Server.Radio.EntitySystems;
|
||||
using Content.Server.StationRecords.Systems;
|
||||
using Content.Shared._Miracle.Components;
|
||||
using Content.Shared._White.SecurityHud;
|
||||
using Content.Shared.Access.Components;
|
||||
using Content.Shared.Access.Systems;
|
||||
using Content.Shared.CriminalRecords;
|
||||
using Content.Shared.Humanoid;
|
||||
using Content.Shared.Inventory;
|
||||
using Content.Shared.Popups;
|
||||
using Content.Shared.Security;
|
||||
using Content.Shared.Security.Components;
|
||||
using Content.Shared.StationRecords;
|
||||
using Content.Shared.Verbs;
|
||||
using Robust.Server.GameObjects;
|
||||
using Robust.Shared.Player;
|
||||
|
||||
namespace Content.Server._White.SecurityHud;
|
||||
|
||||
public sealed class SecurityHudSystem : EntitySystem
|
||||
{
|
||||
[Dependency] private readonly UserInterfaceSystem _ui = default!;
|
||||
[Dependency] private readonly CriminalRecordsSystem _criminalRecordsSystem = default!;
|
||||
[Dependency] private readonly StationRecordsSystem _stationRecordsSystem = default!;
|
||||
[Dependency] private readonly IdCardSystem _idCardSystem = default!;
|
||||
[Dependency] private readonly RadioSystem _radio = default!;
|
||||
[Dependency] private readonly InventorySystem _invSlotsSystem = default!;
|
||||
[Dependency] private readonly PopupSystem _popupSystem = default!;
|
||||
[Dependency] private readonly AccessReaderSystem _accessReaderSystem = default!;
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeLocalEvent<GetVerbsEvent<AlternativeVerb>>(OnAltVerb);
|
||||
SubscribeLocalEvent<SecurityHudComponent, SecurityHudStatusSelectedMessage>(OnStatusSelected);
|
||||
}
|
||||
|
||||
private void OnAltVerb(GetVerbsEvent<AlternativeVerb> args)
|
||||
{
|
||||
if(!HasComp<HumanoidAppearanceComponent>(args.Target))
|
||||
return;
|
||||
|
||||
if(!_invSlotsSystem.TryGetSlotEntity(args.User, "eyes", out var ent))
|
||||
return;
|
||||
|
||||
if(!TryComp<SecurityHudComponent>(ent, out var component))
|
||||
return;
|
||||
|
||||
if(!TryComp<AccessReaderComponent>(ent, out var accessReaderComponent))
|
||||
return;
|
||||
|
||||
if (!_accessReaderSystem.IsAllowed(args.User, (EntityUid) ent, accessReaderComponent))
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("security-hud-not-allowed"), args.User, args.User, PopupType.Medium);
|
||||
return;
|
||||
}
|
||||
|
||||
AlternativeVerb verb = new()
|
||||
{
|
||||
Act = () =>
|
||||
{
|
||||
SetWanted(args.User, args.Target, (EntityUid) ent, component);
|
||||
},
|
||||
Disabled = false,
|
||||
Priority = 0,
|
||||
Text = Loc.GetString("security-hud-verb"),
|
||||
};
|
||||
|
||||
args.Verbs.Add(verb);
|
||||
}
|
||||
|
||||
private void SetWanted(EntityUid uid, EntityUid target, EntityUid hud, SecurityHudComponent component)
|
||||
{
|
||||
if (!TryComp<ActorComponent>(uid, out var actor))
|
||||
return;
|
||||
|
||||
if (_ui.TryGetUi(hud, SecurityHudUiKey.Key, out var bui))
|
||||
{
|
||||
_ui.SetUiState(bui, new SecurityHudBUIState(component.Status, GetNetEntity(uid), GetNetEntity(target)));
|
||||
_ui.OpenUi(bui, actor.PlayerSession);
|
||||
}
|
||||
}
|
||||
|
||||
private void OnStatusSelected(EntityUid uid, SecurityHudComponent component, SecurityHudStatusSelectedMessage args)
|
||||
{
|
||||
var user = GetEntity(args.User);
|
||||
var target = GetEntity(args.Target);
|
||||
|
||||
if (!_idCardSystem.TryFindIdCard(target, out var idCard))
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("security-hud-id-unknown"), user, user, PopupType.Medium);
|
||||
return;
|
||||
}
|
||||
|
||||
if(!TryComp<StationRecordKeyStorageComponent>(idCard, out var stationRecordKeyComp))
|
||||
return;
|
||||
|
||||
if (stationRecordKeyComp.Key == null)
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("security-hud-key-null"), user, user, PopupType.Medium);
|
||||
return;
|
||||
}
|
||||
|
||||
var key = stationRecordKeyComp.Key.Value;
|
||||
|
||||
if (!SetCriminalStatus(key, args.Status, user, idCard.Comp, component.Reason, component.SecurityChannel))
|
||||
{
|
||||
_popupSystem.PopupEntity(Loc.GetString("security-hud-cant-set-status"), user, user, PopupType.Medium);
|
||||
}
|
||||
}
|
||||
|
||||
private bool SetCriminalStatus(StationRecordKey key, SecurityStatus status, EntityUid hud, IdCardComponent idCard, string reason, string securityChannel)
|
||||
{
|
||||
if (!_stationRecordsSystem.TryGetRecord<GeneralStationRecord>(key, out var rec))
|
||||
return false;
|
||||
|
||||
var name = string.Empty;
|
||||
reason = idCard.FullName != null ? $"{reason} ({idCard.FullName})" : reason;
|
||||
|
||||
if (!_stationRecordsSystem.TryGetRecord<CriminalRecord>(key, out var record) || record.Status == status)
|
||||
return false;
|
||||
|
||||
if (_stationRecordsSystem.TryGetRecord<GeneralStationRecord>(key, out var generalRecord))
|
||||
name = generalRecord.Name;
|
||||
|
||||
_criminalRecordsSystem.TryChangeStatus(key, status, reason);
|
||||
|
||||
var locArgs = new (string, object)[] { ("name", name), ("officer", idCard.FullName)!, ("reason", reason) };
|
||||
|
||||
var statusString = (record.Status, status) switch
|
||||
{
|
||||
(_, SecurityStatus.Detained) => "detained",
|
||||
(SecurityStatus.Detained, SecurityStatus.None) => "released",
|
||||
(_, SecurityStatus.None) => "not-wanted",
|
||||
(_, SecurityStatus.Wanted) => "wanted",
|
||||
(_, SecurityStatus.Discharged) => "released",
|
||||
(_, SecurityStatus.Suspected) => "suspected",
|
||||
_ => "not-wanted"
|
||||
};
|
||||
|
||||
_radio.SendRadioMessage(hud, Loc.GetString($"criminal-records-console-{statusString}", locArgs), securityChannel, hud);
|
||||
|
||||
var criminalData = EnsureComp<CriminalRecordComponent>(hud);
|
||||
|
||||
criminalData.StatusIcon = status switch
|
||||
{
|
||||
SecurityStatus.Detained => "SecurityIconIncarcerated",
|
||||
SecurityStatus.None => "CriminalRecordIconRemove",
|
||||
SecurityStatus.Wanted => "SecurityIconWanted",
|
||||
SecurityStatus.Discharged => "SecurityIconDischarged",
|
||||
SecurityStatus.Suspected => "SecurityIconSuspected",
|
||||
_ => criminalData.StatusIcon
|
||||
};
|
||||
|
||||
Dirty(hud, criminalData);
|
||||
|
||||
return true;
|
||||
}
|
||||
}
|
||||
44
Content.Shared/_White/SecurityHud/SecurityHudBUIState.cs
Normal file
@@ -0,0 +1,44 @@
|
||||
using Content.Shared.Security;
|
||||
using Robust.Shared.Serialization;
|
||||
|
||||
namespace Content.Shared._White.SecurityHud;
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public enum SecurityHudUiKey
|
||||
{
|
||||
Key
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class SecurityHudBUIState : BoundUserInterfaceState
|
||||
{
|
||||
public IReadOnlyCollection<string> Ids { get; set; }
|
||||
|
||||
public NetEntity User { get; set; }
|
||||
|
||||
public NetEntity Target { get; private set; }
|
||||
|
||||
public SecurityHudBUIState(IReadOnlyCollection<string> ids, NetEntity user, NetEntity target)
|
||||
{
|
||||
Ids = ids;
|
||||
User = user;
|
||||
Target = target;
|
||||
}
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public class SecurityHudStatusSelectedMessage : BoundUserInterfaceMessage
|
||||
{
|
||||
public SecurityStatus Status { get; private set; }
|
||||
|
||||
public NetEntity User { get; private set; }
|
||||
|
||||
public NetEntity Target { get; private set; }
|
||||
|
||||
public SecurityHudStatusSelectedMessage(SecurityStatus status, NetEntity user, NetEntity target)
|
||||
{
|
||||
Status = status;
|
||||
User = user;
|
||||
Target = target;
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ criminal-records-console-status = Статус
|
||||
criminal-records-status-none = Нет
|
||||
criminal-records-status-wanted = В розыске
|
||||
criminal-records-status-detained = В заключении
|
||||
criminal-records-status-parolled = Имеет имплант защиты разума
|
||||
criminal-records-status-discharged = Уволен
|
||||
|
||||
criminal-records-status-suspected = Подозреваемый
|
||||
criminal-records-status-released = Отпущен
|
||||
@@ -32,7 +34,7 @@ criminal-records-permission-denied = Доступ воспрещен
|
||||
|
||||
criminal-records-console-wanted = {$name} отправлен в розыск по указу {$officer} по причине: {$reason}.
|
||||
criminal-records-console-detained = {$name} был задержан {$officer}.
|
||||
criminal-records-console-released = {$name} был задержан {$officer}.
|
||||
criminal-records-console-released = {$name} был освобожден {$officer}.
|
||||
criminal-records-console-not-wanted = {$name} больше не в розыске.
|
||||
criminal-records-console-unknown-officer = <неизвестный офицер>
|
||||
|
||||
|
||||
6
Resources/Locale/ru-RU/white/securityhud/securityhud.ftl
Normal file
@@ -0,0 +1,6 @@
|
||||
security-hud-key-null = Визор не может установить личность человека!
|
||||
security-hud-id-unknown = Визор не может установить идентификационную карту человека!
|
||||
security-hud-verb = Изменить статус
|
||||
security-hud-cant-set-status = Произошла ошибка при попытке установить статус!
|
||||
security-hud-remove-status = Убрать статус.
|
||||
security-hud-not-allowed = Недостаточный доступ для взаимодействия.
|
||||
@@ -44,6 +44,19 @@
|
||||
- type: Clothing
|
||||
sprite: Clothing/Eyes/Hud/sec.rsi
|
||||
- type: ShowSecurityIcons
|
||||
- type: AccessReader
|
||||
access: [["Security"]]
|
||||
- type: SecurityHud
|
||||
criminalrecords:
|
||||
- SecurityIconDischarged
|
||||
- SecurityIconSuspected
|
||||
- SecurityIconWanted
|
||||
- SecurityIconIncarcerated
|
||||
- CriminalRecordIconRemove
|
||||
- type: UserInterface
|
||||
interfaces:
|
||||
- key: enum.SecurityHudUiKey.Key
|
||||
type: SecurityHudBUI
|
||||
- type: Tag
|
||||
tags:
|
||||
- HudSecurity
|
||||
|
||||
@@ -40,3 +40,7 @@
|
||||
icon:
|
||||
sprite: /Textures/Interface/Misc/security_icons.rsi
|
||||
state: hud_wanted
|
||||
|
||||
- type: statusIcon
|
||||
parent: SecurityIcon
|
||||
id: CriminalRecordIconRemove
|
||||
@@ -1,47 +0,0 @@
|
||||
- type: statusIcon
|
||||
id: CriminalRecordIcon
|
||||
abstract: true
|
||||
priority: 2
|
||||
locationPreference: Right
|
||||
|
||||
- type: statusIcon
|
||||
parent: CriminalRecordIcon
|
||||
id: CriminalRecordIconReleased
|
||||
icon:
|
||||
sprite: /Textures/White/Interface/records.rsi
|
||||
state: released
|
||||
|
||||
- type: statusIcon
|
||||
parent: CriminalRecordIcon
|
||||
id: CriminalRecordIconDischarged
|
||||
icon:
|
||||
sprite: /Textures/White/Interface/records.rsi
|
||||
state: discharged
|
||||
|
||||
- type: statusIcon
|
||||
parent: CriminalRecordIcon
|
||||
id: CriminalRecordIconParolled
|
||||
icon:
|
||||
sprite: /Textures/White/Interface/records.rsi
|
||||
state: parolled
|
||||
|
||||
- type: statusIcon
|
||||
parent: CriminalRecordIcon
|
||||
id: CriminalRecordIconSuspected
|
||||
icon:
|
||||
sprite: /Textures/White/Interface/records.rsi
|
||||
state: suspected
|
||||
|
||||
- type: statusIcon
|
||||
parent: CriminalRecordIcon
|
||||
id: CriminalRecordIconWanted
|
||||
icon:
|
||||
sprite: /Textures/White/Interface/records.rsi
|
||||
state: wanted
|
||||
|
||||
- type: statusIcon
|
||||
parent: CriminalRecordIcon
|
||||
id: CriminalRecordIconIncarcerated
|
||||
icon:
|
||||
sprite: /Textures/White/Interface/records.rsi
|
||||
state: incarcerated
|
||||
|
Before Width: | Height: | Size: 139 B After Width: | Height: | Size: 141 B |
|
After Width: | Height: | Size: 232 B |
23
Resources/Textures/White/Interface/securityhud.rsi/meta.json
Normal file
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"license": "CC-BY-SA-3.0",
|
||||
"copyright": "https://github.com/tgstation/tgstation/blob/8e49222b72f6fdcbe741d2a6ce0a8425d95010b7/icons/mob/huds/hud.dmi",
|
||||
"version": 1,
|
||||
"size": { "y": 32, "x": 32 },
|
||||
"states": [
|
||||
{
|
||||
"name": "wanted"
|
||||
},
|
||||
{
|
||||
"name": "suspected"
|
||||
},
|
||||
{
|
||||
"name": "released"
|
||||
},
|
||||
{
|
||||
"name": "incarcerated"
|
||||
},
|
||||
{
|
||||
"name": "remove"
|
||||
}
|
||||
]
|
||||
}
|
||||
BIN
Resources/Textures/White/Interface/securityhud.rsi/released.png
Normal file
|
After Width: | Height: | Size: 202 B |
BIN
Resources/Textures/White/Interface/securityhud.rsi/remove.png
Normal file
|
After Width: | Height: | Size: 288 B |
BIN
Resources/Textures/White/Interface/securityhud.rsi/suspected.png
Normal file
|
After Width: | Height: | Size: 217 B |
BIN
Resources/Textures/White/Interface/securityhud.rsi/wanted.png
Normal file
|
After Width: | Height: | Size: 204 B |