hoa_system::GameSystem Class Reference

Engine class that manages system information and functions. More...

#include <system.h>

Inheritance diagram for hoa_system::GameSystem:

Inheritance graph
[legend]
Collaboration diagram for hoa_system::GameSystem:

Collaboration graph
[legend]
List of all members.

Public Member Functions

void ExamineSystemTimers ()
 Checks all system timers for whether they should be paused or resumed This function is typically called whenever the GameModeManager class has changed the active game mode. When this is done, all system timers that are owned by the new game mode are resumed, all timers with a different owner are paused, and all timers with no owner are ignored.
void ExitGame ()
 The function to call to initialize the exit process of the game.
std::string GetLanguage () const
 Used to determine what language the game is running in.
uint32 GetUpdateTime () const
 Retrieves the amount of time that the game should be updated by for time-based movement. This function should only be called in the main game loop, located in main.cpp.
void InitializeTimers ()
 Initializes the timers used in the game.
bool NotDone () const
 Determines whether the user is done with the game.
void SetLanguage (std::string lang)
 Sets the language that the game should use.
void SetPlayTime (const uint8 h, const uint8 m, const uint8 s)
 Sets the play-time of a game instance.
bool SingletonInitialize ()
 A method for the inheriting class to implement, which initializes the class.
void UpdateTimers ()
 Updates the game timer variables.
 ~GameSystem ()
uint8 GetPlayHours () const
 Functions for retrieving the play time.
uint8 GetPlayMinutes () const
uint8 GetPlaySeconds () const

Private Member Functions

 GameSystem ()

Private Attributes

std::string _language
 The language in which to render text.
uint32 _last_update
 The last time that the UpdateTimers function was called, in milliseconds.
bool _not_done
 When this member is set to false, the program will exit.
std::set< SystemTimer * > _system_timers
 A set container for all SystemTimer objects that have been initialized The timers in this container are updated on each call to UpdateTimers(). Timers are inserted and erased from this class not by the SystemManager, but by the SystemTimer objects themselves.
uint32 _update_time
 The number of milliseconds that have transpired on the last timer update.
Play time variables
Timers that retain the total amount of time that the user has been playing When the player starts a new game or loads an existing game, these timers are reset.

uint8 _hours_played
uint16 _milliseconds_played
 
Note:
Milliseconds are not retained when saving or loading a saved game file.

uint8 _minutes_played
uint8 _seconds_played

Friends

class hoa_utils::Singleton< GameSystem >
class SystemTimer

Detailed Description

Engine class that manages system information and functions.

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

This is somewhat of a "miscellaneous" game engine class that manages constructs that don't really fit in with any other engine component. Perhaps the most important task that this engine component handles is that of timing.

Note:
This class is a singleton.

Definition at line 226 of file system.h.


Constructor & Destructor Documentation

hoa_system::GameSystem::~GameSystem (  ) 

Definition at line 160 of file system.cpp.

References hoa_system::SYSTEM_DEBUG.

hoa_system::GameSystem::GameSystem (  )  [private]

Definition at line 150 of file system.cpp.

References _language, _not_done, and hoa_system::SYSTEM_DEBUG.


Member Function Documentation

void hoa_system::GameSystem::ExamineSystemTimers (  ) 

Checks all system timers for whether they should be paused or resumed This function is typically called whenever the GameModeManager class has changed the active game mode. When this is done, all system timers that are owned by the new game mode are resumed, all timers with a different owner are paused, and all timers with no owner are ignored.

Definition at line 241 of file system.cpp.

References _system_timers, hoa_mode_manager::GameModeManager::GetTop(), and hoa_mode_manager::ModeManager.

Referenced by hoa_mode_manager::GameModeManager::Update().

Here is the call graph for this function:

void hoa_system::GameSystem::ExitGame (  )  [inline]

The function to call to initialize the exit process of the game.

Note:
The game will exit the main loop once it reaches the end of its current iteration

Definition at line 312 of file system.h.

References _not_done.

