Repository navigation
Hooking
Hooking is the mechanism behind how you interact with the game at runtime. Put simply, it allows you to hook into different functions ran by the game.
Diva exposes hookManager, which contains registration methods for various hooks types, being mod "hooks", game hooks, menu hooks, and DFT menu hooks. To actually create a hook, it's simple. Choose a hook type first:
- A mod "hook" is run by DML, and has functions like
PreInit,Init, andPostInit, but also some likeOnFrame,OnResize,OnD3DInit(Direct3D init). - A game hook is a hook that's called some time during player gameplay. It includes things like
OnPvInit,OnPvUpdate,OnPvGetHitState, etc. - A menu hook is a hook that's called some time while in the PV/song select menu, including things like
OnMenuInit,OnMenuDraw, etc. - a DFT(Diva Future Tone) menu hook is a hook that's called some time while in the PV/song select menu, SPECIFICALLY with Future Tone UI, including things like
OnMenuInit,OnMenuDraw, etc.
Once you have a hook type chosen, you can choose any hook from the list of available hooks below. Once you know exactly what you're going to hook into, you can register your hook. For example, if I chose the Init mod hook, I would do this:
Diva.hookManager.registerModHook(Init(() -> {
// Code here.
}));Some of these hooks even pass in parameters, some giving you you ___Context objects (mod "hooks" are an exception, and come in the form of normal parameters). For more information on the ___Context objects, look here.
The reason I put hooks in quotations was because the calls that will be listed aren't truly hooking into the game, they're simply called for us by Diva Mod Loader.
You can register/unregister these hooks via:
Diva.hookManager.registerModHook(hook);
Diva.hookManager.unregisterModHook(hook);This hook is run before the game's global variables are initialized. You may not need to use this one often.
This hook is run after the game's global variables are initialized. Run most of your mod initialization here.
This hook is run after all mod DLL's are fully loaded.
This hook is run when the game's Direct3D is initialized. You can use this in combination with the OnFrame() mod hook and ImGuiDx11 to render ImGui. Look at the ImGui page of the wiki.
This hook is run every frame before the current frame is presented to the screen.
This hook is run every time the games buffers are resized, primarily during window resizing.
This hook is run when the swap chain is changed.
These are hooks that run while someone is playing a song/PV, with the one exception being OnPvDBParseEntry.
You can register/unregister these hooks via:
Diva.hookManager.registerGameHook(hook);
Diva.hookManager.unregisterGameHook(hook);This hook runs when the PV is being initialized. If you need to preload or anything along that line for something that's going to happen during the PV, do that here.
This hook runs when the PV is fully initialized, and is about to start. If you need to do, play, or show something on screen once the PV begins, do that here.
This hook runs every frame that the PV is being updated.
This hook runs when you exit to the PV/song selection screen. Please, do not mistake this for running when the PV is complete. This does not run when you go to the results screen. This only runs when you're going back to the PV/song selection screen. I do need to add a hook for specifically PV completion eventually.
This hook runs when the PV restarts. For example, when the player restarts the PV in the pause menu.
This hook runs for the target that's next to be hit by the player. To see what a HitContext is, look here.
This hook runs when loading the current PV's DSC, during the loading screen. To see what a DscCtrlContext is, look here.
This is the one exception to my earlier statement about "These are hooks that run while someone is playing a song/PV." This hook runs at the game's startup when loading all PV's. To see what a PvDBParseContext is, look here.
This hook runs when drawing the game. If you want to draw anything to the screen, do that here. To see what a DrawContext is, look here.
This hook runs after drawing the game. To see what a DrawContext is, look here.
This hook runs when updating all targets. To see what a TargetUpdateContext is, look here.
This hook runs when drawing the tail of a target, called a kiseki. To see what a TargetContext is, look here.
There are two different types of PV select menu hooks. There are ones that work on specifically Future Tone UI, and ones that work specifically on normal UI.
You can register/unregister these hooks via:
Diva.hookManager.registerMenuHook(hook);
Diva.hookManager.unregisterMenuHook(hook);This hook runs when the PV select menu is initialized. If you need anything to load when the PV select menu is loading up, do that here. To see what a ResultContext is, look here.
This hook runs when the game builds its list of sorted PV's for the menu. To see what a MenuSelectionContext is, look here.
This hook runs when the PV select menu is updated. To see what a MenuSelectionContext is, look here.
This hook runs when the PV select menu is drawn. If you need to draw anything to the screen, draw it here.
This hook runs when the PV select menu is exited. To see what a ResultContext is, look here.
You can register/unregister these hooks via:
Diva.hookManager.registerDFTMenuHook(hook);
Diva.hookManager.unregisterDFTMenuHook(hook);This hook runs when the PV select menu is initialized. If you need anything to load when the PV select menu is loading up, do that here. To see what a FTMenuSelectionContext is, look here.
This hook runs when the game builds its list of sorted PV's for the menu. To see what a BasicFTMenuSelectionContext is, look here.
This hook runs when the PV select menu is updated. To see what a FTMenuSelectionContext is, look here.
This hook runs when the PV select menu is drawn. If you need to draw anything to the screen, draw it here.
This hook runs when the PV select menu is exited. To see what a ResultContext is, look here.