aboutsummaryrefslogtreecommitdiff
path: root/engines/kyra
diff options
context:
space:
mode:
authorJohannes Schickel2011-12-30 20:39:27 +0100
committerJohannes Schickel2011-12-30 20:40:06 +0100
commit548a3e25342c44cd8ebaecf7a62968f8b62c15f7 (patch)
treee463b7ac9899ee5796280a90f86b5ab38cbdebbf /engines/kyra
parent7d00a997cd064469e975b3453974d811abb4127e (diff)
downloadscummvm-rg350-548a3e25342c44cd8ebaecf7a62968f8b62c15f7.tar.gz
scummvm-rg350-548a3e25342c44cd8ebaecf7a62968f8b62c15f7.tar.bz2
scummvm-rg350-548a3e25342c44cd8ebaecf7a62968f8b62c15f7.zip
KYRA: Add basic keymapper support to EoB 1+2.
Diffstat (limited to 'engines/kyra')
-rw-r--r--engines/kyra/eobcommon.cpp53
-rw-r--r--engines/kyra/eobcommon.h7
2 files changed, 59 insertions, 1 deletions
diff --git a/engines/kyra/eobcommon.cpp b/engines/kyra/eobcommon.cpp
index 15cabd9293..f1a6c5d699 100644
--- a/engines/kyra/eobcommon.cpp
+++ b/engines/kyra/eobcommon.cpp
@@ -30,12 +30,17 @@
#include "kyra/debugger.h"
#include "common/config-manager.h"
+#include "common/translation.h"
#include "audio/mididrv.h"
#include "audio/mixer.h"
+#include "backends/keymapper/keymapper.h"
+
namespace Kyra {
+const char *const EoBCoreEngine::kKeymapName = "eob";
+
EoBCoreEngine::EoBCoreEngine(OSystem *system, const GameFlags &flags)
: KyraRpgEngine(system, flags), _numLargeItemShapes(flags.gameID == GI_EOB1 ? 14 : 11),
_numSmallItemShapes(flags.gameID == GI_EOB1 ? 23 : 26),
@@ -308,6 +313,50 @@ EoBCoreEngine::~EoBCoreEngine() {
_txt = 0;
}
+void EoBCoreEngine::initKeymap() {
+#ifdef ENABLE_KEYMAPPER
+ Common::Keymapper *const mapper = _eventMan->getKeymapper();
+
+ // Do not try to recreate same keymap over again
+ if (mapper->getKeymap(kKeymapName) != 0)
+ return;
+
+ Common::Keymap *const engineKeyMap = new Common::Keymap(kKeymapName);
+
+ const Common::KeyActionEntry keyActionEntries[] = {
+ { Common::KeyState(Common::KEYCODE_UP), "MVF", _("Move Forward") },
+ { Common::KeyState(Common::KEYCODE_DOWN), "MVB", _("Move Back") },
+ { Common::KeyState(Common::KEYCODE_LEFT), "MVL", _("Move Left") },
+ { Common::KeyState(Common::KEYCODE_RIGHT), "MVR", _("Move Right") },
+ { Common::KeyState(Common::KEYCODE_HOME), "TL", _("Turn Left") },
+ { Common::KeyState(Common::KEYCODE_PAGEUP), "TR", _("Turn Right") },
+ { Common::KeyState(Common::KEYCODE_i), "INV", _("Open/Close Inventory") },
+ { Common::KeyState(Common::KEYCODE_p), "SCE", _("Switch Inventory/Character screen") },
+ { Common::KeyState(Common::KEYCODE_c), "CMP", _("Camp") },
+ { Common::KeyState(Common::KEYCODE_SPACE), "CSP", _("Cast Spell") },
+ // TODO: Spell cursor, but this needs more thought, since different
+ // game versions use different keycodes.
+ { Common::KeyState(Common::KEYCODE_1), "SL1", _("Spell Level 1") },
+ { Common::KeyState(Common::KEYCODE_2), "SL2", _("Spell Level 2") },
+ { Common::KeyState(Common::KEYCODE_3), "SL3", _("Spell Level 3") },
+ { Common::KeyState(Common::KEYCODE_4), "SL4", _("Spell Level 4") },
+ { Common::KeyState(Common::KEYCODE_5), "SL5", _("Spell Level 5") }
+ };
+
+ for (uint i = 0; i < ARRAYSIZE(keyActionEntries); ++i) {
+ Common::Action *const act = new Common::Action(engineKeyMap, keyActionEntries[i].id, keyActionEntries[i].description, Common::kGenericActionType, Common::kActionKeyType);
+ act->addKeyEvent(keyActionEntries[i].ks);
+ }
+
+ if (_flags.gameID == GI_EOB2) {
+ Common::Action *const act = new Common::Action(engineKeyMap, "SL6", _("Spell Level 6"), Common::kGenericActionType, Common::kActionKeyType);
+ act->addKeyEvent(Common::KeyState(Common::KEYCODE_6));
+ }
+
+ mapper->addGameKeymap(engineKeyMap);
+#endif
+}
+
Common::Error EoBCoreEngine::init() {
// In EOB the timer proc is directly invoked via interrupt 0x1c, 18.2 times per second.
// This makes a tick length of 54.94.
@@ -439,6 +488,10 @@ Common::Error EoBCoreEngine::init() {
// Prevent autosave on game startup
_lastAutosave = _system->getMillis();
+#ifdef ENABLE_KEYMAPPER
+ _eventMan->getKeymapper()->pushKeymap(kKeymapName, true);
+#endif
+
return Common::kNoError;
}
diff --git a/engines/kyra/eobcommon.h b/engines/kyra/eobcommon.h
index f02b76d267..e7b3a7357a 100644
--- a/engines/kyra/eobcommon.h
+++ b/engines/kyra/eobcommon.h
@@ -250,6 +250,8 @@ public:
EoBCoreEngine(OSystem *system, const GameFlags &flags);
virtual ~EoBCoreEngine();
+ virtual void initKeymap();
+
Screen *screen() { return _screen; }
GUI *gui() const { return _gui; }
@@ -1127,9 +1129,12 @@ protected:
// sound
void snd_playSoundEffect(int id, int volume=0xFF);
void snd_stopSound();
+
+ // keymap
+ static const char *const kKeymapName;
};
-} // End of namespace Kyra
+} // End of namespace Kyra
#endif // ENABLE_EOB