hoa_video::private_video::GUISupervisor Class Reference

A helper class to the video engine to manage all of the GUI functionality. More...

#include <gui.h>

Inheritance diagram for hoa_video::private_video::GUISupervisor:

Inheritance graph
[legend]
Collaboration diagram for hoa_video::private_video::GUISupervisor:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void AddMenuWindow (MenuWindow *new_window)
 Adds a newly created MenuWindow into the map of existing windows.
void DeleteMenuSkin (std::string &skin_name)
 Deletes a menu skin that has been loaded.
void DrawFPS (uint32 frame_time)
 Updates the FPS counter and draws it on the screen.
MenuSkinGetDefaultMenuSkin () const
 Returns a pointer to the default menu skin.
MenuSkinGetMenuSkin (std::string &skin_name)
 Returns a pointer to the MenuSkin of a corresponding skin name.
uint32 GetNextMenuWindowID ()
 Returns the next available MenuWindow ID for a MenuWindow to use.
 GUISupervisor ()
bool LoadMenuSkin (std::string skin_name, std::string border_image, std::string background_image="", Color top_left=Color::clear, Color top_right=Color::clear, Color bottom_left=Color::clear, Color bottom_right=Color::clear, bool make_default=false)
 Prepares a new menu skin for use in game.
void RemoveMenuWindow (MenuWindow *old_window)
 Removes an existing MenuWindow from the map of existing windows.
void SetDefaultMenuSkin (std::string &skin_name)
 Sets the default menu skin to use from the set of pre-loaded skins.
bool SingletonInitialize ()
 A method for the inheriting class to implement, which initializes the class.
 ~GUISupervisor ()

Private Attributes

uint32 _current_sample
 An index variable to keep track of the start of the circular fps_samples array.
MenuSkin_default_skin
 A pointer to the default menu skin that GUI objects will use if a skin is not explicitly declared If no menu skins exist, this member will be NULL. It will never be NULL as long as one menu skin is loaded. If the default menu skin is deleted by the user, an alternative default skin will automatically be set.
uint32 _fps_samples [FPS_SAMPLES]
 A circular array of FPS samples used for calculating average FPS.
uint32 _fps_sum
 Keeps track of the sum of FPS values over the last VIDEO_FPS_SAMPLES frames This is used to simplify the calculation of average frames per second.
std::map< std::string, MenuSkin_menu_skins
 A map containing all of the menu skins which have been loaded The string argument is the reference name of the menu, which is defined by the user when they load a new skin.
std::map< uint32, MenuWindow * > _menu_windows
 A map containing all of the actively created MenuWindow objects The integer key is the MenuWindow's ID number. This primary purpose of this map is to coordinate menu windows with menu skins. A menu skin can not be deleted when a menu window is still using that skin, and menu windows must be re-drawn when the properties of a menu skin that it uses changes.
uint32 _next_window_id
 The next ID to assign to a MenuWindow when one is created.
uint32 _number_samples
 The number of FPS samples currently recorded. This value should always be VIDEO_FPS_SAMPLES, unless the game has just started, in which case it could be anywhere from 0 to VIDEO_FPS_SAMPLES depending on how many frames have been displayed.

Friends

class hoa_utils::Singleton< GUISupervisor >

Detailed Description

A helper class to the video engine to manage all of the GUI functionality.

****************************************************************************

There is exactly one instance of this class, which is both created and destroyed by the GameVideo class. This class is essentially an extension of the GameVideo class which manages the GUI system. It also happens to handle the drawing of the average frames per second (FPS) on the screen.

Definition at line 179 of file gui.h.


Constructor & Destructor Documentation

hoa_video::private_video::GUISupervisor::GUISupervisor (  ) 

Definition at line 138 of file gui.cpp.

References _current_sample, _fps_samples, _fps_sum, _number_samples, and hoa_video::private_video::FPS_SAMPLES.

hoa_video::private_video::GUISupervisor::~GUISupervisor (  ) 

Definition at line 149 of file gui.cpp.

References _menu_skins, _menu_windows, hoa_video::GameVideo::DeleteImage(), hoa_video::VIDEO_DEBUG, and hoa_video::VideoManager.

Here is the call graph for this function:


Member Function Documentation

void hoa_video::private_video::GUISupervisor::AddMenuWindow ( MenuWindow new_window  ) 

Adds a newly created MenuWindow into the map of existing windows.

Parameters:
new_window A pointer to the newly created MenuWindow Don't call this method anywhere else but from MenuWindow::Create(), or you may cause problems.

