]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Add `PopupPredictedCursor` and fix doubled popups on vending machines (#36655)
authorTayrtahn <tayrtahn@gmail.com>
Fri, 18 Apr 2025 04:01:46 +0000 (00:01 -0400)
committerGitHub <noreply@github.com>
Fri, 18 Apr 2025 04:01:46 +0000 (14:01 +1000)
* Add PopupCursorPredicted method

* Fix doubled popups on vending machine restock failures

* Rename to match existing pattern

Content.Client/Popups/PopupSystem.cs
Content.Server/Popups/PopupSystem.cs
Content.Shared/Popups/SharedPopupSystem.cs
Content.Shared/VendingMachines/SharedVendingMachineSystem.Restock.cs

index b0a3d9b21ed46d4855ae5eef31dd07652b3f2d26..725568344d55071ffef7b2cafdbad9b65753c5da 100644 (file)
@@ -173,6 +173,16 @@ namespace Content.Client.Popups
                 PopupCursor(message, type);
         }
 
+        public override void PopupPredictedCursor(string? message, ICommonSession recipient, PopupType type = PopupType.Small)
+        {
+            PopupCursor(message, recipient, type);
+        }
+
+        public override void PopupPredictedCursor(string? message, EntityUid recipient, PopupType type = PopupType.Small)
+        {
+            PopupCursor(message, recipient, type);
+        }
+
         public override void PopupCoordinates(string? message, EntityCoordinates coordinates, Filter filter, bool replayRecord, PopupType type = PopupType.Small)
         {
             PopupCoordinates(message, coordinates, type);
index 9338d81b924db4db2cb4edecf0d5211d97dc7ca4..aec4dbbfb3e0acc69099a14377002929b315f08b 100644 (file)
@@ -35,6 +35,16 @@ namespace Content.Server.Popups
                 RaiseNetworkEvent(new PopupCursorEvent(message, type), actor.PlayerSession);
         }
 
+        public override void PopupPredictedCursor(string? message, ICommonSession recipient, PopupType type = PopupType.Small)
+        {
+            // Do nothing, since the client already predicted the popup.
+        }
+
+        public override void PopupPredictedCursor(string? message, EntityUid recipient, PopupType type = PopupType.Small)
+        {
+            // Do nothing, since the client already predicted the popup.
+        }
+
         public override void PopupCoordinates(string? message, EntityCoordinates coordinates, Filter filter, bool replayRecord, PopupType type = PopupType.Small)
         {
             if (message == null)
index 66f901c59f67ef6247033e2651342720e4b82dd6..b57ed6659e825f48e19c17d37c79dbbf7458eaaf 100644 (file)
@@ -32,6 +32,18 @@ namespace Content.Shared.Popups
         /// <param name="type">Used to customize how this popup should appear visually.</param>
         public abstract void PopupCursor(string? message, EntityUid recipient, PopupType type = PopupType.Small);
 
+        /// <summary>
+        /// Variant of <see cref="PopupCursor(string?, ICommonSession, PopupType)"/> for use with prediction.
+        /// The local client will show the popup to the recipient. Does nothing on the server.
+        /// </summary>
+        public abstract void PopupPredictedCursor(string? message, ICommonSession recipient, PopupType type = PopupType.Small);
+
+        /// <summary>
+        /// Variant of <see cref="PopupCursor(string?, EntityUid, PopupType)"/> for use with prediction.
+        /// The local client will show the popup to the recipient. Does nothing on the server.
+        /// </summary>
+        public abstract void PopupPredictedCursor(string? message, EntityUid recipient, PopupType type = PopupType.Small);
+
         /// <summary>
         ///     Shows a popup at a world location to every entity in PVS range.
         /// </summary>
@@ -60,7 +72,7 @@ namespace Content.Shared.Popups
 
         /// <summary>
         ///    Variant of <see cref="PopupCoordinates(string, EntityCoordinates, PopupType)"/> for use with prediction. The local client will
-        ///    the popup to the recipient, and the server will show it to every other player in PVS range. If recipient is null, the local 
+        ///    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 will do nothing and the server will show the message to every player in PVS range.
         /// </summary>
         public abstract void PopupPredictedCoordinates(string? message, EntityCoordinates coordinates, EntityUid? recipient, PopupType type = PopupType.Small);
index 20c8f1195a3b61f9b1da363e1c78d33c95dbf3db..00355dedff83131656cc65869fa50299c4154905 100644 (file)
@@ -17,7 +17,7 @@ public abstract partial class SharedVendingMachineSystem
     {
         if (!TryComp<WiresPanelComponent>(target, out var panel) || !panel.Open)
         {
-            Popup.PopupCursor(Loc.GetString("vending-machine-restock-needs-panel-open",
+            Popup.PopupPredictedCursor(Loc.GetString("vending-machine-restock-needs-panel-open",
                     ("this", uid),
                     ("user", user),
                     ("target", target)),
@@ -37,7 +37,7 @@ public abstract partial class SharedVendingMachineSystem
     {
         if (!component.CanRestock.Contains(machineComponent.PackPrototypeId))
         {
-            Popup.PopupCursor(Loc.GetString("vending-machine-restock-invalid-inventory", ("this", uid), ("user", user),
+            Popup.PopupPredictedCursor(Loc.GetString("vending-machine-restock-invalid-inventory", ("this", uid), ("user", user),
                 ("target", target)), user);
 
             return false;