Referenced by hoa_input::GameInput::_JoystickEventHandler(), hoa_input::GameInput::_KeyEventHandler(), hoa_boot::BootMode::_OnQuit(), hoa_quit::QuitMode::_QuitGame(), hoa_boot::BootMode::BootMode(), hoa_input::GameInput::EventHandler(), and hoa_battle::BattleMode::SetPerformingScript().

std::string hoa_system::GameSystem::GetLanguage (  )  const [inline]

Used to determine what language the game is running in.

Returns:
The language that the game is running in.

Definition at line 295 of file system.h.

References _language.

uint8 hoa_system::GameSystem::GetPlayHours (  )  const [inline]

Functions for retrieving the play time.

Returns:
The number of hours, minutes, or seconds of play time.

Definition at line 282 of file system.h.

References _hours_played.

Referenced by hoa_menu::MenuMode::_DrawBottomMenu().

uint8 hoa_system::GameSystem::GetPlayMinutes (  )  const [inline]

Definition at line 285 of file system.h.

References _minutes_played.

Referenced by hoa_menu::MenuMode::_DrawBottomMenu().

uint8 hoa_system::GameSystem::GetPlaySeconds (  )  const [inline]

Definition at line 288 of file system.h.

References _seconds_played.

Referenced by hoa_menu::MenuMode::_DrawBottomMenu().

uint32 hoa_system::GameSystem::GetUpdateTime (  )  const [inline]

Retrieves the amount of time that the game should be updated by for time-based movement. This function should only be called in the main game loop, located in main.cpp.

Returns:
The number of milliseconds that have transpired since the last update.
Note:
There's a chance we could get errors in other parts of the program code if the value returned by this function is zero. We can prevent this if we always make sure the function returns at least one, but I'm not sure there exists a computer fast enough that we have to worry about it.

Definition at line 265 of file system.h.

References _update_time.

Referenced by hoa_boot::BootMode::_AnimateLogo(), hoa_system::SystemTimer::_UpdateTimer(), hoa_battle::private_battle::BattleEnemyActor::DrawSprite(), hoa_battle::private_battle::BattleCharacterActor::DrawSprite(), hoa_map::private_map::ActionAnimate::Execute(), hoa_map::private_map::ActionRandomMove::Execute(), main(), hoa_shop::private_shop::ObjectSellListWindow::Update(), hoa_shop::private_shop::ObjectListWindow::Update(), hoa_shop::private_shop::ShopActionWindow::Update(), hoa_scene::SceneMode::Update(), hoa_quit::QuitMode::Update(), hoa_menu::private_menu::InventoryWindow::Update(), hoa_map::private_map::EnemySprite::Update(), hoa_map::MapMode::Update(), hoa_boot::BootMode::Update(), hoa_battle::private_battle::ActionWindow::Update(), hoa_battle::private_battle::BattleEnemyActor::Update(), hoa_battle::private_battle::BattleCharacterActor::Update(), hoa_battle::private_battle::ScriptEvent::Update(), and hoa_audio::GameAudio::Update().

void hoa_system::GameSystem::InitializeTimers (  ) 

Initializes the timers used in the game.

This function should only be called once in main.cpp, just before the main game loop begins.

Definition at line 199 of file system.cpp.

References _hours_played, _last_update, _milliseconds_played, _minutes_played, _seconds_played, _system_timers, and _update_time.

Referenced by InitializeEngine().

bool hoa_system::GameSystem::NotDone (  )  const [inline]

Determines whether the user is done with the game.

Returns:
False if the user would like to exit the game.

Definition at line 306 of file system.h.

References _not_done.

Referenced by main().

void hoa_system::GameSystem::SetLanguage ( std::string  lang  ) 

Sets the language that the game should use.

Parameters:
lang A two-character string representing the language to execute the game in

Definition at line 259 of file system.cpp.

References _language.

void hoa_system::GameSystem::SetPlayTime ( const uint8  h,
const uint8  m,
const uint8  s 
) [inline]

