OnBwoinkTextMessageRecieved?.Invoke(this, message);
}
- public void Send(NetUserId channelId, string text, bool playSound)
+ public void Send(NetUserId channelId, string text, bool playSound, bool adminOnly)
{
// 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, playSound: playSound));
+ RaiseNetworkEvent(new BwoinkTextMessage(channelId, channelId, text, playSound: playSound, adminOnly: adminOnly));
SendInputTextUpdated(channelId, false);
}
<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" />
+ <CheckBox Name="AdminOnly" Access="Public" Text="{Loc 'admin-ahelp-admin-only'}" ToolTip="{Loc 'admin-ahelp-admin-only-tooltip'}" />
+ <Control HorizontalExpand="True" MinWidth="5" />
+ <CheckBox 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" />
_adminManager.AdminStatusUpdated += UpdateButtons;
UpdateButtons();
+ AdminOnly.OnToggled += args => PlaySound.Disabled = args.Pressed;
+
ChannelSelector.OnSelectionChanged += sel =>
{
_currentPlayer = sel;
UIHelper = isAdmin ? new AdminAHelpUIHandler(ownerUserId) : new UserAHelpUIHandler(ownerUserId);
UIHelper.DiscordRelayChanged(_discordRelayActive);
- UIHelper.SendMessageAction = (userId, textMessage, playSound) => _bwoinkSystem?.Send(userId, textMessage, playSound);
+ UIHelper.SendMessageAction = (userId, textMessage, playSound, adminOnly) => _bwoinkSystem?.Send(userId, textMessage, playSound, adminOnly);
UIHelper.InputTextChanged += (channel, text) => _bwoinkSystem?.SendInputTextUpdated(channel, text.Length > 0);
UIHelper.OnClose += () => { SetAHelpPressed(false); };
UIHelper.OnOpen += () => { SetAHelpPressed(true); };
public void PeopleTypingUpdated(BwoinkPlayerTypingUpdated args);
public event Action OnClose;
public event Action OnOpen;
- public Action<NetUserId, string, bool>? SendMessageAction { get; set; }
+ public Action<NetUserId, string, bool, bool>? SendMessageAction { get; set; }
public event Action<NetUserId, string>? InputTextChanged;
}
public sealed class AdminAHelpUIHandler : IAHelpUIHandler
public event Action? OnClose;
public event Action? OnOpen;
- public Action<NetUserId, string, bool>? SendMessageAction { get; set; }
+ public Action<NetUserId, string, bool, bool>? SendMessageAction { get; set; }
public event Action<NetUserId, string>? InputTextChanged;
public void Open(NetUserId channelId, bool relayActive)
if (_activePanelMap.TryGetValue(channelId, out var existingPanel))
return existingPanel;
- _activePanelMap[channelId] = existingPanel = new BwoinkPanel(text => SendMessageAction?.Invoke(channelId, text, Window?.Bwoink.PlaySound.Pressed ?? true));
+ _activePanelMap[channelId] = existingPanel = new BwoinkPanel(text => SendMessageAction?.Invoke(channelId, text, Window?.Bwoink.PlaySound.Pressed ?? true, Window?.Bwoink.AdminOnly.Pressed ?? false));
existingPanel.InputTextChanged += text => InputTextChanged?.Invoke(channelId, text);
existingPanel.Visible = false;
if (!Control!.BwoinkArea.Children.Contains(existingPanel))
public event Action? OnClose;
public event Action? OnOpen;
- public Action<NetUserId, string, bool>? SendMessageAction { get; set; }
+ public Action<NetUserId, string, bool, bool>? SendMessageAction { get; set; }
public event Action<NetUserId, string>? InputTextChanged;
public void Open(NetUserId channelId, bool relayActive)
{
if (_window is { Disposed: false })
return;
- _chatPanel = new BwoinkPanel(text => SendMessageAction?.Invoke(_ownerId, text, true));
+ _chatPanel = new BwoinkPanel(text => SendMessageAction?.Invoke(_ownerId, text, true, false));
_chatPanel.InputTextChanged += text => InputTextChanged?.Invoke(_ownerId, text);
_chatPanel.RelayedToDiscordLabel.Visible = relayActive;
_window = new DefaultWindow()
var personalChannel = senderSession.UserId == message.UserId;
var senderAdmin = _adminManager.GetAdminData(senderSession);
var senderAHelpAdmin = senderAdmin?.HasFlag(AdminFlags.Adminhelp) ?? false;
- var authorized = personalChannel || senderAHelpAdmin;
+ var authorized = personalChannel && !message.AdminOnly || senderAHelpAdmin;
if (!authorized)
{
// Unauthorized bwoink (log?)
bwoinkText = $"{senderSession.Name}";
}
- bwoinkText = $"{(message.PlaySound ? "" : "(S) ")}{bwoinkText}: {escapedText}";
+ bwoinkText = $"{(message.AdminOnly ? Loc.GetString("bwoink-message-admin-only") : !message.PlaySound ? Loc.GetString("bwoink-message-silent") : "")} {bwoinkText}: {escapedText}";
- // If it's not an admin / admin chooses to keep the sound then play it.
- var playSound = !senderAHelpAdmin || message.PlaySound;
- var msg = new BwoinkTextMessage(message.UserId, senderSession.UserId, bwoinkText, playSound: playSound);
+ // If it's not an admin / admin chooses to keep the sound and message is not an admin only message, then play it.
+ var playSound = (!senderAHelpAdmin || message.PlaySound) && !message.AdminOnly;
+ var msg = new BwoinkTextMessage(message.UserId, senderSession.UserId, bwoinkText, playSound: playSound, adminOnly: message.AdminOnly);
LogBwoink(msg);
}
// Notify player
- if (_playerManager.TryGetSessionById(message.UserId, out var session))
+ if (_playerManager.TryGetSessionById(message.UserId, out var session) && !message.AdminOnly)
{
if (!admins.Contains(session.Channel))
{
public bool PlaySound { get; }
- public BwoinkTextMessage(NetUserId userId, NetUserId trueSender, string text, DateTime? sentAt = default, bool playSound = true)
+ public readonly bool AdminOnly;
+
+ public BwoinkTextMessage(NetUserId userId, NetUserId trueSender, string text, DateTime? sentAt = default, bool playSound = true, bool adminOnly = false)
{
SentAt = sentAt ?? DateTime.Now;
UserId = userId;
TrueSender = trueSender;
Text = text;
PlaySound = playSound;
+ AdminOnly = adminOnly;
}
}
}
*[other] are
} typing...
+admin-ahelp-admin-only = Admin Only
+admin-ahelp-admin-only-tooltip = If checked, then the message won't be visible for the player,
+ but will be visible for other admins and still will be Discord relayed.
+
admin-bwoink-play-sound = Bwoink?
bwoink-title-none-selected = None selected
bwoink-system-player-disconnecting = has disconnected.
bwoink-system-player-reconnecting = has reconnected.
bwoink-system-player-banned = has been banned for: {$banReason}
+
+bwoink-message-admin-only = (Admin Only)
+bwoink-message-silent = (S)