]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add two-message overload to PopupPredicted (#26907)
authorTayrtahn <tayrtahn@gmail.com>
Sun, 14 Apr 2024 03:42:45 +0000 (23:42 -0400)
committerGitHub <noreply@github.com>
Sun, 14 Apr 2024 03:42:45 +0000 (13:42 +1000)
Added two-message overload to PopupPredicted

Content.Client/Popups/PopupSystem.cs
Content.Server/Popups/PopupSystem.cs
Content.Shared/Burial/BurialSystem.cs
Content.Shared/Climbing/Systems/BonkSystem.cs
Content.Shared/Climbing/Systems/ClimbSystem.cs
Content.Shared/Popups/SharedPopupSystem.cs
Content.Shared/Wieldable/WieldableSystem.cs

index fcc8bfc420a144c19edb1409ecf1f22aff0e638e..3faa392e58d5b26bb6612db5e2321bf28b9358d4 100644 (file)
@@ -184,6 +184,12 @@ namespace Content.Client.Popups
                 PopupEntity(message, uid, recipient.Value, type);
         }
 
+        public override void PopupPredicted(string? recipientMessage, string? othersMessage, EntityUid uid, EntityUid? recipient, PopupType type = PopupType.Small)
+        {
+            if (recipient != null && _timing.IsFirstTimePredicted)
+                PopupEntity(recipientMessage, uid, recipient.Value, type);
+        }
+
         #endregion
 
         #region Network Event Handlers
index 237ca33a4db4c16484bab6024930098875571ff2..d1163a2be1b8b9dfe4c0a7b823008ad03616cba8 100644 (file)
@@ -126,5 +126,10 @@ namespace Content.Server.Popups
                 RaiseNetworkEvent(new PopupEntityEvent(message, type, GetNetEntity(uid)));
             }
         }
+
+        public override void PopupPredicted(string? recipientMessage, string? othersMessage, EntityUid uid, EntityUid? recipient, PopupType type = PopupType.Small)
+        {
+            PopupPredicted(othersMessage, uid, recipient, type);
+        }
     }
 }
index ccf5f1a298f9555f86cbabbd5d0105fc2a64a4ce..326272cc7decd1ecddd6a908cddc80a81c9094ec 100644 (file)
@@ -116,8 +116,9 @@ public sealed class BurialSystem : EntitySystem
     {
         if (used != null)
         {
-            _popupSystem.PopupClient(Loc.GetString("grave-start-digging-user", ("grave", uid), ("tool", used)), user, user);
-            _popupSystem.PopupEntity(Loc.GetString("grave-start-digging-others", ("user", user), ("grave", uid), ("tool", used)), user, Filter.PvsExcept(user), true);
+            var selfMessage = Loc.GetString("grave-start-digging-user", ("grave", uid), ("tool", used));
+            var othersMessage = Loc.GetString("grave-start-digging-others", ("user", user), ("grave", uid), ("tool", used));
+            _popupSystem.PopupPredicted(selfMessage, othersMessage, user, user);
             component.ActiveShovelDigging = true;
             Dirty(uid, component);
         }
index 4fe2661aff950745364551674423f76e3cd6c005..ea4e04c621af74244c378ec135b5dc3e864d904b 100644 (file)
@@ -57,9 +57,11 @@ public sealed partial class BonkSystem : EntitySystem
         if (user == source)
         {
             // Non-local, non-bonking players
-            _popupSystem.PopupEntity(Loc.GetString("bonkable-success-message-others", ("user", userName), ("bonkable", bonkableName)), user, Filter.PvsExcept(user), true);
+            var othersMessage = Loc.GetString("bonkable-success-message-others", ("user", userName), ("bonkable", bonkableName));
             // Local, bonking player
-            _popupSystem.PopupClient(Loc.GetString("bonkable-success-message-user", ("user", userName), ("bonkable", bonkableName)), user, user);
+            var selfMessage = Loc.GetString("bonkable-success-message-user", ("user", userName), ("bonkable", bonkableName));
+
+            _popupSystem.PopupPredicted(selfMessage, othersMessage, user, user);
         }
         else if (source != null)
         {
index 5471f072501abebac4c4a9a50c6ce44e207d1c4a..1bdaecf730fe127772c34195411a876b7d2449e3 100644 (file)
@@ -307,8 +307,7 @@ public sealed partial class ClimbSystem : VirtualController
                 ("climbable", climbable));
         }
 
-        _popupSystem.PopupEntity(othersMessage, uid, Filter.PvsExcept(user, entityManager: EntityManager), true);
-        _popupSystem.PopupClient(selfMessage, uid, user);
+        _popupSystem.PopupPredicted(selfMessage, othersMessage, uid, user);
     }
 
     /// <summary>
index b199884afb48f001244c7193955b2d2abf619316..10e8ca9be11294a0fe1b3826a41232471dee0a98 100644 (file)
@@ -94,6 +94,12 @@ namespace Content.Shared.Popups
         /// will do nothing and the server will show the message to every player in PVS range.
         /// </summary>
         public abstract void PopupPredicted(string? message, EntityUid uid, EntityUid? recipient, PopupType type = PopupType.Small);
+
+        /// <summary>
+        /// Variant of <see cref="PopupPredicted(string?, EntityUid, EntityUid?, PopupType)"/> that displays <paramref name="recipientMessage"/>
+        /// to the recipient and <paramref name="othersMessage"/> to everyone else in PVS range.
+        /// </summary>
+        public abstract void PopupPredicted(string? recipientMessage, string? othersMessage, EntityUid uid, EntityUid? recipient, PopupType type = PopupType.Small);
     }
 
     /// <summary>
index 9fe76c625b8ffb616686a8860d098f8f11a9b118..2baed19ef85455e3ace6e34dfc2325b98077a123 100644 (file)
@@ -195,8 +195,9 @@ public sealed class WieldableSystem : EntitySystem
             && !_delay.TryResetDelay((used, useDelay), true))
             return false;
 
-        _popupSystem.PopupClient(Loc.GetString("wieldable-component-successful-wield", ("item", used)), user, user);
-        _popupSystem.PopupEntity(Loc.GetString("wieldable-component-successful-wield-other", ("user", user), ("item", used)), user, Filter.PvsExcept(user), true);
+        var selfMessage = Loc.GetString("wieldable-component-successful-wield", ("item", used));
+        var othersMessage = Loc.GetString("wieldable-component-successful-wield-other", ("user", user), ("item", used));
+        _popupSystem.PopupPredicted(selfMessage, othersMessage, user, user);
 
         var targEv = new ItemWieldedEvent();
         RaiseLocalEvent(used, ref targEv);
@@ -239,10 +240,9 @@ public sealed class WieldableSystem : EntitySystem
             if (component.UnwieldSound != null)
                 _audioSystem.PlayPredicted(component.UnwieldSound, uid, args.User);
 
-            _popupSystem.PopupClient(Loc.GetString("wieldable-component-failed-wield",
-                ("item", uid)), args.User.Value, args.User.Value);
-            _popupSystem.PopupEntity(Loc.GetString("wieldable-component-failed-wield-other",
-                ("user", args.User.Value), ("item", uid)), args.User.Value, Filter.PvsExcept(args.User.Value), true);
+            var selfMessage = Loc.GetString("wieldable-component-failed-wield", ("item", uid));
+            var othersMessage = Loc.GetString("wieldable-component-failed-wield-other", ("user", args.User.Value), ("item", uid));
+            _popupSystem.PopupPredicted(selfMessage, othersMessage, args.User.Value, args.User.Value);
         }
 
         _appearance.SetData(uid, WieldableVisuals.Wielded, false);