diff --git a/Content.Client/DeltaV/FeedbackPopup/FeedbackPopupSystem.cs b/Content.Client/DeltaV/FeedbackPopup/FeedbackPopupSystem.cs new file mode 100644 index 00000000000..f5f0de53f60 --- /dev/null +++ b/Content.Client/DeltaV/FeedbackPopup/FeedbackPopupSystem.cs @@ -0,0 +1,29 @@ +using Content.Shared.DeltaV.FeedbackOverwatch; +using Robust.Shared.Configuration; + +namespace Content.Client.DeltaV.FeedbackPopup; + +/// +/// This handles getting feedback popup messages from the server and making a popup in the client. +/// Currently, this system can only support one window at a time. +/// +public sealed class FeedbackPopupSystem : EntitySystem +{ + private FeedbackPopupWindow? _window; + + public override void Initialize() + { + base.Initialize(); + SubscribeNetworkEvent(OnFeedbackPopup); + } + + private void OnFeedbackPopup(FeedbackPopupMessage msg) + { + // If a window is already open, close it + _window?.Close(); + + _window = new FeedbackPopupWindow(msg.FeedbackPrototype); + _window.OpenCentered(); + _window.OnClose += () => _window = null; + } +} diff --git a/Content.Client/DeltaV/FeedbackPopup/FeedbackPopupWindow.xaml b/Content.Client/DeltaV/FeedbackPopup/FeedbackPopupWindow.xaml new file mode 100644 index 00000000000..a2860ea4145 --- /dev/null +++ b/Content.Client/DeltaV/FeedbackPopup/FeedbackPopupWindow.xaml @@ -0,0 +1,11 @@ + + + + + + + diff --git a/Content.Client/DeltaV/FeedbackPopup/FeedbackPopupWindow.xaml.cs b/Content.Client/DeltaV/FeedbackPopup/FeedbackPopupWindow.xaml.cs new file mode 100644 index 00000000000..f86637f9933 --- /dev/null +++ b/Content.Client/DeltaV/FeedbackPopup/FeedbackPopupWindow.xaml.cs @@ -0,0 +1,78 @@ +using Content.Client.UserInterface.Controls; +using Content.Shared.DeltaV.FeedbackOverwatch; +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.DeltaV.FeedbackPopup; + +[GenerateTypedNameReferences] +public sealed partial class FeedbackPopupWindow : FancyWindow +{ + [Dependency] private readonly IPrototypeManager _proto = default!; + private readonly IUriOpener _uri; + + private readonly FeedbackPopupPrototype _feedbackpopup; + public FeedbackPopupWindow(ProtoId popupProto) + { + RobustXamlLoader.Load(this); + IoCManager.InjectDependencies(this); + _uri = IoCManager.Resolve(); + + _feedbackpopup = _proto.Index(popupProto); + PopulateWindow(); + } + + private void PopulateWindow() + { + // Title + TitleLabel.Text = _feedbackpopup.Title; + + // Description + foreach (var section in _feedbackpopup.Description) + CreateSection(section); + + // Feedback location + if (_feedbackpopup.FeedbackLocation != null) + { + var label = new RichTextLabel + { + Text = _feedbackpopup.FeedbackLocation, + Margin = new Thickness(0,0,0,10), + HorizontalAlignment = HAlignment.Center, + }; + + FeedbackLocationContainer.AddChild(label); + } + + // Discord link button + if (_feedbackpopup.DiscordLink != null && _feedbackpopup.DiscordLink.StartsWith("https://discord.com/")) + { + var button = new Button + { + Text = Loc.GetString("feedbackpopup-discord-button-name"), + }; + button.OnPressed += OnButtonPressed; + FeedbackLocationContainer.AddChild(button); + } + } + + private void CreateSection(string text) + { + var label = new RichTextLabel + { + Text = text, + Margin = new Thickness(0,0,0,10), + }; + SectionContainer.AddChild(label); + } + + private void OnButtonPressed(BaseButton.ButtonEventArgs args) + { + if (_feedbackpopup.DiscordLink != null) + _uri.OpenUri(_feedbackpopup.DiscordLink); + } +} + diff --git a/Content.Shared/DeltaV/FeedbackOverwatch/FeedbackOverwatchEvents.cs b/Content.Shared/DeltaV/FeedbackOverwatch/FeedbackOverwatchEvents.cs new file mode 100644 index 00000000000..099471bdd83 --- /dev/null +++ b/Content.Shared/DeltaV/FeedbackOverwatch/FeedbackOverwatchEvents.cs @@ -0,0 +1,18 @@ +using Robust.Shared.Prototypes; +using Robust.Shared.Serialization; + +namespace Content.Shared.DeltaV.FeedbackOverwatch; + +/// +/// When clients recieve this message a popup will appear on their screen with the contents from the given prototype. +/// +[Serializable, NetSerializable] +public sealed class FeedbackPopupMessage : EntityEventArgs +{ + public ProtoId FeedbackPrototype; + + public FeedbackPopupMessage(ProtoId feedbackPrototype) + { + FeedbackPrototype = feedbackPrototype; + } +}; diff --git a/Content.Shared/DeltaV/FeedbackOverwatch/FeedbackPopupPrototype.cs b/Content.Shared/DeltaV/FeedbackOverwatch/FeedbackPopupPrototype.cs new file mode 100644 index 00000000000..1f35cc2725f --- /dev/null +++ b/Content.Shared/DeltaV/FeedbackOverwatch/FeedbackPopupPrototype.cs @@ -0,0 +1,42 @@ +using Robust.Shared.Prototypes; + +namespace Content.Shared.DeltaV.FeedbackOverwatch; + +/// +/// Prototype that describes the contents of a feedback popup. +/// +[Prototype] +public sealed partial class FeedbackPopupPrototype : IPrototype +{ + /// + [IdDataField] + public string ID { get; } = default!; + + /// + /// Title of the popup. This supports rich text so you can use colors and stuff. + /// + [DataField(required: true)] + public string Title = ""; + + /// + /// List of "paragraphs" that are placed in the middle of the popup. Put the any relavent information about + /// what to give feedback on here! + /// + [DataField(required: true)] + public List Description = new(); + + /// + /// Describe where you want to put the feedback here. + /// + [DataField] + public string? FeedbackLocation; + + /// + /// Link to the discord channel that will be linked when the button is clicked. + /// + /// + /// Must start with "https://discord.com/". + /// + [DataField] + public string? DiscordLink; +} diff --git a/Content.Shared/DeltaV/FeedbackOverwatch/SharedFeedbackOverwatchSystem.Events.cs b/Content.Shared/DeltaV/FeedbackOverwatch/SharedFeedbackOverwatchSystem.Events.cs new file mode 100644 index 00000000000..033255c7673 --- /dev/null +++ b/Content.Shared/DeltaV/FeedbackOverwatch/SharedFeedbackOverwatchSystem.Events.cs @@ -0,0 +1,9 @@ +namespace Content.Shared.DeltaV.FeedbackOverwatch; + +public sealed partial class SharedFeedbackOverwatchSystem +{ + public override void Initialize() + { + // Subscribe to events that would be good for popups here. + } +} diff --git a/Content.Shared/DeltaV/FeedbackOverwatch/SharedFeedbackOverwatchSystem.cs b/Content.Shared/DeltaV/FeedbackOverwatch/SharedFeedbackOverwatchSystem.cs new file mode 100644 index 00000000000..250369cfa78 --- /dev/null +++ b/Content.Shared/DeltaV/FeedbackOverwatch/SharedFeedbackOverwatchSystem.cs @@ -0,0 +1,42 @@ +using Content.Shared.Mind; +using Robust.Shared.Prototypes; + +namespace Content.Shared.DeltaV.FeedbackOverwatch; + +public sealed partial class SharedFeedbackOverwatchSystem : EntitySystem +{ + [Dependency] private readonly SharedMindSystem _mind = default!; + + /// + /// Send a popup to the given client controlling the given UID. + /// + /// UID of the entity the player is controlling. + /// Popup to send them. + public void SendPopup(EntityUid? uid, ProtoId popupPrototype) + { + if (uid == null) + return; + + if (!_mind.TryGetMind(uid.Value, out var mindUid, out _)) + return; + + SendPopupMind(mindUid, popupPrototype); + } + + /// + /// Send a popup to the given client controlling the given mind. + /// + /// UID of the players mind. + /// Popup to send them. + public void SendPopupMind(EntityUid? uid, ProtoId popupPrototype) + { + if (uid == null) + return; + + if (!_mind.TryGetSession(uid, out var session)) + return; + + var msg = new FeedbackPopupMessage(popupPrototype); + RaiseNetworkEvent(msg, session); + } +} diff --git a/Resources/Locale/en-US/deltav/feedbackpopup/feedbackpopup.ftl b/Resources/Locale/en-US/deltav/feedbackpopup/feedbackpopup.ftl new file mode 100644 index 00000000000..3acd9cda6d6 --- /dev/null +++ b/Resources/Locale/en-US/deltav/feedbackpopup/feedbackpopup.ftl @@ -0,0 +1,2 @@ +feedbackpopup-window-name = Feedback popup +feedbackpopup-discord-button-name = Click here to go to discord channel diff --git a/Resources/Prototypes/DeltaV/FeedbackPopup/feedbackpopups.yml b/Resources/Prototypes/DeltaV/FeedbackPopup/feedbackpopups.yml new file mode 100644 index 00000000000..e1784f3adce --- /dev/null +++ b/Resources/Prototypes/DeltaV/FeedbackPopup/feedbackpopups.yml @@ -0,0 +1,11 @@ +# Example +- type: feedbackPopup + id: ExampleFeedbackPopup + title: "[color=red]FEEDBACK[/color] on new popup system." + description: + - "This is a new system to get feedback on features. It will give popups!" + - "It also supports multiple sections if it looks better." + feedbackLocation: "Please go to the [color=red]#general[/color] channel to give your feedback!" + discordLink: "https://discord.com/channels/968983104247185448/968983104662409244" + +# Popups