diff options
author | Max Horn | 2007-10-28 12:57:25 +0000 |
---|---|---|
committer | Max Horn | 2007-10-28 12:57:25 +0000 |
commit | 3f958711a28eaa843642c06c3e5e94cdfffd024a (patch) | |
tree | b2123cadf99fa2f77e6ba880bc1f2697df086379 | |
parent | 61c96353cf0cc5b418ad64af2c607309221409d4 (diff) | |
download | scummvm-rg350-3f958711a28eaa843642c06c3e5e94cdfffd024a.tar.gz scummvm-rg350-3f958711a28eaa843642c06c3e5e94cdfffd024a.tar.bz2 scummvm-rg350-3f958711a28eaa843642c06c3e5e94cdfffd024a.zip |
Refactored ScummEngine*::checkExecVerbs method
svn-id: r29284
-rw-r--r-- | engines/scumm/he/intern_he.h | 3 | ||||
-rw-r--r-- | engines/scumm/input.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/intern.h | 1 | ||||
-rw-r--r-- | engines/scumm/scumm.cpp | 2 | ||||
-rw-r--r-- | engines/scumm/scumm.h | 1 | ||||
-rw-r--r-- | engines/scumm/verbs.cpp | 78 |
6 files changed, 71 insertions, 16 deletions
diff --git a/engines/scumm/he/intern_he.h b/engines/scumm/he/intern_he.h index 84ad8adb3b..5f474b6c68 100644 --- a/engines/scumm/he/intern_he.h +++ b/engines/scumm/he/intern_he.h @@ -279,6 +279,7 @@ protected: virtual void readMAXS(int blockSize); virtual void redrawBGAreas(); + virtual void checkExecVerbs(); byte *defineArray(int array, int type, int dim2start, int dim2end, int dim1start, int dim1end); virtual int readArray(int array, int idx2, int idx1); @@ -359,6 +360,8 @@ protected: byte VAR_NUM_CHARSETS; byte VAR_POLYGONS_ONLY; + + byte VAR_MOUSE_STATE; // Used in checkExecVerbs(); }; class ScummEngine_v80he : public ScummEngine_v72he { diff --git a/engines/scumm/input.cpp b/engines/scumm/input.cpp index 6b45b7b415..e2ba127e5e 100644 --- a/engines/scumm/input.cpp +++ b/engines/scumm/input.cpp @@ -90,6 +90,8 @@ void ScummEngine::parseEvents() { } if (_game.heversion >= 80) { + // FIXME: Move this code & VAR_KEY_STATE to class ScummEngine_v80he + // Keyboard is controlled via variable int keyState = 0; diff --git a/engines/scumm/intern.h b/engines/scumm/intern.h index 6723081dfe..373d17fe62 100644 --- a/engines/scumm/intern.h +++ b/engines/scumm/intern.h @@ -332,6 +332,7 @@ protected: void setUserState(byte state); virtual void handleMouseOver(bool updateInventory); + virtual void checkExecVerbs(); void initV2MouseOver(); void initNESMouseOver(); diff --git a/engines/scumm/scumm.cpp b/engines/scumm/scumm.cpp index f0e0fd10b6..da01d7bbb8 100644 --- a/engines/scumm/scumm.cpp +++ b/engines/scumm/scumm.cpp @@ -443,7 +443,6 @@ ScummEngine::ScummEngine(OSystem *syst, const DetectorResult &dr) VAR_NUM_GLOBAL_OBJS = 0xFF; VAR_KEY_STATE = 0xFF; - VAR_MOUSE_STATE = 0xFF; // Use g_scumm from error() ONLY g_scumm = this; @@ -780,6 +779,7 @@ ScummEngine_v72he::ScummEngine_v72he(OSystem *syst, const DetectorResult &dr) VAR_NUM_IMAGES = 0xFF; VAR_NUM_CHARSETS = 0xFF; VAR_POLYGONS_ONLY = 0xFF; + VAR_MOUSE_STATE = 0xFF; } ScummEngine_v80he::ScummEngine_v80he(OSystem *syst, const DetectorResult &dr) diff --git a/engines/scumm/scumm.h b/engines/scumm/scumm.h index 2a155c7e02..510af6d1d2 100644 --- a/engines/scumm/scumm.h +++ b/engines/scumm/scumm.h @@ -1342,7 +1342,6 @@ public: byte VAR_NUM_SCRIPT_CYCLES; // Used in runAllScripts() byte VAR_KEY_STATE; // Used in parseEvents() - byte VAR_MOUSE_STATE; // Used in checkExecVerbs(); // Exists both in V7 and in V72HE: byte VAR_NUM_GLOBAL_OBJS; diff --git a/engines/scumm/verbs.cpp b/engines/scumm/verbs.cpp index 99e88b5a1d..9b47667920 100644 --- a/engines/scumm/verbs.cpp +++ b/engines/scumm/verbs.cpp @@ -26,6 +26,7 @@ #include "scumm/actor.h" #include "scumm/charset.h" +#include "scumm/he/intern_he.h" #include "scumm/intern.h" #include "scumm/object.h" #include "scumm/resource.h" @@ -513,19 +514,26 @@ void ScummEngine_v0::handleMouseOver(bool updateInventory) { drawSentence(); } +#ifndef DISABLE_HE +void ScummEngine_v72he::checkExecVerbs() { + VAR(VAR_MOUSE_STATE) = 0; + + if (_userPut <= 0 || _mouseAndKeyboardStat == 0) + return; + + VAR(VAR_MOUSE_STATE) = _mouseAndKeyboardStat; + + ScummEngine::checkExecVerbs(); +} +#endif + void ScummEngine::checkExecVerbs() { int i, over; VerbSlot *vs; - if (VAR_MOUSE_STATE != 0xFF) - VAR(VAR_MOUSE_STATE) = 0; - if (_userPut <= 0 || _mouseAndKeyboardStat == 0) return; - if (VAR_MOUSE_STATE != 0xFF) - VAR(VAR_MOUSE_STATE) = _mouseAndKeyboardStat; - if (_mouseAndKeyboardStat < MBS_MAX_KEY) { /* Check keypresses */ if (!(_game.id == GID_MONKEY && _game.platform == Common::kPlatformSegaCD)) { @@ -572,7 +580,7 @@ void ScummEngine::checkExecVerbs() { if ((_game.platform == Common::kPlatformFMTowns && _game.id == GID_ZAK) && (_mouseAndKeyboardStat >= 315 && _mouseAndKeyboardStat <= 318)) { // Hack: Handle switching to a person via F1-F4 keys. - // This feature isn't available in the scripts of the FM-TOWNS verison. + // This feature isn't available in the scripts of the FM-TOWNS version. int fKey = _mouseAndKeyboardStat - 314; int switchSlot = getVerbSlot(36, 0); // check if switch-verb is enabled @@ -590,25 +598,67 @@ void ScummEngine::checkExecVerbs() { runInputScript(kKeyClickArea, _mouseAndKeyboardStat, 1); } else if (_mouseAndKeyboardStat & MBS_MOUSE_MASK) { VirtScreen *zone = findVirtScreen(_mouse.y); - byte code = _mouseAndKeyboardStat & MBS_LEFT_CLICK ? 1 : 2; - int inventoryArea = (_game.platform == Common::kPlatformNES) ? 48: 32; + const byte code = _mouseAndKeyboardStat & MBS_LEFT_CLICK ? 1 : 2; + + // This could be kUnkVirtScreen. + // Fixes bug #1536932: "MANIACNES: Crash on click in speechtext-area" + if (!zone) + return; + + over = findVerbAtPos(_mouse.x, _mouse.y); + if (over != 0) { + // Verb was clicked + runInputScript(kVerbClickArea, _verbs[over].verbid, code); + } else { + // Scene was clicked + runInputScript((zone->number == kMainVirtScreen) ? kSceneClickArea : kVerbClickArea, 0, code); + } + } +} + +void ScummEngine_v2::checkExecVerbs() { + int i, over; + VerbSlot *vs; + + if (_userPut <= 0 || _mouseAndKeyboardStat == 0) + return; + + if (_mouseAndKeyboardStat < MBS_MAX_KEY) { + /* Check keypresses */ + vs = &_verbs[1]; + for (i = 1; i < _numVerbs; i++, vs++) { + if (vs->verbid && vs->saveid == 0 && vs->curmode == 1) { + if (_mouseAndKeyboardStat == vs->key) { + // Trigger verb as if the user clicked it + runInputScript(1, vs->verbid, 1); + return; + } + } + } + + // Generic keyboard input + runInputScript(4, _mouseAndKeyboardStat, 1); + } else if (_mouseAndKeyboardStat & MBS_MOUSE_MASK) { + VirtScreen *zone = findVirtScreen(_mouse.y); + const byte code = _mouseAndKeyboardStat & MBS_LEFT_CLICK ? 1 : 2; + const int inventoryArea = (_game.platform == Common::kPlatformNES) ? 48: 32; // This could be kUnkVirtScreen. // Fixes bug #1536932: "MANIACNES: Crash on click in speechtext-area" if (!zone) return; - if (_game.version <= 2 && zone->number == kVerbVirtScreen && _mouse.y <= zone->topline + 8) { + if (zone->number == kVerbVirtScreen && _mouse.y <= zone->topline + 8) { // Click into V2 sentence line - runInputScript(kSentenceClickArea, 0, 0); - } else if (_game.version <= 2 && zone->number == kVerbVirtScreen && _mouse.y > zone->topline + inventoryArea) { + runInputScript(5, 0, 0); + } else if (zone->number == kVerbVirtScreen && _mouse.y > zone->topline + inventoryArea) { // Click into V2 inventory - ((ScummEngine_v2 *)this)->checkV2Inventory(_mouse.x, _mouse.y); + checkV2Inventory(_mouse.x, _mouse.y); } else { over = findVerbAtPos(_mouse.x, _mouse.y); if (over != 0) { // Verb was clicked - runInputScript(kVerbClickArea, _verbs[over].verbid, code); + runInputScript(1, _verbs[over].verbid, code); } else { // Scene was clicked runInputScript((zone->number == kMainVirtScreen) ? kSceneClickArea : kVerbClickArea, 0, code); |