ISource2ModCustomHud

Interface for the panorama custom HUD layouts.

custom_hud_layout entities render a panorama layout on top of the game HUD. The entity itself is driven through CCSCustomHudLayout; this interface only owns the click callbacks, because the button press arrives as a user message on the core's own hook and has to be routed back to whichever plugin created the layout.

Plugins do not normally touch this interface -- CCSCustomHudLayout's HookClick() forwards here for them.

Registry of custom HUD click callbacks.

Callbacks are keyed by layout entity, so several plugins may listen on their own layouts at once. Every callback a plugin registers is dropped when that plugin unloads, and the whole registry is cleared on level shutdown along with the entities it points at.

Interface id ISource2ModCustomHud002 (SOURCE2MOD_CUSTOMHUD_INTERFACE) · Global g_pSource2ModCustomHud · Header source2mod/ISource2ModCustomHud.h

Types

Source2ModCustomHudHookId

using Source2ModCustomHudHookId = Source2ModHookId;

A custom HUD click hook (HookCustomHudClick).

CustomHudClickHandler

using CustomHudClickHandler = Source2ModCallback<void(CCSPlayerController* player, CCSCustomHudLayout* pLayout, const char* pszButtonId)>;

Callback type for custom HUD button clicks.

Methods

HookCustomHudClick

virtual Source2ModCustomHudHookId HookCustomHudClick(CCSCustomHudLayout* pLayout, CustomHudClickHandler handler) = 0;

Registers a click callback for one layout entity.

Whose it is, the core reads off the handler (see Source2ModCallback); what a plugin still holds at unload the core drops for it.

ParameterTypeDescription
pLayoutCCSCustomHudLayout*Layout to listen on
handlerCustomHudClickHandlerA function, an object and a method, or a lambda

Returns Source2ModCustomHudHookId — The id UnhookCustomHudClick(id) takes

UnhookCustomHudClick

virtual bool UnhookCustomHudClick(CCSCustomHudLayout* pLayout, const CustomHudClickHandler& handler) = 0;
virtual bool UnhookCustomHudClick(Source2ModCustomHudHookId id) = 0;
virtual void UnhookCustomHudClick(CCSCustomHudLayout* pLayout) = 0;

Drops the hook with this handler -- a function or an object and a method; a lambda goes by its id.

Drops the hook HookCustomHudClick() returned the id for.

Drops every callback registered for a layout.

ParameterTypeDescription
pLayoutCCSCustomHudLayout*Layout to stop listening on
handlerconst CustomHudClickHandler&
idSource2ModCustomHudHookId

Returns bool — true when one was found

Macros

HOOK_CUSTOM_HUD_CLICK

#define HOOK_CUSTOM_HUD_CLICK(pLayout, handler) g_pSource2ModCustomHud->HookCustomHudClick(pLayout, handler)

Hook macros, matching HOOK_GAME_EVENT.

Other macros

MacroExpands to
UNHOOK_CUSTOM_HUD_CLICK(pLayout)g_pSource2ModCustomHud->UnhookCustomHudClick(pLayout)

On this page