| 1 |
/* |
| 2 |
* Copyright (C) 2004 Ivo Danihelka ([email protected]) |
| 3 |
* |
| 4 |
* This program is free software; you can redistribute it and/or modify |
| 5 |
* it under the terms of the GNU General Public License as published by |
| 6 |
* the Free Software Foundation; either version 2 of the License, or |
| 7 |
* (at your option) any later version. |
| 8 |
*/ |
| 9 |
#include "WorldInput.h" |
| 10 |
|
| 11 |
#include "WorldMap.h" |
| 12 |
#include "Keymap.h" |
| 13 |
|
| 14 |
#include "KeyStroke.h" |
| 15 |
#include "MouseStroke.h" |
| 16 |
|
| 17 |
//----------------------------------------------------------------- |
| 18 |
WorldInput::WorldInput(WorldMap *world) |
| 19 |
: GameInput(world) |
| 20 |
{ |
| 21 |
//TODO: 'O' ... options, 'I' ... intro, 'E' ... exit, 'C' ... credits |
| 22 |
KeyDesc key_tab(KEY_TAB, "select next level"); |
| 23 |
KeyDesc key_enter(KEY_ENTER, "run selected"); |
| 24 |
|
| 25 |
m_keymap->registerKey(KeyStroke(SDLK_TAB, KMOD_NONE), key_tab); |
| 26 |
m_keymap->registerKey(KeyStroke(SDLK_RETURN, KMOD_NONE), key_enter); |
| 27 |
} |
| 28 |
//----------------------------------------------------------------- |
| 29 |
WorldMap * |
| 30 |
WorldInput::getWorld() |
| 31 |
{ |
| 32 |
return dynamic_cast<WorldMap*>(m_state); |
| 33 |
} |
| 34 |
//----------------------------------------------------------------- |
| 35 |
void |
| 36 |
WorldInput::specKey(int keyIndex) |
| 37 |
{ |
| 38 |
switch (keyIndex) { |
| 39 |
case KEY_TAB: |
| 40 |
getWorld()->selectNextLevel(); |
| 41 |
break; |
| 42 |
case KEY_ENTER: |
| 43 |
getWorld()->runSelected(); |
| 44 |
break; |
| 45 |
default: |
| 46 |
GameInput::specKey(keyIndex); |
| 47 |
} |
| 48 |
} |
| 49 |
//----------------------------------------------------------------- |
| 50 |
void |
| 51 |
WorldInput::mouseEvent(const MouseStroke &buttons) |
| 52 |
{ |
| 53 |
if (buttons.isLeft()) { |
| 54 |
getWorld()->runSelected(); |
| 55 |
} |
| 56 |
} |
| 57 |
|