Add option for admins to disable bwoink (#25008)
* Add option for admins to disable bwoink In a vain attempt to get people to ahelp more, provide the possibility for admins to not play the bwoink sound if they don't want to scare the player. * Add silent indicator to discord relay * Use string interpolation
This commit is contained in:
@@ -19,11 +19,11 @@ namespace Content.Client.Administration.Systems
|
||||
OnBwoinkTextMessageRecieved?.Invoke(this, message);
|
||||
}
|
||||
|
||||
public void Send(NetUserId channelId, string text)
|
||||
public void Send(NetUserId channelId, string text, bool playSound)
|
||||
{
|
||||
// Reuse the channel ID as the 'true sender'.
|
||||
// Server will ignore this and if someone makes it not ignore this (which is bad, allows impersonation!!!), that will help.
|
||||
RaiseNetworkEvent(new BwoinkTextMessage(channelId, channelId, text));
|
||||
RaiseNetworkEvent(new BwoinkTextMessage(channelId, channelId, text, playSound: playSound));
|
||||
SendInputTextUpdated(channelId, false);
|
||||
}
|
||||
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
<BoxContainer Orientation="Vertical" HorizontalExpand="True" SizeFlagsStretchRatio="2">
|
||||
<BoxContainer Access="Public" Name="BwoinkArea" VerticalExpand="True" />
|
||||
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
|
||||
<CheckBox Visible="True" Name="PlaySound" Access="Public" Text="{Loc 'admin-bwoink-play-sound'}" Pressed="True" />
|
||||
<Control HorizontalExpand="True" MinWidth="5" />
|
||||
<Button Visible="True" Name="PopOut" Access="Public" Text="{Loc 'admin-logs-pop-out'}" StyleClasses="OpenBoth" HorizontalAlignment="Left" />
|
||||
<Control HorizontalExpand="True" />
|
||||
<Button Visible="False" Name="Bans" Text="{Loc 'admin-player-actions-bans'}" StyleClasses="OpenRight" />
|
||||
|
||||
@@ -133,7 +133,7 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
|
||||
{
|
||||
return;
|
||||
}
|
||||
if (localPlayer.UserId != message.TrueSender)
|
||||
if (message.PlaySound && localPlayer.UserId != message.TrueSender)
|
||||
{
|
||||
if (_aHelpSound != null)
|
||||
_audio.PlayGlobal(_aHelpSound, Filter.Local(), false);
|
||||
@@ -173,7 +173,7 @@ public sealed class AHelpUIController: UIController, IOnSystemChanged<BwoinkSyst
|
||||
UIHelper = isAdmin ? new AdminAHelpUIHandler(ownerUserId) : new UserAHelpUIHandler(ownerUserId);
|
||||
UIHelper.DiscordRelayChanged(_discordRelayActive);
|
||||
|
||||
UIHelper.SendMessageAction = (userId, textMessage) => _bwoinkSystem?.Send(userId, textMessage);
|
||||
UIHelper.SendMessageAction = (userId, textMessage, playSound) => _bwoinkSystem?.Send(userId, textMessage, playSound);
|
||||
UIHelper.InputTextChanged += (channel, text) => _bwoinkSystem?.SendInputTextUpdated(channel, text.Length > 0);
|
||||
UIHelper.OnClose += () => { SetAHelpPressed(false); };
|
||||
UIHelper.OnOpen += () => { SetAHelpPressed(true); };
|
||||
@@ -322,7 +322,7 @@ public interface IAHelpUIHandler : IDisposable
|
||||
public void PeopleTypingUpdated(BwoinkPlayerTypingUpdated args);
|
||||
public event Action OnClose;
|
||||
public event Action OnOpen;
|
||||
public Action<NetUserId, string>? SendMessageAction { get; set; }
|
||||
public Action<NetUserId, string, bool>? SendMessageAction { get; set; }
|
||||
public event Action<NetUserId, string>? InputTextChanged;
|
||||
}
|
||||
public sealed class AdminAHelpUIHandler : IAHelpUIHandler
|
||||
@@ -406,7 +406,7 @@ public sealed class AdminAHelpUIHandler : IAHelpUIHandler
|
||||
|
||||
public event Action? OnClose;
|
||||
public event Action? OnOpen;
|
||||
public Action<NetUserId, string>? SendMessageAction { get; set; }
|
||||
public Action<NetUserId, string, bool>? SendMessageAction { get; set; }
|
||||
public event Action<NetUserId, string>? InputTextChanged;
|
||||
|
||||
public void Open(NetUserId channelId, bool relayActive)
|
||||
@@ -460,7 +460,7 @@ public sealed class AdminAHelpUIHandler : IAHelpUIHandler
|
||||
if (_activePanelMap.TryGetValue(channelId, out var existingPanel))
|
||||
return existingPanel;
|
||||
|
||||
_activePanelMap[channelId] = existingPanel = new BwoinkPanel(text => SendMessageAction?.Invoke(channelId, text));
|
||||
_activePanelMap[channelId] = existingPanel = new BwoinkPanel(text => SendMessageAction?.Invoke(channelId, text, Window?.Bwoink.PlaySound.Pressed ?? true));
|
||||
existingPanel.InputTextChanged += text => InputTextChanged?.Invoke(channelId, text);
|
||||
existingPanel.Visible = false;
|
||||
if (!Control!.BwoinkArea.Children.Contains(existingPanel))
|
||||
@@ -546,7 +546,7 @@ public sealed class UserAHelpUIHandler : IAHelpUIHandler
|
||||
|
||||
public event Action? OnClose;
|
||||
public event Action? OnOpen;
|
||||
public Action<NetUserId, string>? SendMessageAction { get; set; }
|
||||
public Action<NetUserId, string, bool>? SendMessageAction { get; set; }
|
||||
public event Action<NetUserId, string>? InputTextChanged;
|
||||
|
||||
public void Open(NetUserId channelId, bool relayActive)
|
||||
@@ -559,7 +559,7 @@ public sealed class UserAHelpUIHandler : IAHelpUIHandler
|
||||
{
|
||||
if (_window is { Disposed: false })
|
||||
return;
|
||||
_chatPanel = new BwoinkPanel(text => SendMessageAction?.Invoke(_ownerId, text));
|
||||
_chatPanel = new BwoinkPanel(text => SendMessageAction?.Invoke(_ownerId, text, true));
|
||||
_chatPanel.InputTextChanged += text => InputTextChanged?.Invoke(_ownerId, text);
|
||||
_chatPanel.RelayedToDiscordLabel.Visible = relayActive;
|
||||
_window = new DefaultWindow()
|
||||
|
||||
Reference in New Issue
Block a user