Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion RELEASE-NOTES.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ END TEMPLATE-->

### Breaking changes

*None yet*
* `BoundUserInterfaceMessageAttempt` is now a by-ref struct. It can no longer be assigned to `CancellableEntityEventArgs`.

### New features

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -144,20 +144,23 @@ public InterfaceData(InterfaceData data)
}

/// <summary>
/// Raised whenever the server receives a BUI message from a client relating to a UI that requires input
/// validation.
/// Raised whenever the server receives a BUI message from a client relating to a UI that requires input validation.
/// This is first broadcast then, if not cancelled already, raised directly on the BUI's owner.
/// </summary>
public sealed class BoundUserInterfaceMessageAttempt(
EntityUid actor,
EntityUid target,
Enum uiKey,
BoundUserInterfaceMessage message)
: CancellableEntityEventArgs
[ByRefEvent]
public record struct BoundUserInterfaceMessageAttempt(EntityUid Actor, EntityUid Target, Enum UiKey, BoundUserInterfaceMessage Message)
{
public readonly EntityUid Actor = actor;
public readonly EntityUid Target = target;
public readonly Enum UiKey = uiKey;
public readonly BoundUserInterfaceMessage Message = message;
public bool Cancelled { get; private set; }

public void Cancel()
{
Cancelled = true;
}

public void Uncancel()
{
Cancelled = false;
}
}

/// <summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,11 @@ private void OnMessageReceived(BoundUIWrapMessage msg, EntityUid sender)
{
var attempt = new BoundUserInterfaceMessageAttempt(sender, uid, msg.UiKey, msg.Message);

RaiseLocalEvent(attempt);
RaiseLocalEvent(ref attempt);
if (attempt.Cancelled)
return;

RaiseLocalEvent(uid, attempt);
RaiseLocalEvent(uid, ref attempt);
if (attempt.Cancelled)
return;
}
Expand Down
Loading