adminmenu fixes (#5305)

This commit is contained in:
Paul Ritter
2021-11-12 19:46:05 +01:00
committed by GitHub
parent e8232af00e
commit 7b48fdd7f5
3 changed files with 40 additions and 1 deletions

View File

@@ -1,14 +1,28 @@
using Content.Client.Administration.Managers;
using Robust.Client.UserInterface.Controls;
using Robust.Shared.IoC;
namespace Content.Client.Administration
{
public partial class AdminSystem
{
[Dependency] private readonly IClientAdminManager _adminManager = default!;
private AdminNameOverlay _adminNameOverlay = default!;
private void InitializeOverlay()
{
_adminNameOverlay = new AdminNameOverlay(this, _entityManager, _eyeManager, _resourceCache, _entityLookup);
_adminManager.AdminStatusUpdated += OnAdminStatusUpdated;
}
private void ShutdownOverlay()
{
_adminManager.AdminStatusUpdated -= OnAdminStatusUpdated;
}
private void OnAdminStatusUpdated()
{
AdminOverlayOff();
}
public void AdminOverlayOn(BaseButton.ButtonEventArgs? _ = null)

View File

@@ -40,6 +40,12 @@ namespace Content.Client.Administration
SubscribeNetworkEvent<PlayerInfoRemovalMessage>(OnPlayerInfoRemoval);
}
public override void Shutdown()
{
base.Shutdown();
ShutdownOverlay();
}
private void OnPlayerInfoRemoval(PlayerInfoRemovalMessage ev)
{
if (_playerList == null) _playerList = new();

View File

@@ -2,6 +2,8 @@ using System;
using System.Linq;
using Content.Server.Administration.Managers;
using Content.Server.Players;
using Content.Server.Roles;
using Content.Server.Traitor;
using Content.Shared.Administration;
using Content.Shared.Administration.Events;
using Robust.Server.GameObjects;
@@ -25,11 +27,28 @@ namespace Content.Server.Administration
_adminManager.OnPermsChanged += OnAdminPermsChanged;
SubscribeLocalEvent<PlayerAttachedEvent>(OnPlayerAttached);
SubscribeLocalEvent<PlayerDetachedEvent>(OnPlayerDetached);
SubscribeLocalEvent<RoleAddedEvent>(OnRoleAddedEvent);
}
private void OnRoleAddedEvent(RoleAddedEvent ev)
{
if (ev.Role.Antagonist && ev.Role.Mind.Session != null)
{
foreach (var admin in _adminManager.ActiveAdmins)
{
RaiseNetworkEvent(GetChangedEvent(ev.Role.Mind.Session), admin.ConnectedClient);
}
}
}
private void OnAdminPermsChanged(AdminPermsChangedEventArgs obj)
{
if(!obj.IsAdmin) return;
if(!obj.IsAdmin)
{
RaiseNetworkEvent(new FullPlayerListEvent(), obj.Player.ConnectedClient);
return;
}
SendFullPlayerList(obj.Player);
}