TurtleBrains  0.3.5
High quality, portable, C++ framework for rapid 2D game development.
TurtleBrains::Application::RealtimeApplication Class Reference

#include <tb_realtime_application.hpp>

Inheritance diagram for TurtleBrains::Application::RealtimeApplication:
TurtleBrains::Core::Noncopyable TurtleBrains::Game::GameApplication

Public Member Functions

 RealtimeApplication (ApplicationHandlerInterface &applicationHandler)
 
virtual ~RealtimeApplication (void)
 
void Open (void)
 
void Run (void)
 
void Close (void)
 
void SetWindowMenu (const ApplicationMenu &menu)
 
void SetContextMenu (const ApplicationMenu &menu)
 
void SetWindowStatus (const ApplicationStatus &status)
 
void SetWindowTitle (const tbCore::tbString &windowTitle)
 
WindowProperties GetWindowProperties (void)
 
void SetWindowProperties (const WindowProperties &windowProperties)
 
void ShowMouseCursor (bool showMouse)
 
void OpenDialog (const ApplicationDialog &dialog)
 
void CloseDialog (const ApplicationDialog &dialog)
 
bool OkayMessageBox (const tbCore::tbString &title, const tbCore::tbString &message)
 
bool OkayCancelMessageBox (const tbCore::tbString &title, const tbCore::tbString &message)
 
bool OpenFileDialog (tbCore::tbString &fileToOpen, const tbCore::tbString &fileExtension)
 
bool SaveFileDialog (tbCore::tbString &fileToSave, const tbCore::tbString &fileExtension)
 

Detailed Description

Create an application using OpenGL to render a real-time view-port. A real-time message pump will be used instead of blocking until a system message/event is fired.

Constructor & Destructor Documentation

TurtleBrains::Application::RealtimeApplication::RealtimeApplication ( ApplicationHandlerInterface applicationHandler)
explicit

Prepares an application to create a window with an OpenGL context. The window will not be created or opened in the constructor of the RealtimeApplication, instead it will be delayed until Open() is called.

Parameters
applicationHandlerThe object to be invoked when the system fires an event or the user acts upon items within the application. The scope of this object must outlive the scope of the RealtimeApplication object.
Note
only a single RealtimeApplication object can exist at a single-time despite not being a singleton, this may change to either a singleton or allow multiple Application objects in future versions of TurtleBrains.
virtual TurtleBrains::Application::RealtimeApplication::~RealtimeApplication ( void  )
virtual

Cleanup any resources created when preparing or running a RealtimeApplication.

Member Function Documentation

void TurtleBrains::Application::RealtimeApplication::Close ( void  )

Mark the application to close, the actual close event will be delayed and may be performed after the current frame when the operating system messages are processed.

void TurtleBrains::Application::RealtimeApplication::CloseDialog ( const ApplicationDialog dialog)

Closes a custom built dialog prompt, must be called for any dialog opened with OpenDialog and will clean up any system resources allocated for the dialog box.

Parameters
dialogThe dialog box to be closed.
WindowProperties TurtleBrains::Application::RealtimeApplication::GetWindowProperties ( void  )

Returns an object with the current window properties.

bool TurtleBrains::Application::RealtimeApplication::OkayCancelMessageBox ( const tbCore::tbString title,
const tbCore::tbString message 
)

Opens a small, modal, message box displaying a title, a message and two buttons to the user to press Okay or Cancel. The function will not return until the user has pressed either to Okay or Cancel buttons, and the result will be returned.

Parameters
titleThe title of the message box, it is wise to contain your application name for user reference.
messageThe message that the user needs to see and accept or decline with the Okay/Cancel buttons.
Returns
kResultOkay if the user pressed the Okay button or kResultCancel if the user pressed Cancel.
bool TurtleBrains::Application::RealtimeApplication::OkayMessageBox ( const tbCore::tbString title,
const tbCore::tbString message 
)

Opens a small, modal, message box displaying a title, a message and an Okay button. Due to the nature of a modal prompt this function will not return until the user has pressed the Okay button.

Parameters
titleThe title of the message box, it is wise to contain your application name for user reference.
messageThe message that the user needs to see and accept with the Okay button.
Returns
kResultOkay will be returned once the user presses the Okay button.
void TurtleBrains::Application::RealtimeApplication::Open ( void  )

