Clone the repository with all submodules.
git clone https://github.com/TheIndra55/TRAE-menu-hook
cd TRAE-menu-hook
git submodule update --init
Next generate the project files with Premake, for example for Visual Studio:
premake5 vs2022
Now open the solution (.sln) and build for the preferred game.
The codebase uses modules for adding new functionality or menus. Modules are implemented by inheriting the Module
class.
To add a new module create a class inheriting Module
. You can
#include "Module.h"
class MyModule : public Module
{
}
Then register the module in Hook.cpp
in RegisterModules
.
void Hook::RegisterModules()
{
...
RegisterModule<MyModule>();
}
In case you want to interact with a module somewhere else in the code, you can get the module instance.
auto log = Hook::GetInstance().GetModule<Log>();
log->WriteLine("Hello, World!");
Modules can implement some abstract methods to be called during a stage.
class MyModule : public Module
{
public:
void OnFrame()
{
auto font = Font::GetMainFont();
font->SetCursor(0.f, 0.f);
font->Print("Hello, World!");
}
}
Called while the main menu is being drawn, this can be used for adding new menu items.
void MyModule::OnMenu()
{
if (ImGui::BeginMenu("Your menu"))
{
ImGui::MenuItem("Your menu item");
ImGui::EndMenu();
}
}
Called during an ImGui frame, use this to draw your menus.
Called just before a frame ends, use this to use font or draw functions.
Called every frame before the game loop.
Called for every message from the window procedure.
void MyModule::OnInput(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
if (msg == WM_KEYUP && wParam == VK_F1)
{
// F1 pressed!
}
}
Called on post initialization after the device has been obtained