From 81f2dc7cf90de43c6a854c28ae9243be1c8c7d4d Mon Sep 17 00:00:00 2001 From: DrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com> Date: Sun, 21 Apr 2024 20:57:13 -0700 Subject: [PATCH] Add SharedPopupSystem.PopupClient for cursor and coordinates (#27231) --- Content.Client/Popups/PopupSystem.cs | 19 ++++++++++++++++++- Content.Server/Popups/PopupSystem.cs | 8 ++++++++ Content.Shared/Popups/SharedPopupSystem.cs | 12 ++++++++++++ 3 files changed, 38 insertions(+), 1 deletion(-) diff --git a/Content.Client/Popups/PopupSystem.cs b/Content.Client/Popups/PopupSystem.cs index 3faa392e58..1ef8dfba2d 100644 --- a/Content.Client/Popups/PopupSystem.cs +++ b/Content.Client/Popups/PopupSystem.cs @@ -5,7 +5,6 @@ using Content.Shared.Popups; using Robust.Client.Graphics; using Robust.Client.Input; using Robust.Client.Player; -using Robust.Client.ResourceManagement; using Robust.Client.UserInterface; using Robust.Shared.Configuration; using Robust.Shared.Map; @@ -163,6 +162,15 @@ namespace Content.Client.Popups PopupEntity(message, uid, type); } + public override void PopupClient(string? message, EntityUid? recipient, PopupType type = PopupType.Small) + { + if (recipient == null) + return; + + if (_timing.IsFirstTimePredicted) + PopupCursor(message, recipient.Value, type); + } + public override void PopupClient(string? message, EntityUid uid, EntityUid? recipient, PopupType type = PopupType.Small) { if (recipient == null) @@ -172,6 +180,15 @@ namespace Content.Client.Popups PopupEntity(message, uid, recipient.Value, type); } + public override void PopupClient(string? message, EntityCoordinates coordinates, EntityUid? recipient, PopupType type = PopupType.Small) + { + if (recipient == null) + return; + + if (_timing.IsFirstTimePredicted) + PopupCoordinates(message, coordinates, recipient.Value, type); + } + public override void PopupEntity(string? message, EntityUid uid, PopupType type = PopupType.Small) { if (TryComp(uid, out TransformComponent? transform)) diff --git a/Content.Server/Popups/PopupSystem.cs b/Content.Server/Popups/PopupSystem.cs index d1163a2be1..4aa3d39224 100644 --- a/Content.Server/Popups/PopupSystem.cs +++ b/Content.Server/Popups/PopupSystem.cs @@ -88,11 +88,19 @@ namespace Content.Server.Popups RaiseNetworkEvent(new PopupEntityEvent(message, type, GetNetEntity(uid)), actor.PlayerSession); } + public override void PopupClient(string? message, EntityUid? recipient, PopupType type = PopupType.Small) + { + } + public override void PopupClient(string? message, EntityUid uid, EntityUid? recipient, PopupType type = PopupType.Small) { // do nothing duh its for client only } + public override void PopupClient(string? message, EntityCoordinates coordinates, EntityUid? recipient, PopupType type = PopupType.Small) + { + } + public override void PopupEntity(string? message, EntityUid uid, ICommonSession recipient, PopupType type = PopupType.Small) { if (message == null) diff --git a/Content.Shared/Popups/SharedPopupSystem.cs b/Content.Shared/Popups/SharedPopupSystem.cs index 10e8ca9be1..38d2030cd5 100644 --- a/Content.Shared/Popups/SharedPopupSystem.cs +++ b/Content.Shared/Popups/SharedPopupSystem.cs @@ -82,12 +82,24 @@ namespace Content.Shared.Popups /// public abstract void PopupEntity(string? message, EntityUid uid, Filter filter, bool recordReplay, PopupType type = PopupType.Small); + /// + /// Variant of that only runs on the client, outside of prediction. + /// Useful for shared code that is always ran by both sides to avoid duplicate popups. + /// + public abstract void PopupClient(string? message, EntityUid? recipient, PopupType type = PopupType.Small); + /// /// Variant of that only runs on the client, outside of prediction. /// Useful for shared code that is always ran by both sides to avoid duplicate popups. /// public abstract void PopupClient(string? message, EntityUid uid, EntityUid? recipient, PopupType type = PopupType.Small); + /// + /// Variant of that only runs on the client, outside of prediction. + /// Useful for shared code that is always ran by both sides to avoid duplicate popups. + /// + public abstract void PopupClient(string? message, EntityCoordinates coordinates, EntityUid? recipient, PopupType type = PopupType.Small); + /// /// Variant of for use with prediction. The local client will show /// the popup to the recipient, and the server will show it to every other player in PVS range. If recipient is null, the local client