diff options
author | Matthew Hoops | 2011-12-12 15:25:28 -0500 |
---|---|---|
committer | Matthew Hoops | 2011-12-12 15:25:28 -0500 |
commit | 00279659b22cbd5db739d5351e83a9fc2a2ae408 (patch) | |
tree | 497f06f46820043cbdf1725652b8f0073223e24a /engines/kyra/lol.cpp | |
parent | d932df79bed5aac97e17c0920a5e75cb5ce733ee (diff) | |
parent | d1628feb761acc9f4607f64de3eb620fea53bcc9 (diff) | |
download | scummvm-rg350-00279659b22cbd5db739d5351e83a9fc2a2ae408.tar.gz scummvm-rg350-00279659b22cbd5db739d5351e83a9fc2a2ae408.tar.bz2 scummvm-rg350-00279659b22cbd5db739d5351e83a9fc2a2ae408.zip |
Merge remote branch 'upstream/master' into pegasus
Conflicts:
video/qt_decoder.cpp
Diffstat (limited to 'engines/kyra/lol.cpp')
-rw-r--r-- | engines/kyra/lol.cpp | 83 |
1 files changed, 78 insertions, 5 deletions
diff --git a/engines/kyra/lol.cpp b/engines/kyra/lol.cpp index 5aba264ceb..538e88aa90 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; @@ -425,6 +434,9 @@ Common::Error LoLEngine::init() { assert(_screen); _screen->setResolution(); + _debugger = new Debugger_LoL(this); + assert(_debugger); + KyraEngine_v1::init(); initStaticResource(); @@ -538,12 +550,67 @@ Common::Error LoLEngine::init() { _spellProcs.push_back(new SpellProc(this, 0)); _spellProcs.push_back(new SpellProc(this, &LoLEngine::castGuardian)); - _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; @@ -896,7 +963,7 @@ void LoLEngine::startupNew() { _availableSpells[0] = 0; setupScreenDims(); - memset(_globalScriptVars2, 0x100, 8); + Common::fill(_globalScriptVars2, ARRAYEND(_globalScriptVars2), 0x100); static const int selectIds[] = { -9, -1, -8, -5 }; assert(_charSelection >= 0); @@ -911,6 +978,9 @@ void LoLEngine::startupNew() { } void LoLEngine::runLoop() { + // Initialize debugger since how it should be fully usable + _debugger->initialize(); + enableSysTimer(2); bool _runFlag = true; @@ -993,6 +1063,10 @@ void LoLEngine::writeSettings() { void LoLEngine::readSettings() { _monsterDifficulty = ConfMan.getInt("monster_difficulty"); + if (_monsterDifficulty < 0 || _monsterDifficulty > 2) { + _monsterDifficulty = CLIP(_monsterDifficulty, 0, 2); + warning("LoLEngine: Config file contains invalid difficulty setting."); + } _smoothScrollingEnabled = ConfMan.getBool("smooth_scrolling"); _floatingCursorsEnabled = ConfMan.getBool("floating_cursors"); @@ -1922,8 +1996,7 @@ int LoLEngine::playCharacterScriptChat(int charId, int mode, int restorePortrait stopPortraitSpeechAnim(); if (charId < 0) { - charId = ch = (_rnd.getRandomNumber(0x7fff) * countActiveCharacters()) / 0x8000; - ch = _rnd.getRandomNumber(countActiveCharacters() - 1); + charId = ch = _rnd.getRandomNumber(countActiveCharacters() - 1); } else if (charId > 0) { int i = 0; |