#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
{
///
/// This window connects to a BwoinkSystem channel. BwoinkSystem manages the rest.
///
[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();
bwoink.Send(_channelId, args.Text);
}
SenderLineEdit.Clear();
}
public void ReceiveLine(string text)
{
TextOutput.AddMessage(Basic.RenderMarkup(text));
}
}
}