Files
tbd-station-14/Content.Client/Administration/UI/BwoinkWindow.xaml.cs
E F R b2da936848 Everything: Rich text redux (#5625)
* lord save me

* UI/ChatBox: Use the new `defStyle` param for `RenderMarkup`

The previous iteration didn't work because `AddMessage` can't inherit
its color from the PushColor (since we're not doing actual tag stacks
anymore).

* rebase touchup
2021-12-12 18:25:42 -08:00

66 lines
2.0 KiB
C#

#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.Player;
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 Robust.Shared.Utility.Markup;
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!;
[Dependency] private readonly IPlayerManager _playerManager = default!;
private readonly NetUserId _channelId;
public BwoinkWindow(NetUserId channelId, string title)
{
RobustXamlLoader.Load(this);
IoCManager.InjectDependencies(this);
_channelId = channelId;
Title = (_playerManager.LocalPlayer?.UserId == _channelId) ? "Admin Message" : title;
SenderLineEdit.OnTextEntered += Input_OnTextEntered;
}
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)
{
TextOutput.AddMessage(Basic.RenderMarkup(text));
}
}
}