Definition at line 291 of file gui.cpp.

References hoa_video::MenuWindow::_id, _menu_windows, and hoa_video::VIDEO_DEBUG.

Referenced by hoa_video::MenuWindow::Create().

void hoa_video::private_video::GUISupervisor::DeleteMenuSkin ( std::string &  skin_name  ) 

Deletes a menu skin that has been loaded.

Parameters:
skin_name The name of the loaded menu skin that should be removed
This function could fail on one of two circumstances. First, if there is no MenuSkin loaded for the key skin_name, the function will do nothing. Second, if any MenuWindow objects are still referencing the skin that is trying to be deleted, the function will print a warning message and not delete the skin. Therefore, before you call this function, you must delete any and all MenuWindow objects which make use of this skin, or change the skin used by those objects.

Definition at line 266 of file gui.cpp.

References _menu_skins, _menu_windows, and hoa_video::VIDEO_DEBUG.

void hoa_video::private_video::GUISupervisor::DrawFPS ( uint32  frame_time  ) 

Updates the FPS counter and draws it on the screen.

Parameters:
frame_time The number of milliseconds it took for the last frame.
Calculates and draws the FPS based on the time the frame took. To make the FPS appear more "steady", the FPS that's displayed on the screen is actually the average over the last several frames.

Definition at line 316 of file gui.cpp.

References _current_sample, _fps_samples, _fps_sum, _number_samples, hoa_video::GameVideo::DrawText(), hoa_video::private_video::FPS_CATCHUP, hoa_video::private_video::FPS_SAMPLES, hoa_video::private_video::MAX_FTIME_DIFF, hoa_video::GameVideo::Move(), hoa_video::GameVideo::SetDrawFlags(), hoa_video::GameVideo::SetFont(), hoa_video::GameVideo::SetTextColor(), hoa_video::VIDEO_BLEND, hoa_video::VIDEO_DEBUG, hoa_video::VIDEO_X_LEFT, hoa_video::VIDEO_X_NOFLIP, hoa_video::VIDEO_Y_BOTTOM, hoa_video::VIDEO_Y_NOFLIP, hoa_video::VideoManager, and hoa_video::Color::white.

Referenced by hoa_video::GameVideo::DrawFPS().

Here is the call graph for this function:

MenuSkin* hoa_video::private_video::GUISupervisor::GetDefaultMenuSkin (  )  const [inline]

Returns a pointer to the default menu skin.

Definition at line 220 of file gui.h.

References _default_skin.

Referenced by hoa_video::MenuWindow::Create().

MenuSkin* hoa_video::private_video::GUISupervisor::GetMenuSkin ( std::string &  skin_name  )  [inline]

Returns a pointer to the MenuSkin of a corresponding skin name.

Parameters:
skin_name The name of the menu skin to grab
Returns:
A pointer to the MenuSkin, or NULL if the skin name was not found

Definition at line 227 of file gui.h.

References _menu_skins.

uint32 hoa_video::private_video::GUISupervisor::GetNextMenuWindowID (  )  [inline]

Returns the next available MenuWindow ID for a MenuWindow to use.

Returns:
The ID number for the MenuWindow to use This method should only need to be called from the MenuWindow constructor.

Definition at line 243 of file gui.h.

References _next_window_id.

Referenced by hoa_video::MenuWindow::MenuWindow().

bool hoa_video::private_video::GUISupervisor::LoadMenuSkin ( std::string  skin_name,
std::string  border_image,
std::string  background_image = "",
Color  top_left = Color::clear,
Color  top_right = Color::clear,
Color  bottom_left = Color::clear,
Color  bottom_right = Color::clear,
bool  make_default = false 
)

Prepares a new menu skin for use in game.

Parameters:
skin_name The name that will be used to refer to the skin after it is successfully loaded
border_image The filename for the multi-image that contains the menu's border images
background_image The filename for the skin's background image (optional)
top_left Sets the background color for the top left portion of the skin
top_right Sets the background color for the top right portion of the skin
bottom_left Sets the background color for the bottom left portion of the skin
bottom_right Sets the background color for the bottom right portion of the skin
make_default If this skin should be the default menu skin to be used, set this argument to true
Returns:
True if the skin was loaded successfully, or false in case of an error
A few notes about this function:

Referenced by hoa_video::GameVideo::LoadMenuSkin().

void hoa_video::private_video::GUISupervisor::RemoveMenuWindow ( MenuWindow old_window  ) 

