Add HUD Hooks - #151
Merged
Merged
Conversation
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.
Adds HUD Hooks, a small API plugin that lets mods take over parts of the HUD the Mod API does not expose.
8d912fe20ccecf3105ca70fac591763330bd75daHudHooksWhat it does: a mod sends a mod message (id
2735914000, payloadMyTuple<string, bool, bool>as(token, open, interceptEscape)) to claim a token while its own HUD screen is open, and releases it on close. While any token is held the in-world crosshair is not drawn. Tokens that ask for it also swallow ESC, so the pause menu does not open over the mod's screen. Tokens are tracked per screen so several mods can hold hooks at once, and state is cleared onOnSessionReady.Patches: two prefixes.
MyHudCrosshair.Drawreturns false while a token is held.MyGuiSandbox.AddScreendrops the main menu screen when the menu was opened by a new ESC press or theMAIN_MENUcontrol while an intercept token is held, and pops the pause the constructor pushed in single player. It returns true in every other case, so the patch is a no-op unless a mod is actively holding a token.Failsafe: two ESC presses within 500 ms always let the menu through, so a mod that fails to release its token cannot lock a player out.
Compatibility: client-side only, no world or network state, safe on any server.