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

Add an custom Status Bar to your Realt-ime 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 status bar and status items. (ex. StatusIdentifier / StatusItemIdentifier)
  2. Create and customized the status bar as desired, setting up everything as needed. (ex. ApplicationStatus / AddStatusItem)
  3. Handle events in the ApplicationHandler when the user interacts with the object.

Creating a status bar, is not so different from creating a Menu or Dialog, first create the identifiers, then customize the status bar. With a status bar there is no user interaction to handle, so it is even easier!

MyApplicationValues.h (modify to add status bar values)

enum MyStatusBars { kMyStatusBar, }
enum MyStatusItems { kStatusName, kStatusAge, kStatusHeight }

MyApplicationHandler.cpp (modify to add status bar)

void MyApplicationHandler::OnWindowOpen(void)
{
tbApplication::ApplicationStatus statusBar(kMyStatusBar);
statusBar.AddStatusItem(kStatusName, tb_string("Current Name: Unknown"), 0);
statusBar.AddStatusItem(kStatusAge, tb_string("Current Age: 42"), 50);
statusBar.AddStatusItem(kStatusHeight, tb_string("Height: 5ft"), 75);
theApplication.SetWindowStatus(statusBar);
}

MyApplicationHandler.cpp (modify to add status bar)

void MyApplicationHandler::OnMenuAction(const MenuIdentifier& menu, const MenuItemIdentifier& menuItem)
{
//Whenever the status, or a status item changes, the following will update the status bar.
tbApplication::ApplicationStatus statusBar(kMyStatusBar);
statusBar.SetStatusItem(kStatusAge, tb_string("Old Age: 100"));
statusBar.SetStatusItem(kStatusHeight, tb_string("Height: 4ft"));
theApplication.SetWindowStatus(statusBar);
}
Note
The status bar currently only works on Windows, no Mac support at this time. Also there is no way to remove a status bar once added to the application, although the status items can be changed easily as shown above.