Basic AHelp Panel, Ported & Fixed (#4776)
* Graft from https://github.com/space-wizards/space-station-14/pull/3049
* 'openahelp' command
* Add AHelp into escape menu
* Add a way to ahelp a player from the kick window
* bwoink: XAMLify, bugfix, etc.
* Rename the kick/bwoink window the Player Actions Panel
* Add the bwoink sound y'all know and love
adminhelp.ogg taken from d775e1ac80/sound/effects/adminhelp.ogg
(available in master, therefore see master license: "All assets including icons and sound are under a Creative Commons 3.0 BY-SA license unless otherwise indicated.")
"Changed the adminhelpsound to some creative commons sound I pinched. Until somebody can get a better one. I'm sick of MAAAAAAAAOOOOOOW."
Actual source is https://freesound.org/people/martian/sounds/19261/ (CC0)
The sound had been reversed and the volume altered.
* Actually play the bwoink sound on receiving an ahelp that you didn't send
This commit is contained in:
77
Content.Client/Administration/BwoinkSystem.cs
Normal file
77
Content.Client/Administration/BwoinkSystem.cs
Normal file
@@ -0,0 +1,77 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Client.Administration.UI;
|
||||
using Content.Shared.Administration;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Client.Player;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Player;
|
||||
using Robust.Shared.Audio;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.Administration
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class BwoinkSystem : SharedBwoinkSystem
|
||||
{
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
private readonly Dictionary<NetUserId, BwoinkWindow> _activeWindowMap = new();
|
||||
|
||||
protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySessionEventArgs eventArgs)
|
||||
{
|
||||
base.OnBwoinkTextMessage(message, eventArgs);
|
||||
LogBwoink(message);
|
||||
// Actual line
|
||||
var window = EnsureWindow(message.ChannelId);
|
||||
window.ReceiveLine(message.Text);
|
||||
// Play a sound if we didn't send it
|
||||
var localPlayer = _playerManager.LocalPlayer;
|
||||
if (localPlayer?.UserId != message.TrueSender)
|
||||
{
|
||||
SoundSystem.Play(Filter.Local(), "/Audio/Effects/adminhelp.ogg");
|
||||
}
|
||||
}
|
||||
|
||||
public BwoinkWindow EnsureWindow(NetUserId channelId)
|
||||
{
|
||||
if (_activeWindowMap.TryGetValue(channelId, out var existingWindow))
|
||||
{
|
||||
existingWindow.Open();
|
||||
return existingWindow;
|
||||
}
|
||||
string title;
|
||||
if (_playerManager.SessionsDict.TryGetValue(channelId, out var otherSession))
|
||||
{
|
||||
title = otherSession.Name;
|
||||
}
|
||||
else
|
||||
{
|
||||
title = channelId.ToString();
|
||||
}
|
||||
var window = new BwoinkWindow(channelId, title);
|
||||
_activeWindowMap[channelId] = window;
|
||||
window.Open();
|
||||
return window;
|
||||
}
|
||||
|
||||
public void EnsureWindowForLocalPlayer()
|
||||
{
|
||||
var localPlayer = _playerManager.LocalPlayer;
|
||||
if (localPlayer != null)
|
||||
EnsureWindow(localPlayer.UserId);
|
||||
}
|
||||
|
||||
public void Send(NetUserId channelId, string text)
|
||||
{
|
||||
// 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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
11
Content.Client/Administration/UI/BwoinkWindow.xaml
Normal file
11
Content.Client/Administration/UI/BwoinkWindow.xaml
Normal file
@@ -0,0 +1,11 @@
|
||||
<SS14Window
|
||||
xmlns="https://spacestation14.io"
|
||||
xmlns:adminTab="clr-namespace:Content.Client.Administration.UI.Tabs.AdminTab"
|
||||
xmlns:adminbusTab="clr-namespace:Content.Client.Administration.UI.Tabs.AdminbusTab"
|
||||
xmlns:atmosTab="clr-namespace:Content.Client.Administration.UI.Tabs.AtmosTab"
|
||||
xmlns:tabs="clr-namespace:Content.Client.Administration.UI.Tabs">
|
||||
<BoxContainer Orientation="Vertical">
|
||||
<OutputPanel Name="TextOutput" VerticalExpand="true" />
|
||||
<HistoryLineEdit Name="SenderLineEdit" />
|
||||
</BoxContainer>
|
||||
</SS14Window>
|
||||
65
Content.Client/Administration/UI/BwoinkWindow.xaml.cs
Normal file
65
Content.Client/Administration/UI/BwoinkWindow.xaml.cs
Normal file
@@ -0,0 +1,65 @@
|
||||
#nullable enable
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using Content.Client.UserInterface;
|
||||
using Content.Client.Administration;
|
||||
using Content.Shared;
|
||||
using Robust.Client.Credits;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.UserInterface;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.IoC;
|
||||
using Robust.Shared.Localization;
|
||||
using Robust.Shared.Maths;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.GameObjects;
|
||||
using YamlDotNet.RepresentationModel;
|
||||
|
||||
namespace Content.Client.Administration.UI
|
||||
{
|
||||
/// <summary>
|
||||
/// This window connects to a BwoinkSystem channel. BwoinkSystem manages the rest.
|
||||
/// </summary>
|
||||
[GenerateTypedNameReferences]
|
||||
public partial class BwoinkWindow : SS14Window
|
||||
{
|
||||
[Dependency] private readonly IEntitySystemManager _systemManager = default!;
|
||||
|
||||
private readonly NetUserId _channelId;
|
||||
|
||||
public BwoinkWindow(NetUserId channelId, string title)
|
||||
{
|
||||
RobustXamlLoader.Load(this);
|
||||
IoCManager.InjectDependencies(this);
|
||||
|
||||
Title = title;
|
||||
_channelId = channelId;
|
||||
|
||||
SenderLineEdit.OnTextEntered += Input_OnTextEntered;
|
||||
|
||||
MinSize = (650, 450);
|
||||
}
|
||||
|
||||
private void Input_OnTextEntered(LineEdit.LineEditEventArgs args)
|
||||
{
|
||||
if (!string.IsNullOrWhiteSpace(args.Text))
|
||||
{
|
||||
var bwoink = _systemManager.GetEntitySystem<BwoinkSystem>();
|
||||
bwoink.Send(_channelId, args.Text);
|
||||
}
|
||||
|
||||
SenderLineEdit.Clear();
|
||||
}
|
||||
|
||||
public void ReceiveLine(string text)
|
||||
{
|
||||
var formatted = new FormattedMessage(1);
|
||||
formatted.AddText(text);
|
||||
TextOutput.AddMessage(formatted);
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -7,7 +7,7 @@
|
||||
MinSize="50 50">
|
||||
<BoxContainer Orientation="Vertical">
|
||||
<GridContainer Columns="4">
|
||||
<cc:UICommandButton Command="kick" Text="{Loc Kick}" WindowType="{x:Type at:KickWindow}" />
|
||||
<cc:UICommandButton Command="kick" Text="{Loc admin-kick-window-title}" WindowType="{x:Type at:KickWindow}" />
|
||||
<cc:UICommandButton Command="ban" Text="{Loc Ban}" WindowType="{x:Type at:BanWindow}" />
|
||||
<cc:CommandButton Command="aghost" Text="{Loc Admin Ghost}" />
|
||||
<cc:UICommandButton Command="tpto" Text="{Loc Teleport}" WindowType="{x:Type at:TeleportWindow}" />
|
||||
|
||||
@@ -1,14 +1,17 @@
|
||||
<SS14Window
|
||||
xmlns="https://spacestation14.io"
|
||||
xmlns:cc="clr-namespace:Content.Client.Administration.UI.CustomControls"
|
||||
Title="{Loc Kick}" MinSize="425 272">
|
||||
Title="{Loc admin-kick-window-title}" MinSize="425 272">
|
||||
<BoxContainer Orientation="Vertical">
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Label Text="{Loc Reason}" MinWidth="100" />
|
||||
<Control MinWidth="50" />
|
||||
<LineEdit Name="ReasonLine" MinWidth="100" HorizontalExpand="True" />
|
||||
</BoxContainer>
|
||||
<cc:PlayerListControl Name="PlayerList" />
|
||||
<Button Name="SubmitButton" Text="{Loc Kick}" />
|
||||
<cc:PlayerListControl Name="PlayerList" VerticalExpand="True" />
|
||||
<BoxContainer Orientation="Horizontal">
|
||||
<Button Name="SubmitButton" Text="{Loc admin-kick-window-kick-text}" />
|
||||
<Button Name="SubmitAHButton" Text="{Loc admin-kick-window-ahelp-text}" />
|
||||
</BoxContainer>
|
||||
</BoxContainer>
|
||||
</SS14Window>
|
||||
|
||||
@@ -18,13 +18,16 @@ namespace Content.Client.Administration.UI.Tabs.AdminTab
|
||||
protected override void EnteredTree()
|
||||
{
|
||||
SubmitButton.OnPressed += SubmitButtonOnOnPressed;
|
||||
SubmitAHButton.OnPressed += SubmitAHButtonOnOnPressed;
|
||||
PlayerList.OnSelectionChanged += OnListOnOnSelectionChanged;
|
||||
}
|
||||
|
||||
private void OnListOnOnSelectionChanged(ICommonSession? obj)
|
||||
{
|
||||
_selectedSession = obj;
|
||||
SubmitButton.Disabled = _selectedSession == null;
|
||||
var disableButtons = _selectedSession == null;
|
||||
SubmitButton.Disabled = disableButtons;
|
||||
SubmitAHButton.Disabled = disableButtons;
|
||||
}
|
||||
|
||||
private void SubmitButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
||||
@@ -34,5 +37,13 @@ namespace Content.Client.Administration.UI.Tabs.AdminTab
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
|
||||
$"kick \"{_selectedSession.Name}\" \"{CommandParsing.Escape(ReasonLine.Text)}\"");
|
||||
}
|
||||
|
||||
private void SubmitAHButtonOnOnPressed(BaseButton.ButtonEventArgs obj)
|
||||
{
|
||||
if (_selectedSession == null)
|
||||
return;
|
||||
IoCManager.Resolve<IClientConsoleHost>().ExecuteCommand(
|
||||
$"openahelp \"{_selectedSession.UserId}\"");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
45
Content.Client/Commands/OpenAHelpCommand.cs
Normal file
45
Content.Client/Commands/OpenAHelpCommand.cs
Normal file
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using Content.Client.Administration;
|
||||
using Content.Shared.Body.Mechanism;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.GameObjects;
|
||||
using Robust.Shared.Console;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Containers;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Client.Commands
|
||||
{
|
||||
public class OpenAHelpCommand : IConsoleCommand
|
||||
{
|
||||
public string Command => "openahelp";
|
||||
public string Description => $"Opens AHelp channel for a given NetUserID, or your personal channel if none given.";
|
||||
public string Help => $"{Command} [<netuserid>]";
|
||||
|
||||
public void Execute(IConsoleShell shell, string argStr, string[] args)
|
||||
{
|
||||
if (args.Length >= 2)
|
||||
{
|
||||
shell.WriteLine(Help);
|
||||
return;
|
||||
}
|
||||
if (args.Length == 0)
|
||||
{
|
||||
EntitySystem.Get<BwoinkSystem>().EnsureWindowForLocalPlayer();
|
||||
}
|
||||
else
|
||||
{
|
||||
if (Guid.TryParse(args[0], out var guid))
|
||||
{
|
||||
EntitySystem.Get<BwoinkSystem>().EnsureWindow(new NetUserId(guid));
|
||||
}
|
||||
else
|
||||
{
|
||||
shell.WriteLine("Bad GUID!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -8,6 +8,7 @@
|
||||
<changelog:ChangelogButton />
|
||||
<ui:VoteCallMenuButton />
|
||||
<Button Name="OptionsButton" Text="{Loc 'ui-escape-options'}" />
|
||||
<Button Name="AHelpButton" Text="{Loc 'ui-escape-ahelp'}" />
|
||||
<Button Name="DisconnectButton" Text="{Loc 'ui-escape-disconnect'}" />
|
||||
<Button Name="QuitButton" Text="{Loc 'ui-escape-quit'}" />
|
||||
</BoxContainer>
|
||||
|
||||
@@ -1,8 +1,10 @@
|
||||
using Content.Client.Administration;
|
||||
using Robust.Client.AutoGenerated;
|
||||
using Robust.Client.Console;
|
||||
using Robust.Client.UserInterface.Controls;
|
||||
using Robust.Client.UserInterface.CustomControls;
|
||||
using Robust.Client.UserInterface.XAML;
|
||||
using Robust.Shared.GameObjects;
|
||||
|
||||
namespace Content.Client.EscapeMenu.UI
|
||||
{
|
||||
@@ -23,6 +25,7 @@ namespace Content.Client.EscapeMenu.UI
|
||||
|
||||
OptionsButton.OnPressed += OnOptionsButtonClicked;
|
||||
QuitButton.OnPressed += OnQuitButtonClicked;
|
||||
AHelpButton.OnPressed += OnAHelpButtonClicked;
|
||||
DisconnectButton.OnPressed += OnDisconnectButtonClicked;
|
||||
}
|
||||
|
||||
@@ -32,6 +35,13 @@ namespace Content.Client.EscapeMenu.UI
|
||||
Dispose();
|
||||
}
|
||||
|
||||
private void OnAHelpButtonClicked(BaseButton.ButtonEventArgs args)
|
||||
{
|
||||
_consoleHost.ExecuteCommand("openahelp");
|
||||
// Doing Dispose() here causes issues because you can't un-dispose the escape menu.
|
||||
// The other commands don't really suffer as much from it. Unsure if bug.
|
||||
}
|
||||
|
||||
private void OnDisconnectButtonClicked(BaseButton.ButtonEventArgs args)
|
||||
{
|
||||
_consoleHost.ExecuteCommand("disconnect");
|
||||
|
||||
54
Content.Server/Administration/BwoinkSystem.cs
Normal file
54
Content.Server/Administration/BwoinkSystem.cs
Normal file
@@ -0,0 +1,54 @@
|
||||
#nullable enable
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Content.Server.Administration.Managers;
|
||||
using Content.Shared.Administration;
|
||||
using JetBrains.Annotations;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components;
|
||||
using Robust.Shared.Map;
|
||||
using Robust.Shared.Players;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Server.Player;
|
||||
using Robust.Shared.IoC;
|
||||
|
||||
namespace Content.Server.Administration
|
||||
{
|
||||
[UsedImplicitly]
|
||||
public class BwoinkSystem : SharedBwoinkSystem
|
||||
{
|
||||
[Dependency] private readonly IPlayerManager _playerManager = default!;
|
||||
[Dependency] private readonly IAdminManager _adminManager = default!;
|
||||
|
||||
protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySessionEventArgs eventArgs)
|
||||
{
|
||||
base.OnBwoinkTextMessage(message, eventArgs);
|
||||
var senderSession = (IPlayerSession) eventArgs.SenderSession;
|
||||
|
||||
// TODO: Sanitize text?
|
||||
// Confirm that this person is actually allowed to send a message here.
|
||||
if ((senderSession.UserId != message.ChannelId) && (_adminManager.GetAdminData(senderSession) == null))
|
||||
{
|
||||
// Unauthorized bwoink (log?)
|
||||
return;
|
||||
}
|
||||
|
||||
var msg = new BwoinkTextMessage(message.ChannelId, senderSession.UserId, $"{senderSession.Name}: {message.Text}");
|
||||
|
||||
LogBwoink(msg);
|
||||
|
||||
var targets = _adminManager.ActiveAdmins.Select(p => p.ConnectedClient);
|
||||
|
||||
// Admins
|
||||
foreach (var channel in targets)
|
||||
RaiseNetworkEvent(msg, channel);
|
||||
|
||||
// And involved player
|
||||
if (_playerManager.TryGetSessionById(message.ChannelId, out var session))
|
||||
if (!targets.Contains(session.ConnectedClient))
|
||||
RaiseNetworkEvent(msg, session.ConnectedClient);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
51
Content.Shared/Administration/SharedBwoinkSystem.cs
Normal file
51
Content.Shared/Administration/SharedBwoinkSystem.cs
Normal file
@@ -0,0 +1,51 @@
|
||||
#nullable enable
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics.CodeAnalysis;
|
||||
using Robust.Shared.Network;
|
||||
using Robust.Shared.Serialization;
|
||||
using Robust.Shared.Utility;
|
||||
using Robust.Shared.GameObjects;
|
||||
using Robust.Shared.GameObjects.Components;
|
||||
using Robust.Shared.Log;
|
||||
|
||||
namespace Content.Shared.Administration
|
||||
{
|
||||
public abstract class SharedBwoinkSystem : EntitySystem
|
||||
{
|
||||
public override void Initialize()
|
||||
{
|
||||
base.Initialize();
|
||||
|
||||
SubscribeNetworkEvent<BwoinkTextMessage>(OnBwoinkTextMessage);
|
||||
}
|
||||
|
||||
protected virtual void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySessionEventArgs eventArgs)
|
||||
{
|
||||
// Specific side code in target.
|
||||
}
|
||||
|
||||
protected void LogBwoink(BwoinkTextMessage message)
|
||||
{
|
||||
Logger.InfoS("c.s.go.es.bwoink", $"@{message.ChannelId}: {message.Text}");
|
||||
}
|
||||
|
||||
[Serializable, NetSerializable]
|
||||
public sealed class BwoinkTextMessage : EntityEventArgs
|
||||
{
|
||||
public NetUserId ChannelId { get; }
|
||||
// This is ignored from the client.
|
||||
// It's checked by the client when receiving a message from the server for bwoink noises.
|
||||
// This could be a boolean "Incoming", but that would require making a second instance.
|
||||
public NetUserId TrueSender { get; }
|
||||
public string Text { get; }
|
||||
|
||||
public BwoinkTextMessage(NetUserId channelId, NetUserId trueSender, string text)
|
||||
{
|
||||
ChannelId = channelId;
|
||||
TrueSender = trueSender;
|
||||
Text = text;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
BIN
Resources/Audio/Effects/adminhelp.ogg
Normal file
BIN
Resources/Audio/Effects/adminhelp.ogg
Normal file
Binary file not shown.
@@ -2,3 +2,10 @@
|
||||
(https://taira-komori.jpn.org/freesounden.html)
|
||||
|
||||
smoke.ogg taken from https://github.com/tgstation/tgstation/blob/a5d362ce84e4f0c61026236d5ec84d3c81553664/sound/effects/smoke.ogg
|
||||
|
||||
adminhelp.ogg taken from https://github.com/tgstation/tgstation/blob/d775e1ac804eb9d0259573f5f29a18d320c97ef3/sound/effects/adminhelp.ogg
|
||||
(available in master, therefore see master license: "All assets including icons and sound are under a Creative Commons 3.0 BY-SA license unless otherwise indicated.")
|
||||
"Changed the adminhelpsound to some creative commons sound I pinched. Until somebody can get a better one. I'm sick of MAAAAAAAAOOOOOOW."
|
||||
Actual source is https://freesound.org/people/martian/sounds/19261/ (CC0)
|
||||
The sound had been reversed and the volume altered.
|
||||
|
||||
|
||||
@@ -0,0 +1,4 @@
|
||||
admin-kick-window-title = Player Actions Panel
|
||||
admin-kick-window-kick-text = Kick
|
||||
admin-kick-window-ahelp-text = AHelp
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
|
||||
ui-escape-title = Esc Menu
|
||||
ui-escape-options = Options
|
||||
ui-escape-ahelp = AHelp
|
||||
ui-escape-disconnect = Disconnect
|
||||
ui-escape-quit = Quit
|
||||
|
||||
|
||||
Reference in New Issue
Block a user