TurtleBrains  0.3.1
High quality, portable, C++ framework for rapid 2D game development.
HowTo: Add a Dialog Prompt

Add an custom Dialog Prompt to your Real-time Application in TurtleBrains.

The following guide is a continuation of HowTo: Start a Real-time Application which provides a great way to start an application if you haven't already.

The following steps are the same basic steps taken to add a Status Bar, Menu, or Dialog Prompt to your application.

  1. Create the necessary identifiers for the dialog and dialog controls. (ex. DialogIdentifier / DialogControlIdentifier)
  2. Create and customized the dialog prompt as desired, setting up everything as needed. (ex. ApplicationDialog / AddDialogControl)
  3. Handle events in the ApplicationHandler when the user interacts with the dialog prompt. (ex. OnDialogAction).

Creating a dialog prompt, is not so different from creating a Menu, first create the identifiers, then customize the dialog and finally handle the events from user interaction.

MyApplicationValues.h (modify to add dialog values)

enum MyDialogs { kDialogCreate, }
enum MyDialogControls { kControlStatic, kControlOkayButton, }

MyApplicationHandler.cpp (modify to add dialog prompt)

void MyApplicationHandler::OnWindowOpen(void)
{
//Set the kStaticLabel control identifier as safe for duplication so it can be reused.
//Create a dialog prompt and customize it.
tbApplication::ApplicationDialog createPrompt(kDialogCreate);
//TODO: TIM: More dialog example...
}

MyApplicationHandler.cpp (modify to add dialog prompt)

void MyApplicationHandler::OnDialogAction(const DialogIdentifier& dialog, const DialogControlIdentifier& dialogControl)
{
if (kDialogCreate == dialog)
{
tbApplicationDialog createPrompt(kDialogCreate);
if (kControlOkayButton == dialogControl)
{
//TODO: TIM: More dialog example...
}
}
}