CatStation/Content.Client/FeedbackPopup/FeedbackPopupWindow.xaml.cs

49 lines
1.4 KiB
C#

using Content.Client.UserInterface.Controls;
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 FeedbackPopupWindow : FancyWindow
{
private readonly IPrototypeManager _proto;
private readonly IUriOpener _uri;
public FeedbackPopupWindow(IPrototypeManager proto, IUriOpener uri)
{
_proto = proto;
_uri = uri;
RobustXamlLoader.Load(this);
DisplayNoEntryLabel();
}
public void Update(IReadOnlyCollection<ProtoId<FeedbackPopupPrototype>> prototypes)
{
NotificationContainer.RemoveAllChildren();
if (prototypes.Count == 0)
DisplayNoEntryLabel();
foreach (var proto in prototypes)
{
NotificationContainer.AddChild(new FeedbackEntry(proto, _proto, _uri));
}
NumNotifications.Text = Loc.GetString("feedbackpopup-control-total-surveys", ("num", prototypes.Count));
}
private void DisplayNoEntryLabel()
{
NotificationContainer.AddChild(new Label()
{
Text = Loc.GetString("feedbackpopup-control-no-entries"),
HorizontalAlignment = HAlignment.Center,
VerticalAlignment = VAlignment.Center,
});
}
}