66 lines
2.0 KiB
C#
66 lines
2.0 KiB
C#
using Content.Client.UserInterface.Controls;
|
|
using Content.Shared._DV.FeedbackOverwatch;
|
|
using Robust.Client.AutoGenerated;
|
|
using Robust.Client.UserInterface.Controls;
|
|
using Robust.Client.UserInterface.XAML;
|
|
using Robust.Shared.Prototypes;
|
|
using Robust.Shared.Utility;
|
|
|
|
namespace Content.Client._DV.FeedbackPopup;
|
|
|
|
[GenerateTypedNameReferences]
|
|
public sealed partial class FeedbackPopupWindow : FancyWindow
|
|
{
|
|
[Dependency] private readonly IPrototypeManager _proto = default!;
|
|
|
|
private readonly FeedbackPopupPrototype _feedbackpopup;
|
|
|
|
public event Action<(LocId, string)>? OnSubmitted;
|
|
|
|
public FeedbackPopupWindow(ProtoId<FeedbackPopupPrototype> popupProto)
|
|
{
|
|
RobustXamlLoader.Load(this);
|
|
IoCManager.InjectDependencies(this);
|
|
|
|
// Save the proto so we can use it later.
|
|
_feedbackpopup = _proto.Index(popupProto);
|
|
|
|
// When the submit button is pressed, pass up the vars back to the UI controller.
|
|
SubmitButton.OnPressed += OnSubmitButtonPressed;
|
|
|
|
PopulateWindow();
|
|
}
|
|
|
|
private void PopulateWindow()
|
|
{
|
|
// Title
|
|
TitleLabel.Text = Loc.GetString(_feedbackpopup.Title);
|
|
|
|
// Description
|
|
foreach (var section in _feedbackpopup.Description)
|
|
CreateSection(Loc.GetString(section));
|
|
|
|
// Set the feedback submission to the correct visibility
|
|
FeedbackReplyContainer.Visible = _feedbackpopup.FeedbackField;
|
|
}
|
|
|
|
private void CreateSection(string text)
|
|
{
|
|
var label = new RichTextLabel
|
|
{
|
|
Text = text,
|
|
Margin = new Thickness(0,0,0,10),
|
|
};
|
|
SectionContainer.AddChild(label);
|
|
}
|
|
|
|
private void OnSubmitButtonPressed(BaseButton.ButtonEventArgs args)
|
|
{
|
|
// If they haven't written anything, ignore it.
|
|
if (string.IsNullOrWhiteSpace(Rope.Collapse(FeedbackReply.TextRope)))
|
|
return;
|
|
|
|
OnSubmitted?.Invoke((_feedbackpopup.PopupName, Rope.Collapse(FeedbackReply.TextRope)));
|
|
}
|
|
}
|