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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user