
Message Hooks
Provides hooks inside Message_Update and Message_DrawMain.
Last updated | 2 weeks ago |
Total downloads | 5494 |
Total rating | 9 |
Categories | Libraries |
Dependency string | danielryb-Message_Hooks-2.0.0 |
Dependants | 2 other packages depend on this package |
README
Message Hooks
This is a dependency mod. It provides hooks inside Message_Update and Message_DrawMain for use in other mods.
Features
Events
This mod provides events with following signatures:
mh_on_Message_Update_<MSGMODE>(PlayState* play)
mh_on_Message_DrawMain_<MSGMODE>(PlayState* play, Gfx** gfxP)
where <MSGMODE>
is the name of a MessageMode value without the MSGMODE_
prefix.
Each of these events is called only when play->msgCtx->msgMode
matches it's <MSGMODE>
.
For example, if you want to hook into MSGMODE_TEXT_DONE
in Message_Update
's switch clause, you should make a callback to mh_on_Message_Update_TEXT_DONE
.
There are also universal events called no matter the play->msgCtx->msgMode
's value. Their syntax is the same but they don't have a suffix:
mh_on_Message_Update(PlayState* play)
mh_on_Message_DrawMain(PlayState* play, Gfx** gfxP)
However, they should be avoided unless necessary.
Early return
The mod provides an import for use inside the callbacks. It sets the flag that makes the vanilla function return early before it dives into it's switch clause:
void mh_set_return_flag(void);
Usage example
RECOMP_IMPORT("mm_recomp_message_hooks", void mh_set_return_flag(void));
RECOMP_CALLBACK("mm_recomp_message_hooks", mh_on_Message_Update_TEXT_DONE) void on_Message_Update(PlayState* play) {
if (...) {
...
mh_set_return_flag();
}
}
RECOMP_CALLBACK("mm_recomp_message_hooks", mh_on_Message_DrawMain_TEXT_CLOSING) void on_Message_DrawMain(PlayState* play, Gfx** gfxP) {
...
}