BUI changes required for Engine PR (#10608)

This commit is contained in:
Leon Friedrich
2022-08-21 05:38:30 +12:00
committed by GitHub
parent 25093f5146
commit 921e2ee57d
69 changed files with 79 additions and 86 deletions

View File

@@ -1,10 +1,10 @@
using System.Linq;
using System.Linq;
using Content.Server.Arcade.Components;
using Content.Server.UserInterface;
using Content.Shared.Arcade;
using Robust.Shared.Utility;
using Robust.Server.GameObjects;
using Robust.Server.Player;
namespace Content.Server.Arcade
{
@@ -19,6 +19,7 @@ namespace Content.Server.Arcade
base.Initialize();
SubscribeLocalEvent<BlockGameArcadeComponent, AfterActivatableUIOpenEvent>(OnAfterUIOpen);
SubscribeLocalEvent<SpaceVillainArcadeComponent, AfterActivatableUIOpenEvent>(OnAfterUIOpenSV);
SubscribeLocalEvent<BlockGameArcadeComponent, BoundUIClosedEvent>((_,c,args) => c.UnRegisterPlayerSession((IPlayerSession)args.Session));
InitializeBlockGame();
InitializeSpaceVillain();
}

View File

@@ -48,7 +48,7 @@ namespace Content.Server.Arcade.Components
UpdatePlayerStatus(temp);
}
private void UnRegisterPlayerSession(IPlayerSession session)
public void UnRegisterPlayerSession(IPlayerSession session)
{
if (_player == session)
{
@@ -72,7 +72,6 @@ namespace Content.Server.Arcade.Components
if (UserInterface != null)
{
UserInterface.OnReceiveMessage += UserInterfaceOnOnReceiveMessage;
UserInterface.OnClosed += UnRegisterPlayerSession;
}
_game = new BlockGame(this);
}

View File

@@ -35,7 +35,6 @@ namespace Content.Server.Atmos.Components
if (UserInterface != null)
{
UserInterface.OnReceiveMessage += UserInterfaceOnReceiveMessage;
UserInterface.OnClosed += UserInterfaceOnClose;
}
_entities.TryGetComponent(Owner, out _appearance);
@@ -96,12 +95,7 @@ namespace Content.Server.Atmos.Components
Resync();
}
private void UserInterfaceOnClose(IPlayerSession obj)
{
UpdateAppearance(false);
}
private void UpdateAppearance(bool open)
public void UpdateAppearance(bool open)
{
_appearance?.SetData(GasAnalyzerVisuals.VisualState,
open ? GasAnalyzerVisualState.Working : GasAnalyzerVisualState.Off);

View File

@@ -21,6 +21,7 @@ namespace Content.Server.Atmos.EntitySystems
base.Initialize();
SubscribeLocalEvent<GasAnalyzableComponent, GetVerbsEvent<ExamineVerb>>(OnGetExamineVerbs);
SubscribeLocalEvent<GasAnalyzerComponent, BoundUIClosedEvent>((_,c,_) => c.UpdateAppearance(false));
}
private void OnGetExamineVerbs(EntityUid uid, GasAnalyzableComponent component, GetVerbsEvent<ExamineVerb> args)

View File

@@ -653,12 +653,12 @@ namespace Content.Server.Storage.EntitySystems
DebugTools.Assert(storedStorageComp != storageComp, $"Storage component contains itself!? Entity: {uid}");
}
if (TryComp(entity, out ServerUserInterfaceComponent? uiComponent))
if (!TryComp(entity, out ServerUserInterfaceComponent? ui))
continue;
foreach (var bui in ui.Interfaces.Values)
{
foreach (var ui in uiComponent.Interfaces)
{
ui.Close(session);
}
_uiSystem.TryClose(entity, bui.UiKey, session, ui);
}
}
}

View File

@@ -17,6 +17,7 @@ namespace Content.Server.UserInterface
{
[Dependency] private readonly IAdminManager _adminManager = default!;
[Dependency] private readonly ActionBlockerSystem _blockerSystem = default!;
[Dependency] private readonly UserInterfaceSystem _uiSystem = default!;
public override void Initialize()
{
@@ -56,11 +57,7 @@ namespace Content.Server.UserInterface
if (!TryComp(args.Performer, out ActorComponent? actor))
return;
if (!component.TryGetBoundUserInterface(args.Key, out var bui))
return;
bui.Toggle(actor.PlayerSession);
args.Handled = true;
args.Handled = _uiSystem.TryToggleUi(uid, args.Key, actor.PlayerSession);
}
private void AddOpenUiVerb(EntityUid uid, ActivatableUIComponent component, GetVerbsEvent<ActivationVerb> args)

View File

@@ -4,9 +4,10 @@ namespace Content.Server.UserInterface
{
public static class UserInterfaceHelpers
{
public static BoundUserInterface? GetUIOrNull(this EntityUid entity, object uiKey)
[Obsolete("Use UserInterfaceSystem")]
public static BoundUserInterface? GetUIOrNull(this EntityUid entity, Enum uiKey)
{
return IoCManager.Resolve<IEntityManager>().GetComponentOrNull<ServerUserInterfaceComponent>(entity)?.GetBoundUserInterfaceOrNull(uiKey);
return IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<UserInterfaceSystem>().GetUiOrNull(entity, uiKey);
}
}
}