Co-authored-by: metalgearsloth <31366439+metalgearsloth@users.noreply.github.com> Co-authored-by: metalgearsloth <comedian_vs_clown@hotmail.com>
66 lines
2.0 KiB
C#
66 lines
2.0 KiB
C#
using Content.Server.Administration.Managers;
|
|
using Content.Server.Chat;
|
|
using Content.Server.Chat.Managers;
|
|
using Content.Server.EUI;
|
|
using Content.Shared.Administration;
|
|
using Content.Shared.Eui;
|
|
|
|
namespace Content.Server.Administration.UI
|
|
{
|
|
public sealed class AdminAnnounceEui : BaseEui
|
|
{
|
|
[Dependency] private readonly IAdminManager _adminManager = default!;
|
|
[Dependency] private readonly IChatManager _chatManager = default!;
|
|
[Dependency] private readonly ChatSystem _chatSystem = 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.Admin))
|
|
{
|
|
Close();
|
|
break;
|
|
}
|
|
|
|
switch (doAnnounce.AnnounceType)
|
|
{
|
|
case AdminAnnounceType.Server:
|
|
_chatManager.DispatchServerAnnouncement(doAnnounce.Announcement);
|
|
break;
|
|
// TODO: Per-station announcement support
|
|
case AdminAnnounceType.Station:
|
|
_chatSystem.DispatchGlobalStationAnnouncement(doAnnounce.Announcement, doAnnounce.Announcer, colorOverride: Color.Gold);
|
|
break;
|
|
}
|
|
|
|
StateDirty();
|
|
|
|
if (doAnnounce.CloseAfter)
|
|
Close();
|
|
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|