BUI bugfixes / improvements (#23881)

* Fix ActivatableUIRequiresPowerCellComponent stopping power draw when one of two people closes the UI.

Also fixes it to check UiKey properly.

* Remove unnecessary CrewManifestViewer on PDAs

This is for a pop-up crew manifest UI, which the PDA doesn't use.

* Fix BoundUIClosedEvents that didn't check UI key/not correctly at least.

Uses the new helper method in engine.

* Fix drone (cargo shuttle) pilot console UI breaking if two people open it and one person closes it.

* Fixes for disposal router/tagger UI.

Code was badly copy pasted without changing identifiers, never worked.

Also cleaned up some of the logic (text trimming, sounds).

Also removed the "refuse to work if you have something in your active hand" check like why.

* Avoid running most ActivatableUIComponent logic when closing a UI via toggle

Activating the UI while it's already open closes it via toggle. Except it still ran 99% of the "attempting to open" logic which makes no sense.

This probably fixes a bug or some other dumb behavior somewhere.

* Bitch
This commit is contained in:
Pieter-Jan Briers
2024-01-14 08:18:39 +01:00
committed by GitHub
parent b51d69184e
commit 123a4147de
22 changed files with 174 additions and 125 deletions

View File

@@ -13,6 +13,7 @@ using Content.Shared.StationRecords;
using Robust.Shared.Configuration;
using Robust.Shared.Console;
using Robust.Shared.Player;
using Robust.Shared.Utility;
namespace Content.Server.CrewManifest;
@@ -37,10 +38,11 @@ public sealed class CrewManifestSystem : EntitySystem
SubscribeLocalEvent<AfterGeneralRecordCreatedEvent>(AfterGeneralRecordCreated);
SubscribeLocalEvent<RecordModifiedEvent>(OnRecordModified);
SubscribeLocalEvent<RecordRemovedEvent>(OnRecordRemoved);
SubscribeLocalEvent<CrewManifestViewerComponent, BoundUIClosedEvent>(OnBoundUiClose);
SubscribeLocalEvent<CrewManifestViewerComponent, CrewManifestOpenUiMessage>(OpenEuiFromBui);
SubscribeLocalEvent<RoundRestartCleanupEvent>(OnRoundRestart);
SubscribeNetworkEvent<RequestCrewManifestMessage>(OnRequestCrewManifest);
SubscribeLocalEvent<CrewManifestViewerComponent, BoundUIClosedEvent>(OnBoundUiClose);
SubscribeLocalEvent<CrewManifestViewerComponent, CrewManifestOpenUiMessage>(OpenEuiFromBui);
}
private void OnRoundRestart(RoundRestartCleanupEvent ev)
@@ -91,6 +93,9 @@ public sealed class CrewManifestSystem : EntitySystem
private void OnBoundUiClose(EntityUid uid, CrewManifestViewerComponent component, BoundUIClosedEvent ev)
{
if (!Equals(ev.UiKey, component.OwnerKey))
return;
var owningStation = _stationSystem.GetOwningStation(uid);
if (owningStation == null || ev.Session is not { } session)
{
@@ -124,6 +129,14 @@ public sealed class CrewManifestSystem : EntitySystem
private void OpenEuiFromBui(EntityUid uid, CrewManifestViewerComponent component, CrewManifestOpenUiMessage msg)
{
if (!msg.UiKey.Equals(component.OwnerKey))
{
Log.Error(
"{User} tried to open crew manifest from wrong UI: {Key}. Correct owned is {ExpectedKey}",
msg.Session, msg.UiKey, component.OwnerKey);
return;
}
var owningStation = _stationSystem.GetOwningStation(uid);
if (owningStation == null || msg.Session is not { } session)
{