* Remove some BUI boilerplate - The disposals overrides got removed due to the helper method handling it. - Replace window creation with CreateWindow helper. - Fixed some stinky code which would cause exceptions. * More * moar * weh * done * More BUIs * More updates * weh * moar * look who it is * weh * merge * weh * fixes
45 lines
1.3 KiB
C#
45 lines
1.3 KiB
C#
using Content.Shared.CCVar;
|
|
using Content.Shared.Chat;
|
|
using Content.Shared.NukeOps;
|
|
using JetBrains.Annotations;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Shared.Configuration;
|
|
using Robust.Shared.Timing;
|
|
|
|
namespace Content.Client.NukeOps;
|
|
|
|
[UsedImplicitly]
|
|
public sealed class WarDeclaratorBoundUserInterface : BoundUserInterface
|
|
{
|
|
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
|
|
|
[ViewVariables]
|
|
private WarDeclaratorWindow? _window;
|
|
|
|
public WarDeclaratorBoundUserInterface(EntityUid owner, Enum uiKey) : base(owner, uiKey) {}
|
|
|
|
protected override void Open()
|
|
{
|
|
base.Open();
|
|
|
|
_window = this.CreateWindow<WarDeclaratorWindow>();
|
|
_window.OnActivated += OnWarDeclaratorActivated;
|
|
}
|
|
|
|
protected override void UpdateState(BoundUserInterfaceState state)
|
|
{
|
|
base.UpdateState(state);
|
|
if (_window == null || state is not WarDeclaratorBoundUserInterfaceState cast)
|
|
return;
|
|
|
|
_window?.UpdateState(cast);
|
|
}
|
|
|
|
private void OnWarDeclaratorActivated(string message)
|
|
{
|
|
var maxLength = _cfg.GetCVar(CCVars.ChatMaxAnnouncementLength);
|
|
var msg = SharedChatSystem.SanitizeAnnouncement(message, maxLength);
|
|
SendMessage(new WarDeclaratorActivateMessage(msg));
|
|
}
|
|
}
|