Cleaner BoundUserInterfaces (#17736)

This commit is contained in:
TemporalOroboros
2023-07-08 09:02:17 -07:00
committed by GitHub
parent 55b4fb1649
commit 3ac4cf85db
137 changed files with 1069 additions and 972 deletions

View File

@@ -1,23 +1,17 @@
using System.Linq;
using Content.Server.DeviceNetwork;
using Content.Server.DeviceNetwork.Systems;
using Content.Server.Medical.SuitSensors;
using Content.Server.UserInterface;
using Content.Shared.Medical.CrewMonitoring;
using Robust.Shared.Map;
using Content.Shared.Medical.SuitSensor;
using Robust.Shared.Timing;
using Content.Server.PowerCell;
using Content.Shared.Medical.CrewMonitoring;
using Content.Shared.Medical.SuitSensor;
using Robust.Server.GameObjects;
namespace Content.Server.Medical.CrewMonitoring
{
public sealed class CrewMonitoringConsoleSystem : EntitySystem
{
[Dependency] private readonly SuitSensorSystem _sensors = default!;
[Dependency] private readonly SharedTransformSystem _xform = default!;
[Dependency] private readonly IGameTiming _gameTiming = default!;
[Dependency] private readonly IMapManager _mapManager = default!;
[Dependency] private readonly PowerCellSystem _cell = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
public override void Initialize()
{
@@ -60,14 +54,12 @@ namespace Content.Server.Medical.CrewMonitoring
if (!Resolve(uid, ref component))
return;
var ui = component.Owner.GetUIOrNull(CrewMonitoringUIKey.Key);
if (ui == null)
if (!_uiSystem.TryGetUi(uid, CrewMonitoringUIKey.Key, out var bui))
return;
// update all sensors info
var allSensors = component.ConnectedSensors.Values.ToList();
var uiState = new CrewMonitoringState(allSensors, component.Snap, component.Precision);
ui.SetState(uiState);
UserInterfaceSystem.SetUiState(bui, new CrewMonitoringState(allSensors, component.Snap, component.Precision));
}
}
}

View File

@@ -88,7 +88,7 @@ namespace Content.Server.Medical
!CanScannerInsert(uid, args.Using.Value, component))
return;
string name = "Unknown";
var name = "Unknown";
if (TryComp<MetaDataComponent>(args.Using.Value, out var metadata))
name = metadata.EntityName;
@@ -109,11 +109,13 @@ namespace Content.Server.Medical
// Eject verb
if (IsOccupied(component))
{
AlternativeVerb verb = new();
verb.Act = () => EjectBody(uid, component);
verb.Category = VerbCategory.Eject;
verb.Text = Loc.GetString("medical-scanner-verb-noun-occupant");
verb.Priority = 1; // Promote to top to make ejecting the ALT-click action
AlternativeVerb verb = new()
{
Act = () => EjectBody(uid, component),
Category = VerbCategory.Eject,
Text = Loc.GetString("medical-scanner-verb-noun-occupant"),
Priority = 1 // Promote to top to make ejecting the ALT-click action
};
args.Verbs.Add(verb);
}
@@ -122,9 +124,11 @@ namespace Content.Server.Medical
CanScannerInsert(uid, args.User, component) &&
_blocker.CanMove(args.User))
{
AlternativeVerb verb = new();
verb.Act = () => InsertBody(uid, args.User, component);
verb.Text = Loc.GetString("medical-scanner-verb-enter");
AlternativeVerb verb = new()
{
Act = () => InsertBody(uid, args.User, component),
Text = Loc.GetString("medical-scanner-verb-enter")
};
args.Verbs.Add(verb);
}
}
@@ -154,7 +158,7 @@ namespace Content.Server.Medical
_cloningConsoleSystem.RecheckConnections(component.ConnectedConsole.Value, console.CloningPod, uid, console);
return;
}
_cloningConsoleSystem.UpdateUserInterface(console);
_cloningConsoleSystem.UpdateUserInterface(component.ConnectedConsole.Value, console);
}
private MedicalScannerStatus GetStatus(EntityUid uid, MedicalScannerComponent scannerComponent)
{
@@ -174,7 +178,7 @@ namespace Content.Server.Medical
return MedicalScannerStatus.Off;
}
public bool IsOccupied(MedicalScannerComponent scannerComponent)
public static bool IsOccupied(MedicalScannerComponent scannerComponent)
{
return scannerComponent.BodyContainer.ContainedEntity != null;
}
@@ -212,7 +216,7 @@ namespace Content.Server.Medical
_updateDif -= UpdateRate;
var query = EntityQueryEnumerator<MedicalScannerComponent>();
while(query.MoveNext(out var uid, out var scanner))
while (query.MoveNext(out var uid, out var scanner))
{
UpdateAppearance(uid, scanner);
}
@@ -238,7 +242,7 @@ namespace Content.Server.Medical
if (!Resolve(uid, ref scannerComponent))
return;
if (scannerComponent.BodyContainer.ContainedEntity is not {Valid: true} contained)
if (scannerComponent.BodyContainer.ContainedEntity is not { Valid: true } contained)
return;
scannerComponent.BodyContainer.Remove(contained);