GameState installs own InputHandler in init phase.
To change state, use m_manager->pushState(topState) or m_manager->changeState(newState)
Definition at line 21 of file GameState.h.
Public Member Functions | ||||
GameState () | ||||
virtual | ~GameState () | |||
virtual bool | allowBg () const | |||
bool | isRunning () const | |||
bool | isOnBg () const | |||
void | setNextState (GameState *nextState) | |||
void | initState (StateManager *manager) | |||
void | updateState () | |||
| ||||
void | pauseState () | |||
| ||||
void | resumeState () | |||
Reactivate state after pause. | ||||
void | cleanState () | |||
Clean state after run. | ||||
void | quitState () | |||
void | pushState (GameState *new_state) | |||
void | noteBg () | |||
void | noteFg () | |||
void | installHandlers () | |||
Install own video and input handler. | ||||
void | unHandlers () | |||
Uninstall own video and input handler. | ||||
void | receiveSimple (const SimpleMsg *msg) | |||
Handle incoming message. | ||||
Protected Member Functions | ||||
void | takeHandler (InputHandler *new_handler) | |||
Obtain input handler. | ||||
const InputProvider * | getInput () | |||
Returns wrapped input. | ||||
virtual void | own_initState ()=0 | |||
virtual void | own_updateState ()=0 | |||
virtual void | own_pauseState ()=0 | |||
virtual void | own_resumeState ()=0 | |||
virtual void | own_cleanState ()=0 | |||
virtual void | own_noteBg () | |||
virtual void | own_noteFg () | |||
void | changeState (GameState *new_state) | |||
void | registerDrawable (Drawable *drawable) | |||
Add new drawable to drawers fifo. | ||||
void | deregisterDrawable (const Drawable *drawable) |
|
Definition at line 23 of file GameState.cpp. 00024 { 00025 m_nextState = NULL; 00026 m_handler = NULL; 00027 m_active = false; 00028 m_onBg = false; 00029 m_drawer = new MultiDrawer(); 00030 }
|
|
Definition at line 32 of file GameState.cpp. 00033 { 00034 if (m_handler) { 00035 delete m_handler; 00036 } 00037 delete m_drawer; 00038 }
|
|
Reimplemented in MenuHelp, MenuOptions, KeyConsole, and PosterScroller. Definition at line 48 of file GameState.h. 00048 { return false; }
|
|
Definition at line 158 of file GameState.cpp. 00159 { 00160 m_manager->changeState(this, new_state); 00161 }
|
|
Clean state after run.
Definition at line 123 of file GameState.cpp. 00124 { 00125 LOG_DEBUG(ExInfo("cleanState").addInfo("name", getName())); 00126 if (!m_active) { 00127 throw LogicException(ExInfo("clean - state is not active") 00128 .addInfo("name", getName())); 00129 } 00130 own_cleanState(); 00131 unHandlers(); 00132 00133 m_active = false; 00134 m_onBg = false; 00135 m_manager = NULL; 00136 removeWatchers(); 00137 MessagerAgent::agent()->removeListener(getName()); 00138 }
|
|
Definition at line 213 of file GameState.cpp. 00214 { 00215 m_drawer->removeDrawer(drawable); 00216 }
|
|
Returns wrapped input.
Definition at line 57 of file GameState.cpp. 00058 {
00059 return m_handler;
00060 }
|
|
Definition at line 63 of file GameState.cpp. 00064 { 00065 LOG_DEBUG(ExInfo("initState").addInfo("name", getName())); 00066 MessagerAgent::agent()->addListener(this); 00067 m_manager = manager; 00068 m_active = true; 00069 m_onBg = false; 00070 own_initState(); 00071 }
|
|
Install own video and input handler.
Definition at line 183 of file GameState.cpp. 00184 { 00185 LOG_DEBUG(ExInfo("installHandlers").addInfo("state", getName())); 00186 InputAgent::agent()->installHandler(m_handler); 00187 VideoAgent::agent()->acceptDrawer(m_drawer); 00188 }
|
|
Definition at line 50 of file GameState.h. 00050 { return m_onBg; }
|
|
Definition at line 49 of file GameState.h. 00049 { return m_active; }
|
|
Definition at line 164 of file GameState.cpp. 00165 { 00166 LOG_DEBUG(ExInfo("noteBg").addInfo("name", getName())); 00167 own_noteBg(); 00168 m_onBg = true; 00169 }
|
|
Definition at line 172 of file GameState.cpp. 00173 { 00174 LOG_DEBUG(ExInfo("noteFg").addInfo("name", getName())); 00175 m_onBg = false; 00176 own_noteFg(); 00177 }
|
|
Implemented in Level, Pedometer, WorldMap, MenuHelp, MenuOptions, KeyConsole, DemoMode, and PosterState. |
|
Implemented in Level, Pedometer, WorldMap, MenuHelp, MenuOptions, KeyConsole, DemoMode, PosterScroller, and PosterState. |
|
Reimplemented in Level. Definition at line 39 of file GameState.h. 00039 {}
|
|
Reimplemented in Level. Definition at line 40 of file GameState.h. 00040 {}
|
|
Implemented in Level, Pedometer, WorldMap, MenuHelp, MenuOptions, KeyConsole, DemoMode, and PosterState. |
|
Implemented in Level, Pedometer, WorldMap, MenuHelp, MenuOptions, KeyConsole, DemoMode, and PosterState. |
|
Implemented in Level, Pedometer, WorldMap, MenuHelp, MenuOptions, KeyConsole, DemoMode, PosterScroller, and PosterState. |
|
Definition at line 91 of file GameState.cpp. 00092 { 00093 if (!m_active) { 00094 throw LogicException(ExInfo("pause - state is not active") 00095 .addInfo("name", getName())); 00096 } 00097 00098 own_pauseState(); 00099 m_active = false; 00100 m_onBg = false; 00101 }
|
|
Definition at line 152 of file GameState.cpp. 00153 { 00154 m_manager->pushState(this, new_state); 00155 }
|
|
Definition at line 141 of file GameState.cpp. 00142 { 00143 if (m_nextState) { 00144 changeState(m_nextState); 00145 } 00146 else { 00147 m_manager->popState(this); 00148 } 00149 }
|
|
Handle incoming message. Messages:
Reimplemented from BaseListener. Definition at line 224 of file GameState.cpp. 00225 { 00226 if (msg->equalsName("quit")) { 00227 quitState(); 00228 } 00229 else { 00230 LOG_WARNING(ExInfo("unknown msg") 00231 .addInfo("msg", msg->toString())); 00232 } 00233 }
|
|
Add new drawable to drawers fifo. NOTE: order is important, the first inserted drawer will be on background Definition at line 207 of file GameState.cpp. 00208 { 00209 m_drawer->acceptDrawer(drawable); 00210 }
|
|
Reactivate state after pause.
Definition at line 108 of file GameState.cpp. 00109 { 00110 if (m_active) { 00111 throw LogicException(ExInfo("resume - state is already active") 00112 .addInfo("name", getName())); 00113 } 00114 m_active = true; 00115 own_resumeState(); 00116 }
|
|
Definition at line 51 of file GameState.h. 00051 { m_nextState = nextState; }
|
|
Obtain input handler.
Definition at line 45 of file GameState.cpp. 00046 { 00047 if (m_handler) { 00048 delete m_handler; 00049 } 00050 m_handler = new_handler; 00051 }
|
|
Uninstall own video and input handler.
Definition at line 194 of file GameState.cpp. 00195 { 00196 InputAgent::agent()->installHandler(NULL); 00197 VideoAgent::agent()->removeDrawer(m_drawer); 00198 }
|
|
Definition at line 77 of file GameState.cpp. 00078 { 00079 if (!m_active) { 00080 throw LogicException(ExInfo("update - state is not active") 00081 .addInfo("name", getName())); 00082 } 00083 00084 own_updateState(); 00085 }
|