Add chat.max_announcement_length cvar (#23571)
* Add announce message length to UI and make a cvar for it * Update comm console server-side trim to use the cvar * Rely on the new OnTextChanged event Because OnKeyBindUp only works for keys that have binds * Add a similar indicator to nukies' war declaration UI * Remove message length indicators for now cuz it requires the engine update * Rename cvar slightly * Refactor duplicated code to a helper method * Remove message trimming from *Window class as it's better to live in the BoundUserInterface where the other message handling happens * Rename to chat.max_announcement_length
This commit is contained in:
@@ -1,13 +1,16 @@
|
||||
using Content.Shared.NukeOps;
|
||||
using Content.Shared.CCVar;
|
||||
using Content.Shared.Chat;
|
||||
using Content.Shared.NukeOps;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.Timing;
|
||||
using Robust.Shared.Configuration;
|
||||
|
||||
namespace Content.Client.NukeOps;
|
||||
|
||||
[UsedImplicitly]
|
||||
public sealed class WarDeclaratorBoundUserInterface : BoundUserInterface
|
||||
{
|
||||
[Dependency] private readonly IConfigurationManager _cfg = default!;
|
||||
|
||||
[ViewVariables]
|
||||
private WarDeclaratorWindow? _window;
|
||||
|
||||
@@ -44,6 +47,8 @@ public sealed class WarDeclaratorBoundUserInterface : BoundUserInterface
|
||||
|
||||
private void OnWarDeclaratorActivated(string message)
|
||||
{
|
||||
SendMessage(new WarDeclaratorActivateMessage(message));
|
||||
var maxLength = _cfg.GetCVar(CCVars.ChatMaxAnnouncementLength);
|
||||
var msg = SharedChatSystem.SanitizeAnnouncement(message, maxLength);
|
||||
SendMessage(new WarDeclaratorActivateMessage(msg));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,7 +2,6 @@
|
||||
using Content.Shared.NukeOps;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Graphics;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.Timing;
|
||||
@@ -27,7 +26,7 @@ public sealed partial class WarDeclaratorWindow : DefaultWindow
|
||||
|
||||
_gameTiming = IoCManager.Resolve<IGameTiming>();
|
||||
|
||||
WarButton.OnPressed += ActivateWarDeclarator;
|
||||
WarButton.OnPressed += (_) => OnActivated?.Invoke(Rope.Collapse(MessageEdit.TextRope));
|
||||
|
||||
var loc = IoCManager.Resolve<ILocalizationManager>();
|
||||
MessageEdit.Placeholder = new Rope.Leaf(loc.GetString("war-declarator-message-placeholder"));
|
||||
@@ -129,10 +128,4 @@ public sealed partial class WarDeclaratorWindow : DefaultWindow
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
private void ActivateWarDeclarator(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
var message = Rope.Collapse(MessageEdit.TextRope);
|
||||
OnActivated?.Invoke(message);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user