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

StateInput Class Reference

Inheritance diagram for StateInput:

Inheritance graph
[legend]
Collaboration diagram for StateInput:

Collaboration graph
[legend]

Detailed Description

Handle input for game state.

Definition at line 12 of file StateInput.h.

Public Member Functions

 StateInput (GameState *state)
 Create state input handler.
 ~StateInput ()
virtual void keyEvent (const KeyStroke &stroke)
 Inspects keystroke and call:
  • common function for quit, console, help, menu, subtitles
  • specKey() for defined keystroke but unknown for us
  • specStroke() for other keys.


Protected Member Functions

virtual void quitState ()
virtual void enableConsole ()
virtual void enableHelp ()
virtual void enableMenu ()
virtual void enableSubtitles ()
virtual void specStroke (const KeyStroke &)
virtual void specKey (int keyIndex)
void toggleParam (const std::string &param)

Protected Attributes

Keymapm_keymap
GameStatem_state

Static Protected Attributes

static const int KEY_QUIT = 1
static const int KEY_CONSOLE = 2
static const int KEY_HELP = 3
static const int KEY_MENU = 4
static const int KEY_SUBTITLES = 5


Constructor & Destructor Documentation

StateInput::StateInput GameState state  ) 
 

Create state input handler.

Parameters:
state pointer to the leader

Definition at line 24 of file StateInput.cpp.

00025 {
00026     m_state = state;
00027     m_keymap = new Keymap();
00028     KeyDesc key_quit(KEY_QUIT, "quit");
00029     KeyDesc key_console(KEY_CONSOLE, "debug console");
00030     KeyDesc key_help(KEY_HELP, "help screen");
00031     KeyDesc key_menu(KEY_MENU, "game menu");
00032     m_keymap->registerKey(KeyStroke(SDLK_ESCAPE, KMOD_NONE), key_quit);
00033     m_keymap->registerKey(KeyStroke(SDLK_BACKQUOTE, KMOD_NONE), key_console);
00034     m_keymap->registerKey(KeyStroke(SDLK_F1, KMOD_NONE), key_help);
00035     m_keymap->registerKey(KeyStroke(SDLK_F10, KMOD_NONE), key_menu);
00036     m_keymap->registerKey(KeyStroke(SDLK_F6, KMOD_NONE),
00037             KeyDesc(KEY_SUBTITLES, "enable subtitles"));
00038 }

StateInput::~StateInput  ) 
 

Definition at line 40 of file StateInput.cpp.

00041 {
00042     delete m_keymap;
00043 }


Member Function Documentation

void StateInput::enableConsole  )  [protected, virtual]
 

Reimplemented in ConsoleInput.

Definition at line 94 of file StateInput.cpp.

00095 {
00096     m_state->pushState(new KeyConsole());
00097 }

virtual void StateInput::enableHelp  )  [inline, protected, virtual]
 

Reimplemented in PedoInput, WorldInput, HelpInput, DemoInput, and GameInput.

Definition at line 24 of file StateInput.h.

00024 {};

virtual void StateInput::enableMenu  )  [inline, protected, virtual]
 

Reimplemented in HelpInput, OptionsInput, and GameInput.

Definition at line 25 of file StateInput.h.

00025 {};

void StateInput::enableSubtitles  )  [protected, virtual]
 

Reimplemented in PedoInput, WorldInput, and ConsoleInput.

Definition at line 100 of file StateInput.cpp.

00101 {
00102     toggleParam("subtitles");
00103 }

void StateInput::keyEvent const KeyStroke stroke  )  [virtual]
 

Inspects keystroke and call:

  • common function for quit, console, help, menu, subtitles
  • specKey() for defined keystroke but unknown for us
  • specStroke() for other keys.

Reimplemented from InputHandler.

Definition at line 52 of file StateInput.cpp.

00053 {
00054     int index = m_keymap->indexPressed(stroke);
00055     switch (index) {
00056         case KEY_QUIT:
00057             quitState();
00058             break;
00059         case KEY_CONSOLE:
00060             enableConsole();
00061             break;
00062         case KEY_HELP:
00063             enableHelp();
00064             break;
00065         case KEY_MENU:
00066             enableMenu();
00067             break;
00068         case KEY_SUBTITLES:
00069             enableSubtitles();
00070             break;
00071         case -1:
00072             specStroke(stroke);
00073             break;
00074         default:
00075             specKey(index);
00076             break;
00077     }
00078 }

void StateInput::quitState  )  [protected, virtual]
 

Definition at line 88 of file StateInput.cpp.

00089 {
00090     m_state->quitState();
00091 }

void StateInput::specKey int  keyIndex  )  [protected, virtual]
 

Reimplemented in LevelInput, and ConsoleInput.

Definition at line 81 of file StateInput.cpp.

00082 {
00083     LOG_WARNING(ExInfo("unknown key")
00084             .addInfo("keyIndex", keyIndex));
00085 }

virtual void StateInput::specStroke const KeyStroke  )  [inline, protected, virtual]
 

Reimplemented in LevelInput, HelpInput, and ConsoleInput.

Definition at line 27 of file StateInput.h.

00027 {}

void StateInput::toggleParam const std::string &  param  )  [protected]
 

Definition at line 106 of file StateInput.cpp.

00107 {
00108     OptionAgent *option = OptionAgent::agent();
00109     bool enable = option->getAsBool(param);
00110 
00111     option->setPersistent(param, !enable);
00112 }


Field Documentation

const int StateInput::KEY_CONSOLE = 2 [static, protected]
 

Definition at line 15 of file StateInput.h.

const int StateInput::KEY_HELP = 3 [static, protected]
 

Definition at line 16 of file StateInput.h.

const int StateInput::KEY_MENU = 4 [static, protected]
 

Definition at line 17 of file StateInput.h.

const int StateInput::KEY_QUIT = 1 [static, protected]
 

Definition at line 14 of file StateInput.h.

const int StateInput::KEY_SUBTITLES = 5 [static, protected]
 

Definition at line 18 of file StateInput.h.

Keymap* StateInput::m_keymap [protected]
 

Definition at line 19 of file StateInput.h.

GameState* StateInput::m_state [protected]
 

Definition at line 20 of file StateInput.h.


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