* #272 restructure and restyle chat line edit section * #272 no arrow, actually change id on channel changer * #272 nice round chat channel picker * #272 add chat channel selection logic, and auto-select when a prefix is entered * #272 consistent width of chat channel btn * #272 only show admin channel filter if asay perms * #272 add tutorial info on chat prefixes * #272 added chat filter button * #272 added chat filter button * #272 WIP on filter popup * #272 fix filter popup pressed / unpressed logic * #272 fix filter popup positioning and layout * #272 WIP channel filter logic * #272 WIP channel filter logic * #272 WIP refactoring how chatbox / manager manages available filters and channels to send on * #272 WIP implementing filtering UI / logic and refactoring how chat UI is managed * #272 fix various bugs with new chat filter / selector logic * #272 remove outdated todos * #272 WIP working chat window resize * #272 bounded chatbox resizing * #272 alertUI moves with resized chat * #272 WIP making alertUI not be too large when changing size / UIScale * #272 WIP fixing window / uiscale adjustment * #272 WIP hacky approach for resizing, will try another approach * #272 implement hacky approach for bounded chat resize * #272 no resizing of lobby chat * #272 WIP adding unread marker to chat filters * #272 basic working unread chat message indicators * #272 WIP adding horizontal channel selector items * #272 horizontal channel selector popup * #272 workaround for chat selector staying highlighted when right clicking it while toggled * #272 workaround for chat selector staying highlighted when right clicking it while toggled * #272 wip trying to add tests for chatbox * #272 remove test, not really possible with current system * #272 merge latest * #272 merge latest * #272 fix csproj changes * It works if you disable the lobby * Fixes lobby chat * Adds more channel focusses * Channel cycler * Address review * Address nitpicks * Address more of the review * Fix chat post-viewport * Finalize review stuff Co-authored-by: chairbender <kwhipke1@gmail.com> Co-authored-by: ike709 <sparebytes@protonmail.com>
96 lines
3.2 KiB
C#
96 lines
3.2 KiB
C#
using System.Collections.Generic;
|
|
using Content.Server.GameObjects.EntitySystems;
|
|
using Content.Server.Interfaces;
|
|
using Content.Shared.Chat;
|
|
using Content.Shared.GameObjects.EntitySystems;
|
|
using Robust.Server.GameObjects;
|
|
using Robust.Shared.Containers;
|
|
using Robust.Shared.GameObjects;
|
|
using Robust.Shared.IoC;
|
|
using Robust.Shared.Localization;
|
|
using Robust.Shared.Network;
|
|
using Robust.Shared.Serialization.Manager.Attributes;
|
|
using Robust.Shared.Utility;
|
|
using Robust.Shared.ViewVariables;
|
|
|
|
namespace Content.Server.GameObjects.Components.Headset
|
|
{
|
|
[RegisterComponent]
|
|
[ComponentReference(typeof(IRadio))]
|
|
[ComponentReference(typeof(IListen))]
|
|
public class HeadsetComponent : Component, IListen, IRadio, IExamine
|
|
{
|
|
[Dependency] private readonly IServerNetManager _netManager = default!;
|
|
|
|
public override string Name => "Headset";
|
|
|
|
private RadioSystem _radioSystem = default!;
|
|
|
|
[DataField("channels")]
|
|
private List<int> _channels = new(){1459};
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
[DataField("broadcastChannel")]
|
|
private int BroadcastFrequency { get; set; } = 1459;
|
|
|
|
[ViewVariables(VVAccess.ReadWrite)]
|
|
[DataField("listenRange")]
|
|
public int ListenRange { get; private set; }
|
|
|
|
public IReadOnlyList<int> Channels => _channels;
|
|
|
|
public bool RadioRequested { get; set; }
|
|
|
|
public override void Initialize()
|
|
{
|
|
base.Initialize();
|
|
|
|
_radioSystem = EntitySystem.Get<RadioSystem>();
|
|
}
|
|
|
|
public bool CanListen(string message, IEntity source)
|
|
{
|
|
return RadioRequested;
|
|
}
|
|
|
|
public void Receive(string message, int channel, IEntity source)
|
|
{
|
|
if (Owner.TryGetContainer(out var container))
|
|
{
|
|
if (!container.Owner.TryGetComponent(out IActorComponent? actor))
|
|
return;
|
|
|
|
var playerChannel = actor.playerSession.ConnectedClient;
|
|
|
|
var msg = _netManager.CreateNetMessage<MsgChatMessage>();
|
|
|
|
msg.Channel = ChatChannel.Radio;
|
|
msg.Message = message;
|
|
//Square brackets are added here to avoid issues with escaping
|
|
msg.MessageWrap = Loc.GetString("chat-radio-message-wrap", ("channel", $"[{channel}]"), ("name", source.Name));
|
|
_netManager.ServerSendMessage(msg, playerChannel);
|
|
}
|
|
}
|
|
|
|
public void Listen(string message, IEntity speaker)
|
|
{
|
|
Broadcast(message, speaker);
|
|
}
|
|
|
|
public void Broadcast(string message, IEntity speaker)
|
|
{
|
|
_radioSystem.SpreadMessage(this, speaker, message, BroadcastFrequency);
|
|
RadioRequested = false;
|
|
}
|
|
|
|
public void Examine(FormattedMessage message, bool inDetailsRange)
|
|
{
|
|
message.AddText(Loc.GetString("examine-radio-frequency", ("frequency", BroadcastFrequency)));
|
|
message.AddText("\n");
|
|
message.AddText(Loc.GetString("examine-headset"));
|
|
message.AddText("\n");
|
|
message.AddText(Loc.GetString("examine-headset-chat-prefix", ("prefix", ";")));
|
|
}
|
|
}
|
|
}
|