2007-05-30 21:56:52 +00:00
|
|
|
/* ScummVM - Graphic Adventure Engine
|
|
|
|
*
|
|
|
|
* ScummVM is the legal property of its developers, whose names
|
|
|
|
* are too numerous to list here. Please refer to the COPYRIGHT
|
|
|
|
* file distributed with this source distribution.
|
2004-09-20 22:04:06 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or
|
|
|
|
* modify it under the terms of the GNU General Public License
|
|
|
|
* as published by the Free Software Foundation; either version 2
|
|
|
|
* of the License, or (at your option) any later version.
|
|
|
|
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
2005-10-18 01:30:26 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
2004-09-20 22:04:06 +00:00
|
|
|
*
|
2006-02-11 09:55:41 +00:00
|
|
|
* $URL$
|
|
|
|
* $Id$
|
2004-09-20 22:04:06 +00:00
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include "common/config-manager.h"
|
2007-03-17 00:53:21 +00:00
|
|
|
#include "common/events.h"
|
2005-01-10 22:06:49 +00:00
|
|
|
#include "common/system.h"
|
2004-09-20 22:04:06 +00:00
|
|
|
|
2005-03-12 00:47:17 +00:00
|
|
|
#include "gui/message.h"
|
2009-01-02 03:21:40 +00:00
|
|
|
#include "gui/GuiManager.h"
|
2005-03-12 00:47:17 +00:00
|
|
|
|
2004-09-20 22:04:06 +00:00
|
|
|
#include "scumm/debugger.h"
|
2005-03-06 18:00:54 +00:00
|
|
|
#include "scumm/dialogs.h"
|
2005-05-14 23:28:22 +00:00
|
|
|
#include "scumm/insane/insane.h"
|
2006-02-20 20:57:26 +00:00
|
|
|
#include "scumm/imuse/imuse.h"
|
2008-05-06 03:00:26 +00:00
|
|
|
#ifdef ENABLE_HE
|
2006-02-15 00:57:50 +00:00
|
|
|
#include "scumm/he/intern_he.h"
|
|
|
|
#include "scumm/he/logic_he.h"
|
2006-02-04 12:11:10 +00:00
|
|
|
#endif
|
2009-03-20 16:33:58 +00:00
|
|
|
#include "scumm/scumm_v0.h"
|
2009-03-20 22:33:45 +00:00
|
|
|
#include "scumm/scumm_v6.h"
|
2009-03-20 16:33:58 +00:00
|
|
|
#include "scumm/scumm_v8.h"
|
2004-09-20 22:04:06 +00:00
|
|
|
#include "scumm/sound.h"
|
|
|
|
|
2005-05-14 22:56:41 +00:00
|
|
|
|
2005-04-20 19:59:18 +00:00
|
|
|
#ifdef _WIN32_WCE
|
|
|
|
#define KEY_ALL_SKIP 3457
|
|
|
|
#endif
|
|
|
|
|
2004-09-20 22:04:06 +00:00
|
|
|
namespace Scumm {
|
|
|
|
|
|
|
|
enum MouseButtonStatus {
|
|
|
|
msDown = 1,
|
|
|
|
msClicked = 2
|
|
|
|
};
|
|
|
|
|
2009-07-13 07:55:11 +00:00
|
|
|
#ifdef ENABLE_HE
|
|
|
|
void ScummEngine_v80he::parseEvent(Common::Event event) {
|
|
|
|
ScummEngine::parseEvent(event);
|
|
|
|
|
|
|
|
// Keyboard is controlled via variable
|
|
|
|
switch (event.type) {
|
|
|
|
case Common::EVENT_KEYDOWN:
|
|
|
|
if (event.kbd.keycode == Common::KEYCODE_LEFT)
|
|
|
|
VAR(VAR_KEY_STATE) |= 1;
|
|
|
|
|
|
|
|
if (event.kbd.keycode == Common::KEYCODE_RIGHT)
|
|
|
|
VAR(VAR_KEY_STATE) |= 2;
|
|
|
|
|
|
|
|
if (event.kbd.keycode == Common::KEYCODE_UP)
|
|
|
|
VAR(VAR_KEY_STATE) |= 4;
|
|
|
|
|
|
|
|
if (event.kbd.keycode == Common::KEYCODE_DOWN)
|
|
|
|
VAR(VAR_KEY_STATE) |= 8;
|
|
|
|
|
|
|
|
if (event.kbd.keycode == Common::KEYCODE_LSHIFT || event.kbd.keycode == Common::KEYCODE_RSHIFT)
|
|
|
|
VAR(VAR_KEY_STATE) |= 16;
|
|
|
|
|
|
|
|
if (event.kbd.keycode == Common::KEYCODE_LCTRL || event.kbd.keycode == Common::KEYCODE_RCTRL)
|
|
|
|
VAR(VAR_KEY_STATE) |= 32;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Common::EVENT_KEYUP:
|
|
|
|
if (event.kbd.keycode == Common::KEYCODE_LEFT)
|
|
|
|
VAR(VAR_KEY_STATE) &= ~1;
|
|
|
|
|
|
|
|
if (event.kbd.keycode == Common::KEYCODE_RIGHT)
|
|
|
|
VAR(VAR_KEY_STATE) &= ~2;
|
|
|
|
|
|
|
|
if (event.kbd.keycode == Common::KEYCODE_UP)
|
|
|
|
VAR(VAR_KEY_STATE) &= ~4;
|
|
|
|
|
|
|
|
if (event.kbd.keycode == Common::KEYCODE_DOWN)
|
|
|
|
VAR(VAR_KEY_STATE) &= ~8;
|
|
|
|
|
|
|
|
if (event.kbd.keycode == Common::KEYCODE_LSHIFT || event.kbd.keycode == Common::KEYCODE_RSHIFT)
|
|
|
|
VAR(VAR_KEY_STATE) &= ~16;
|
|
|
|
|
|
|
|
if (event.kbd.keycode == Common::KEYCODE_LCTRL || event.kbd.keycode == Common::KEYCODE_RCTRL)
|
|
|
|
VAR(VAR_KEY_STATE) &= ~32;
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
|
|
|
void ScummEngine::parseEvent(Common::Event event) {
|
|
|
|
switch (event.type) {
|
|
|
|
case Common::EVENT_KEYDOWN:
|
2009-07-23 05:57:00 +00:00
|
|
|
if (event.kbd.keycode >= '0' && event.kbd.keycode <= '9' &&
|
|
|
|
((event.kbd.flags == Common::KBD_ALT && canSaveGameStateCurrently()) ||
|
|
|
|
(event.kbd.flags == Common::KBD_CTRL && canLoadGameStateCurrently()))) {
|
2009-07-13 07:55:11 +00:00
|
|
|
_saveLoadSlot = event.kbd.keycode - '0';
|
|
|
|
|
|
|
|
// don't overwrite autosave (slot 0)
|
|
|
|
if (_saveLoadSlot == 0)
|
|
|
|
_saveLoadSlot = 10;
|
|
|
|
|
|
|
|
sprintf(_saveLoadName, "Quicksave %d", _saveLoadSlot);
|
2009-07-23 05:57:00 +00:00
|
|
|
_saveLoadFlag = (event.kbd.flags == Common::KBD_ALT) ? 1 : 2;
|
2009-07-13 07:55:11 +00:00
|
|
|
_saveTemporaryState = false;
|
|
|
|
} else if (event.kbd.flags == Common::KBD_CTRL && event.kbd.keycode == 'f') {
|
|
|
|
_fastMode ^= 1;
|
|
|
|
} else if (event.kbd.flags == Common::KBD_CTRL && event.kbd.keycode == 'g') {
|
|
|
|
_fastMode ^= 2;
|
|
|
|
} else if ((event.kbd.flags == Common::KBD_CTRL && event.kbd.keycode == 'd') ||
|
|
|
|
event.kbd.ascii == '~' || event.kbd.ascii == '#') {
|
|
|
|
_debugger->attach();
|
|
|
|
} else if (event.kbd.flags == Common::KBD_CTRL && event.kbd.keycode == 's') {
|
|
|
|
_res->resourceStats();
|
|
|
|
} else {
|
|
|
|
// Normal key press, pass on to the game.
|
|
|
|
_keyPressed = event.kbd;
|
|
|
|
}
|
|
|
|
|
|
|
|
// FIXME: We are using ASCII values to index the _keyDownMap here,
|
|
|
|
// yet later one code which checks _keyDownMap will use KEYCODEs
|
|
|
|
// to do so. That is, we are mixing ascii and keycode values here,
|
|
|
|
// which is bad. We probably should be only using keycodes, but at
|
|
|
|
// least INSANE checks for "Shift-V" by looking for the 'V' key
|
|
|
|
// being pressed. It would be easy to solve that by also storing
|
|
|
|
// the modifier flags. However, since getKeyState() is also called
|
|
|
|
// by scripts, we have to be careful with semantic changes.
|
|
|
|
if (_keyPressed.ascii >= 512)
|
|
|
|
debugC(DEBUG_GENERAL, "_keyPressed > 512 (%d)", _keyPressed.ascii);
|
|
|
|
else
|
|
|
|
_keyDownMap[_keyPressed.ascii] = true;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Common::EVENT_KEYUP:
|
|
|
|
if (event.kbd.ascii >= 512) {
|
|
|
|
debugC(DEBUG_GENERAL, "keyPressed > 512 (%d)", event.kbd.ascii);
|
|
|
|
} else {
|
|
|
|
_keyDownMap[event.kbd.ascii] = false;
|
|
|
|
|
|
|
|
// Due to some weird bug with capslock key pressed
|
|
|
|
// generated keydown event is for lower letter but
|
|
|
|
// keyup is for upper letter
|
|
|
|
// On most (all?) keyboards it is safe to assume that
|
|
|
|
// both upper and lower letters are unpressed on keyup event
|
|
|
|
//
|
|
|
|
// Fixes bug #1709430: "FT: CAPSLOCK + V enables cheating for all fights"
|
|
|
|
//
|
|
|
|
// Fingolfin remarks: This wouldn't be a problem if we used keycodes.
|
|
|
|
_keyDownMap[toupper(event.kbd.ascii)] = false;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
|
|
|
|
|
|
|
|
// We update the mouse position whenever the mouse moves or a click occurs.
|
|
|
|
// The latter is done to accomodate systems with a touchpad / pen controller.
|
|
|
|
case Common::EVENT_LBUTTONDOWN:
|
|
|
|
case Common::EVENT_RBUTTONDOWN:
|
|
|
|
case Common::EVENT_MOUSEMOVE:
|
|
|
|
if (event.type == Common::EVENT_LBUTTONDOWN)
|
|
|
|
_leftBtnPressed |= msClicked|msDown;
|
|
|
|
else if (event.type == Common::EVENT_RBUTTONDOWN)
|
|
|
|
_rightBtnPressed |= msClicked|msDown;
|
|
|
|
_mouse.x = event.mouse.x;
|
|
|
|
_mouse.y = event.mouse.y;
|
|
|
|
|
|
|
|
if (_renderMode == Common::kRenderHercA || _renderMode == Common::kRenderHercG) {
|
|
|
|
_mouse.x -= (Common::kHercW - _screenWidth * 2) / 2;
|
|
|
|
_mouse.x >>= 1;
|
|
|
|
_mouse.y = _mouse.y * 4 / 7;
|
|
|
|
} else if (_useCJKMode && _textSurfaceMultiplier == 2) {
|
|
|
|
_mouse.x >>= 1;
|
|
|
|
_mouse.y >>= 1;
|
|
|
|
}
|
|
|
|
break;
|
|
|
|
case Common::EVENT_LBUTTONUP:
|
|
|
|
_leftBtnPressed &= ~msDown;
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Common::EVENT_RBUTTONUP:
|
|
|
|
_rightBtnPressed &= ~msDown;
|
|
|
|
break;
|
|
|
|
|
|
|
|
// The following two cases enable dialog choices to be scrolled
|
|
|
|
// through in the SegaCD version of MI. Values are taken from script-14.
|
|
|
|
// See bug report #1193185 for details.
|
|
|
|
case Common::EVENT_WHEELDOWN:
|
|
|
|
if (_game.id == GID_MONKEY && _game.platform == Common::kPlatformSegaCD)
|
|
|
|
_keyPressed = Common::KeyState(Common::KEYCODE_7, 55); // '7'
|
|
|
|
break;
|
|
|
|
|
|
|
|
case Common::EVENT_WHEELUP:
|
|
|
|
if (_game.id == GID_MONKEY && _game.platform == Common::kPlatformSegaCD)
|
|
|
|
_keyPressed = Common::KeyState(Common::KEYCODE_6, 54); // '6'
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2004-09-20 22:04:06 +00:00
|
|
|
void ScummEngine::parseEvents() {
|
2007-03-17 19:02:05 +00:00
|
|
|
Common::Event event;
|
2004-09-20 22:04:06 +00:00
|
|
|
|
2007-04-01 17:36:13 +00:00
|
|
|
while (_eventMan->pollEvent(event)) {
|
2009-07-13 07:55:11 +00:00
|
|
|
parseEvent(event);
|
2004-09-20 22:04:06 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2008-05-06 03:00:26 +00:00
|
|
|
#ifdef ENABLE_HE
|
2006-10-07 11:54:50 +00:00
|
|
|
void ScummEngine_v90he::clearClickedStatus() {
|
|
|
|
ScummEngine::clearClickedStatus();
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.heversion >= 98) {
|
2007-06-23 10:38:03 +00:00
|
|
|
_logicHE->processKeyStroke(_keyPressed.ascii);
|
2005-05-11 10:09:06 +00:00
|
|
|
}
|
2006-10-07 11:54:50 +00:00
|
|
|
}
|
|
|
|
|
2006-10-07 17:42:32 +00:00
|
|
|
void ScummEngine_v90he::processInput() {
|
2006-10-07 11:54:50 +00:00
|
|
|
if (_game.heversion >= 98) {
|
2007-06-23 10:38:03 +00:00
|
|
|
_logicHE->processKeyStroke(_keyPressed.ascii);
|
2006-10-07 11:54:50 +00:00
|
|
|
}
|
2006-10-07 17:42:32 +00:00
|
|
|
ScummEngine::processInput();
|
2006-10-07 11:54:50 +00:00
|
|
|
}
|
2005-05-14 22:56:41 +00:00
|
|
|
#endif
|
2006-10-07 11:54:50 +00:00
|
|
|
|
|
|
|
void ScummEngine::clearClickedStatus() {
|
2007-06-23 10:38:03 +00:00
|
|
|
_keyPressed.reset();
|
2006-10-07 11:54:50 +00:00
|
|
|
|
2005-04-20 23:33:35 +00:00
|
|
|
_mouseAndKeyboardStat = 0;
|
2004-09-20 22:04:06 +00:00
|
|
|
_leftBtnPressed &= ~msClicked;
|
|
|
|
_rightBtnPressed &= ~msClicked;
|
|
|
|
}
|
|
|
|
|
2007-03-06 09:21:41 +00:00
|
|
|
void ScummEngine_v0::processInput() {
|
|
|
|
// F1 - F3
|
2007-06-23 10:46:32 +00:00
|
|
|
if (_keyPressed.keycode >= Common::KEYCODE_F1 && _keyPressed.keycode <= Common::KEYCODE_F3) {
|
|
|
|
switchActor(_keyPressed.keycode - Common::KEYCODE_F1);
|
2007-03-06 09:21:41 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
ScummEngine::processInput();
|
|
|
|
}
|
2007-06-23 10:38:03 +00:00
|
|
|
|
2009-07-15 02:06:26 +00:00
|
|
|
#ifdef ENABLE_SCUMM_7_8
|
|
|
|
void ScummEngine_v7::processInput() {
|
|
|
|
ScummEngine::processInput();
|
|
|
|
|
|
|
|
if (_skipVideo && !_smushActive) {
|
|
|
|
abortCutscene();
|
|
|
|
_mouseAndKeyboardStat = Common::ASCII_ESCAPE;
|
|
|
|
_skipVideo = false;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2006-10-07 17:42:32 +00:00
|
|
|
void ScummEngine::processInput() {
|
2007-06-23 10:38:03 +00:00
|
|
|
Common::KeyState lastKeyHit = _keyPressed;
|
|
|
|
_keyPressed.reset();
|
2005-07-30 21:11:48 +00:00
|
|
|
|
2004-09-20 22:04:06 +00:00
|
|
|
//
|
|
|
|
// Clip the mouse coordinates, and compute _virtualMouse.x (and clip it, too)
|
|
|
|
//
|
|
|
|
if (_mouse.x < 0)
|
|
|
|
_mouse.x = 0;
|
|
|
|
if (_mouse.x > _screenWidth-1)
|
|
|
|
_mouse.x = _screenWidth-1;
|
|
|
|
if (_mouse.y < 0)
|
|
|
|
_mouse.y = 0;
|
|
|
|
if (_mouse.y > _screenHeight-1)
|
|
|
|
_mouse.y = _screenHeight-1;
|
|
|
|
|
2007-09-08 11:15:27 +00:00
|
|
|
VirtScreen *vs = &_virtscr[kMainVirtScreen];
|
|
|
|
_virtualMouse.x = _mouse.x + vs->xstart;
|
|
|
|
_virtualMouse.y = _mouse.y - vs->topline;
|
2007-02-10 02:05:59 +00:00
|
|
|
if (_game.version >= 7)
|
2004-09-20 22:04:06 +00:00
|
|
|
_virtualMouse.y += _screenTop;
|
|
|
|
|
|
|
|
if (_virtualMouse.y < 0)
|
|
|
|
_virtualMouse.y = -1;
|
2007-09-08 11:15:27 +00:00
|
|
|
if (_virtualMouse.y >= vs->h)
|
2004-09-20 22:04:06 +00:00
|
|
|
_virtualMouse.y = -1;
|
|
|
|
|
|
|
|
//
|
|
|
|
// Determine the mouse button state.
|
|
|
|
//
|
2005-04-20 23:33:35 +00:00
|
|
|
_mouseAndKeyboardStat = 0;
|
2004-09-20 22:04:06 +00:00
|
|
|
|
2007-06-23 10:38:03 +00:00
|
|
|
if ((_leftBtnPressed & msClicked) && (_rightBtnPressed & msClicked) && _game.version >= 4) {
|
2004-09-20 22:04:06 +00:00
|
|
|
// Pressing both mouse buttons is treated as if you pressed
|
2007-06-23 16:02:50 +00:00
|
|
|
// the cutscene exit key (ESC) in V4+ games. That mimicks
|
2004-09-20 22:04:06 +00:00
|
|
|
// the behaviour of the original engine where pressing both
|
|
|
|
// mouse buttons also skips the current cutscene.
|
2005-04-20 23:33:35 +00:00
|
|
|
_mouseAndKeyboardStat = 0;
|
2007-06-23 16:02:50 +00:00
|
|
|
lastKeyHit = Common::KeyState(Common::KEYCODE_ESCAPE);
|
2007-06-23 10:38:03 +00:00
|
|
|
} else if ((_rightBtnPressed & msClicked) && (_game.version <= 3 && _game.id != GID_LOOM)) {
|
2004-09-20 22:04:06 +00:00
|
|
|
// Pressing right mouse button is treated as if you pressed
|
2007-06-23 16:02:50 +00:00
|
|
|
// the cutscene exit key (ESC) in V0-V3 games. That mimicks
|
2004-09-20 22:04:06 +00:00
|
|
|
// the behaviour of the original engine where pressing right
|
|
|
|
// mouse button also skips the current cutscene.
|
2005-04-20 23:33:35 +00:00
|
|
|
_mouseAndKeyboardStat = 0;
|
2007-06-23 16:02:50 +00:00
|
|
|
lastKeyHit = Common::KeyState(Common::KEYCODE_ESCAPE);
|
2004-09-20 22:04:06 +00:00
|
|
|
} else if (_leftBtnPressed & msClicked) {
|
2005-04-20 23:33:35 +00:00
|
|
|
_mouseAndKeyboardStat = MBS_LEFT_CLICK;
|
2004-09-20 22:04:06 +00:00
|
|
|
} else if (_rightBtnPressed & msClicked) {
|
2005-04-20 23:33:35 +00:00
|
|
|
_mouseAndKeyboardStat = MBS_RIGHT_CLICK;
|
2004-09-20 22:04:06 +00:00
|
|
|
}
|
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version >= 6) {
|
2004-09-20 22:04:06 +00:00
|
|
|
VAR(VAR_LEFTBTN_HOLD) = (_leftBtnPressed & msDown) != 0;
|
|
|
|
VAR(VAR_RIGHTBTN_HOLD) = (_rightBtnPressed & msDown) != 0;
|
|
|
|
|
2006-02-20 16:51:30 +00:00
|
|
|
if (_game.version >= 7) {
|
2004-09-20 22:04:06 +00:00
|
|
|
VAR(VAR_LEFTBTN_DOWN) = (_leftBtnPressed & msClicked) != 0;
|
|
|
|
VAR(VAR_RIGHTBTN_DOWN) = (_rightBtnPressed & msClicked) != 0;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
_leftBtnPressed &= ~msClicked;
|
|
|
|
_rightBtnPressed &= ~msClicked;
|
|
|
|
|
|
|
|
#ifdef _WIN32_WCE
|
2007-06-23 10:38:03 +00:00
|
|
|
if (lastKeyHit.ascii == KEY_ALL_SKIP) {
|
2005-07-30 21:11:48 +00:00
|
|
|
// Skip talk
|
2007-06-23 10:38:03 +00:00
|
|
|
if (VAR_TALKSTOP_KEY != 0xFF && _talkDelay > 0) {
|
2007-06-23 16:46:00 +00:00
|
|
|
lastKeyHit = Common::KeyState(Common::KEYCODE_PERIOD);
|
2007-06-23 10:38:03 +00:00
|
|
|
} else {
|
2007-06-23 12:24:49 +00:00
|
|
|
lastKeyHit = Common::KeyState(Common::KEYCODE_ESCAPE);
|
2007-06-23 10:38:03 +00:00
|
|
|
}
|
2004-09-20 22:04:06 +00:00
|
|
|
}
|
|
|
|
#endif
|
|
|
|
|
2007-06-23 10:38:03 +00:00
|
|
|
if (!lastKeyHit.ascii)
|
2006-10-07 12:19:28 +00:00
|
|
|
return;
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2006-10-07 17:49:05 +00:00
|
|
|
processKeyboard(lastKeyHit);
|
2006-10-07 12:33:22 +00:00
|
|
|
}
|
2006-10-07 12:19:28 +00:00
|
|
|
|
2008-05-06 03:00:26 +00:00
|
|
|
#ifdef ENABLE_SCUMM_7_8
|
2007-06-23 10:38:03 +00:00
|
|
|
void ScummEngine_v8::processKeyboard(Common::KeyState lastKeyHit) {
|
2009-05-10 09:51:05 +00:00
|
|
|
// F1 (the trigger for the original save/load dialog) is mapped to F5
|
|
|
|
if (!(_game.features & GF_DEMO) && lastKeyHit.keycode == Common::KEYCODE_F1 && lastKeyHit.flags == 0) {
|
|
|
|
lastKeyHit = Common::KeyState(Common::KEYCODE_F5, 319);
|
|
|
|
}
|
|
|
|
|
2008-12-30 14:41:44 +00:00
|
|
|
// Alt-F5 should bring up the original save/load dialog, so map it to F1.
|
|
|
|
if (!(_game.features & GF_DEMO) && lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == Common::KBD_ALT) {
|
|
|
|
lastKeyHit = Common::KeyState(Common::KEYCODE_F1, 315);
|
|
|
|
}
|
|
|
|
|
2006-10-07 12:19:28 +00:00
|
|
|
// If a key script was specified (a V8 feature), and it's trigger
|
2007-06-23 16:46:00 +00:00
|
|
|
// key was pressed, run it. Usually used to display the built-in menu.
|
2007-06-23 10:38:03 +00:00
|
|
|
if (_keyScriptNo && (_keyScriptKey == lastKeyHit.ascii)) {
|
2006-10-07 12:19:28 +00:00
|
|
|
runScript(_keyScriptNo, 0, 0, 0);
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2006-10-07 13:31:27 +00:00
|
|
|
// Fall back to V7 behavior
|
2006-10-07 17:49:05 +00:00
|
|
|
ScummEngine_v7::processKeyboard(lastKeyHit);
|
2006-10-07 13:31:27 +00:00
|
|
|
}
|
|
|
|
|
2007-06-23 10:38:03 +00:00
|
|
|
void ScummEngine_v7::processKeyboard(Common::KeyState lastKeyHit) {
|
2007-06-23 16:46:00 +00:00
|
|
|
const bool cutsceneExitKeyEnabled = (VAR_CUTSCENEEXIT_KEY == 0xFF || VAR(VAR_CUTSCENEEXIT_KEY) != 0);
|
2006-10-07 13:31:27 +00:00
|
|
|
|
2007-06-23 14:16:04 +00:00
|
|
|
// VAR_VERSION_KEY (usually ctrl-v) is used in COMI, Dig and FT to trigger
|
|
|
|
// a version dialog, unless VAR_VERSION_KEY is set to 0. However, the COMI
|
|
|
|
// version string is hard coded in the engine, hence we don't invoke
|
|
|
|
// versionDialog for it. Dig/FT version strings are partly hard coded, too.
|
|
|
|
if (_game.id != GID_CMI && 0 != VAR(VAR_VERSION_KEY) &&
|
|
|
|
lastKeyHit.keycode == Common::KEYCODE_v && lastKeyHit.flags == Common::KBD_CTRL) {
|
2006-10-07 13:31:27 +00:00
|
|
|
versionDialog();
|
2007-06-23 16:02:50 +00:00
|
|
|
|
2007-06-23 16:46:00 +00:00
|
|
|
} else if (cutsceneExitKeyEnabled && lastKeyHit.keycode == Common::KEYCODE_ESCAPE) {
|
2006-10-07 13:31:27 +00:00
|
|
|
// Skip cutscene (or active SMUSH video).
|
2006-10-07 17:42:32 +00:00
|
|
|
if (_smushActive) {
|
2006-10-07 13:31:27 +00:00
|
|
|
if (_game.id == GID_FT)
|
|
|
|
_insane->escapeKeyHandler();
|
|
|
|
else
|
|
|
|
_smushVideoShouldFinish = true;
|
2009-07-15 02:06:26 +00:00
|
|
|
_skipVideo = true;
|
|
|
|
} else {
|
2006-10-07 13:31:27 +00:00
|
|
|
abortCutscene();
|
2009-07-15 02:06:26 +00:00
|
|
|
}
|
2006-10-07 13:31:27 +00:00
|
|
|
|
2007-06-23 16:02:50 +00:00
|
|
|
_mouseAndKeyboardStat = Common::ASCII_ESCAPE;
|
2006-10-07 13:31:27 +00:00
|
|
|
|
2007-06-23 16:46:00 +00:00
|
|
|
} else {
|
|
|
|
// Fall back to V6 behavior
|
|
|
|
ScummEngine_v6::processKeyboard(lastKeyHit);
|
|
|
|
}
|
2006-10-07 12:33:22 +00:00
|
|
|
}
|
2006-10-07 13:31:27 +00:00
|
|
|
#endif
|
2006-10-07 12:33:22 +00:00
|
|
|
|
2007-06-23 10:38:03 +00:00
|
|
|
void ScummEngine_v6::processKeyboard(Common::KeyState lastKeyHit) {
|
2007-06-23 10:46:32 +00:00
|
|
|
if (lastKeyHit.keycode == Common::KEYCODE_t && lastKeyHit.flags == Common::KBD_CTRL) {
|
2007-06-03 17:32:42 +00:00
|
|
|
SubtitleSettingsDialog dialog(this, _voiceMode);
|
|
|
|
_voiceMode = runDialog(dialog);
|
2005-03-12 00:47:17 +00:00
|
|
|
|
2006-07-14 13:33:58 +00:00
|
|
|
switch (_voiceMode) {
|
2005-03-12 00:47:17 +00:00
|
|
|
case 0:
|
2006-04-16 19:23:14 +00:00
|
|
|
ConfMan.setBool("speech_mute", false);
|
|
|
|
ConfMan.setBool("subtitles", false);
|
2005-03-12 00:47:17 +00:00
|
|
|
break;
|
|
|
|
case 1:
|
2006-04-16 19:23:14 +00:00
|
|
|
ConfMan.setBool("speech_mute", false);
|
|
|
|
ConfMan.setBool("subtitles", true);
|
2005-03-12 00:47:17 +00:00
|
|
|
break;
|
|
|
|
case 2:
|
2006-04-16 19:23:14 +00:00
|
|
|
ConfMan.setBool("speech_mute", true);
|
|
|
|
ConfMan.setBool("subtitles", true);
|
2005-03-12 00:47:17 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
|
2005-11-15 22:50:14 +00:00
|
|
|
if (VAR_VOICE_MODE != 0xFF)
|
2005-03-12 00:47:17 +00:00
|
|
|
VAR(VAR_VOICE_MODE) = _voiceMode;
|
|
|
|
|
|
|
|
return;
|
|
|
|
}
|
2006-10-07 13:11:51 +00:00
|
|
|
|
|
|
|
// Fall back to default behavior
|
2006-10-07 17:49:05 +00:00
|
|
|
ScummEngine::processKeyboard(lastKeyHit);
|
2006-10-07 12:33:22 +00:00
|
|
|
}
|
|
|
|
|
2007-06-23 10:38:03 +00:00
|
|
|
void ScummEngine_v2::processKeyboard(Common::KeyState lastKeyHit) {
|
2007-06-23 16:27:28 +00:00
|
|
|
// Fall back to default behavior
|
|
|
|
ScummEngine::processKeyboard(lastKeyHit);
|
2006-10-07 13:11:51 +00:00
|
|
|
|
2009-03-16 04:45:12 +00:00
|
|
|
// On Alt-F5 prepare savegame for the original save/load dialog.
|
|
|
|
if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == Common::KBD_ALT) {
|
|
|
|
prepareSavegame();
|
2009-08-29 14:08:19 +00:00
|
|
|
if (_game.id == GID_MANIAC && _game.version == 0) {
|
|
|
|
runScript(2, 0, 0, 0);
|
|
|
|
}
|
2009-03-16 04:45:12 +00:00
|
|
|
}
|
|
|
|
|
2007-06-23 16:27:28 +00:00
|
|
|
if (VAR_KEYPRESS != 0xFF && _mouseAndKeyboardStat) { // Key Input
|
|
|
|
if (315 <= _mouseAndKeyboardStat && _mouseAndKeyboardStat <= 323) {
|
|
|
|
// Convert F-Keys for V1/V2 games (they start at 1)
|
|
|
|
VAR(VAR_KEYPRESS) = _mouseAndKeyboardStat - 314;
|
2006-10-07 13:31:27 +00:00
|
|
|
} else {
|
2007-06-23 16:27:28 +00:00
|
|
|
VAR(VAR_KEYPRESS) = _mouseAndKeyboardStat;
|
2006-10-07 13:11:51 +00:00
|
|
|
}
|
2004-09-20 22:04:06 +00:00
|
|
|
}
|
2006-10-07 13:11:51 +00:00
|
|
|
}
|
2004-09-20 22:04:06 +00:00
|
|
|
|
2007-06-23 10:38:03 +00:00
|
|
|
void ScummEngine_v3::processKeyboard(Common::KeyState lastKeyHit) {
|
2007-06-23 16:27:28 +00:00
|
|
|
// Fall back to default behavior
|
|
|
|
ScummEngine::processKeyboard(lastKeyHit);
|
2007-05-30 16:40:11 +00:00
|
|
|
|
2009-03-16 04:45:12 +00:00
|
|
|
// On Alt-F5 prepare savegame for the original save/load dialog.
|
|
|
|
if (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == Common::KBD_ALT) {
|
|
|
|
prepareSavegame();
|
|
|
|
}
|
|
|
|
|
|
|
|
// 'i' brings up an IQ dialog in Indy3 (disabled in save/load dialog for input)
|
|
|
|
if (lastKeyHit.ascii == 'i' && _game.id == GID_INDY3 && _currentRoom != 14) {
|
2007-05-30 16:40:11 +00:00
|
|
|
// SCUMM var 244 is the episode score
|
|
|
|
// and var 245 is the series score
|
|
|
|
char text[50];
|
2009-05-24 15:17:42 +00:00
|
|
|
|
2009-03-23 22:34:53 +00:00
|
|
|
updateIQPoints();
|
2009-05-24 15:17:42 +00:00
|
|
|
|
2009-03-23 22:34:53 +00:00
|
|
|
sprintf(text, "IQ Points: Episode = %d, Series = %d", _scummVars[244], _scummVars[245]);
|
2007-05-30 16:40:11 +00:00
|
|
|
Indy3IQPointsDialog indy3IQPointsDialog(this, text);
|
|
|
|
runDialog(indy3IQPointsDialog);
|
|
|
|
}
|
2006-10-07 13:11:51 +00:00
|
|
|
}
|
2004-09-20 22:04:06 +00:00
|
|
|
|
2007-06-23 10:38:03 +00:00
|
|
|
void ScummEngine::processKeyboard(Common::KeyState lastKeyHit) {
|
2007-06-23 16:27:28 +00:00
|
|
|
// Enable the following five special keys conditionally:
|
|
|
|
bool restartKeyEnabled = (VAR_RESTART_KEY == 0xFF || VAR(VAR_RESTART_KEY) != 0);
|
|
|
|
bool pauseKeyEnabled = (VAR_PAUSE_KEY == 0xFF || VAR(VAR_PAUSE_KEY) != 0);
|
|
|
|
bool talkstopKeyEnabled = (VAR_TALKSTOP_KEY == 0xFF || VAR(VAR_TALKSTOP_KEY) != 0);
|
|
|
|
bool cutsceneExitKeyEnabled = (VAR_CUTSCENEEXIT_KEY == 0xFF || VAR(VAR_CUTSCENEEXIT_KEY) != 0);
|
|
|
|
bool mainmenuKeyEnabled = (VAR_MAINMENU_KEY == 0xFF || VAR(VAR_MAINMENU_KEY) != 0);
|
2009-03-10 00:26:40 +00:00
|
|
|
bool snapScrollKeyEnabled = (_game.version <= 2 || VAR_CAMERA_FAST_X != 0xFF);
|
2007-06-23 16:27:28 +00:00
|
|
|
|
|
|
|
// In FM-TOWNS games F8 / restart is always enabled
|
|
|
|
if (_game.platform == Common::kPlatformFMTowns)
|
|
|
|
restartKeyEnabled = true;
|
2006-10-07 13:11:51 +00:00
|
|
|
|
2007-06-23 16:02:50 +00:00
|
|
|
// For games which use VAR_MAINMENU_KEY, disable the mainmenu key if
|
|
|
|
// requested by the scripts. We make an exception for COMI (i.e.
|
|
|
|
// forcefully always enable it there), as that always disables it.
|
2007-06-23 16:27:28 +00:00
|
|
|
if (_game.id == GID_CMI)
|
|
|
|
mainmenuKeyEnabled = true;
|
2007-06-23 16:02:50 +00:00
|
|
|
|
2007-06-23 16:46:00 +00:00
|
|
|
if (mainmenuKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_F5 && lastKeyHit.flags == 0)) {
|
2004-09-20 22:04:06 +00:00
|
|
|
if (VAR_SAVELOAD_SCRIPT != 0xFF && _currentRoom != 0)
|
|
|
|
runScript(VAR(VAR_SAVELOAD_SCRIPT), 0, 0, 0);
|
|
|
|
|
2008-12-25 23:55:36 +00:00
|
|
|
scummMenuDialog(); // Display GUI
|
2004-09-20 22:04:06 +00:00
|
|
|
|
|
|
|
if (VAR_SAVELOAD_SCRIPT != 0xFF && _currentRoom != 0)
|
|
|
|
runScript(VAR(VAR_SAVELOAD_SCRIPT2), 0, 0, 0);
|
2006-10-07 13:31:27 +00:00
|
|
|
|
2007-06-23 16:02:50 +00:00
|
|
|
} else if (restartKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_F8 && lastKeyHit.flags == 0)) {
|
2006-10-07 13:31:27 +00:00
|
|
|
confirmRestartDialog();
|
|
|
|
|
2007-06-23 16:02:50 +00:00
|
|
|
} else if (pauseKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_SPACE && lastKeyHit.flags == 0)) {
|
2006-10-07 13:31:27 +00:00
|
|
|
pauseGame();
|
|
|
|
|
2007-06-23 16:02:50 +00:00
|
|
|
} else if (talkstopKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_PERIOD && lastKeyHit.flags == 0)) {
|
2004-09-20 22:04:06 +00:00
|
|
|
_talkDelay = 0;
|
|
|
|
if (_sound->_sfxMode & 2)
|
|
|
|
stopTalk();
|
|
|
|
|
2007-06-23 16:02:50 +00:00
|
|
|
} else if (cutsceneExitKeyEnabled && (lastKeyHit.keycode == Common::KEYCODE_ESCAPE && lastKeyHit.flags == 0)) {
|
|
|
|
abortCutscene();
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2009-03-10 00:26:40 +00:00
|
|
|
// VAR_CUTSCENEEXIT_KEY doesn't exist in SCUMM0
|
2009-03-10 00:36:56 +00:00
|
|
|
if (VAR_CUTSCENEEXIT_KEY != 0xFF)
|
2008-01-02 11:25:17 +00:00
|
|
|
_mouseAndKeyboardStat = VAR(VAR_CUTSCENEEXIT_KEY);
|
2009-03-10 00:26:40 +00:00
|
|
|
} else if (snapScrollKeyEnabled && lastKeyHit.keycode == Common::KEYCODE_r &&
|
|
|
|
lastKeyHit.flags == Common::KBD_CTRL) {
|
|
|
|
_snapScroll ^= 1;
|
|
|
|
if (_snapScroll) {
|
2009-03-10 00:44:33 +00:00
|
|
|
messageDialog("Snap scroll on");
|
2009-03-10 00:26:40 +00:00
|
|
|
} else {
|
2009-03-10 00:44:33 +00:00
|
|
|
messageDialog("Snap scroll off");
|
2009-03-16 04:45:12 +00:00
|
|
|
}
|
2007-06-23 16:02:50 +00:00
|
|
|
|
2009-03-10 00:26:40 +00:00
|
|
|
if (VAR_CAMERA_FAST_X != 0xFF)
|
|
|
|
VAR(VAR_CAMERA_FAST_X) = _snapScroll;
|
2007-06-23 16:27:28 +00:00
|
|
|
} else if (lastKeyHit.ascii == '[' || lastKeyHit.ascii == ']') { // Change music volume
|
|
|
|
int vol = ConfMan.getInt("music_volume") / 16;
|
|
|
|
if (lastKeyHit.ascii == ']' && vol < 16)
|
|
|
|
vol++;
|
|
|
|
else if (lastKeyHit.ascii == '[' && vol > 0)
|
|
|
|
vol--;
|
2007-06-23 16:02:50 +00:00
|
|
|
|
2007-06-23 16:27:28 +00:00
|
|
|
// Display the music volume
|
|
|
|
ValueDisplayDialog dlg("Music volume: ", 0, 16, vol, ']', '[');
|
|
|
|
vol = runDialog(dlg);
|
|
|
|
|
|
|
|
vol *= 16;
|
|
|
|
if (vol > Audio::Mixer::kMaxMixerVolume)
|
|
|
|
vol = Audio::Mixer::kMaxMixerVolume;
|
|
|
|
|
|
|
|
ConfMan.setInt("music_volume", vol);
|
2008-06-30 17:44:21 +00:00
|
|
|
syncSoundSettings();
|
2007-06-23 16:27:28 +00:00
|
|
|
|
|
|
|
} else if (lastKeyHit.ascii == '-' || lastKeyHit.ascii == '+') { // Change text speed
|
|
|
|
if (lastKeyHit.ascii == '+' && _defaultTalkDelay > 0)
|
|
|
|
_defaultTalkDelay--;
|
|
|
|
else if (lastKeyHit.ascii == '-' && _defaultTalkDelay < 9)
|
|
|
|
_defaultTalkDelay++;
|
2007-06-23 16:02:50 +00:00
|
|
|
|
2007-06-23 16:27:28 +00:00
|
|
|
// Display the talk speed
|
|
|
|
ValueDisplayDialog dlg("Subtitle speed: ", 0, 9, 9 - _defaultTalkDelay, '+', '-');
|
|
|
|
_defaultTalkDelay = 9 - runDialog(dlg);
|
2007-09-19 08:40:12 +00:00
|
|
|
|
2007-06-23 16:27:28 +00:00
|
|
|
// Save the new talkspeed value to ConfMan
|
2009-02-13 10:04:17 +00:00
|
|
|
setTalkSpeed(_defaultTalkDelay);
|
2007-06-23 16:27:28 +00:00
|
|
|
|
|
|
|
if (VAR_CHARINC != 0xFF)
|
|
|
|
VAR(VAR_CHARINC) = _defaultTalkDelay;
|
|
|
|
|
|
|
|
} else {
|
2007-06-30 11:57:50 +00:00
|
|
|
|
2007-06-30 12:07:51 +00:00
|
|
|
if (lastKeyHit.keycode >= Common::KEYCODE_F1 &&
|
|
|
|
lastKeyHit.keycode <= Common::KEYCODE_F9) {
|
2007-06-23 16:27:28 +00:00
|
|
|
_mouseAndKeyboardStat = lastKeyHit.keycode - Common::KEYCODE_F1 + 315;
|
2007-06-30 12:07:51 +00:00
|
|
|
|
2007-06-29 22:36:56 +00:00
|
|
|
} else if (_game.id == GID_MONKEY2 && (lastKeyHit.flags & Common::KBD_ALT)) {
|
|
|
|
// Handle KBD_ALT combos in MI2. We know that the result must be 273 for Alt-W
|
|
|
|
// because that's what MI2 looks for in its "instant win" cheat.
|
|
|
|
_mouseAndKeyboardStat = lastKeyHit.keycode + 154;
|
2007-06-30 12:07:51 +00:00
|
|
|
|
|
|
|
} else if (lastKeyHit.keycode >= Common::KEYCODE_UP &&
|
|
|
|
lastKeyHit.keycode <= Common::KEYCODE_LEFT) {
|
2007-06-30 11:57:50 +00:00
|
|
|
if (_game.id == GID_MONKEY && _game.platform == Common::kPlatformSegaCD) {
|
|
|
|
// Map arrow keys to number keys in the SEGA version of MI to support
|
2007-06-30 12:07:51 +00:00
|
|
|
// scrolling to conversation choices. See bug report #1193185 for details.
|
2007-06-30 11:57:50 +00:00
|
|
|
_mouseAndKeyboardStat = lastKeyHit.keycode - Common::KEYCODE_UP + 54;
|
2009-10-31 09:48:19 +00:00
|
|
|
} else if (_game.id == GID_LOOM && _game.platform == Common::kPlatformPCEngine) {
|
|
|
|
// Map arrow keys to number keys in the PCEngine version of Loom to support
|
|
|
|
// the menu screen.
|
|
|
|
switch (lastKeyHit.keycode) {
|
|
|
|
case Common::KEYCODE_UP:
|
|
|
|
_mouseAndKeyboardStat = 328;
|
|
|
|
break;
|
|
|
|
case Common::KEYCODE_DOWN:
|
|
|
|
_mouseAndKeyboardStat = 336;
|
|
|
|
break;
|
|
|
|
case Common::KEYCODE_LEFT:
|
|
|
|
_mouseAndKeyboardStat = 331;
|
|
|
|
break;
|
|
|
|
case Common::KEYCODE_RIGHT:
|
|
|
|
_mouseAndKeyboardStat = 333;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
2007-06-30 11:57:50 +00:00
|
|
|
} else if (_game.version >= 7) {
|
|
|
|
// Don't let pre-V7 game see arrow keys. This fixes bug with up arrow (273)
|
|
|
|
// corresponding to the "instant win" cheat in MI2 mentioned above.
|
|
|
|
//
|
|
|
|
// This is not applicable to V7+ games, which need to see the arrow keys,
|
|
|
|
// too, else certain things (derby scene, asterorid lander) won't work.
|
|
|
|
_mouseAndKeyboardStat = lastKeyHit.ascii;
|
2007-06-30 12:07:51 +00:00
|
|
|
}
|
|
|
|
|
2007-06-29 22:36:56 +00:00
|
|
|
} else {
|
2007-06-23 16:27:28 +00:00
|
|
|
_mouseAndKeyboardStat = lastKeyHit.ascii;
|
2007-06-29 22:36:56 +00:00
|
|
|
}
|
2006-10-07 13:31:27 +00:00
|
|
|
}
|
2004-09-20 22:04:06 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
} // End of namespace Scumm
|