Creates and opens a real-time window with OpenGL clearing and displaying a black screen, but waits until Run() is called to enter the real-time message pump of the OS.

void TurtleBrains::Application::RealtimeApplication::OpenDialog ( const ApplicationDialog dialog)

Opens a custom built, modeless, dialog for your application which will continue to update while your application runs. This is not a modal dialog prompt and the function will return before the user has finished using your dialog. The dialog will remain visible until closed with a call to CloseDialog().

Parameters
dialogThe dialog box to be opened.
bool TurtleBrains::Application::RealtimeApplication::OpenFileDialog ( tbCore::tbString fileToOpen,
const tbCore::tbString fileExtension 
)

Opens a dialog prompt to navigate/open a file using the native prompt on the operating system. This is a modal dialog prompt and the function will not return until the user has finished.

Parameters
fileToOpenThe value passed in is where the OpenFileDialog will let the user begin navigation, and once the user chooses a file it will be changed to the location of that file, (in and out).
fileExtensionWhat type of files to search for, no . included. Use "trk" to search for track.trk files
Returns
kResultOkay if the user pressed Open on the file dialog prompt, or kResultCancel if the user closed the prompt, hit escape or some other action to close without accepting the file.
Note
Currently the fileExtension parameter and initial navigation directory may ignored on some platforms.
void TurtleBrains::Application::RealtimeApplication::Run ( void  )

Begins processing messages from the operating system, this should be called from the main thread as it handles application / interface objects, and will not return the application has been closed. Once running, the ApplicationHandlerInterface object will be invoked during system events and user actions.

Note
This function will block until Close() is called.
bool TurtleBrains::Application::RealtimeApplication::SaveFileDialog ( tbCore::tbString fileToSave,
const tbCore::tbString fileExtension 
)

Opens a dialog prompt to navigate to a file for saving using the native prompt on the operating system. This is a modal dialog prompt and the function will not return until the user has finished.

Parameters
fileToOpenThe value passed in is where the OpenFileDialog will let the user begin navigation, and once the user chooses a file it will be changed to the location of that file, (in and out).
fileExtensionWhat type of files to search for, no . included. Use "trk" to search for track.trk files
Returns
kResultOkay if the user pressed Save on the file dialog prompt, or kResultCancel if the user closed the prompt, hit escape or some other action to close without accepting the file.
Note
Currently the fileExtension parameter and initial navigation directory may ignored on some platforms.
void TurtleBrains::Application::RealtimeApplication::SetContextMenu ( const ApplicationMenu menu)

Apply an ApplicationMenu to open as the context menu when the user right-clicks / secondary clicks within the window. This will not open or show the menu until the user takes action.

void TurtleBrains::Application::RealtimeApplication::SetWindowMenu ( const ApplicationMenu menu)

Apply an ApplicationMenu to the top of the Window in a manner the user will expect depending on the operating system used. To remove the menu, call this with an empty menu object. It is a good idea to keep a MenuIdentifier around to specify an empty menu, much like you would other menus.

Note
On Mac the very first menu item will be named with the application name, it may be desired to add an additional menu item for this.
void TurtleBrains::Application::RealtimeApplication::SetWindowProperties ( const WindowProperties windowProperties)

Change the resolution or from windowed to fullscreen. A new graphics context will get created during this call. It will take a few seconds to cleanup and open a new context and if there are any unmanaged resources they will need to be added to the new context.

Note
This ignores the window position properties and only sets the window to a new resolution.
void TurtleBrains::Application::RealtimeApplication::SetWindowStatus ( const ApplicationStatus status)

Apply a status bar to the application window to inform the user about selection or status of the application.

void TurtleBrains::Application::RealtimeApplication::SetWindowTitle ( const tbCore::tbString windowTitle)

Set the window title to a specified title so the user knows where/what your application is.

void TurtleBrains::Application::RealtimeApplication::ShowMouseCursor ( bool  showMouse)

Make the mouse cursor show or hide... TODO: TurtleBrains: Documentation: Teach the user about this a little better; though it is self-explanitory...

Note
: Currently this is just a suggestion and not a certain feature. May work on some platforms and not others.