diff options
author | Eugene Sandulenko | 2011-11-17 14:22:48 -0800 |
---|---|---|
committer | Eugene Sandulenko | 2011-11-17 14:22:48 -0800 |
commit | 5420ad7619a000313381bfdca7cc768984192d49 (patch) | |
tree | 6b6c356283dc6b22353c54a0425843e072a8d72c /engines | |
parent | e79dda07f469626d9f2c06450a13625c52e47329 (diff) | |
parent | b708d6de79e2893cddf95d72864d4487a483e0c1 (diff) | |
download | scummvm-rg350-5420ad7619a000313381bfdca7cc768984192d49.tar.gz scummvm-rg350-5420ad7619a000313381bfdca7cc768984192d49.tar.bz2 scummvm-rg350-5420ad7619a000313381bfdca7cc768984192d49.zip |
Merge pull request #114 from tsoliman/keymapper2
KEYMAPPER: Keymapper improvements 2
Diffstat (limited to 'engines')
-rw-r--r-- | engines/engine.h | 5 | ||||
-rw-r--r-- | engines/kyra/lol.cpp | 67 | ||||
-rw-r--r-- | engines/kyra/lol.h | 4 |
3 files changed, 76 insertions, 0 deletions
diff --git a/engines/engine.h b/engines/engine.h index 2796df5c4f..d508b4ed18 100644 --- a/engines/engine.h +++ b/engines/engine.h @@ -180,6 +180,11 @@ public: */ virtual void syncSoundSettings(); + /* + * Initialize the engine-specific keymap + */ + virtual void initKeymap() {} + /** * Flip mute all sound option. */ diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp index 43859ddfbb..aed8f5c965 100644 --- a/engines/kyra/lol.cpp +++ b/engines/kyra/lol.cpp @@ -34,9 +34,14 @@ #include "common/config-manager.h" #include "common/system.h" +#include "common/translation.h" + +#include "backends/keymapper/keymapper.h" namespace Kyra { +const char *const LoLEngine::kKeymapName = "lol"; + LoLEngine::LoLEngine(OSystem *system, const GameFlags &flags) : KyraEngine_v1(system, flags) { _screen = 0; _gui = 0; @@ -246,6 +251,10 @@ LoLEngine::LoLEngine(OSystem *system, const GameFlags &flags) : KyraEngine_v1(sy LoLEngine::~LoLEngine() { setupPrologueData(false); +#ifdef ENABLE_KEYMAPPER + _eventMan->getKeymapper()->cleanupGameKeymaps(); +#endif + delete[] _landsFile; delete[] _levelLangFile; @@ -541,9 +550,67 @@ Common::Error LoLEngine::init() { _debugger = new Debugger_LoL(this); assert(_debugger); + initKeymap(); + return Common::kNoError; } +void LoLEngine::initKeymap() { +#ifdef ENABLE_KEYMAPPER + + bool tmp; + Common::Keymapper *mapper = _eventMan->getKeymapper(); + + // Do not try to recreate same keymap over again + if (mapper->getKeymap(kKeymapName, tmp) != 0) + return; + + Common::Action *act; + Common::Keymap *engineKeyMap = new Common::Keymap(kKeymapName); + + act = new Common::Action(engineKeyMap, "AT1", _("Attack 1"), Common::kGenericActionType, Common::kActionKeyType); + act->addKeyEvent(Common::KeyState(Common::KEYCODE_F1, Common::ASCII_F1 , 0)); + + act = new Common::Action(engineKeyMap, "AT2", _("Attack 2"), Common::kGenericActionType, Common::kActionKeyType); + act->addKeyEvent(Common::KeyState(Common::KEYCODE_F2, Common::ASCII_F2 , 0)); + + act = new Common::Action(engineKeyMap, "AT3", _("Attack 3"), Common::kGenericActionType, Common::kActionKeyType); + act->addKeyEvent(Common::KeyState(Common::KEYCODE_F3, Common::ASCII_F3 , 0)); + + act = new Common::Action(engineKeyMap, "MVF", _("Move Forward"), Common::kGenericActionType, Common::kActionKeyType); + act->addKeyEvent(Common::KeyState(Common::KEYCODE_UP)); + + act = new Common::Action(engineKeyMap, "MVB", _("Move Back"), Common::kGenericActionType, Common::kActionKeyType); + act->addKeyEvent(Common::KeyState(Common::KEYCODE_DOWN)); + + act = new Common::Action(engineKeyMap, "SLL", _("Slide Left"), Common::kGenericActionType, Common::kActionKeyType); + act->addKeyEvent(Common::KeyState(Common::KEYCODE_LEFT)); + + act = new Common::Action(engineKeyMap, "SLR", _("Slide Right"), Common::kGenericActionType, Common::kActionKeyType); + act->addKeyEvent(Common::KeyState(Common::KEYCODE_RIGHT)); + + act = new Common::Action(engineKeyMap, "TL", _("Turn Left"), Common::kGenericActionType, Common::kActionKeyType); + act->addKeyEvent(Common::KeyState(Common::KEYCODE_HOME)); + + act = new Common::Action(engineKeyMap, "TR", _("Turn Right"), Common::kGenericActionType, Common::kActionKeyType); + act->addKeyEvent(Common::KeyState(Common::KEYCODE_PAGEUP)); + + act = new Common::Action(engineKeyMap, "RST", _("Rest"), Common::kGenericActionType, Common::kActionKeyType); + act->addKeyEvent(Common::KeyState(Common::KEYCODE_r)); + + act = new Common::Action(engineKeyMap, "OPT", _("Options"), Common::kGenericActionType, Common::kActionKeyType); + act->addKeyEvent(Common::KeyState(Common::KEYCODE_o)); + + act = new Common::Action(engineKeyMap, "SPL", _("Choose Spell"), Common::kGenericActionType, Common::kActionKeyType); + act->addKeyEvent(Common::KeyState(Common::KEYCODE_SLASH)); + + mapper->addGameKeymap(engineKeyMap); + + mapper->pushKeymap(kKeymapName, true); + +#endif +} + Common::Error LoLEngine::go() { int action = -1; diff --git a/engines/kyra/lol.h b/engines/kyra/lol.h index 5f6be61d64..eb2f6cf2d7 100644 --- a/engines/kyra/lol.h +++ b/engines/kyra/lol.h @@ -307,6 +307,8 @@ public: LoLEngine(OSystem *system, const GameFlags &flags); ~LoLEngine(); + virtual void initKeymap(); + Screen *screen(); GUI *gui() const; @@ -333,6 +335,8 @@ private: void writeSettings(); void readSettings(); + static const char *const kKeymapName; + const char *const *_pakFileList; int _pakFileListSize; |