Implement Sequential Hooking and Notification for Multiplayer Button Click#44
Merged
Extremelyd1 merged 4 commits intoExtremelyd1:mainfrom Mar 28, 2026
Merged
Implement Sequential Hooking and Notification for Multiplayer Button Click#44Extremelyd1 merged 4 commits intoExtremelyd1:mainfrom
Extremelyd1 merged 4 commits intoExtremelyd1:mainfrom
Conversation
Extremelyd1
requested changes
Mar 28, 2026
Owner
Extremelyd1
left a comment
There was a problem hiding this comment.
Thanks for the simple PR!
Couple of easy to click suggestions. The rest looks good.
SSMP/Api/Client/IUiManager.cs
Outdated
|
|
||
| /// <summary> | ||
| /// Fired when the multiplayer button is pressed, before any blocking hooks run. | ||
| /// Use this for fire-and-forget reactions such as logging or showing a notification? |
Owner
There was a problem hiding this comment.
Suggested change
| /// Use this for fire-and-forget reactions such as logging or showing a notification? | |
| /// Use this for fire-and-forget reactions such as logging or showing a notification. |
SSMP/Ui/UiManager.cs
Outdated
| /// </summary> | ||
| private void OnMultiplayerMenuRequested() { | ||
| MultiplayerButtonPressed?.Invoke(); | ||
| _multiplayerMenuChain(); |
Owner
There was a problem hiding this comment.
Suggested change
| _multiplayerMenuChain(); | |
| _multiplayerMenuChain.Invoke(); |
Owner
There was a problem hiding this comment.
I'd prefer explicitly calling .Invoke on Action types to avoid confusion of whether this is an action or a method.
Extremelyd1
approved these changes
Mar 28, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Lack of Interception Logic: There was no built-in mechanism for external addons to react to or intercept the "Start Multiplayer" button click.
Solution
IUiManager.cs: Defined a two-tier API for multiplayer button interactions:
MultiplayerButtonPressed: A standard C# event for fire-and-forget notifications (logging, non-blocking UI effects).RegisterMultiplayerMenuHook: A registration method for "middleware" style hooks. Each hook receives a continuation callback, allowing it to explicitly control when (or if) the menu transition proceeds.UiManager.cs: Implemented a sequential execution chain (
_multiplayerMenuChain).GoToMultiplayerMenu) is only executed at the very end of this chain, provided all hooks have called their respective continuations.