Removes an existing MenuWindow from the map of existing windows.

Parameters:
old_window A pointer to the MenuWindow to be removed Don't call this method anywhere else but from MenuWindow::Destroy(), or you may cause problems.

Definition at line 302 of file gui.cpp.

References hoa_video::MenuWindow::_id, _menu_windows, and hoa_video::VIDEO_DEBUG.

Referenced by hoa_video::MenuWindow::Destroy().

void hoa_video::private_video::GUISupervisor::SetDefaultMenuSkin ( std::string &  skin_name  ) 

Sets the default menu skin to use from the set of pre-loaded skins.

Parameters:
skin_name The name of the already loaded menu skin that should be made the default skin
If the skin_name does not refer to a valid skin, a warning message will be printed and no change will occur.
Note:
This method will not change the skins of any active menu windows.

Definition at line 254 of file gui.cpp.

References _default_skin, _menu_skins, and hoa_video::VIDEO_DEBUG.

bool hoa_video::private_video::GUISupervisor::SingletonInitialize (  )  [virtual]

A method for the inheriting class to implement, which initializes the class.

Returns:
True if initialization was successful, false if it was not

Implements hoa_utils::Singleton< T >.

Definition at line 184 of file gui.cpp.

Referenced by hoa_video::GameVideo::SingletonInitialize().


Friends And Related Function Documentation

friend class hoa_utils::Singleton< GUISupervisor > [friend]

Definition at line 180 of file gui.h.


Member Data Documentation

uint32 hoa_video::private_video::GUISupervisor::_current_sample [private]

An index variable to keep track of the start of the circular fps_samples array.

Definition at line 300 of file gui.h.

Referenced by DrawFPS(), and GUISupervisor().

MenuSkin* hoa_video::private_video::GUISupervisor::_default_skin [private]

A pointer to the default menu skin that GUI objects will use if a skin is not explicitly declared If no menu skins exist, this member will be NULL. It will never be NULL as long as one menu skin is loaded. If the default menu skin is deleted by the user, an alternative default skin will automatically be set.

Definition at line 286 of file gui.h.

Referenced by GetDefaultMenuSkin(), and SetDefaultMenuSkin().

uint32 hoa_video::private_video::GUISupervisor::_fps_samples[FPS_SAMPLES] [private]

A circular array of FPS samples used for calculating average FPS.

Definition at line 292 of file gui.h.

Referenced by DrawFPS(), and GUISupervisor().

uint32 hoa_video::private_video::GUISupervisor::_fps_sum [private]

Keeps track of the sum of FPS values over the last VIDEO_FPS_SAMPLES frames This is used to simplify the calculation of average frames per second.

Definition at line 297 of file gui.h.

Referenced by DrawFPS(), and GUISupervisor().

std::map<std::string, MenuSkin> hoa_video::private_video::GUISupervisor::_menu_skins [private]

A map containing all of the menu skins which have been loaded The string argument is the reference name of the menu, which is defined by the user when they load a new skin.

Definition at line 273 of file gui.h.

Referenced by DeleteMenuSkin(), GetMenuSkin(), SetDefaultMenuSkin(), and ~GUISupervisor().

std::map<uint32, MenuWindow*> hoa_video::private_video::GUISupervisor::_menu_windows [private]

A map containing all of the actively created MenuWindow objects The integer key is the MenuWindow's ID number. This primary purpose of this map is to coordinate menu windows with menu skins. A menu skin can not be deleted when a menu window is still using that skin, and menu windows must be re-drawn when the properties of a menu skin that it uses changes.

Definition at line 280 of file gui.h.

Referenced by AddMenuWindow(), DeleteMenuSkin(), RemoveMenuWindow(), and ~GUISupervisor().

uint32 hoa_video::private_video::GUISupervisor::_next_window_id [private]

The next ID to assign to a MenuWindow when one is created.

Definition at line 289 of file gui.h.

Referenced by GetNextMenuWindowID().

uint32 hoa_video::private_video::GUISupervisor::_number_samples [private]

The number of FPS samples currently recorded. This value should always be VIDEO_FPS_SAMPLES, unless the game has just started, in which case it could be anywhere from 0 to VIDEO_FPS_SAMPLES depending on how many frames have been displayed.

Definition at line 307 of file gui.h.

Referenced by DrawFPS(), and GUISupervisor().


The documentation for this class was generated from the following files:
Generated on Fri Jul 6 23:16:46 2007 for Hero of Allacrost by  doxygen 1.5.1