Admin announcement panel. (#4803)
This commit is contained in:
33
Content.Server/Administration/Commands/AnnounceUiCommand.cs
Normal file
33
Content.Server/Administration/Commands/AnnounceUiCommand.cs
Normal file
@@ -0,0 +1,33 @@
|
||||
using Content.Server.Administration.UI;
|
||||
using Content.Server.EUI;
|
||||
using Content.Shared.Administration;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.Administration.Commands
|
||||
{
|
||||
[AdminCommand(AdminFlags.Fun)]
|
||||
public class AnnounceUiCommand : IConsoleCommand
|
||||
{
|
||||
public string Command => "announceui";
|
||||
|
||||
public string Description => "Opens the announcement UI";
|
||||
|
||||
public string Help => $"{Command}";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
var player = shell.Player as IPlayerSession;
|
||||
if (player == null)
|
||||
{
|
||||
shell.WriteLine("This does not work from the server console.");
|
||||
return;
|
||||
}
|
||||
|
||||
var eui = IoCManager.Resolve<EuiManager>();
|
||||
var ui = new AdminAnnounceEui();
|
||||
eui.OpenEui(ui, player);
|
||||
}
|
||||
}
|
||||
}
|
||||
63
Content.Server/Administration/UI/AdminAnnounceEui.cs
Normal file
63
Content.Server/Administration/UI/AdminAnnounceEui.cs
Normal file
@@ -0,0 +1,63 @@
|
||||
using Content.Server.Administration.Managers;
|
||||
using Content.Server.Chat.Managers;
|
||||
using Content.Server.EUI;
|
||||
using Content.Shared.Administration;
|
||||
using Content.Shared.Eui;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.Administration.UI
|
||||
{
|
||||
public sealed class AdminAnnounceEui : BaseEui
|
||||
{
|
||||
[Dependency] private readonly IAdminManager _adminManager = default!;
|
||||
[Dependency] private readonly IChatManager _chatManager = default!;
|
||||
|
||||
public AdminAnnounceEui()
|
||||
{
|
||||
IoCManager.InjectDependencies(this);
|
||||
}
|
||||
|
||||
public override void Opened()
|
||||
{
|
||||
StateDirty();
|
||||
}
|
||||
|
||||
public override EuiStateBase GetNewState()
|
||||
{
|
||||
return new AdminAnnounceEuiState();
|
||||
}
|
||||
|
||||
public override void HandleMessage(EuiMessageBase msg)
|
||||
{
|
||||
switch (msg)
|
||||
{
|
||||
case AdminAnnounceEuiMsg.Close:
|
||||
Close();
|
||||
break;
|
||||
case AdminAnnounceEuiMsg.DoAnnounce doAnnounce:
|
||||
if (!_adminManager.HasAdminFlag(Player, AdminFlags.Fun))
|
||||
{
|
||||
Close();
|
||||
break;
|
||||
}
|
||||
|
||||
switch (doAnnounce.AnnounceType)
|
||||
{
|
||||
case AdminAnnounceType.Server:
|
||||
_chatManager.DispatchServerAnnouncement(doAnnounce.Announcement);
|
||||
break;
|
||||
case AdminAnnounceType.Station:
|
||||
_chatManager.DispatchStationAnnouncement(doAnnounce.Announcement, doAnnounce.Announcer);
|
||||
break;
|
||||
}
|
||||
|
||||
StateDirty();
|
||||
|
||||
if (doAnnounce.CloseAfter)
|
||||
Close();
|
||||
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user