State Class Reference

Controlls the state of the application. More...

#include <State.h>

Inheritance diagram for State:

Inheritance graph
[legend]
Collaboration diagram for State:

Collaboration graph
[legend]
List of all members.

Public Member Functions

 State ()
 State (StateID state)
virtual ~State ()
virtual void paint ()
 Callback for painting, overload in other states.
virtual void doKey (int key, int x, int y, bool special, bool down, unsigned int modifiers)
 Callback for key event, overload in other states.
virtual void doMouseDown (Interface::MouseButtonType button, int x, int y)
 Callback for mouse down, overload in other states.
virtual void doMouseUp (Interface::MouseButtonType button, int x, int y)
 Callback for mouse up, overload in other states.
virtual void doMouseDragged (int x, int y)
 Callback for mouse dragged, overload in other states.

Static Public Member Functions

static void SetState (StateID state)
 Switch state.
static void Destroy ()
 Cleans up any resources used by states such as deleting the current state and current gamestate.
static void DoRepaint ()
 Calls currentState->paint and flushes the current inteface.
static void DoKey (int key, int x, int y, bool special, bool down, unsigned int modifiers)
 Calls currentState->doKey.
static void DoMouseDragged (int x, int y)
 Calls currentState->doMouseDragged.
static void DoMouse (int x, int y, Interface::MouseButtonType button, bool down)
 Calls currentState->doMouseUp/doMouseDown.
static void DoAnimateOneFrame (int value)
 Periodic call to paint and flush.
static void SynchronizePreferences (int ignore)
 Timer callback to synchronize preferences with disc.

Protected Attributes

StateID ID
bool stopIntro

Static Protected Attributes

static StatecurrentState

Detailed Description

Controlls the state of the application.

Changes how the application handles events depending on the current state. Simple states can be incorporated to the State class, but for more complex states a sub-class should be created to provide encapsulation.

Often static functions can be reused by having them call member functions in the current state.

Author:
Daniel Aarno


Constructor & Destructor Documentation

State::State (  )  [inline]

State::State ( StateID  state  ) 

virtual State::~State (  )  [virtual]


Member Function Documentation

static void State::Destroy (  )  [static]

Cleans up any resources used by states such as deleting the current state and current gamestate.

static void State::DoAnimateOneFrame ( int  value  )  [static]

Periodic call to paint and flush.

static void State::DoKey ( int  key,
int  x,
int  y,
bool  special,
bool  down,
unsigned int  modifiers 
) [static]

Calls currentState->doKey.

virtual void State::doKey ( int  key,
int  x,
int  y,
bool  special,
bool  down,
unsigned int  modifiers 
) [virtual]

Callback for key event, overload in other states.

Reimplemented in GameState, and MainMenuState.

static void State::DoMouse ( int  x,
int  y,
Interface::MouseButtonType  button,
bool  down 
) [static]

Calls currentState->doMouseUp/doMouseDown.

virtual void State::doMouseDown ( Interface::MouseButtonType  button,
int  x,
int  y 
) [inline, virtual]

Callback for mouse down, overload in other states.

Reimplemented in GameState.

static void State::DoMouseDragged ( int  x,
int  y 
) [static]

Calls currentState->doMouseDragged.

virtual void State::doMouseDragged ( int  x,
int  y 
) [inline, virtual]

Callback for mouse dragged, overload in other states.

Reimplemented in GameState.

virtual void State::doMouseUp ( Interface::MouseButtonType  button,
int  x,
int  y 
) [inline, virtual]

Callback for mouse up, overload in other states.

Reimplemented in GameState.

static void State::DoRepaint (  )  [static]

Calls currentState->paint and flushes the current inteface.

virtual void State::paint (  )  [virtual]

Callback for painting, overload in other states.

Reimplemented in GameState, and MainMenuState.

static void State::SetState ( StateID  state  )  [static]

Switch state.

Note:
Deletes the current state

static void State::SynchronizePreferences ( int  ignore  )  [static]

Timer callback to synchronize preferences with disc.


Member Data Documentation

State* State::currentState [static, protected]

StateID State::ID [protected]

bool State::stopIntro [protected]


The documentation for this class was generated from the following file:
Generated on Sun Mar 11 15:33:26 2007 for MetalWarriors by  doxygen 1.4.7