Sets the play-time of a game instance.

Parameters:
h The amount of hours to set.
m The amount of minutes to set.
s The amount of seconds to set.
This function is meant to be called whenever the user loads a saved game.

Definition at line 275 of file system.h.

References _hours_played, _milliseconds_played, _minutes_played, and _seconds_played.

bool hoa_system::GameSystem::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 167 of file system.cpp.

References hoa_audio::AudioManager, hoa_script::ReadScriptDescriptor::CloseFile(), hoa_script::ReadScriptDescriptor::CloseTable(), hoa_script::ScriptDescriptor::GetErrorMessages(), hoa_script::ScriptDescriptor::IsErrorDetected(), hoa_script::ReadScriptDescriptor::OpenFile(), hoa_script::ReadScriptDescriptor::OpenTable(), hoa_script::ReadScriptDescriptor::ReadFloat(), hoa_audio::GameAudio::SetMusicVolume(), and hoa_audio::GameAudio::SetSoundVolume().

Referenced by InitializeEngine().

Here is the call graph for this function:

void hoa_system::GameSystem::UpdateTimers (  ) 

Updates the game timer variables.

This function should only be called once for each cycle through the main game loop. Since it is called inside the loop in main.cpp, you should have no reason to call this function anywhere else.

Definition at line 211 of file system.cpp.

References _hours_played, _last_update, _milliseconds_played, _minutes_played, _seconds_played, _system_timers, and _update_time.

Referenced by hoa_battle::BattleMode::_Initialize(), and main().


Friends And Related Function Documentation

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

Definition at line 227 of file system.h.

friend class SystemTimer [friend]

Definition at line 228 of file system.h.


Member Data Documentation

uint8 hoa_system::GameSystem::_hours_played [private]

Definition at line 328 of file system.h.

Referenced by GetPlayHours(), InitializeTimers(), SetPlayTime(), and UpdateTimers().

std::string hoa_system::GameSystem::_language [private]

The language in which to render text.

Note:
This string will always be two characters wide.

Definition at line 341 of file system.h.

Referenced by GameSystem(), GetLanguage(), and SetLanguage().

uint32 hoa_system::GameSystem::_last_update [private]

The last time that the UpdateTimers function was called, in milliseconds.

Definition at line 319 of file system.h.

Referenced by InitializeTimers(), and UpdateTimers().

uint16 hoa_system::GameSystem::_milliseconds_played [private]

Note:
Milliseconds are not retained when saving or loading a saved game file.

Definition at line 332 of file system.h.

Referenced by InitializeTimers(), SetPlayTime(), and UpdateTimers().

uint8 hoa_system::GameSystem::_minutes_played [private]

Definition at line 329 of file system.h.

Referenced by GetPlayMinutes(), InitializeTimers(), SetPlayTime(), and UpdateTimers().

bool hoa_system::GameSystem::_not_done [private]

When this member is set to false, the program will exit.

Definition at line 336 of file system.h.

Referenced by ExitGame(), GameSystem(), and NotDone().

uint8 hoa_system::GameSystem::_seconds_played [private]

Definition at line 330 of file system.h.

Referenced by GetPlaySeconds(), InitializeTimers(), SetPlayTime(), and UpdateTimers().

std::set<SystemTimer*> hoa_system::GameSystem::_system_timers [private]

A set container for all SystemTimer objects that have been initialized The timers in this container are updated on each call to UpdateTimers(). Timers are inserted and erased from this class not by the SystemManager, but by the SystemTimer objects themselves.

Definition at line 348 of file system.h.

Referenced by ExamineSystemTimers(), hoa_system::SystemTimer::Initialize(), InitializeTimers(), UpdateTimers(), and hoa_system::SystemTimer::~SystemTimer().

uint32 hoa_system::GameSystem::_update_time [private]

The number of milliseconds that have transpired on the last timer update.

Definition at line 321 of file system.h.

Referenced by GetUpdateTime(), InitializeTimers(), and UpdateTimers().


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