-
Notifications
You must be signed in to change notification settings - Fork 23
API Reference
The API is a simple set of functions that you can use to interact with OpenHack. Here is a list of all available functions:
Returns true
if OpenHack is loaded and the API is available.
Note
This function is only available if you include the API with dynamic symbol loading. If you include the API as a dependency, you can assume that OpenHack is loaded.
if (!openhack::isLoaded()) {
// Break or return out of the function, because OpenHack is not loaded
return;
}
You're supposed to call this function before calling any other API functions to make sure that OpenHack is loaded.
Returns true
if user have any cheats enabled (e.g. auto safe mode is active).
if (openhack::isCheating()) {
// User is cheating
}
Returns true
if the setting with the specified key is enabled.
if (openhack::getSetting("level.noclip")) {
// Noclip is enabled
}
The following functions are used to use the OpenHack UI system to create custom windows and buttons.
Draws a label with the specified text.
openhack::ui::label("My Custom Label");
openhack::ui::label(fmt::format("Hello, {}!", "World").c_str());
Pushes the width of the next UI element.
openhack::ui::width(200.f);
// The next UI element will have a width of 200 pixels
// Don't forget to call this function again with 0.f to reset the width
// (may lead to memory leaks)
openhack::ui::width();
bool openhack::ui::inputFloat(char const* label, float* value, float min = FLT_MIN, float max = FLT_MAX, char const* format = "%.3f")
Draws an input field for a float value.
// somewhere in your code
float myValue = 0.f;
// in your draw callback
openhack::ui::width(120.f); // Set the width of the input field
// Create an input field for the value
// with a minimum of 0 and a maximum of 100
if (openhack::ui::inputFloat("My Value", &myValue, 0.f, 100.f)) {
// Value has changed
}
openhack::ui::width();
bool openhack::ui::inputText(char const* label, const std::string* value, int maxLength = 256, char const* placeholder = "")
Draws an input field for a string value.
// somewhere in your code
std::string myText = "Hello, World!";
// in your draw callback
openhack::ui::width(120.f); // Set the width of the input field
// Create an input field for the value
if (openhack::ui::inputText("My Text", &myText)) {
// Text has changed
}
openhack::ui::width();
Draws a button with the specified label.
if (openhack::ui::button("My Button")) {
// Button was clicked
}
Draws a checkbox with the specified label.
// somewhere in your code
bool myValue = false;
// in your draw callback
if (openhack::ui::checkbox("My Checkbox", &myValue)) {
// Checkbox was toggled
}
Adds a tooltip to the last UI element.
openhack::ui::button("My Button");
openhack::ui::tooltip("This is a tooltip for the button");
Creates a new UI window with the specified title and draw callback.
Warning
You should only call this function once! Calling it multiple times will create multiple windows. If you want to update the window content, you should use the draw callback function.
openhack::createWindow("My Custom Window", []() {
openhack::ui::label("Hello, World!");
if (openhack::ui::button("My Button")) {
FLAlertLayer::create("Hi!", "You've pressed the button!", "OK")->show();
}
// You can use any other UI functions here...
});