Files
wwdpublic/Content.Server/Administration/UI/AdminAnnounceEui.cs
DEATHB4DEFEAT e3bc8d4c0e Random Announcer System (#415)
# Description

Replaces every instance of station announcements with an announcer
system meant to handle audio and messages for various announcers defined
in prototypes instead of each server replacing the scattered files
inconsistently with whatever singular thing they want to hear announce
messages.

# TODO

- [x] Systems
- [x] CVars
- [x] Sounds
- [x] Client volume slider
- [x] Collections
- [x] Prototypes
- [x] Events
- [x] Commands
- [x] PR media
- [x] Deglobalize
- [x] Passthrough localization parameters to overrides
- [x] Make every announcer follow the template
- [x] Move sounds into subdirectories
- [x] Make announcement IDs camelCased
- [x] Test announcement localizations
- [x] Weighted announcer lists

---

<details><summary><h1>Media</h1></summary>
<p>


https://github.com/Simple-Station/Parkstation-Friendly-Chainsaw/assets/77995199/caf5805d-acb0-4140-b344-875a8f79e5ee

</p>
</details>

---

# Changelog

🆑
- add: Added 4 new announcers that will randomly be selected every shift
2024-07-12 16:13:50 -04:00

73 lines
2.3 KiB
C#

using Content.Server.Administration.Managers;
using Content.Server.Chat;
using Content.Server.Chat.Managers;
using Content.Server.Chat.Systems;
using Content.Server.EUI;
using Content.Shared.Administration;
using Content.Shared.Eui;
using Content.Server.Announcements.Systems;
using Robust.Shared.Player;
namespace Content.Server.Administration.UI
{
public sealed class AdminAnnounceEui : BaseEui
{
[Dependency] private readonly IAdminManager _adminManager = default!;
[Dependency] private readonly IChatManager _chatManager = default!;
private readonly AnnouncerSystem _announcer;
private readonly ChatSystem _chatSystem;
public AdminAnnounceEui()
{
IoCManager.InjectDependencies(this);
_announcer = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<AnnouncerSystem>();
_chatSystem = IoCManager.Resolve<IEntitySystemManager>().GetEntitySystem<ChatSystem>();
}
public override void Opened()
{
StateDirty();
}
public override EuiStateBase GetNewState()
{
return new AdminAnnounceEuiState();
}
public override void HandleMessage(EuiMessageBase msg)
{
base.HandleMessage(msg);
switch (msg)
{
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:
_announcer.SendAnnouncement(_announcer.GetAnnouncementId("Announce"), Filter.Broadcast(),
doAnnounce.Announcement, doAnnounce.Announcer, Color.Gold);
break;
}
StateDirty();
if (doAnnounce.CloseAfter)
Close();
break;
}
}
}
}