mirror of
https://github.com/DeltaV-Station/Delta-v.git
synced 2026-10-02 17:17:25 +00:00
* Commit * add the form post * dv * fixes * Change wording * Address review * wording change * Added some stuff * New format * bruh * thanks perry! * yes * More fixes! * typo * Add a command to show the list, improve the UI slightly, split up command names * Fix UI controller * Add better comment * Get rid of weird recursive thing * Cleanup * Work on moving feedback popups out of simulation * Move round end screen subscription to feedback ui controller * Finish moving feedback popups out of simulation * Fix _ as parameter * Clean up FeedbackPopupUIController * Clean up commands * Fix prototype yaml * Fix openfeedbackpopup command description * Update Resources/Locale/en-US/feedbackpopup/feedbackpopup.ftl Co-authored-by: Simon <63975668+Simyon264@users.noreply.github.com> * Apply suggestions from code review Co-authored-by: Simon <63975668+Simyon264@users.noreply.github.com> * Address reviews * Address reviews * Fix FeedbackPopupPrototype.cs using empty string instead of string.empty * Address some more of the reviews, style nano is still trolling sadly * Fix feedback popup styling * Fix PopupPrototype ID field not having a setter * Address reviews * Add label when no feedback entries are present Change link button to not show when no link is set --------- Co-authored-by: beck-thompson <beck314159@hotmail.com> Co-authored-by: SlamBamActionman <slambamactionman@gmail.com> Co-authored-by: Simon <63975668+Simyon264@users.noreply.github.com> # Conflicts: # Content.Client/Stylesheets/StyleNano.cs
76 lines
2.2 KiB
C#
76 lines
2.2 KiB
C#
using Content.Shared.FeedbackSystem;
|
|
using Content.Shared.GameTicking;
|
|
using Robust.Client.UserInterface.Controllers;
|
|
using JetBrains.Annotations;
|
|
using Robust.Client.UserInterface;
|
|
using Robust.Shared.Prototypes;
|
|
|
|
namespace Content.Client.FeedbackPopup;
|
|
|
|
/// <summary>
|
|
/// This handles getting feedback popup messages from the server and making a popup in the client.
|
|
/// </summary>
|
|
[UsedImplicitly]
|
|
public sealed class FeedbackPopupUIController : UIController
|
|
{
|
|
[Dependency] private readonly ClientFeedbackManager _feedbackManager = null!;
|
|
[Dependency] private readonly IPrototypeManager _proto = null!;
|
|
[Dependency] private readonly IUriOpener _uri = null!;
|
|
|
|
private FeedbackPopupWindow _window = null!;
|
|
|
|
public override void Initialize()
|
|
{
|
|
_window = new FeedbackPopupWindow(_proto, _uri);
|
|
|
|
SubscribeLocalEvent<PrototypesReloadedEventArgs>(OnPrototypesReloaded);
|
|
SubscribeNetworkEvent<RoundEndMessageEvent>(OnRoundEnd);
|
|
|
|
_feedbackManager.DisplayedPopupsChanged += OnPopupsChanged;
|
|
}
|
|
|
|
public void ToggleWindow()
|
|
{
|
|
if (_window.IsOpen)
|
|
{
|
|
_window.Close();
|
|
}
|
|
else
|
|
{
|
|
_window.OpenCentered();
|
|
}
|
|
}
|
|
|
|
private void OnRoundEnd(RoundEndMessageEvent ev, EntitySessionEventArgs args)
|
|
{
|
|
// Add round end prototypes.
|
|
var roundEndPrototypes = _feedbackManager.GetOriginFeedbackPrototypes(true);
|
|
if (roundEndPrototypes.Count == 0)
|
|
return;
|
|
|
|
_feedbackManager.Display(roundEndPrototypes);
|
|
|
|
// Even if no new prototypes were added, we still want to open the window.
|
|
if (!_window.IsOpen)
|
|
_window.OpenCentered();
|
|
}
|
|
|
|
private void OnPopupsChanged(bool newPopups)
|
|
{
|
|
UpdateWindow(_feedbackManager.DisplayedPopups);
|
|
|
|
if (newPopups && !_window.IsOpen)
|
|
_window.OpenCentered();
|
|
}
|
|
|
|
private void OnPrototypesReloaded(PrototypesReloadedEventArgs ev)
|
|
{
|
|
UpdateWindow(_feedbackManager.DisplayedPopups);
|
|
}
|
|
|
|
private void UpdateWindow(IReadOnlyCollection<ProtoId<FeedbackPopupPrototype>> prototypes)
|
|
{
|
|
_window.Update(prototypes);
|
|
}
|
|
}
|