RegisterValidationHandler Function
Registers a validation handler. You can think of the validation handler as a completely separate bruteforce/other algorithm that works on its own: when your handler is active (chosen in the bruteforce tab), no other handler will be called.
Syntax
void RegisterValidationHandler(
const string&in identifier,
const string&in title,
RenderValidationHandlerSettings@ renderCallback = null
)
Parameters
const string&in identifier
The unique handler ID.
const string&in title
The title that will be displayed in the bruteforce tab and in replay menu.
RenderValidationHandlerSettings@ renderCallback = null
Optional. A function that will be called to render the settings for this handler.
Return value
None.
Remarks
Choosing the handler in the UI sets the controller
variable to the unique identifier you passed. From there, your plugin should ensure that in OnSimulation*
functions, the controller
variable is set to your ID before doing any work. This means that TMInterface does not enforce running other handlers, instead, it is expected that plugins themselves respect the controller
variable. To do that, see this example:
bool executeHandler = false;
void OnSimulationBegin(SimulationManager@ simManager)
{
executeHandler = GetVariableString("controller") == "my_handler";
}
void OnSimulationStep(SimulationManager@ simManager, bool userCancelled) {
if (!executeHandler) {
// Not our handler, do nothing.
return;
}
// Do work here.
}
void Main()
{
RegisterValidationHandler("my_handler", "My Handler");
}
The handler will be deregistered automatically, if the plugin is disabled or the game closed.