using Content.Shared.FeedbackSystem; using Robust.Client.AutoGenerated; using Robust.Client.UserInterface; using Robust.Client.UserInterface.Controls; using Robust.Client.UserInterface.XAML; using Robust.Shared.Prototypes; namespace Content.Client.FeedbackPopup; [GenerateTypedNameReferences] public sealed partial class FeedbackEntry : Control { private readonly IUriOpener _uri; private readonly FeedbackPopupPrototype? _prototype; public FeedbackEntry(ProtoId popupProto, IPrototypeManager proto, IUriOpener uri) { RobustXamlLoader.Load(this); _uri = uri; _prototype = proto.Index(popupProto); // Title TitleLabel.Text = _prototype.Title; DescriptionLabel.Text = _prototype.Description; TypeLabel.Text = _prototype.ResponseType; LinkButton.Visible = !string.IsNullOrEmpty(_prototype.ResponseLink); // link button if (!string.IsNullOrEmpty(_prototype.ResponseLink)) { LinkButton.OnPressed += OnButtonPressed; } } private void OnButtonPressed(BaseButton.ButtonEventArgs args) { if (!string.IsNullOrWhiteSpace(_prototype?.ResponseLink)) _uri.OpenUri(_prototype.ResponseLink); } protected override void Resized() { base.Resized(); // magic TitleLabel.SetWidth = Width - TitleLabel.Margin.SumHorizontal; TitleLabel.InvalidateArrange(); DescriptionLabel.SetWidth = Width - DescriptionLabel.Margin.SumHorizontal; DescriptionLabel.InvalidateArrange(); } }