#include <mode_manager.h>
Inheritance diagram for hoa_mode_manager::GameModeManager:


Public Member Functions | |
| void | DEBUG_PrintStack () |
| Prints the contents of the game_stack member to standard output. | |
| void | Draw () |
| Calls the Draw() function on the active game mode. | |
| uint8 | GetGameType () |
| Gets the type of the currently active game mode. | |
| GameMode * | GetTop () |
| Gets a pointer to the top game stack object. | |
| void | Pop () |
| Increments by one the number of game modes to pop off the stack. | |
| void | PopAll () |
| Removes all game modes from the stack on the next call to GameModeManager::Update(). | |
| void | Push (GameMode *gm) |
| Pushes a new GameMode object on top of the stack. | |
| bool | SingletonInitialize () |
| A method for the inheriting class to implement, which initializes the class. | |
| void | Update () |
| Checks if the game stack needs modes pushed or popped, then calls Update on the active game mode. | |
| ~GameModeManager () | |
Private Member Functions | |
| GameModeManager () | |
Private Attributes | |
| std::vector< GameMode * > | _game_stack |
| A stack containing all the live game modes. | |
| uint32 | _pop_count |
| The number of game modes to pop from the back of the stack on the next call to GameModeManager::Update(). | |
| std::vector< GameMode * > | _push_stack |
| A vector of game modes to push to the stack on the next call to GameModeManager::Update(). | |
| bool | _state_change |
| True if a state change occured and we need to change the active game mode. | |
Friends | |
| class | hoa_utils::Singleton< GameModeManager > |
***************************************************************************
The GameModeManager class keeps a stack of GameMode objects, where the object on the top of the stack is the active GameMode (there can only be one active game mode at any time). The Update() and Draw() functions for this class are wrapper calls to the GameMode functions of the same name, and act on the active game mode.
When a condition is encountered in which a game mode wishes to destroy itself and/or push a new mode onto the stack, this does not occur until the next call to the GameModeManager::Update() function. The GameModeManager::push_stack retains all the game modes we wish to push onto the stack on the next call to GameModeManager::Update(), and the GameModeManager::pop_count member retains how many modes to delete and pop off the GameModeManager::game_stack. Pop operations are always performed before push operations.
2) You might be wondering why the game stack uses a vector container rather than a stack container. There are two reasons: the first being that we can't do a debug printout of the game_stack without removing elements *if* a stack is used. The second reason is "just in case" we need to access a stack element that is not on the top of the stack.
Definition at line 120 of file mode_manager.h.
| hoa_mode_manager::GameModeManager::GameModeManager | ( | ) | [private] |
Definition at line 59 of file mode_manager.cpp.
References _pop_count, _state_change, and hoa_mode_manager::MODE_MANAGER_DEBUG.
| hoa_mode_manager::GameModeManager::~GameModeManager | ( | ) |
Definition at line 67 of file mode_manager.cpp.
References _game_stack, _push_stack, and hoa_mode_manager::MODE_MANAGER_DEBUG.
| void hoa_mode_manager::GameModeManager::DEBUG_PrintStack | ( | ) |
Prints the contents of the game_stack member to standard output.
Definition at line 204 of file mode_manager.cpp.
References _game_stack.
| void hoa_mode_manager::GameModeManager::Draw | ( | ) |
Calls the Draw() function on the active game mode.
Definition at line 194 of file mode_manager.cpp.
References _game_stack.
Referenced by main().
| uint8 hoa_mode_manager::GameModeManager::GetGameType | ( | ) |
Gets the type of the currently active game mode.
Definition at line 132 of file mode_manager.cpp.
References _game_stack, and hoa_mode_manager::MODE_MANAGER_DUMMY_MODE.
Referenced by hoa_input::GameInput::_JoystickEventHandler(), hoa_input::GameInput::_KeyEventHandler(), hoa_input::GameInput::EventHandler(), hoa_input::TEMP_HandlePause(), and hoa_input::GameInput::TogglePause().
| GameMode * hoa_mode_manager::GameModeManager::GetTop | ( | ) |
Gets a pointer to the top game stack object.
Definition at line 141 of file mode_manager.cpp.
References _game_stack.
Referenced by hoa_system::GameSystem::ExamineSystemTimers().
| void hoa_mode_manager::GameModeManager::Pop | ( | ) |
Increments by one the number of game modes to pop off the stack.
Definition at line 111 of file mode_manager.cpp.
References _pop_count, and _state_change.
Referenced by hoa_quit::QuitMode::_Cancel(), hoa_menu::MenuMode::_HandleMainMenu(), hoa_battle::BattleMode::_Initialize(), hoa_input::GameInput::_JoystickEventHandler(), hoa_input::GameInput::_KeyEventHandler(), hoa_boot::BootMode::_OnBattleDebug(), hoa_boot::BootMode::_OnMenuDebug(), hoa_battle::BattleMode::_ShutDown(), hoa_input::GameInput::TogglePause(), hoa_shop::private_shop::ShopActionWindow::Update(), hoa_scene::SceneMode::Update(), hoa_menu::MenuMode::Update(), and hoa_boot::BootMode::Update().
| void hoa_mode_manager::GameModeManager::PopAll | ( | ) |
Removes all game modes from the stack on the next call to GameModeManager::Update().
This function sets the GameModeManager::pop_count member to the size of GameModeManager::game_stack. If there is no game mode in GameModeManager::push_stack before the next call to GameModeManager::Update(), The game will encounter a segmentation fault and die. Therefore, be careful with this function.
Definition at line 119 of file mode_manager.cpp.
References _game_stack, and _pop_count.
Referenced by hoa_quit::QuitMode::_QuitToBootMenu(), and hoa_battle::BattleMode::PlayerDefeat().
| void hoa_mode_manager::GameModeManager::Push | ( | GameMode * | gm | ) |
Pushes a new GameMode object on top of the stack.
| gm | The new GameMode object that will go to the top of the stack. |
Definition at line 125 of file mode_manager.cpp.
References _push_stack, and _state_change.
Referenced by hoa_map::MapMode::_HandleInputExplore(), hoa_input::GameInput::_JoystickEventHandler(), hoa_input::GameInput::_KeyEventHandler(), hoa_boot::BootMode::_OnBattleDebug(), hoa_boot::BootMode::_OnMenuDebug(), hoa_boot::BootMode::_OnShopDebug(), hoa_quit::QuitMode::_QuitToBootMenu(), hoa_input::GameInput::EventHandler(), hoa_battle::BattleMode::PlayerDefeat(), hoa_input::GameInput::TogglePause(), and hoa_boot::BootMode::Update().
| bool hoa_mode_manager::GameModeManager::SingletonInitialize | ( | ) | [virtual] |
A method for the inheriting class to implement, which initializes the class.
Implements hoa_utils::Singleton< T >.
Definition at line 84 of file mode_manager.cpp.
References _game_stack, _pop_count, _push_stack, and _state_change.
Referenced by InitializeEngine(), and Update().
| void hoa_mode_manager::GameModeManager::Update | ( | ) |
Checks if the game stack needs modes pushed or popped, then calls Update on the active game mode.
Definition at line 150 of file mode_manager.cpp.
References _game_stack, _pop_count, _push_stack, _state_change, hoa_system::GameSystem::ExamineSystemTimers(), hoa_mode_manager::MODE_MANAGER_DEBUG, SingletonInitialize(), and hoa_system::SystemManager.
Referenced by main().
Here is the call graph for this function:

friend class hoa_utils::Singleton< GameModeManager > [friend] |
Definition at line 121 of file mode_manager.h.
std::vector<GameMode*> hoa_mode_manager::GameModeManager::_game_stack [private] |
A stack containing all the live game modes.
Definition at line 129 of file mode_manager.h.
Referenced by DEBUG_PrintStack(), Draw(), GetGameType(), GetTop(), PopAll(), SingletonInitialize(), Update(), and ~GameModeManager().
The number of game modes to pop from the back of the stack on the next call to GameModeManager::Update().
Definition at line 138 of file mode_manager.h.
Referenced by GameModeManager(), Pop(), PopAll(), SingletonInitialize(), and Update().
std::vector<GameMode*> hoa_mode_manager::GameModeManager::_push_stack [private] |
A vector of game modes to push to the stack on the next call to GameModeManager::Update().
Definition at line 132 of file mode_manager.h.
Referenced by Push(), SingletonInitialize(), Update(), and ~GameModeManager().
bool hoa_mode_manager::GameModeManager::_state_change [private] |
True if a state change occured and we need to change the active game mode.
Definition at line 135 of file mode_manager.h.
Referenced by GameModeManager(), Pop(), Push(), SingletonInitialize(), and Update().
1.5.1