Skip to content

Event Listeners

For more specific examples on how to use the functions you can look through the Example Plugin

When putting the function into the API subscriber functions don't add the brackets (). Eg. for the AddDrawPluginUI one you would just run it like API::AddDrawPluginUI(DrawUI);.

AddDrawPluginUI


Syntax

API::AddDrawPluginUI(func);

Parameters

func

The function you want to be ran every frame that the TygerFramework menu is open.

Input function just needs to be void:
void DrawUI()

Return Value

bool

If the input function is successfully subscribed to the draw plugin UI event it'll return true.

AddPluginImGuiWantCaptureMouse


Required for fixing the resize cursor on plugin windows, and to stop the game from registering inputs while the window is focused

Syntax

//Make sure to cast this, otherwise TygerFramework won't get the return value
API::AddPluginImGuiWantCaptureMouse((ImGuiWantCaptureMouseFunc)func);
//Make sure to cast this, otherwise TygerFramework won't get the return value
API::AddPluginImGuiHasFocus((ImGuiHasFocusFunc)func);

Parameters

func

The function you want to be used to check if your plugin's ImGui context has any windows that want mouse capture.

All your event function needs to contain:
//To block clicks from the game when the window is focused
bool GUI::ImGuiWantCaptureMouse() {
    //WantCaptureMouse works better than window focus
    return ImGui::GetIO().WantCaptureMouse;
}
return:
Just return your plugin's ImGui WantCaptureMouse state.

Return Value

bool

If the input function is successfully subscribed to the ImGui want capture mouse event it'll return true.

AddPluginWndProc


Required for interacting with your ImGui window.
Also used to block any WndProc events from the game by returning true.

Syntax

//Make sure to cast this, otherwise TygerFramework won't get the return value
API::AddPluginWndProc((WndProcFunc)func);

Parameters

func

The function you want any WndProc events to be sent to.

Minimal amount that you may typically need for your plugin:
//WndProc to be able to interact with imgui or block any WndProc from interacting with the Ty window
extern LRESULT ImGui_ImplWin32_WndProcHandler(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam);
bool WndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam) {
    if (API::DrawingGUI())
        if (ImGui_ImplWin32_WndProcHandler(hWnd, msg, wParam, lParam))
            return true;
    return false;
}

Return Value

bool

If the input function is successfully subscribed to the WndProc event it'll return true.

AddTickBeforeGame


Tick event that runs every frame before the game runs its own logic.

Syntax

API::AddTickBeforeGame(func);

Parameters

func

The function you want to be ran every frame before the game's logic.

Input function just needs to be void and have a float input:
void TickBeforeGame(float deltaSeconds)

  deltaSeconds

  The amount of seconds the last frame took to render.

Return Value

bool

If the input function is successfully subscribed to the tick before game event it'll return true.

AddOnTyInitialized


Only in v1.1.0 or newer ↓

Event that fires once Ty has finished it's initialization step

Syntax

API::AddOnTyInitialized(func);

Parameters

func

The function you want to be ran once the game is initialized.

Input function just needs to be void:
void OnTyInitialized()

Return Value

bool

If the input function is successfully subscribed to the on Ty initialized event it'll return true.

AddOnTyBeginShutdown


Only in v1.1.0 or newer ↓

Event that fires when Ty starts shutting down, before it has a chance to deinitialize anything. Useful for if you need to deinitialize something before Ty shuts down to avoid a crash/error

Recommended only to have shutdown logic that would cause a crash with the game on this event, instead of general shutdown logic for your plugin. As this in some cases won't run (usually when Ty is closed through the close button on the window)

Syntax

API::AddOnTyBeginShutdown(func);

Parameters

func

The function you want to be ran when Ty begins shutting down.

Input function just needs to be void:
void OnTyBeginShutdown()

Return Value

bool

If the input function is successfully subscribed to the on Ty begin shutdown event it'll return true.