Main Page | Class Hierarchy | Alphabetical List | Data Structures | Directories | File List | Data Fields | Globals

StateManager Class Reference

Inheritance diagram for StateManager:

Inheritance graph
[legend]
Collaboration diagram for StateManager:

Collaboration graph
[legend]

Detailed Description

Stack of states.

Definition at line 13 of file StateManager.h.

Public Member Functions

virtual ~StateManager ()
void updateGame ()
 Update current state and states on background and empty trash.
void changeState (GameState *who, GameState *new_state)
 Remove given state and set this one.
void pushState (GameState *who, GameState *new_state)
 Pause given state and activate this one.
void popState (GameState *who)
 Remove given state and resume paused states below it.


Constructor & Destructor Documentation

StateManager::~StateManager  )  [virtual]
 

Definition at line 18 of file StateManager.cpp.

00019 {
00020     emptyTrash();
00021 
00022     t_states::iterator end = m_states.end();
00023     for (t_states::iterator i = m_states.begin(); i != end; ++i) {
00024         delete (*i);
00025     }
00026 }


Member Function Documentation

void StateManager::changeState GameState who,
GameState new_state
 

Remove given state and set this one.

Definition at line 75 of file StateManager.cpp.

00076 {
00077     insertAfter(who, new_state);
00078     removeState(who);
00079     new_state->initState(this);
00080     checkStack();
00081 }

void StateManager::popState GameState who  ) 
 

Remove given state and resume paused states below it.

Definition at line 99 of file StateManager.cpp.

00100 {
00101     removeState(who);
00102 
00103     if (!m_states.empty()) {
00104         checkStack();
00105     }
00106     else {
00107         MessagerAgent::agent()->forwardNewMsg(
00108                 new SimpleMsg(Name::APP_NAME, "quit"));
00109     }
00110 }

void StateManager::pushState GameState who,
GameState new_state
 

Pause given state and activate this one.

Definition at line 87 of file StateManager.cpp.

00088 {
00089     insertAfter(who, new_state);
00090     new_state->initState(this);
00091     checkStack();
00092 }

void StateManager::updateGame  ) 
 

Update current state and states on background and empty trash.

The states at bottom will be updated as first.

Definition at line 44 of file StateManager.cpp.

00045 {
00046     t_states::iterator end = m_states.end();
00047     for (t_states::iterator i = m_states.begin(); i != end; /* empty */) {
00048         //NOTE: state can remove self and thus invalide current iterator
00049         GameState *cur = *(i++);
00050         if (cur->isRunning()) {
00051             cur->updateState();
00052         }
00053     }
00054 
00055     emptyTrash();
00056 }


The documentation for this class was generated from the following files:
Generated on Wed Jun 1 09:56:57 2005 for Fish Fillets - Next Generation by  doxygen 1.4.2