Skip to content

Hooking

ZSolarDev edited this page Nov 12, 2026 · 13 revisions

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.

How to use

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, and PostInit, but also some like OnFrame, 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.


Available Hooks

Mod "hooks"

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);

PreInit(Void -> Void)

This hook is run before the game's global variables are initialized. You may not need to use this one often.

Init(Void -> Void)

This hook is run after the game's global variables are initialized. Run most of your mod initialization here.

PostInit(Void -> Void)

This hook is run after all mod DLL's are fully loaded.

D3DInit((DxgiSwapChain, D3d11Device, D3d11DeviceContext) -> Void)

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.

OnFrame(DxgiSwapChain -> Void)

This hook is run every frame before the current frame is presented to the screen.

OnResize(DxgiSwapChain -> Void)

This hook is run every time the games buffers are resized, primarily during window resizing.

OnSwapChain(DxgiSwapChain -> Void)

This hook is run when the swap chain is changed.


Gameplay hooks

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);

OnPvInit(Void -> Void)

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.

OnPvInitComplete(Void -> Void)

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.

OnPvUpdate(Void -> Void)

This hook runs every frame that the PV is being updated.

OnPvExit(Void -> Void)

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.

OnPvReset(Void -> Void)

This hook runs when the PV restarts. For example, when the player restarts the PV in the pause menu.

OnPvGetHitState(HitContext -> Void)

This hook runs for the target that's next to be hit by the player. To see what a HitContext is, look here.

OnLoadDscUpdate(DscCtrlContext -> Void)

This hook runs when loading the current PV's DSC, during the loading screen. To see what a DscCtrlContext is, look here.

OnPvDBParseEntry(PvDBParseContext -> Void)

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.

OnDrawGame(DrawContext -> Void)

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.

OnDrawGamePost(DrawContext -> Void)

This hook runs after drawing the game. To see what a DrawContext is, look here.

OnUpdateTargets(TargetUpdateContext -> Void)

This hook runs when updating all targets. To see what a TargetUpdateContext is, look here.

OnDrawKiseki(TargetContext -> Void)

This hook runs when drawing the tail of a target, called a kiseki. To see what a TargetContext is, look here.


PV Select Menu Hooks

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.

Normal UI Hooks

You can register/unregister these hooks via:

Diva.hookManager.registerMenuHook(hook);
Diva.hookManager.unregisterMenuHook(hook);

OnMenuInit(ResultContext -> Void)

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.

OnMenuCreateSortedPVList(MenuSelectionContext -> Void)

This hook runs when the game builds its list of sorted PV's for the menu. To see what a MenuSelectionContext is, look here.

OnMenuUpdate(MenuSelectionContext -> Void)

This hook runs when the PV select menu is updated. To see what a MenuSelectionContext is, look here.

OnMenuDraw(Void -> Void)

This hook runs when the PV select menu is drawn. If you need to draw anything to the screen, draw it here.

OnMenuExit(ResultContext -> Void)

This hook runs when the PV select menu is exited. To see what a ResultContext is, look here.

Future Tone UI Hooks

You can register/unregister these hooks via:

Diva.hookManager.registerDFTMenuHook(hook);
Diva.hookManager.unregisterDFTMenuHook(hook);

OnMenuInit(FTMenuSelectionContext -> Void)

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.

OnMenuCreateSortedPVList(BasicFTMenuSelectionContext -> Void)

This hook runs when the game builds its list of sorted PV's for the menu. To see what a BasicFTMenuSelectionContext is, look here.

OnMenuUpdate(FTMenuSelectionContext -> Void)

This hook runs when the PV select menu is updated. To see what a FTMenuSelectionContext is, look here.

OnMenuDraw(Void -> Void)

This hook runs when the PV select menu is drawn. If you need to draw anything to the screen, draw it here.

OnMenuExit(ResultContext -> Void)

This hook runs when the PV select menu is exited. To see what a ResultContext is, look here.

Clone this wiki locally