Add PopupPredictedCursor and fix doubled popups on vending machines (#36655)

* Add PopupCursorPredicted method

* Fix doubled popups on vending machine restock failures

* Rename to match existing pattern
This commit is contained in:
Tayrtahn
2025-04-18 00:01:46 -04:00
committed by GitHub
parent 725522c183
commit e00e2ba407
4 changed files with 35 additions and 3 deletions

View 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);

View 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)

View 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);

View 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;