[Scummvm-git-logs] scummvm master -> 369ef801c094d5e158e12e003393b1cc18892c58
sev-
noreply at scummvm.org
Thu Aug 21 06:58:13 UTC 2025
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://api.github.com/repos/scummvm/scummvm .
Summary:
369ef801c0 SHERLOCK: Add keymapper support
Commit: 369ef801c094d5e158e12e003393b1cc18892c58
https://github.com/scummvm/scummvm/commit/369ef801c094d5e158e12e003393b1cc18892c58
Author: aunnoman1 (aunnoman123 at outlook.com)
Date: 2025-08-21T08:58:10+02:00
Commit Message:
SHERLOCK: Add keymapper support
Changed paths:
engines/sherlock/animation.cpp
engines/sherlock/events.cpp
engines/sherlock/events.h
engines/sherlock/metaengine.cpp
engines/sherlock/saveload.cpp
engines/sherlock/scalpel/scalpel.cpp
engines/sherlock/scalpel/scalpel_darts.cpp
engines/sherlock/scalpel/scalpel_fixed_text.cpp
engines/sherlock/scalpel/scalpel_fixed_text.h
engines/sherlock/scalpel/scalpel_inventory.cpp
engines/sherlock/scalpel/scalpel_inventory.h
engines/sherlock/scalpel/scalpel_journal.cpp
engines/sherlock/scalpel/scalpel_journal.h
engines/sherlock/scalpel/scalpel_map.cpp
engines/sherlock/scalpel/scalpel_saveload.cpp
engines/sherlock/scalpel/scalpel_saveload.h
engines/sherlock/scalpel/scalpel_talk.cpp
engines/sherlock/scalpel/scalpel_talk.h
engines/sherlock/scalpel/scalpel_user_interface.cpp
engines/sherlock/scalpel/scalpel_user_interface.h
engines/sherlock/scalpel/settings.cpp
engines/sherlock/scalpel/settings.h
engines/sherlock/scalpel/tsage/logo.cpp
engines/sherlock/sherlock.h
engines/sherlock/sound.cpp
engines/sherlock/talk.cpp
engines/sherlock/tattoo/tattoo.cpp
engines/sherlock/tattoo/tattoo_darts.cpp
engines/sherlock/tattoo/tattoo_journal.cpp
engines/sherlock/tattoo/tattoo_map.cpp
engines/sherlock/tattoo/tattoo_people.cpp
engines/sherlock/tattoo/tattoo_scene.cpp
engines/sherlock/tattoo/tattoo_user_interface.cpp
engines/sherlock/tattoo/tattoo_user_interface.h
engines/sherlock/tattoo/widget_base.cpp
engines/sherlock/tattoo/widget_files.cpp
engines/sherlock/tattoo/widget_foolscap.cpp
engines/sherlock/tattoo/widget_inventory.cpp
engines/sherlock/tattoo/widget_options.cpp
engines/sherlock/tattoo/widget_password.cpp
engines/sherlock/tattoo/widget_quit.cpp
engines/sherlock/tattoo/widget_talk.cpp
engines/sherlock/tattoo/widget_text.cpp
engines/sherlock/tattoo/widget_verbs.cpp
engines/sherlock/user_interface.cpp
engines/sherlock/user_interface.h
diff --git a/engines/sherlock/animation.cpp b/engines/sherlock/animation.cpp
index 7fe9bcdd874..ac2b0970864 100644
--- a/engines/sherlock/animation.cpp
+++ b/engines/sherlock/animation.cpp
@@ -26,6 +26,8 @@
#include "common/algorithm.h"
+#include "backends/keymapper/keymapper.h"
+
namespace Sherlock {
static const int NO_FRAMES = FRAMES_END;
@@ -70,6 +72,10 @@ bool Animation::play(const Common::Path &filename, bool intro, int minDelay, int
screen.setPalette(images._palette);
}
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->disableAllGameKeymaps();
+ keymapper->getKeymap("animation")->setEnabled(true);
+
int frameNumber = 0;
Common::Point pt;
bool skipped = false;
@@ -124,10 +130,9 @@ bool Animation::play(const Common::Path &filename, bool intro, int minDelay, int
events.wait(speed * 3);
}
- if (events.kbHit()) {
- Common::KeyState keyState = events.getKey();
- if (keyState.keycode == Common::KEYCODE_ESCAPE ||
- keyState.keycode == Common::KEYCODE_SPACE) {
+ if (events.actionHit()) {
+ Common::CustomEventType action = events.getAction();
+ if (action == kActionSkipAnim) {
skipped = true;
break;
}
@@ -137,6 +142,11 @@ bool Animation::play(const Common::Path &filename, bool intro, int minDelay, int
}
}
+ keymapper->getKeymap("animation")->setEnabled(false);
+ keymapper->getKeymap("sherlock-default")->setEnabled(true);
+ keymapper->getKeymap("scalpel")->setEnabled(true);
+ keymapper->getKeymap("scalpel-quit")->setEnabled(true);
+
events.clearEvents();
sound.stopSound();
delete stream;
@@ -185,6 +195,10 @@ bool Animation::play3DO(const Common::Path &filename, bool intro, int minDelay,
fadeLimitColor = 0xCE59; // RGB565: 25, 50, 25 -> "grey"
}
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->disableAllGameKeymaps();
+ keymapper->getKeymap("animation")->setEnabled(true);
+
int frameNumber = 0;
Common::Point pt;
bool skipped = false;
@@ -251,10 +265,9 @@ bool Animation::play3DO(const Common::Path &filename, bool intro, int minDelay,
events.wait(speed * 3);
}
- if (events.kbHit()) {
- Common::KeyState keyState = events.getKey();
- if (keyState.keycode == Common::KEYCODE_ESCAPE ||
- keyState.keycode == Common::KEYCODE_SPACE) {
+ if (events.actionHit()) {
+ Common::CustomEventType action = events.getAction();
+ if (action == kActionSkipAnim) {
skipped = true;
break;
}
@@ -264,6 +277,11 @@ bool Animation::play3DO(const Common::Path &filename, bool intro, int minDelay,
}
}
+ keymapper->getKeymap("animation")->setEnabled(false);
+ keymapper->getKeymap("sherlock-default")->setEnabled(true);
+ keymapper->getKeymap("scalpel")->setEnabled(true);
+ keymapper->getKeymap("scalpel-quit")->setEnabled(true);
+
events.clearEvents();
sound.stopSound();
diff --git a/engines/sherlock/events.cpp b/engines/sherlock/events.cpp
index 6d6e11fa0fc..7a74562a96c 100644
--- a/engines/sherlock/events.cpp
+++ b/engines/sherlock/events.cpp
@@ -199,6 +199,11 @@ void Events::pollEvents() {
case Common::EVENT_RETURN_TO_LAUNCHER:
return;
+ case Common::EVENT_CUSTOM_ENGINE_ACTION_START:
+ _pendingActions.push(event.customType);
+ return;
+ case Common::EVENT_CUSTOM_ENGINE_ACTION_END:
+ return;
case Common::EVENT_KEYDOWN:
_pendingKeys.push(event.kbd);
return;
@@ -277,43 +282,19 @@ bool Events::checkForNextFrameCounter() {
Common::KeyState Events::getKey() {
Common::KeyState keyState = _pendingKeys.pop();
- switch (keyState.keycode) {
- case Common::KEYCODE_KP1:
- keyState.keycode = Common::KEYCODE_END;
- break;
- case Common::KEYCODE_KP2:
- keyState.keycode = Common::KEYCODE_DOWN;
- break;
- case Common::KEYCODE_KP3:
- keyState.keycode = Common::KEYCODE_PAGEDOWN;
- break;
- case Common::KEYCODE_KP4:
- keyState.keycode = Common::KEYCODE_LEFT;
- break;
- case Common::KEYCODE_KP6:
- keyState.keycode = Common::KEYCODE_RIGHT;
- break;
- case Common::KEYCODE_KP7:
- keyState.keycode = Common::KEYCODE_HOME;
- break;
- case Common::KEYCODE_KP8:
- keyState.keycode = Common::KEYCODE_UP;
- break;
- case Common::KEYCODE_KP9:
- keyState.keycode = Common::KEYCODE_PAGEUP;
- break;
- case Common::KEYCODE_KP_ENTER:
+ if (keyState.keycode == Common::KEYCODE_KP_ENTER)
keyState.keycode = Common::KEYCODE_RETURN;
- break;
- default:
- break;
- }
return keyState;
}
+Common::CustomEventType Events::getAction() {
+ return _pendingActions.pop();
+}
+
void Events::clearEvents() {
_pendingKeys.clear();
+ _pendingActions.clear();
_mouseButtons = 0;
_pressed = _released = false;
_rightPressed = _rightReleased = false;
@@ -325,6 +306,10 @@ void Events::clearKeyboard() {
_pendingKeys.clear();
}
+void Events::clearActions() {
+ _pendingActions.clear();
+}
+
void Events::wait(int numFrames) {
uint32 totalMilli = numFrames * 1000 / _frameRate;
delay(totalMilli);
@@ -350,7 +335,7 @@ bool Events::delay(uint32 time, bool interruptable) {
while (!_vm->shouldQuit() && g_system->getMillis() < delayEnd) {
pollEventsAndWait();
- if (interruptable && (kbHit() || _mouseButtons)) {
+ if (interruptable && (kbHit() || _mouseButtons || actionHit())) {
clearEvents();
return false;
}
@@ -383,7 +368,7 @@ void Events::setButtonState() {
bool Events::checkInput() {
setButtonState();
- return kbHit() || _pressed || _released || _rightPressed || _rightReleased;
+ return kbHit() || actionHit() || _pressed || _released || _rightPressed || _rightReleased;
}
void Events::incWaitCounter() {
diff --git a/engines/sherlock/events.h b/engines/sherlock/events.h
index ee1731e59e7..08948db4edf 100644
--- a/engines/sherlock/events.h
+++ b/engines/sherlock/events.h
@@ -61,6 +61,7 @@ public:
bool _oldRightButton;
bool _firstPress;
Common::Queue<Common::KeyState> _pendingKeys;
+ Common::Queue<Common::CustomEventType> _pendingActions;
Common::Point _hotspotPos;
public:
Events(SherlockEngine *vm);
@@ -162,13 +163,23 @@ public:
*/
bool kbHit() const { return !_pendingKeys.empty(); }
+ /**
+ * Returns true if there's a pending action
+ */
+ bool actionHit() const { return !_pendingActions.empty(); }
+
/**
* Get a pending keypress
*/
Common::KeyState getKey();
/**
- * Clear any current keypress or mouse click
+ * Get a pending action
+ */
+ Common::CustomEventType getAction();
+
+ /**
+ * Clear any current keypress, mouse click or action
*/
void clearEvents();
@@ -177,6 +188,11 @@ public:
*/
void clearKeyboard();
+ /**
+ * Clear any pending actions
+ */
+ void clearActions();
+
/**
* Delay for a given number of game frames, where each frame is 1/60th of a second
*/
diff --git a/engines/sherlock/metaengine.cpp b/engines/sherlock/metaengine.cpp
index 2cb3794b368..8427b848113 100644
--- a/engines/sherlock/metaengine.cpp
+++ b/engines/sherlock/metaengine.cpp
@@ -30,6 +30,14 @@
#include "sherlock/detection.h"
+#include "backends/keymapper/action.h"
+#include "backends/keymapper/keymapper.h"
+#include "backends/keymapper/standard-actions.h"
+
+#include "sherlock/fixed_text.h"
+#include "sherlock/scalpel/scalpel_fixed_text.h"
+//#include "sherlock/scalpel/scalpel_fixed_text_tables.h"
+
namespace Sherlock {
static const ADExtraGuiOptionsMap optionsList[] = {
@@ -133,6 +141,30 @@ Common::Language SherlockEngine::getLanguage() const {
return _gameDescription->desc.language;
}
+static const SHERLOCKActions fileActions[] = {
+ kActionScalpelFiles1,
+ kActionScalpelFiles2,
+ kActionScalpelFiles3,
+ kActionScalpelFiles4,
+ kActionScalpelFiles5,
+ kActionScalpelFiles6,
+ kActionScalpelFiles7,
+ kActionScalpelFiles8,
+ kActionScalpelFiles9
+};
+
+static const char *fileIds[] = {
+ "FILE1",
+ "FILE2",
+ "FILE3",
+ "FILE4",
+ "FILE5",
+ "FILE6",
+ "FILE7",
+ "FILE8",
+ "FILE9"
+};
+
} // End of namespace Sherlock
@@ -175,6 +207,11 @@ public:
* Given a specified savegame slot, returns extended information for the save
*/
SaveStateDescriptor querySaveMetaInfos(const char *target, int slot) const override;
+
+ /**
+ * Returns keymaps for the game
+ */
+ Common::KeymapArray initKeymaps(const char *target) const override;
};
Common::Error SherlockMetaEngine::createInstance(OSystem *syst, Engine **engine, const Sherlock::SherlockGameDescription *gd) const {
@@ -252,6 +289,1021 @@ SaveStateDescriptor SherlockMetaEngine::querySaveMetaInfos(const char *target, i
return SaveStateDescriptor();
}
+Common::String getString(int fixedTextId, const Sherlock::Scalpel::FixedTextLanguageEntry *curLanguageEntry, const char *target) {
+
+ Common::String str = curLanguageEntry->fixedTextArray[fixedTextId];
+ str.toLowercase();
+
+ return str;
+}
+
+Common::String getKey(int fixedTextId, const Sherlock::Scalpel::FixedTextLanguageEntry *curLanguageEntry, const char *target, int pos = 0) {
+
+ Common::String str = getString(fixedTextId, curLanguageEntry, target);
+
+ return str.substr(pos, 1);
+}
+
+Common::KeymapArray SherlockMetaEngine::initKeymaps(const char *target) const {
+ using namespace Common;
+ using namespace Sherlock;
+
+ KeymapArray keymaps;
+
+ Keymap *engineKeymap = new Keymap(Keymap::kKeymapTypeGame, "sherlock-default", _("Default keymappings"));
+
+ Action *act;
+
+ if (ConfMan.get("gameid", target) == "scalpel") {
+ using namespace Scalpel;
+
+ Language curLanguage = parseLanguage(ConfMan.get("language", target));
+ const FixedTextLanguageEntry *curLanguageEntry = fixedTextLanguages;
+
+ while (curLanguageEntry->language != UNK_LANG) {
+ if (curLanguageEntry->language == curLanguage)
+ break; // found current language
+ curLanguageEntry++;
+ }
+
+ Keymap *scalpelQuitKeymap = new Keymap(Keymap::kKeymapTypeGame, "scalpel-quit", _("Quit keymappings"));
+ Keymap *animationKeymap = new Keymap(Keymap::kKeymapTypeGame, "animation", _("Animation keymappings"));
+ Keymap *scalpelScrollKeymap = new Keymap(Keymap::kKeymapTypeGame, "scalpel-scroll", _("Scroll keymappings"));
+ Keymap *scalpelKeymap = new Keymap(Keymap::kKeymapTypeGame, "scalpel", _("Main user interface keymappings"));
+ Keymap *scalpelDartsKeymap = new Keymap(Keymap::kKeymapTypeGame, "scalpel-darts", _("Darts minigame keymappings"));
+ Keymap *scalpelJournalKeymap = new Keymap(Keymap::kKeymapTypeGame, "scalpel-journal", _("Journal keymappings"));
+ Keymap *scalpelTalkKeymap = new Keymap(Keymap::kKeymapTypeGame, "scalpel-talk", _("Talk keymappings"));
+ Keymap *scalpelInvKeymap = new Keymap(Keymap::kKeymapTypeGame, "scalpel-inv", _("Inventory keymappings"));
+ Keymap *scalpelFilesKeymap = new Keymap(Keymap::kKeymapTypeGame, "scalpel-files", _("Files keymappings"));
+ Keymap *scalpelQuitDialogKeymap = new Keymap(Keymap::kKeymapTypeGame, "scalpel-quit-dialog", _("Quit dialog keymappings"));
+ Keymap *scalpelMapKeymap = new Keymap(Keymap::kKeymapTypeGame, "scalpel-map", _("Map keymappings"));
+ Keymap *scalpelSettingsKeymap = new Keymap(Keymap::kKeymapTypeGame, "scalpel-settings", _("Settings keymappings"));
+ Keymap *scalpel3D0MovieKeymap = new Keymap(Keymap::kKeymapTypeGame, "scalpel-3d0-movie", _("Movie keymappings"));
+
+ act = new Common::Action(kStandardActionLeftClick, _("Move / Interact / Select"));
+ act->setLeftClickEvent();
+ act->addDefaultInputMapping("MOUSE_LEFT");
+ act->addDefaultInputMapping("JOY_A");
+ engineKeymap->addAction(act);
+
+ act = new Common::Action(kStandardActionRightClick, _("Skip / Deselect verb"));
+ act->setRightClickEvent();
+ act->addDefaultInputMapping("MOUSE_RIGHT");
+ act->addDefaultInputMapping("JOY_B");
+ engineKeymap->addAction(act);
+
+ //
+ // Quit keymap
+ //
+
+ act = new Action("QUIT", _("Quit game"));
+ act->setCustomEngineActionEvent(kActionScalpelQuit);
+ act->addDefaultInputMapping("A+x");
+ scalpelQuitKeymap->addAction(act);
+
+ //
+ // Scroll keymap
+ //
+
+ act = new Action("SCROLLUP", _("Scroll up")); // scroll up in journal, talk, and files UI all use the same key in all the languages hence using the same action for all three.
+ act->setCustomEngineActionEvent(kActionScalpelScrollUp);
+ act->addDefaultInputMapping(getKey(kFixedText_Window_Up, curLanguageEntry, target));
+ act->addDefaultInputMapping("JOY_UP");
+ scalpelScrollKeymap->addAction(act);
+
+ act = new Action("SCROLLDOWN", _("Scroll down")); // scroll down in journal, talk, and files UI all use the same key in all the languages hence using the same action for all three.
+ act->setCustomEngineActionEvent(kActionScalpelScrollDown);
+ act->addDefaultInputMapping(getKey(kFixedText_Window_Down, curLanguageEntry, target));
+ act->addDefaultInputMapping("JOY_DOWN");
+ scalpelScrollKeymap->addAction(act);
+
+ //
+ // Animation keymap
+ //
+
+ act = new Action("SKIP", _("Skip"));
+ act->setCustomEngineActionEvent(kActionSkipAnim);
+ act->addDefaultInputMapping("ESCAPE");
+ act->addDefaultInputMapping("SPACE");
+ act->addDefaultInputMapping("JOY_Y");
+ animationKeymap->addAction(act);
+
+ //
+ // Darts minigame keymap
+ //
+
+ act = new Action("EXIT", _("Exit"));
+ act->setCustomEngineActionEvent(kActionScalpelDartsExit);
+ act->addDefaultInputMapping("ESCAPE");
+ act->addDefaultInputMapping("JOY_B");
+ scalpelDartsKeymap->addAction(act);
+
+ //
+ // Scalpel main Game keymap
+ //
+
+ act = new Action("LOOK", _("Look"));
+ act->setCustomEngineActionEvent(kActionScalpelLook);
+ act->addDefaultInputMapping(getKey(kFixedText_Game_Hotkeys, curLanguageEntry, target, 0));
+ scalpelKeymap->addAction(act);
+
+ act = new Action("MOVE", _("Move"));
+ act->setCustomEngineActionEvent(kActionScalpelMove);
+ act->addDefaultInputMapping(getKey(kFixedText_Game_Hotkeys, curLanguageEntry, target, 1));
+ scalpelKeymap->addAction(act);
+
+ act = new Action("TALK", _("Talk"));
+ act->setCustomEngineActionEvent(kActionScalpelTalk);
+ act->addDefaultInputMapping(getKey(kFixedText_Game_Hotkeys, curLanguageEntry, target, 2));
+ scalpelKeymap->addAction(act);
+
+ act = new Action("PICKUP", _("Pick up"));
+ act->setCustomEngineActionEvent(kActionScalpelPickUp);
+ act->addDefaultInputMapping(getKey(kFixedText_Game_Hotkeys, curLanguageEntry, target, 3));
+ scalpelKeymap->addAction(act);
+
+ act = new Action("OPEN", _("Open"));
+ act->setCustomEngineActionEvent(kActionScalpelOpen);
+ act->addDefaultInputMapping(getKey(kFixedText_Game_Hotkeys, curLanguageEntry, target, 4));
+ scalpelKeymap->addAction(act);
+
+ act = new Action("CLOSE", _("Close"));
+ act->setCustomEngineActionEvent(kActionScalpelClose);
+ act->addDefaultInputMapping(getKey(kFixedText_Game_Hotkeys, curLanguageEntry, target, 5));
+ scalpelKeymap->addAction(act);
+
+ act = new Action("INVENTORY", _("Inventory"));
+ act->setCustomEngineActionEvent(kActionScalpelInventory);
+ act->addDefaultInputMapping(getKey(kFixedText_Game_Hotkeys, curLanguageEntry, target, 6));
+ scalpelKeymap->addAction(act);
+
+ act = new Action("USE", _("Use"));
+ act->setCustomEngineActionEvent(kActionScalpelUse);
+ act->addDefaultInputMapping(getKey(kFixedText_Game_Hotkeys, curLanguageEntry, target, 7));
+ scalpelKeymap->addAction(act);
+
+ act = new Action("GIVE", _("Give"));
+ act->setCustomEngineActionEvent(kActionScalpelGive);
+ act->addDefaultInputMapping(getKey(kFixedText_Game_Hotkeys, curLanguageEntry, target, 8));
+ scalpelKeymap->addAction(act);
+
+ act = new Action("SETUP", _("Setup"));
+ act->setCustomEngineActionEvent(kActionScalpelSetup);
+ act->addDefaultInputMapping(getKey(kFixedText_Game_Hotkeys, curLanguageEntry, target, 11));
+ scalpelKeymap->addAction(act);
+
+ // 3DO version has different actions in the main UI
+ if (parsePlatform(ConfMan.get("platform")) == kPlatform3DO) {
+ act = new Action("LOAD", _("Load game"));
+ act->setCustomEngineActionEvent(kActionScalpelLoad);
+ act->addDefaultInputMapping("a");
+ scalpelKeymap->addAction(act);
+
+ act = new Action("SAVE", _("Save game"));
+ act->setCustomEngineActionEvent(kActionScalpelSave);
+ act->addDefaultInputMapping("v");
+ scalpelKeymap->addAction(act);
+ } else {
+ act = new Action("JOURNAL", _("Journal"));
+ act->setCustomEngineActionEvent(kActionScalpelJournal);
+ act->addDefaultInputMapping(getKey(kFixedText_Game_Hotkeys, curLanguageEntry, target, 9));
+ scalpelKeymap->addAction(act);
+
+ act = new Action("FILES", _("Files"));
+ act->setCustomEngineActionEvent(kActionScalpelFiles);
+ act->addDefaultInputMapping(getKey(kFixedText_Game_Hotkeys, curLanguageEntry, target, 10));
+ scalpelKeymap->addAction(act);
+ }
+
+ //
+ // 3DO Movie keymap
+ //
+
+ if (parsePlatform(ConfMan.get("platform")) == kPlatform3DO) {
+ act = new Action("SKIPMOVIE", _("Skip movie"));
+ act->setCustomEngineActionEvent(kActionScalpelSkipMovie);
+ act->addDefaultInputMapping("ESCAPE");
+ act->addDefaultInputMapping("JOY_Y");
+ scalpel3D0MovieKeymap->addAction(act);
+ }
+
+ //
+ // Journal keymap
+ //
+
+ act = new Action("JOURNALEXIT", _("Exit"));
+ act->setCustomEngineActionEvent(kActionScalpelJournalExit);
+ act->addDefaultInputMapping("ESCAPE");
+ act->addDefaultInputMapping(getKey(kFixedText_Journal_Exit, curLanguageEntry, target));
+ scalpelJournalKeymap->addAction(act);
+
+ // I18N: (Game: The Lost Files of Sherlock Holmes: The Case of the Serrated Scalpel) The game has a journal, this action is used to go back 10 pages in the journal
+ act = new Action("BACK10", _("Go back 10 pages"));
+ act->setCustomEngineActionEvent(kActionScalpelJournalBack10);
+ act->addDefaultInputMapping(getKey(kFixedText_Journal_Back10, curLanguageEntry, target));
+ scalpelJournalKeymap->addAction(act);
+
+ // I18N: (Game: The Lost Files of Sherlock Holmes: The Case of the Serrated Scalpel) The game has a journal, this action is used to go forward 10 pages in the journal
+ act = new Action("AHEAD10", _("Go ahead 10 pages"));
+ act->setCustomEngineActionEvent(kActionScalpelJournalAhead10);
+ act->addDefaultInputMapping(getKey(kFixedText_Journal_Ahead10, curLanguageEntry, target));
+ act->addDefaultInputMapping("JOY_RIGHT");
+ scalpelJournalKeymap->addAction(act);
+
+ // I18N: (Game: The Lost Files of Sherlock Holmes: The Case of the Serrated Scalpel) The game has a journal, this action is used to search the journal
+ act = new Action("SEARCH", _("Search"));
+ act->setCustomEngineActionEvent(kActionScalpelJournalSearch);
+ act->addDefaultInputMapping(getKey(kFixedText_Journal_Search, curLanguageEntry, target));
+ act->addDefaultInputMapping("JOY_X");
+ scalpelJournalKeymap->addAction(act);
+
+ // I18N: (Game: The Lost Files of Sherlock Holmes: The Case of the Serrated Scalpel) The game has a journal, this action is used to go to the first page of the journal
+ act = new Action("FIRST_PAGE", _("First page"));
+ act->setCustomEngineActionEvent(kActionScalpelJournalFirstPage);
+ act->addDefaultInputMapping(getKey(kFixedText_Journal_FirstPage, curLanguageEntry, target));
+ act->addDefaultInputMapping("JOY_LEFT_TRIGGER");
+ scalpelJournalKeymap->addAction(act);
+
+ // I18N: (Game: The Lost Files of Sherlock Holmes: The Case of the Serrated Scalpel) The game has a journal, this action is used to go to the last page of the journal
+ act = new Action("LAST_PAGE", _("Last page"));
+ act->setCustomEngineActionEvent(kActionScalpelJournalLastPage);
+ act->addDefaultInputMapping(getKey(kFixedText_Journal_LastPage, curLanguageEntry, target));
+ act->addDefaultInputMapping("JOY_RIGHT_TRIGGER");
+ scalpelJournalKeymap->addAction(act);
+
+ //
+ // Talk keymap
+ //
+
+ act = new Action("TALKEXIT", _("Exit"));
+ act->setCustomEngineActionEvent(kActionScalpelTalkExit);
+ act->addDefaultInputMapping(getKey(kFixedText_Window_Exit, curLanguageEntry, target));
+ act->addDefaultInputMapping("ESCAPE");
+ act->addDefaultInputMapping("JOY_Y");
+ scalpelTalkKeymap->addAction(act);
+
+ //
+ // Inventory keymap
+ //
+
+ act = new Action("INVEXIT", _("Exit"));
+ act->setCustomEngineActionEvent(kActionScalpelInvExit);
+ act->addDefaultInputMapping(getKey(kFixedText_Inventory_Exit, curLanguageEntry, target));
+ act->addDefaultInputMapping("ESCAPE");
+ act->addDefaultInputMapping("JOY_Y");
+ scalpelInvKeymap->addAction(act);
+
+ act = new Action("LOOK", _("Look"));
+ act->setCustomEngineActionEvent(kActionScalpelInvLook);
+ act->addDefaultInputMapping(getKey(kFixedText_Inventory_Look, curLanguageEntry, target));
+ scalpelInvKeymap->addAction(act);
+
+ act = new Action("USE", _("Use"));
+ act->setCustomEngineActionEvent(kActionScalpelInvUse);
+ act->addDefaultInputMapping(getKey(kFixedText_Inventory_Use, curLanguageEntry, target));
+ scalpelInvKeymap->addAction(act);
+
+ act = new Action("GIVE", _("Give"));
+ act->setCustomEngineActionEvent(kActionScalpelInvGive);
+ act->addDefaultInputMapping(getKey(kFixedText_Inventory_Give, curLanguageEntry, target));
+ scalpelInvKeymap->addAction(act);
+
+ // I18N: (Game: The Lost Files of Sherlock Holmes: The Case of the Serrated Scalpel) The game has an inventory, this action is go back a page (one page displays 6 items) in the inventory
+ act = new Action("PAGE_LEFT", _("Go back a page"));
+ act->setCustomEngineActionEvent(kActionScalpelInvPageLeft);
+ act->addDefaultInputMapping("COMMA");
+ act->addDefaultInputMapping("JOY_UP");
+ scalpelInvKeymap->addAction(act);
+
+ act = new Action("LEFT", _("Scroll left"));
+ act->setCustomEngineActionEvent(kActionScalpelInvLeft);
+ act->addDefaultInputMapping("MINUS");
+ act->addDefaultInputMapping("JOY_LEFT");
+ scalpelInvKeymap->addAction(act);
+
+ act = new Action("RIGHT", _("Scroll Right"));
+ act->setCustomEngineActionEvent(kActionScalpelInvRight);
+ act->addDefaultInputMapping("PLUS");
+ act->addDefaultInputMapping("JOY_RIGHT");
+ scalpelInvKeymap->addAction(act);
+
+ // I18N: (Game: The Lost Files of Sherlock Holmes: The Case of the Serrated Scalpel) The game has an inventory, this action is go ahead a page (one page displays 6 items) in the inventory
+ act = new Action("PAGE_RIGHT", _("Go ahead a page"));
+ act->setCustomEngineActionEvent(kActionScalpelInvPageRight);
+ act->addDefaultInputMapping("PERIOD");
+ act->addDefaultInputMapping("JOY_DOWN");
+ scalpelInvKeymap->addAction(act);
+
+ //
+ // Files keymap
+ //
+
+ act = new Action("EXIT", _("Exit"));
+ act->setCustomEngineActionEvent(kActionScalpelFilesExit);
+ act->addDefaultInputMapping(getKey(kFixedText_LoadSave_Exit, curLanguageEntry, target));
+ act->addDefaultInputMapping("ESCAPE");
+ act->addDefaultInputMapping("JOY_Y");
+ scalpelFilesKeymap->addAction(act);
+
+ act = new Action("LOAD", _("Load game"));
+ act->setCustomEngineActionEvent(kActionScalpelFilesLoad);
+ act->addDefaultInputMapping(getKey(kFixedText_LoadSave_Load, curLanguageEntry, target));
+ scalpelFilesKeymap->addAction(act);
+
+ act = new Action("SAVE", _("Save game"));
+ act->setCustomEngineActionEvent(kActionScalpelFilesSave);
+ act->addDefaultInputMapping(getKey(kFixedText_LoadSave_Save, curLanguageEntry, target));
+ scalpelFilesKeymap->addAction(act);
+
+ act = new Action("QUIT", _("Quit game"));
+ act->setCustomEngineActionEvent(kActionScalpelFilesQuit);
+ act->addDefaultInputMapping(getKey(kFixedText_LoadSave_Quit, curLanguageEntry, target));
+ scalpelFilesKeymap->addAction(act);
+
+ String fileLabel[9];
+
+ for (int i = 0; i < 9; ++i) {
+ fileLabel[i] = String::format("Save game slot %d", i + 1);
+
+ act = new Action(fileIds[i], _(fileLabel[i]));
+ act->setCustomEngineActionEvent(fileActions[i]);
+ act->addDefaultInputMapping(String::format("%d", i + 1));
+ scalpelFilesKeymap->addAction(act);
+ }
+
+ //
+ // Quit dialog keymap
+ //
+
+ act = new Action("YES", _("Yes"));
+ act->setCustomEngineActionEvent(kActionScalpelQuitDialogYes);
+ act->addDefaultInputMapping(getKey(kFixedText_QuitGame_Yes, curLanguageEntry, target));
+ scalpelQuitDialogKeymap->addAction(act);
+
+ act = new Action("NO", _("No"));
+ act->setCustomEngineActionEvent(kActionScalpelQuitDialogNo);
+ act->addDefaultInputMapping(getKey(kFixedText_QuitGame_No, curLanguageEntry, target));
+ act->addDefaultInputMapping("ESCAPE");
+ scalpelQuitDialogKeymap->addAction(act);
+
+ act = new Action("QUITDLGSELECT", _("Select option"));
+ act->setCustomEngineActionEvent(kActionScalpelQuitDialogSelect);
+ act->addDefaultInputMapping("RETURN");
+ act->addDefaultInputMapping("KP_ENTER");
+ act->addDefaultInputMapping("SPACE");
+ scalpelQuitDialogKeymap->addAction(act);
+
+ //
+ // Map keymap
+ //
+
+ act = new Action("MAPSELECT", _("Select"));
+ act->setCustomEngineActionEvent(kActionScalpelMapSelect);
+ act->addDefaultInputMapping("RETURN");
+ act->addDefaultInputMapping("KP_ENTER");
+ act->addDefaultInputMapping("SPACE");
+ scalpelMapKeymap->addAction(act);
+
+ //
+ // Settings keymap
+ //
+
+ act = new Action("SETTINGSSELECT", _("Select"));
+ act->setCustomEngineActionEvent(kActionScalpelSettingsSelect);
+ act->addDefaultInputMapping("RETURN");
+ act->addDefaultInputMapping("KP_ENTER");
+ act->addDefaultInputMapping("SPACE");
+ scalpelSettingsKeymap->addAction(act);
+
+ act = new Action("SETTINGSEXIT", _("Exit"));
+ act->setCustomEngineActionEvent(kActionScalpelSettingsExit);
+ act->addDefaultInputMapping(getKey(kFixedText_Settings_Exit, curLanguageEntry, target));
+ act->addDefaultInputMapping("ESCAPE");
+ act->addDefaultInputMapping("JOY_Y");
+ scalpelSettingsKeymap->addAction(act);
+
+ act = new Action("TOGGLEMUSIC", _("Toggle music"));
+ act->setCustomEngineActionEvent(kActionScalpelSettingsToggleMusic);
+ act->addDefaultInputMapping(getKey(kFixedText_Settings_MusicOn, curLanguageEntry, target)); // Same key for on/off in all languages
+ scalpelSettingsKeymap->addAction(act);
+
+ act = new Action("TOGGLEPORTRAITS", _("Toggle portraits"));
+ act->setCustomEngineActionEvent(kActionScalpelSettingsTogglePortraits);
+ act->addDefaultInputMapping(getKey(kFixedText_Settings_PortraitsOn, curLanguageEntry, target)); // Same key for on/off in all languages
+ scalpelSettingsKeymap->addAction(act);
+
+ act = new Action("FONT", _("Change font style"));
+ act->setCustomEngineActionEvent(kActionScalpelSettingsChangeFontStyle);
+ act->addDefaultInputMapping(getKey(kFixedText_Settings_NewFontStyle, curLanguageEntry, target));
+ scalpelSettingsKeymap->addAction(act);
+
+ act = new Action("TOGGLESOUNDS", _("Toggle sound effects"));
+ act->setCustomEngineActionEvent(kActionScalpelSettingsToggleSoundEffects);
+ act->addDefaultInputMapping(getKey(kFixedText_Settings_SoundEffectsOn, curLanguageEntry, target)); // Same key for on/off in all languages
+ scalpelSettingsKeymap->addAction(act);
+
+ act = new Action("WINDOW", _("Toggle windows mode"));
+ act->setCustomEngineActionEvent(kActionScalpelSettingsToggleWindowsMode);
+ act->addDefaultInputMapping(getKey(kFixedText_Settings_WindowsSlide, curLanguageEntry, target)); // Same key for various window modes in all languages
+ scalpelSettingsKeymap->addAction(act);
+
+ // I18N: (Game: The Lost Files of Sherlock Holmes: The Case of the Serrated Scalpel) The game has an auto-help feature, this action is used to change the auto-help location between left and right
+ act = new Action("AUTOHELP", _("Change auto-help location"));
+ act->setCustomEngineActionEvent(kActionScalpelSettingsChangeAutohelpLoc);
+ act->addDefaultInputMapping(getKey(kFixedText_Settings_AutoHelpRight, curLanguageEntry, target)); // Same key for various auto-help location in all languages
+ scalpelSettingsKeymap->addAction(act);
+
+ act = new Action("TOGGLEVOICES", _("Toggle voices"));
+ act->setCustomEngineActionEvent(kActionScalpelSettingsToggleVoices);
+ act->addDefaultInputMapping(getKey(kFixedText_Settings_VoicesOn, curLanguageEntry, target)); // Same key for on/off in all languages
+ scalpelSettingsKeymap->addAction(act);
+
+ // German version has different keys for fade modes, every other language uses the same key for all fade modes
+ if (parseLanguage(ConfMan.get("language", target)) == Common::DE_DEU) {
+ // I18N: (Game: The Lost Files of Sherlock Holmes: The Case of the Serrated Scalpel) The game has a fade animation when switching scenes, this action is used to change the fade mode to "Fade by pixel"
+ act = new Action("FADEBYPIXEL", _("Fade by pixel"));
+ act->setCustomEngineActionEvent(kActionScalpelSettingsFadeByPixels);
+ act->addDefaultInputMapping(getKey(kFixedText_Settings_FadeByPixel, curLanguageEntry, target));
+ scalpelSettingsKeymap->addAction(act);
+
+ // I18N: (Game: The Lost Files of Sherlock Holmes: The Case of the Serrated Scalpel) The game has a fade animation when switching scenes, this action is used to change the fade mode to "Fade directly"
+ act = new Action("FADEDIRECTLY", _("Fade directly"));
+ act->setCustomEngineActionEvent(kActionScalpelSettingsFadeDirectly);
+ act->addDefaultInputMapping(getKey(kFixedText_Settings_FadeDirectly, curLanguageEntry, target));
+ scalpelSettingsKeymap->addAction(act);
+ } else {
+ // I18N: (Game: The Lost Files of Sherlock Holmes: The Case of the Serrated Scalpel) The game has a fade animation when switching scenes, this action is used to change the fade mode
+ act = new Action("FADE", _("Change fade mode"));
+ act->setCustomEngineActionEvent(kActionScalpelSettingsChangeFadeMode);
+ act->addDefaultInputMapping(getKey(kFixedText_Settings_FadeByPixel, curLanguageEntry, target));
+ scalpelSettingsKeymap->addAction(act);
+ }
+
+ keymaps.push_back(engineKeymap);
+ keymaps.push_back(scalpelQuitKeymap);
+ keymaps.push_back(scalpelScrollKeymap);
+ keymaps.push_back(animationKeymap);
+ keymaps.push_back(scalpelKeymap);
+ keymaps.push_back(scalpelJournalKeymap);
+ keymaps.push_back(scalpelTalkKeymap);
+ keymaps.push_back(scalpelInvKeymap);
+ keymaps.push_back(scalpelFilesKeymap);
+ keymaps.push_back(scalpelQuitDialogKeymap);
+ keymaps.push_back(scalpelMapKeymap);
+ keymaps.push_back(scalpelSettingsKeymap);
+
+ scalpelScrollKeymap->setEnabled(false);
+ animationKeymap->setEnabled(false);
+ scalpelJournalKeymap->setEnabled(false);
+ scalpelTalkKeymap->setEnabled(false);
+ scalpelInvKeymap->setEnabled(false);
+ scalpelFilesKeymap->setEnabled(false);
+ scalpelQuitDialogKeymap->setEnabled(false);
+ scalpelMapKeymap->setEnabled(false);
+ scalpelSettingsKeymap->setEnabled(false);
+
+ if (parsePlatform(ConfMan.get("platform")) == kPlatform3DO) {
+ keymaps.push_back(scalpel3D0MovieKeymap);
+ scalpel3D0MovieKeymap->setEnabled(false);
+ }
+
+ } else if (ConfMan.get("gameid", target) == "rosetattoo") {
+
+ Keymap *tattooKeymap = new Keymap(Keymap::kKeymapTypeGame, "tattoo", _("Main user interface keymappings"));
+ Keymap *tattooExitKeymap = new Keymap(Keymap::kKeymapTypeGame, "tattoo-exit", _("Exit keymappings"));
+ Keymap *tattooPrologKeymap = new Keymap(Keymap::kKeymapTypeGame, "tattoo-prolog", _("Movie keymappings"));
+ Keymap *tattooJournalKeymap = new Keymap(Keymap::kKeymapTypeGame, "tattoo-journal", _("Journal keymappings"));
+ Keymap *tattooJournalSearchKeymap = new Keymap(Keymap::kKeymapTypeGame, "tattoo-journal-search", _("Journal search keymappings"));
+ Keymap *tattooDartsKeymap = new Keymap(Keymap::kKeymapTypeGame, "tattoo-darts", _("Darts minigame keymappings"));
+ Keymap *tattooMapKeymap = new Keymap(Keymap::kKeymapTypeGame, "tattoo-map", _("Map keymappings"));
+ Keymap *tattooScrollingKeymap = new Keymap(Keymap::kKeymapTypeGame, "tattoo-scrolling", _("Menu scrolling keymappings"));
+ Keymap *tattooFilesKeymap = new Keymap(Keymap::kKeymapTypeGame, "tattoo-files", _("save / load menu keymappings"));
+ Keymap *tattooFilesNameKeymap = new Keymap(Keymap::kKeymapTypeGame, "tattoo-files-name", _("Save files name editing keymappings"));
+ Keymap *tattooFoolscapKeymap = new Keymap(Keymap::kKeymapTypeGame, "tattoo-foolscap", _("Foolscap puzzle keymappings"));
+ Keymap *tattooInvKeymap = new Keymap(Keymap::kKeymapTypeGame, "tattoo-inv", _("Inventory keymappings"));
+ Keymap *tattooOptionsKeymap = new Keymap(Keymap::kKeymapTypeGame, "tattoo-options", _("Options menu keymappings"));
+ Keymap *tattooPasswordKeymap = new Keymap(Keymap::kKeymapTypeGame, "tattoo-password", _("Password entry keymappings"));
+ Keymap *tattooQuitDialogKeymap = new Keymap(Keymap::kKeymapTypeGame, "tattoo-quit-dialog", _("Quit dialog keymappings"));
+ Keymap *tattooTalkKeymap = new Keymap(Keymap::kKeymapTypeGame, "tattoo-talk", _("Talk options keymappings"));
+
+ act = new Common::Action(kStandardActionLeftClick, _("Move / Examine / Select"));
+ act->setLeftClickEvent();
+ act->addDefaultInputMapping("MOUSE_LEFT");
+ act->addDefaultInputMapping("JOY_A");
+ engineKeymap->addAction(act);
+
+ act = new Common::Action(kStandardActionRightClick, _("Open verb menu / close menu"));
+ act->setRightClickEvent();
+ act->addDefaultInputMapping("MOUSE_RIGHT");
+ act->addDefaultInputMapping("JOY_B");
+ engineKeymap->addAction(act);
+
+ //
+ // tattoo main Game keymap
+ //
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) This action changes the speed of the game (walking, animations, etc.)
+ act = new Action("SPEED", _("Change speed"));
+ act->setCustomEngineActionEvent(kActionTattooChangeSpeed);
+ act->addDefaultInputMapping("s");
+ act->addDefaultInputMapping("JOY_X");
+ tattooKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) This action is used to look at an object or npc in the game
+ act = new Action("LOOK", _("Look"));
+ act->setCustomEngineActionEvent(kActionTattooLook);
+ act->addDefaultInputMapping("l");
+ act->addDefaultInputMapping("JOY_Y");
+ tattooKeymap->addAction(act);
+
+ act = new Action("SAVE", _("Save game"));
+ act->setCustomEngineActionEvent(kActionTattooSave);
+ act->addDefaultInputMapping("F5");
+ tattooKeymap->addAction(act);
+
+ act = new Action("LOAD", _("Load game"));
+ act->setCustomEngineActionEvent(kActionTattooLoad);
+ act->addDefaultInputMapping("F7");
+ tattooKeymap->addAction(act);
+
+ act = new Action("JOURNAL", _("Open journal"));
+ act->setCustomEngineActionEvent(kActionTattooJournal);
+ act->addDefaultInputMapping("F1");
+ act->addDefaultInputMapping("JOY_UP");
+ tattooKeymap->addAction(act);
+
+ act = new Action("INV", _("Open inventory"));
+ act->setCustomEngineActionEvent(kActionTattooInv);
+ act->addDefaultInputMapping("TAB");
+ act->addDefaultInputMapping("F3");
+ act->addDefaultInputMapping("JOY_DOWN");
+ tattooKeymap->addAction(act);
+
+ act = new Action("OPTIONS", _("Open options"));
+ act->setCustomEngineActionEvent(kActionTattooOptions);
+ act->addDefaultInputMapping("F4");
+ act->addDefaultInputMapping("JOY_LEFT");
+ tattooKeymap->addAction(act);
+
+ act = new Action("QUIT", _("Quit game"));
+ act->setCustomEngineActionEvent(kActionTattooQuit);
+ act->addDefaultInputMapping("F10");
+ act->addDefaultInputMapping("JOY_RIGHT");
+ tattooKeymap->addAction(act);
+
+ //
+ // Exit keymap
+ //
+
+ act = new Action("EXIT", _("Exit / Close window"));
+ act->setCustomEngineActionEvent(kActionTattooExit);
+ act->addDefaultInputMapping("ESCAPE");
+ act->addDefaultInputMapping("JOY_Y");
+ tattooExitKeymap->addAction(act);
+
+ //
+ // Prolog keymap
+ //
+
+ act = new Action("SKIPPROLOG", _("Skip prolog"));
+ act->setCustomEngineActionEvent(kActionTattooSkipProlog);
+ act->addDefaultInputMapping("ESCAPE");
+ act->addDefaultInputMapping("JOY_Y");
+ tattooPrologKeymap->addAction(act);
+
+ //
+ // Journal keymap
+ //
+
+ act = new Action("OPTIONSLEFT", _("Change selected option to the left"));
+ act->setCustomEngineActionEvent(kActionTattooJournalOptionsLeft);
+ act->addDefaultInputMapping("S+TAB");
+ act->addDefaultInputMapping("JOY_LEFT_SHOULDER");
+ tattooJournalKeymap->addAction(act);
+
+ act = new Action("OPTIONSRIGHT", _("Change selected option to the right"));
+ act->setCustomEngineActionEvent(kActionTattooJournalOptionsRight);
+ act->addDefaultInputMapping("TAB");
+ act->addDefaultInputMapping("JOY_RIGHT_SHOULDER");
+ tattooJournalKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) The game has a journal, this action is used to go forward 10 pages in the journal
+ act = new Action("PAGEFORWARD10", _("Go forward 10 pages"));
+ act->setCustomEngineActionEvent(kActionTattooJournalForward10);
+ act->addDefaultInputMapping("S+PAGEDOWN");
+ act->addDefaultInputMapping("JOY_RIGHT");
+ tattooJournalKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) The game has a journal, this action is used to go forward 1 page in the journal
+ act = new Action("PAGEFORWARD1", _("Go forward 1 page"));
+ act->setCustomEngineActionEvent(kActionTattooJournalForward1);
+ act->addDefaultInputMapping("PAGEDOWN");
+ act->addDefaultInputMapping("KP3");
+ act->addDefaultInputMapping("JOY_DOWN");
+ tattooJournalKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) The game has a journal, this action is used to go back 10 pages in the journal
+ act = new Action("PAGEBACK10", _("Go back 10 pages"));
+ act->setCustomEngineActionEvent(kActionTattooJournalBack10);
+ act->addDefaultInputMapping("S+PAGEUP");
+ act->addDefaultInputMapping("JOY_LEFT");
+ tattooJournalKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) The game has a journal, this action is used to go back 1 page in the journal
+ act = new Action("PAGEBACK1", _("Go back 1 page"));
+ act->setCustomEngineActionEvent(kActionTattooJournalBack1);
+ act->addDefaultInputMapping("PAGEUP");
+ act->addDefaultInputMapping("KP9");
+ act->addDefaultInputMapping("JOY_UP");
+ tattooJournalKeymap->addAction(act);
+
+ act = new Action("GOSTART", _("Go to start of journal"));
+ act->setCustomEngineActionEvent(kActionTattooJournalStart);
+ act->addDefaultInputMapping("HOME");
+ act->addDefaultInputMapping("KP7");
+ act->addDefaultInputMapping("JOY_LEFT_TRIGGER");
+ tattooJournalKeymap->addAction(act);
+
+ act = new Action("GOEND", _("Go to end of journal"));
+ act->setCustomEngineActionEvent(kActionTattooJournalEnd);
+ act->addDefaultInputMapping("END");
+ act->addDefaultInputMapping("KP1");
+ act->addDefaultInputMapping("JOY_RIGHT_TRIGGER");
+ tattooJournalKeymap->addAction(act);
+
+ act = new Action("SELECT", _("Select option"));
+ act->setCustomEngineActionEvent(kActionTattooJournalSelect);
+ act->addDefaultInputMapping("RETURN");
+ act->addDefaultInputMapping("KP_ENTER");
+ act->addDefaultInputMapping("JOY_X");
+ tattooJournalKeymap->addAction(act);
+
+ //
+ // Journal search keymap
+ //
+
+ act = new Action("OPTIONSLEFT", _("Change selected option to the left"));
+ act->setCustomEngineActionEvent(kActionTattooJournalSearchOptionsLeft);
+ act->addDefaultInputMapping("S+TAB");
+ act->addDefaultInputMapping("JOY_LEFT");
+ tattooJournalSearchKeymap->addAction(act);
+
+ act = new Action("OPTIONSRIGHT", _("Change selected option to the right"));
+ act->setCustomEngineActionEvent(kActionTattooJournalSearchOptionsRight);
+ act->addDefaultInputMapping("TAB");
+ act->addDefaultInputMapping("JOY_RIGHT");
+ tattooJournalSearchKeymap->addAction(act);
+
+ act = new Action("SEARCH", _("Search"));
+ act->setCustomEngineActionEvent(kActionTattooJournalSearch);
+ act->addDefaultInputMapping("RETURN");
+ act->addDefaultInputMapping("KP_ENTER");
+ act->addDefaultInputMapping("JOY_X");
+ tattooJournalSearchKeymap->addAction(act);
+
+ //
+ // Darts keymap
+ //
+
+ act = new Action("SKIPGAME", _("Skip darts minigame"));
+ act->setCustomEngineActionEvent(kActionTattooSkipDarts);
+ act->addDefaultInputMapping("ESCAPE");
+ act->addDefaultInputMapping("JOY_Y");
+ tattooDartsKeymap->addAction(act);
+
+ //
+ // Map keymap
+ //
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) The game has a map, this action is used to scroll to the top left of the map
+ act = new Action("TOPLEFT", _("Scroll to top left"));
+ act->setCustomEngineActionEvent(kActionTattooMapTopLeft);
+ act->addDefaultInputMapping("HOME");
+ act->addDefaultInputMapping("KP7");
+ act->addDefaultInputMapping("JOY_LEFT");
+ tattooMapKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) The game has a map, this action is used to scroll to the bottom right of the map
+ act = new Action("BOTTOMRIGHT", _("Scroll to bottom right"));
+ act->setCustomEngineActionEvent(kActionTattooMapBottomRight);
+ act->addDefaultInputMapping("END");
+ act->addDefaultInputMapping("KP1");
+ act->addDefaultInputMapping("JOY_RIGHT");
+ tattooMapKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) The game has a map, this action is used to scroll up in the map
+ act = new Action("UP", _("Scroll up"));
+ act->setCustomEngineActionEvent(kActionTattooMapUp);
+ act->addDefaultInputMapping("PAGEUP");
+ act->addDefaultInputMapping("KP9");
+ act->addDefaultInputMapping("JOY_UP");
+ tattooMapKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) The game has a map, this action is used to scroll down in the map
+ act = new Action("DOWN", _("Scroll down"));
+ act->setCustomEngineActionEvent(kActionTattooMapDown);
+ act->addDefaultInputMapping("PAGEDOWN");
+ act->addDefaultInputMapping("KP3");
+ act->addDefaultInputMapping("JOY_DOWN");
+ tattooMapKeymap->addAction(act);
+
+ act = new Action("SELECT", _("Select"));
+ act->setCustomEngineActionEvent(kActionTattooMapSelect);
+ act->addDefaultInputMapping("SPACE");
+ act->addDefaultInputMapping("JOY_X");
+ tattooMapKeymap->addAction(act);
+
+ //
+ // Scrolling keymap
+ //
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) The game has multiple widgets for various purposes (eg. inventory, save files, etc.), this action is used to scroll up in the widget
+ act = new Action("SCROLLUP", _("Scroll up"));
+ act->setCustomEngineActionEvent(kActionTattooWidgetScrollUp);
+ act->addDefaultInputMapping("UP");
+ act->addDefaultInputMapping("KP8");
+ act->addDefaultInputMapping("JOY_UP");
+ tattooScrollingKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) The game has multiple widgets for various purposes (eg. inventory, save files, etc.), this action is used to scroll down in the widget
+ act = new Action("SCROLLDOWN", _("Scroll down"));
+ act->setCustomEngineActionEvent(kActionTattooWidgetScrollDown);
+ act->addDefaultInputMapping("DOWN");
+ act->addDefaultInputMapping("KP2");
+ act->addDefaultInputMapping("JOY_DOWN");
+ tattooScrollingKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) The game has multiple widgets for various purposes (eg. inventory, save files, etc.), this action is used to scroll up by a page in the widget
+ act = new Action("SCROLLPGUP", _("Scroll page up"));
+ act->setCustomEngineActionEvent(kActionTattooWidgetScrollPageUp);
+ act->addDefaultInputMapping("PAGEUP");
+ act->addDefaultInputMapping("KP9");
+ tattooScrollingKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) The game has multiple widgets for various purposes (eg. inventory, save files, etc.), this action is used to scroll down by a page in the widget
+ act = new Action("SCROLLPGDOWN", _("Scroll page down"));
+ act->setCustomEngineActionEvent(kActionTattooWidgetScrollPageDown);
+ act->addDefaultInputMapping("PAGEDOWN");
+ act->addDefaultInputMapping("KP3");
+ tattooScrollingKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) The game has multiple widgets for various purposes (eg. inventory, save files, etc.), this action is used to scroll to the end of the widget
+ act = new Action("SCROLLEND", _("Scroll to end"));
+ act->setCustomEngineActionEvent(kActionTattooWidgetScrollEnd);
+ act->addDefaultInputMapping("END");
+ act->addDefaultInputMapping("KP1");
+ tattooScrollingKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) The game has multiple widgets for various purposes (eg. inventory, save files, etc.), this action is used to scroll to the start of the widget
+ act = new Action("SCROLLSTART", _("Scroll to start"));
+ act->setCustomEngineActionEvent(kActionTattooWidgetScrollStart);
+ act->addDefaultInputMapping("HOME");
+ act->addDefaultInputMapping("KP7");
+ tattooScrollingKeymap->addAction(act);
+
+ //
+ // Files keymap
+ //
+
+ act = new Action("NEXT", _("Go to next save file slot"));
+ act->setCustomEngineActionEvent(kActionTattooFilesNextSlot);
+ act->addDefaultInputMapping("TAB");
+ act->addDefaultInputMapping("JOY_RIGHT");
+ tattooFilesKeymap->addAction(act);
+
+ act = new Action("NEXTPGE", _("Go to next page of save files"));
+ act->setCustomEngineActionEvent(kActionTattooFilesNextPageSlot);
+ act->addDefaultInputMapping("S+TAB");
+ tattooFilesKeymap->addAction(act);
+
+ act = new Action("SELECT", _("Select save file"));
+ act->setCustomEngineActionEvent(kActionTattooFilesSelect);
+ act->addDefaultInputMapping("ESCAPE");
+ act->addDefaultInputMapping("JOY_X");
+ tattooFilesKeymap->addAction(act);
+
+ //
+ // Files name keymap
+ //
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) cursor refers to the text cursor in the save file name input field
+ act = new Action("LEFT", _("Move cursor left"));
+ act->setCustomEngineActionEvent(kActionTattooFilesNameLeft);
+ act->addDefaultInputMapping("LEFT");
+ act->addDefaultInputMapping("KP4");
+ act->addDefaultInputMapping("JOY_LEFT");
+ tattooFilesNameKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) cursor refers to the text cursor in the save file name input field
+ act = new Action("RIGHT", _("Move cursor right"));
+ act->setCustomEngineActionEvent(kActionTattooFilesNameRight);
+ act->addDefaultInputMapping("RIGHT");
+ act->addDefaultInputMapping("KP6");
+ act->addDefaultInputMapping("JOY_RIGHT");
+ tattooFilesNameKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) This action is used to go to the start of the save file name input field
+ act = new Action("GOSTART", _("Go to the line start"));
+ act->setCustomEngineActionEvent(kActionTattooFilesNameStart);
+ act->addDefaultInputMapping("HOME");
+ act->addDefaultInputMapping("KP7");
+ tattooFilesNameKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) This action is used to go to the end of the save file name input field
+ act = new Action("GOEND", _("Go to the line end"));
+ act->setCustomEngineActionEvent(kActionTattooFilesNameEnd);
+ act->addDefaultInputMapping("END");
+ act->addDefaultInputMapping("KP1");
+ tattooFilesNameKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) save file name input field has 2 modes, insert and overwrite, this action toggles between them
+ act = new Action("INSERTMODE", _("Toggle insert mode"));
+ act->setCustomEngineActionEvent(kActionTattooFilesNameToggleInsertMode);
+ act->addDefaultInputMapping("INSERT");
+ act->addDefaultInputMapping("JOY_UP");
+ tattooFilesNameKeymap->addAction(act);
+
+ //
+ // Foolscap puzzle keymap
+ //
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) The game has a foolscap puzzle, where the player has to decode a hidden message on a piece of paper called a foolscap. this action is used to exit the puzzle
+ act = new Action("EXIT", _("Close puzzle"));
+ act->setCustomEngineActionEvent(kActionTattooFoolscapExit);
+ act->addDefaultInputMapping("ESCAPE");
+ act->addDefaultInputMapping("JOY_Y");
+ tattooFoolscapKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) cursor refers to the text cursor in the foolscap puzzle input field
+ act = new Action("UP", _("Move cursor up"));
+ act->setCustomEngineActionEvent(kActionTattooFoolscapUp);
+ act->addDefaultInputMapping("UP");
+ act->addDefaultInputMapping("KP8");
+ act->addDefaultInputMapping("JOY_UP");
+ tattooFoolscapKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) cursor refers to the text cursor in the foolscap puzzle input field
+ act = new Action("DOWN", _("Move cursor down"));
+ act->setCustomEngineActionEvent(kActionTattooFoolscapDown);
+ act->addDefaultInputMapping("DOWN");
+ act->addDefaultInputMapping("KP2");
+ act->addDefaultInputMapping("JOY_DOWN");
+ tattooFoolscapKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) cursor refers to the text cursor in the foolscap puzzle input field
+ act = new Action("LEFT", _("Move cursor left"));
+ act->setCustomEngineActionEvent(kActionTattooFoolscapLeft);
+ act->addDefaultInputMapping("LEFT");
+ act->addDefaultInputMapping("KP4");
+ act->addDefaultInputMapping("JOY_LEFT");
+ tattooFoolscapKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) cursor refers to the text cursor in the foolscap puzzle input field
+ act = new Action("RIGHT", _("Move cursor right"));
+ act->setCustomEngineActionEvent(kActionTattooFoolscapRight);
+ act->addDefaultInputMapping("RIGHT");
+ act->addDefaultInputMapping("KP6");
+ act->addDefaultInputMapping("JOY_RIGHT");
+ tattooFoolscapKeymap->addAction(act);
+
+ //
+ // Inventory keymap
+ //
+
+ act = new Action("EXIT", _("Exit inventory / Close verb menu / Cancel item use action"));
+ act->setCustomEngineActionEvent(kActionTattooInvExit);
+ act->addDefaultInputMapping("ESCAPE");
+ act->addDefaultInputMapping("JOY_Y");
+ tattooInvKeymap->addAction(act);
+
+ //
+ // Options menu keymap
+ //
+
+ act = new Action("SELECT", _("Select / Interact"));
+ act->setCustomEngineActionEvent(kActionTattooOptionsSelect);
+ act->addDefaultInputMapping("RETURN");
+ act->addDefaultInputMapping("KP_ENTER");
+ act->addDefaultInputMapping("SPACE");
+ tattooOptionsKeymap->addAction(act);
+
+ //
+ // Password entry keymap
+ //
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) cursor refers to the text cursor in the password input field
+ act = new Action("LEFT", _("Move cursor left"));
+ act->setCustomEngineActionEvent(kActionTattooPasswordLeft);
+ act->addDefaultInputMapping("LEFT");
+ act->addDefaultInputMapping("KP4");
+ act->addDefaultInputMapping("JOY_LEFT");
+ tattooPasswordKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) cursor refers to the text cursor in the password input field
+ act = new Action("RIGHT", _("Move cursor right"));
+ act->setCustomEngineActionEvent(kActionTattooPasswordRight);
+ act->addDefaultInputMapping("RIGHT");
+ act->addDefaultInputMapping("KP6");
+ act->addDefaultInputMapping("JOY_RIGHT");
+ tattooPasswordKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) This action is used to go to the start of the password input field
+ act = new Action("GOSTART", _("Go to the line start"));
+ act->setCustomEngineActionEvent(kActionTattooPasswordStart);
+ act->addDefaultInputMapping("HOME");
+ act->addDefaultInputMapping("KP7");
+ tattooPasswordKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) This action is used to go to the end of the password input field
+ act = new Action("GOEND", _("Go to the line end"));
+ act->setCustomEngineActionEvent(kActionTattooPasswordEnd);
+ act->addDefaultInputMapping("END");
+ act->addDefaultInputMapping("KP1");
+ tattooPasswordKeymap->addAction(act);
+
+ // I18N: (Game name: The Lost Files of Sherlock Holmes: The Case of the Rose Tattoo) save password input field has 2 modes, insert and overwrite, this action toggles between them
+ act = new Action("INSERTMODE", _("Toggle insert mode"));
+ act->setCustomEngineActionEvent(kActionTattooPasswordToggleInsertMode);
+ act->addDefaultInputMapping("INSERT");
+ act->addDefaultInputMapping("JOY_UP");
+ tattooPasswordKeymap->addAction(act);
+
+ //
+ // Quit dialog keymap
+ //
+
+ act = new Action("NEXTOPTION", _("Select next option"));
+ act->setCustomEngineActionEvent(kActionTattooQuitDialogNextOption);
+ act->addDefaultInputMapping("TAB");
+ tattooQuitDialogKeymap->addAction(act);
+
+ act = new Action("YES", _("Yes"));
+ act->setCustomEngineActionEvent(kActionTattooQuitDialogYes);
+ act->addDefaultInputMapping("y");
+ act->addDefaultInputMapping("JOY_X");
+ tattooQuitDialogKeymap->addAction(act);
+
+ act = new Action("NO", _("No"));
+ act->setCustomEngineActionEvent(kActionTattooQuitDialogNo);
+ act->addDefaultInputMapping("n");
+ act->addDefaultInputMapping("ESCAPE");
+ act->addDefaultInputMapping("JOY_Y");
+ tattooQuitDialogKeymap->addAction(act);
+
+ //
+ // Talk keymap
+ //
+
+ act = new Action("NEXT", _("Go to next talk option"));
+ act->setCustomEngineActionEvent(kActionTattooTalkNext);
+ act->addDefaultInputMapping("TAB");
+ act->addDefaultInputMapping("JOY_DOWN");
+ tattooTalkKeymap->addAction(act);
+
+ act = new Action("PREVIOUS", _("Go to previous talk option"));
+ act->setCustomEngineActionEvent(kActionTattooTalkPrevious);
+ act->addDefaultInputMapping("S+TAB");
+ act->addDefaultInputMapping("JOY_UP");
+ tattooTalkKeymap->addAction(act);
+
+ keymaps.push_back(tattooExitKeymap);
+ keymaps.push_back(engineKeymap);
+ keymaps.push_back(tattooKeymap);
+ keymaps.push_back(tattooPrologKeymap);
+ keymaps.push_back(tattooJournalKeymap);
+ keymaps.push_back(tattooJournalSearchKeymap);
+ keymaps.push_back(tattooDartsKeymap);
+ keymaps.push_back(tattooMapKeymap);
+ keymaps.push_back(tattooScrollingKeymap);
+ keymaps.push_back(tattooFilesKeymap);
+ keymaps.push_back(tattooFilesNameKeymap);
+ keymaps.push_back(tattooFoolscapKeymap);
+ keymaps.push_back(tattooInvKeymap);
+ keymaps.push_back(tattooOptionsKeymap);
+ keymaps.push_back(tattooPasswordKeymap);
+ keymaps.push_back(tattooQuitDialogKeymap);
+ keymaps.push_back(tattooTalkKeymap);
+
+ tattooExitKeymap->setEnabled(false);
+ tattooPrologKeymap->setEnabled(false);
+ tattooJournalKeymap->setEnabled(false);
+ tattooJournalSearchKeymap->setEnabled(false);
+ tattooDartsKeymap->setEnabled(false);
+ tattooMapKeymap->setEnabled(false);
+ tattooScrollingKeymap->setEnabled(false);
+ tattooFilesKeymap->setEnabled(false);
+ tattooFilesNameKeymap->setEnabled(false);
+ tattooFoolscapKeymap->setEnabled(false);
+ tattooInvKeymap->setEnabled(false);
+ tattooOptionsKeymap->setEnabled(false);
+ tattooPasswordKeymap->setEnabled(false);
+ tattooQuitDialogKeymap->setEnabled(false);
+ tattooTalkKeymap->setEnabled(false);
+ }
+
+ return keymaps;
+}
+
#if PLUGIN_ENABLED_DYNAMIC(SHERLOCK)
REGISTER_PLUGIN_DYNAMIC(SHERLOCK, PLUGIN_TYPE_ENGINE, SherlockMetaEngine);
#else
diff --git a/engines/sherlock/saveload.cpp b/engines/sherlock/saveload.cpp
index e89c3f1a619..d581955991d 100644
--- a/engines/sherlock/saveload.cpp
+++ b/engines/sherlock/saveload.cpp
@@ -28,6 +28,8 @@
#include "graphics/scaler.h"
#include "graphics/thumbnail.h"
+#include "backends/keymapper/keymapper.h"
+
namespace Sherlock {
const char *const EMPTY_SAVEGAME_SLOT = "-EMPTY-";
@@ -211,6 +213,16 @@ void SaveManager::loadGame(int slot) {
s.setVersion(header._version);
synchronize(s);
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->disableAllGameKeymaps();
+ keymapper->getKeymap("sherlock-default")->setEnabled(true);
+ if (IS_SERRATED_SCALPEL) {
+ keymapper->getKeymap("scalpel")->setEnabled(true);
+ keymapper->getKeymap("scalpel-quit")->setEnabled(true);
+ } else if (IS_ROSE_TATTOO) {
+ keymapper->getKeymap("tattoo")->setEnabled(true);
+ }
+
delete saveFile;
events.clearEvents();
}
diff --git a/engines/sherlock/scalpel/scalpel.cpp b/engines/sherlock/scalpel/scalpel.cpp
index de22003ef89..17c706bab5b 100644
--- a/engines/sherlock/scalpel/scalpel.cpp
+++ b/engines/sherlock/scalpel/scalpel.cpp
@@ -35,6 +35,8 @@
#include "sherlock/animation.h"
#include "video/3do_decoder.h"
+#include "backends/keymapper/keymapper.h"
+
namespace Sherlock {
namespace Scalpel {
@@ -643,7 +645,7 @@ bool ScalpelEngine::scrollCredits() {
_screen->_backBuffer1.SHblitFrom(*_screen);
// Loop for showing the credits
- for(int idx = 0; idx < 600 && !_events->kbHit() && !shouldQuit(); ++idx) {
+ for(int idx = 0; idx < 600 && !_events->kbHit() && !_events->actionHit() && !shouldQuit(); ++idx) {
// Copy the entire screen background before writing text
_screen->SHblitFrom(_screen->_backBuffer1);
@@ -1321,6 +1323,10 @@ bool ScalpelEngine::play3doMovie(const Common::Path &filename, const Common::Poi
if (halfSize)
tempSurface.create(width / 2, height / 2, videoDecoder->getPixelFormat());
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->disableAllGameKeymaps();
+ keymapper->getKeymap("scalpel-3d0-movie")->setEnabled(true);
+
while (!shouldQuit() && !videoDecoder->endOfVideo() && !skipVideo) {
if (videoDecoder->needsUpdate()) {
const Graphics::Surface *frame = videoDecoder->decodeNextFrame();
@@ -1405,15 +1411,20 @@ bool ScalpelEngine::play3doMovie(const Common::Path &filename, const Common::Poi
_events->pollEventsAndWait();
_events->setButtonState();
- if (_events->kbHit()) {
- Common::KeyState keyState = _events->getKey();
- if (keyState.keycode == Common::KEYCODE_ESCAPE)
+ if (_events->actionHit()) {
+ Common::CustomEventType action = _events->getAction();
+ if (action == kActionScalpelSkipMovie)
skipVideo = true;
} else if (_events->_pressed) {
skipVideo = true;
}
}
+ keymapper->getKeymap("scalpel-3d0-movie")->setEnabled(false);
+ keymapper->getKeymap("sherlock-default")->setEnabled(true);
+ keymapper->getKeymap("scalpel-quit")->setEnabled(true);
+ keymapper->getKeymap("scalpel")->setEnabled(true);
+
if (halfSize)
tempSurface.free();
diff --git a/engines/sherlock/scalpel/scalpel_darts.cpp b/engines/sherlock/scalpel/scalpel_darts.cpp
index 1df4ea19ae9..626960b1b32 100644
--- a/engines/sherlock/scalpel/scalpel_darts.cpp
+++ b/engines/sherlock/scalpel/scalpel_darts.cpp
@@ -22,6 +22,8 @@
#include "sherlock/scalpel/scalpel_darts.h"
#include "sherlock/scalpel/scalpel.h"
+#include "backends/keymapper/keymapper.h"
+
namespace Sherlock {
namespace Scalpel {
@@ -76,6 +78,11 @@ void Darts::playDarts() {
loadDarts();
initDarts();
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->getKeymap("scalpel")->setEnabled(false);
+ keymapper->getKeymap("scalpel-quit")->setEnabled(false);
+ keymapper->getKeymap("scalpel-darts")->setEnabled(true);
+
bool done = false;
do {
int score, roundStartScore;
@@ -145,7 +152,7 @@ void Darts::playDarts() {
while (!(dartKey = dartHit()) && !_vm->shouldQuit())
events.delay(10);
- if (dartKey == Common::KEYCODE_ESCAPE) {
+ if (dartKey == kActionScalpelDartsExit) {
idx = 10;
done = true;
}
@@ -174,6 +181,10 @@ void Darts::playDarts() {
closeDarts();
screen.fadeToBlack();
+ keymapper->getKeymap("scalpel-darts")->setEnabled(false);
+ keymapper->getKeymap("scalpel")->setEnabled(true);
+ keymapper->getKeymap("scalpel-quit")->setEnabled(true);
+
// Restore font
screen.setFont(oldFont);
}
@@ -420,6 +431,12 @@ int Darts::dartHit() {
// Process pending events
events.pollEvents();
+ if (events.actionHit()) {
+ // Action was pressed, so return it
+ Common::CustomEventType action = events.getAction();
+ return action;
+ }
+
if (events.kbHit()) {
// Key was pressed, so return it
Common::KeyState keyState = events.getKey();
diff --git a/engines/sherlock/scalpel/scalpel_fixed_text.cpp b/engines/sherlock/scalpel/scalpel_fixed_text.cpp
index 9eb7be78eaf..800793ddc34 100644
--- a/engines/sherlock/scalpel/scalpel_fixed_text.cpp
+++ b/engines/sherlock/scalpel/scalpel_fixed_text.cpp
@@ -519,13 +519,13 @@ static const char *const fixedTextZH[] = {
// SH1: Settings
"E\xc2\xf7\xb6\x7d(E)", /* "é¢é"; "EExit" */
"M\xad\xb5\xbc\xd6\xb6\x7d(M)", /* "M鳿¨é"; "MMusic on" */
- "M\xad\xb5\xbc\xd6\xc3\xf6(M)", /* "M鳿¨é"; "MMusic off" */
+ "M\xad\xb5\xbc\xd6\xc3\xf6(M)", /* "M鳿¨é"; "MMusic off" */
"P\xa8\x76\xb9\xb3\xb6\x7d(P)", /* "Pèåé"; "PPortrait on" */
"P\xa8\x76\xb9\xb3\xc3\xf6(P)", /* "Pèåé"; "PPortrait off" */
"JJoystick off", // Not used in Chinese as this button is skipped
"NNew Font Style", // Not used in Chinese as only one font is available
"S\xad\xb5\xae\xc4\xb6\x7d(S)", /* "S鳿é"; "SSound Effects on" */
- "S\xad\xb5\xae\xc4\xc3\xf6(S)", /* "S鳿é"; "SSound Effects off" */
+ "S\xad\xb5\xae\xc4\xc3\xf6(S)", /* "S鳿é"; "SSound Effects off" */
"W\xb5\xf8\xb5\xa1\xb7\xc6\xb1\xb2(W)", /* "Wè¦çªæ»æ²"; "WWindow Slide Scroll" */
"W\xb5\xf8\xb5\xa1\xa8\x71\xa5\x58(W)", /* "Wè¦çªç§åº"; "WWindow Show" */
"C\xbd\xd5\xbe\xe3\xb7\x6e\xb1\xec(C)", /* "èª¿æ´ææ¡¿"; "CCalibrate Joystick" */
@@ -534,7 +534,7 @@ static const char *const fixedTextZH[] = {
"VVoices on", // Not used in Chinese as no voices are available
"VVoices off", // Not used in Chinese as no voices are available
"F\xb2\x48\xa5\x58\xc2\x49\xaa\xac(F)", /* "Fæ·¡åºé»ç"; "FFade by Pixel" */
- "F\xb2\x48\xa5\x58\xaa\xbd\xb1\xb5(F)", /* "Fæ·¡åºç´æ¥"; "FFade Directly" */
+ "F\xb2\x48\xa5\x58\xaa\xbd\xb1\xb5(F)", /* "Fæ·¡åºç´æ¥"; "FFade Directly" */
"K\xc1\xe4\xaa\xa9\xba\x43(K)", /* "Kéµçæ
¢"; "KKey Pad Slow" */
"K\xc1\xe4\xaa\xa9\xa7\xd6(K)", /* "Kéµçå¿«"; "KKey Pad Fast" */
// Load/Save
@@ -845,7 +845,7 @@ static const FixedTextActionEntry fixedTextZH_Actions[] = {
// =========================================
-static const FixedTextLanguageEntry fixedTextLanguages[] = {
+const FixedTextLanguageEntry fixedTextLanguages[] = {
{ Common::DE_DEU, fixedTextDE, fixedTextDE_Actions },
{ Common::ES_ESP, fixedTextES, fixedTextES_Actions },
{ Common::EN_ANY, fixedTextEN, fixedTextEN_Actions },
diff --git a/engines/sherlock/scalpel/scalpel_fixed_text.h b/engines/sherlock/scalpel/scalpel_fixed_text.h
index 1290f4d4bac..e71cefcdaa8 100644
--- a/engines/sherlock/scalpel/scalpel_fixed_text.h
+++ b/engines/sherlock/scalpel/scalpel_fixed_text.h
@@ -206,6 +206,8 @@ public:
const Common::String getActionMessage(FixedTextActionId actionId, int messageIndex) override;
};
+extern const FixedTextLanguageEntry fixedTextLanguages[];
+
} // End of namespace Scalpel
} // End of namespace Sherlock
diff --git a/engines/sherlock/scalpel/scalpel_inventory.cpp b/engines/sherlock/scalpel/scalpel_inventory.cpp
index bc3d78e8abb..953b6786d06 100644
--- a/engines/sherlock/scalpel/scalpel_inventory.cpp
+++ b/engines/sherlock/scalpel/scalpel_inventory.cpp
@@ -37,28 +37,23 @@ ScalpelInventory::ScalpelInventory(SherlockEngine *vm) : Inventory(vm) {
_fixedTextUse = FIXED(Inventory_Use);
_fixedTextGive = FIXED(Inventory_Give);
- _hotkeyExit = toupper(_fixedTextExit[0]);
- _hotkeyLook = toupper(_fixedTextLook[0]);
- _hotkeyUse = toupper(_fixedTextUse[0]);
- _hotkeyGive = toupper(_fixedTextGive[0]);
-
- _hotkeysIndexed[0] = _hotkeyExit;
- _hotkeysIndexed[1] = _hotkeyLook;
- _hotkeysIndexed[2] = _hotkeyUse;
- _hotkeysIndexed[3] = _hotkeyGive;
- _hotkeysIndexed[4] = '-';
- _hotkeysIndexed[5] = '+';
- _hotkeysIndexed[6] = ',';
- _hotkeysIndexed[7] = '.';
+ _actionsIndexed[0] = kActionScalpelInvExit;
+ _actionsIndexed[1] = kActionScalpelInvLook;
+ _actionsIndexed[2] = kActionScalpelInvUse;
+ _actionsIndexed[3] = kActionScalpelInvGive;
+ _actionsIndexed[4] = kActionScalpelInvLeft;
+ _actionsIndexed[5] = kActionScalpelInvRight;
+ _actionsIndexed[6] = kActionScalpelInvPageLeft;
+ _actionsIndexed[7] = kActionScalpelInvPageRight;
}
ScalpelInventory::~ScalpelInventory() {
}
-int ScalpelInventory::identifyUserButton(int key) {
- for (uint16 hotkeyNr = 0; hotkeyNr < sizeof(_hotkeysIndexed); hotkeyNr++) {
- if (key == _hotkeysIndexed[hotkeyNr])
- return hotkeyNr;
+int ScalpelInventory::identifyUserButton(Common::CustomEventType action) {
+ for (uint16 actionNr = 0; actionNr < ARRAYSIZE(_actionsIndexed); actionNr++) {
+ if (action == _actionsIndexed[actionNr])
+ return actionNr;
}
return -1;
}
@@ -108,10 +103,10 @@ void ScalpelInventory::drawInventory(InvNewMode mode) {
_invMode = (InvMode)((int)mode);
if (mode != PLAIN_INVENTORY) {
- assert((uint)mode < sizeof(_hotkeysIndexed));
- ui._oldKey = _hotkeysIndexed[mode];
+ assert((uint)mode < ARRAYSIZE(_actionsIndexed));
+ ui._oldAction = _actionsIndexed[mode];
} else {
- ui._oldKey = -1;
+ ui._oldAction = -1;
}
invCommands(0);
diff --git a/engines/sherlock/scalpel/scalpel_inventory.h b/engines/sherlock/scalpel/scalpel_inventory.h
index f1b95039abc..70e74490816 100644
--- a/engines/sherlock/scalpel/scalpel_inventory.h
+++ b/engines/sherlock/scalpel/scalpel_inventory.h
@@ -24,6 +24,8 @@
#include "sherlock/inventory.h"
+#include "common/events.h"
+
namespace Sherlock {
namespace Scalpel {
@@ -38,12 +40,7 @@ public:
Common::String _fixedTextUse;
Common::String _fixedTextGive;
- byte _hotkeyExit;
- byte _hotkeyLook;
- byte _hotkeyUse;
- byte _hotkeyGive;
-
- byte _hotkeysIndexed[8];
+ Common::CustomEventType _actionsIndexed[8];
/**
* Put the game into inventory mode and open the interface window.
@@ -78,9 +75,9 @@ public:
void loadInv() override;
/**
- * Identifies a button number according to the key, that the user pressed
+ * Identifies a button number according to the action, that the user pressed
*/
- int identifyUserButton(int key);
+ int identifyUserButton(Common::CustomEventType action);
};
} // End of namespace Scalpel
diff --git a/engines/sherlock/scalpel/scalpel_journal.cpp b/engines/sherlock/scalpel/scalpel_journal.cpp
index df26c088645..9a8fbfd8018 100644
--- a/engines/sherlock/scalpel/scalpel_journal.cpp
+++ b/engines/sherlock/scalpel/scalpel_journal.cpp
@@ -28,6 +28,8 @@
#include "sherlock/tattoo/tattoo_journal.h"
#include "graphics/palette.h"
+#include "backends/keymapper/keymapper.h"
+
namespace Sherlock {
namespace Scalpel {
@@ -96,16 +98,6 @@ ScalpelJournal::ScalpelJournal(SherlockEngine *vm) : Journal(vm) {
_fixedTextLastPage = FIXED(Journal_LastPage);
_fixedTextPrintText = FIXED(Journal_PrintText);
- _hotkeyExit = toupper(_fixedTextExit[0]);
- _hotkeyBack10 = toupper(_fixedTextBack10[0]);
- _hotkeyUp = toupper(_fixedTextUp[0]);
- _hotkeyDown = toupper(_fixedTextDown[0]);
- _hotkeyAhead10 = toupper(_fixedTextAhead10[0]);
- _hotkeySearch = toupper(_fixedTextSearch[0]);
- _hotkeyFirstPage = toupper(_fixedTextFirstPage[0]);
- _hotkeyLastPage = toupper(_fixedTextLastPage[0]);
- _hotkeyPrintText = toupper(_fixedTextPrintText[0]);
-
_fixedTextSearchExit = FIXED(JournalSearch_Exit);
_fixedTextSearchBackward = FIXED(JournalSearch_Backward);
_fixedTextSearchForward = FIXED(JournalSearch_Forward);
@@ -343,7 +335,7 @@ JournalButton ScalpelJournal::getHighlightedButton(const Common::Point &pt) {
return BTN_NONE;
}
-bool ScalpelJournal::handleEvents(int key) {
+bool ScalpelJournal::handleEvents(Common::CustomEventType action) {
Events &events = *_vm->_events;
ScalpelScreen &screen = *(ScalpelScreen *)_vm->_screen;
bool doneFlag = false;
@@ -425,7 +417,7 @@ bool ScalpelJournal::handleEvents(int key) {
// Exit button pressed
doneFlag = true;
- } else if (((btn == BTN_BACK10 && events._released) || key == _hotkeyBack10) && (_page > 1)) {
+ } else if (((btn == BTN_BACK10 && events._released) || action == kActionScalpelJournalBack10) && (_page > 1)) {
// Scrolll up 10 pages
if (_page < 11)
drawJournal(1, (_page - 1) * LINES_PER_PAGE);
@@ -435,19 +427,19 @@ bool ScalpelJournal::handleEvents(int key) {
doArrows();
screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
- } else if (((btn == BTN_UP && events._released) || key == _hotkeyUp) && _up) {
+ } else if (((btn == BTN_UP && events._released) || action == kActionScalpelScrollUp) && _up) {
// Scroll up
drawJournal(1, LINES_PER_PAGE);
doArrows();
screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
- } else if (((btn == BTN_DOWN && events._released) || key == _hotkeyDown) && _down) {
+ } else if (((btn == BTN_DOWN && events._released) || action == kActionScalpelScrollDown) && _down) {
// Scroll down
drawJournal(2, LINES_PER_PAGE);
doArrows();
screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
- } else if (((btn == BTN_AHEAD110 && events._released) || key == _hotkeyAhead10) && _down) {
+ } else if (((btn == BTN_AHEAD110 && events._released) || action == kActionScalpelJournalAhead10) && _down) {
// Scroll down 10 pages
if ((_page + 10) > _maxPage)
drawJournal(2, (_maxPage - _page) * LINES_PER_PAGE);
@@ -457,10 +449,13 @@ bool ScalpelJournal::handleEvents(int key) {
doArrows();
screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
- } else if (((btn == BTN_SEARCH && events._released) || key == _hotkeySearch) && !_journal.empty()) {
+ } else if (((btn == BTN_SEARCH && events._released) || action == kActionScalpelJournalSearch) && !_journal.empty()) {
screen.buttonPrint(getButtonTextPoint(BTN_SEARCH), COMMAND_FOREGROUND, true, _fixedTextSearch);
bool notFound = false;
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->disableAllGameKeymaps();
+
do {
int dir;
if ((dir = getSearchString(notFound)) != 0) {
@@ -488,7 +483,11 @@ bool ScalpelJournal::handleEvents(int key) {
} while (!doneFlag);
doneFlag = false;
- } else if (((btn == BTN_FIRST_PAGE && events._released) || key == _hotkeyFirstPage) && _up) {
+ keymapper->getKeymap("scalpel-journal")->setEnabled(true);
+ keymapper->getKeymap("scalpel-scroll")->setEnabled(true);
+ keymapper->getKeymap("scalpel-quit")->setEnabled(true);
+
+ } else if (((btn == BTN_FIRST_PAGE && events._released) || action == kActionScalpelJournalFirstPage) && _up) {
// First page
_index = _sub = 0;
_up = _down = false;
@@ -499,7 +498,7 @@ bool ScalpelJournal::handleEvents(int key) {
doArrows();
screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
- } else if (((btn == BTN_LAST_PAGE && events._released) || key == _hotkeyLastPage) && _down) {
+ } else if (((btn == BTN_LAST_PAGE && events._released) || action == kActionScalpelJournalLastPage) && _down) {
// Last page
if ((_page + 10) > _maxPage)
drawJournal(2, (_maxPage - _page) * LINES_PER_PAGE);
@@ -566,6 +565,7 @@ int ScalpelJournal::getSearchString(bool printError) {
}
events.clearKeyboard();
+ events.clearActions();
screen._backBuffer1.fillRect(Common::Rect(13, 186, 306, 195), BUTTON_MIDDLE);
if (!_find.empty()) {
diff --git a/engines/sherlock/scalpel/scalpel_journal.h b/engines/sherlock/scalpel/scalpel_journal.h
index 294fda8e0e9..93af4403923 100644
--- a/engines/sherlock/scalpel/scalpel_journal.h
+++ b/engines/sherlock/scalpel/scalpel_journal.h
@@ -26,6 +26,7 @@
#include "sherlock/saveload.h"
#include "common/scummsys.h"
#include "common/array.h"
+#include "common/events.h"
#include "common/rect.h"
#include "common/str-array.h"
#include "common/stream.h"
@@ -52,16 +53,6 @@ public:
Common::String _fixedTextLastPage;
Common::String _fixedTextPrintText;
- byte _hotkeyExit;
- byte _hotkeyBack10;
- byte _hotkeyUp;
- byte _hotkeyDown;
- byte _hotkeyAhead10;
- byte _hotkeySearch;
- byte _hotkeyFirstPage;
- byte _hotkeyLastPage;
- byte _hotkeyPrintText;
-
Common::String _fixedTextSearchExit;
Common::String _fixedTextSearchBackward;
Common::String _fixedTextSearchForward;
@@ -106,7 +97,7 @@ public:
/**
* Handle events whilst the journal is being displayed
*/
- bool handleEvents(int key);
+ bool handleEvents(Common::CustomEventType action);
public:
/**
* Draw the journal background, frame, and interface buttons
diff --git a/engines/sherlock/scalpel/scalpel_map.cpp b/engines/sherlock/scalpel/scalpel_map.cpp
index 5871b4c7fbc..6b5a5e0b863 100644
--- a/engines/sherlock/scalpel/scalpel_map.cpp
+++ b/engines/sherlock/scalpel/scalpel_map.cpp
@@ -26,6 +26,8 @@
#include "sherlock/screen.h"
#include "sherlock/sherlock.h"
+#include "backends/keymapper/keymapper.h"
+
namespace Sherlock {
namespace Scalpel {
@@ -185,6 +187,10 @@ int ScalpelMap::show() {
saveTopLine();
_placesShown = true;
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->disableAllGameKeymaps();
+ keymapper->getKeymap("scalpel-map")->setEnabled(true);
+
// Keep looping until either a location is picked, or the game is ended
while (!_vm->shouldQuit() && !exitFlag) {
events.pollEventsAndWait();
@@ -195,12 +201,12 @@ int ScalpelMap::show() {
screen.slamArea(screen._currentScroll.x, screen._currentScroll.y, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_WIDTH);
}
- // Keyboard handling
- if (events.kbHit()) {
- Common::KeyState keyState = events.getKey();
+ // Action handling
+ if (events.actionHit()) {
+ Common::CustomEventType action = events.getAction();
- if (keyState.keycode == Common::KEYCODE_RETURN || keyState.keycode == Common::KEYCODE_SPACE) {
- // Both space and enter simulate a mouse release
+ if (action == kActionScalpelMapSelect) {
+ // this action simulates a mouse release
events._pressed = false;
events._released = true;
events._oldButtons = 0;
@@ -297,6 +303,11 @@ int ScalpelMap::show() {
events.wait(1);
}
+ keymapper->getKeymap("scalpel-map")->setEnabled(false);
+ keymapper->getKeymap("sherlock-default")->setEnabled(true);
+ keymapper->getKeymap("scalpel")->setEnabled(true);
+ keymapper->getKeymap("scalpel-quit")->setEnabled(true);
+
freeSprites();
_overPos = people[HOLMES]._position;
diff --git a/engines/sherlock/scalpel/scalpel_saveload.cpp b/engines/sherlock/scalpel/scalpel_saveload.cpp
index ca07bbfd3df..e0892b07b28 100644
--- a/engines/sherlock/scalpel/scalpel_saveload.cpp
+++ b/engines/sherlock/scalpel/scalpel_saveload.cpp
@@ -24,6 +24,8 @@
#include "sherlock/scalpel/scalpel_screen.h"
#include "sherlock/scalpel/scalpel.h"
+#include "backends/keymapper/keymapper.h"
+
namespace Sherlock {
namespace Scalpel {
@@ -49,32 +51,31 @@ ScalpelSaveManager::ScalpelSaveManager(SherlockEngine *vm, const Common::String
_fixedTextDown = FIXED(LoadSave_Down);
_fixedTextQuit = FIXED(LoadSave_Quit);
- _hotkeyExit = toupper(_fixedTextExit[0]);
- _hotkeyLoad = toupper(_fixedTextLoad[0]);
- _hotkeySave = toupper(_fixedTextSave[0]);
- _hotkeyUp = toupper(_fixedTextUp[0]);
- _hotkeyDown = toupper(_fixedTextDown[0]);
- _hotkeyQuit = toupper(_fixedTextQuit[0]);
-
- _hotkeysIndexed[0] = _hotkeyExit;
- _hotkeysIndexed[1] = _hotkeyLoad;
- _hotkeysIndexed[2] = _hotkeySave;
- _hotkeysIndexed[3] = _hotkeyUp;
- _hotkeysIndexed[4] = _hotkeyDown;
- _hotkeysIndexed[5] = _hotkeyQuit;
+ _actionsIndexed[0] = kActionScalpelFilesExit;
+ _actionsIndexed[1] = kActionScalpelFilesLoad;
+ _actionsIndexed[2] = kActionScalpelFilesSave;
+ _actionsIndexed[3] = kActionScalpelScrollUp;
+ _actionsIndexed[4] = kActionScalpelScrollDown;
+ _actionsIndexed[5] = kActionScalpelFilesQuit;
+ _actionsIndexed[6] = kActionScalpelFiles1;
+ _actionsIndexed[7] = kActionScalpelFiles2;
+ _actionsIndexed[8] = kActionScalpelFiles3;
+ _actionsIndexed[9] = kActionScalpelFiles4;
+ _actionsIndexed[10] = kActionScalpelFiles5;
+ _actionsIndexed[11] = kActionScalpelFiles6;
+ _actionsIndexed[12] = kActionScalpelFiles7;
+ _actionsIndexed[13] = kActionScalpelFiles8;
+ _actionsIndexed[14] = kActionScalpelFiles9;
_fixedTextQuitGameQuestion = FIXED(QuitGame_Question);
_fixedTextQuitGameYes = FIXED(QuitGame_Yes);
_fixedTextQuitGameNo = FIXED(QuitGame_No);
-
- _hotkeyQuitGameYes = toupper(_fixedTextQuitGameYes[0]);
- _hotkeyQuitGameNo = toupper(_fixedTextQuitGameNo[0]);
}
-int ScalpelSaveManager::identifyUserButton(int key) {
- for (uint16 hotkeyNr = 0; hotkeyNr < sizeof(_hotkeysIndexed); hotkeyNr++) {
- if (key == _hotkeysIndexed[hotkeyNr])
- return hotkeyNr;
+int ScalpelSaveManager::identifyUserButton(Common::CustomEventType action) {
+ for (uint16 actionNr = 0; actionNr < ARRAYSIZE(_actionsIndexed); actionNr++) {
+ if (action == _actionsIndexed[actionNr])
+ return actionNr;
}
return -1;
}
@@ -231,6 +232,9 @@ bool ScalpelSaveManager::promptForDescription(int slot) {
yp = CONTROLS_Y + 12 + (slot - _savegameIndex) * 10;
int done = 0;
+
+ Common::Keymapper *keymapper = _vm->getEventManager()->getKeymapper();
+ keymapper->disableAllGameKeymaps();
do {
while (!_vm->shouldQuit() && !events.kbHit()) {
scene.doBgAnim();
@@ -281,13 +285,19 @@ bool ScalpelSaveManager::promptForDescription(int slot) {
}
} while (!done);
+ keymapper->getKeymap("sherlock-default")->setEnabled(true);
+ keymapper->getKeymap("scalpel-quit")->setEnabled(true);
+
if (done == 1) {
// Enter key perssed
_savegames[slot] = saveName;
+ keymapper->getKeymap("scalpel")->setEnabled(true);
} else {
done = 0;
_envMode = SAVEMODE_NONE;
highlightButtons(-1);
+ keymapper->getKeymap("scalpel-files")->setEnabled(true);
+ keymapper->getKeymap("scalpel-scroll")->setEnabled(true);
}
return done == 1;
diff --git a/engines/sherlock/scalpel/scalpel_saveload.h b/engines/sherlock/scalpel/scalpel_saveload.h
index d34dde4a526..66833c7c7b2 100644
--- a/engines/sherlock/scalpel/scalpel_saveload.h
+++ b/engines/sherlock/scalpel/scalpel_saveload.h
@@ -24,6 +24,8 @@
#include "sherlock/saveload.h"
+#include "common/events.h"
+
namespace Sherlock {
namespace Scalpel {
@@ -41,22 +43,12 @@ public:
Common::String _fixedTextDown;
Common::String _fixedTextQuit;
- byte _hotkeyExit;
- byte _hotkeyLoad;
- byte _hotkeySave;
- byte _hotkeyUp;
- byte _hotkeyDown;
- byte _hotkeyQuit;
-
- byte _hotkeysIndexed[6];
+ Common::CustomEventType _actionsIndexed[15];
Common::String _fixedTextQuitGameQuestion;
Common::String _fixedTextQuitGameYes;
Common::String _fixedTextQuitGameNo;
- byte _hotkeyQuitGameYes;
- byte _hotkeyQuitGameNo;
-
public:
ScalpelSaveManager(SherlockEngine *vm, const Common::String &target);
~ScalpelSaveManager() override {}
@@ -87,9 +79,9 @@ public:
bool promptForDescription(int slot);
/**
- * Identifies a button number according to the key, that the user pressed
+ * Identifies a button number according to the action, that the user pressed
*/
- int identifyUserButton(int key);
+ int identifyUserButton(Common::CustomEventType action);
};
} // End of namespace Scalpel
diff --git a/engines/sherlock/scalpel/scalpel_talk.cpp b/engines/sherlock/scalpel/scalpel_talk.cpp
index 0d68f06f923..1911aee6112 100644
--- a/engines/sherlock/scalpel/scalpel_talk.cpp
+++ b/engines/sherlock/scalpel/scalpel_talk.cpp
@@ -171,10 +171,6 @@ ScalpelTalk::ScalpelTalk(SherlockEngine *vm) : Talk(vm) {
_fixedTextWindowExit = FIXED(Window_Exit);
_fixedTextWindowUp = FIXED(Window_Up);
_fixedTextWindowDown = FIXED(Window_Down);
-
- _hotkeyWindowExit = toupper(_fixedTextWindowExit[0]);
- _hotkeyWindowUp = toupper(_fixedTextWindowUp[0]);
- _hotkeyWindowDown = toupper(_fixedTextWindowDown[0]);
}
void ScalpelTalk::talkTo(const Common::String &filename) {
diff --git a/engines/sherlock/scalpel/scalpel_talk.h b/engines/sherlock/scalpel/scalpel_talk.h
index add106c198a..886b795a3c2 100644
--- a/engines/sherlock/scalpel/scalpel_talk.h
+++ b/engines/sherlock/scalpel/scalpel_talk.h
@@ -91,10 +91,6 @@ public:
Common::String _fixedTextWindowUp;
Common::String _fixedTextWindowDown;
- byte _hotkeyWindowExit;
- byte _hotkeyWindowUp;
- byte _hotkeyWindowDown;
-
/**
* Opens the talk file 'talk.tlk' and searches the index for the specified
* conversation. If found, the data for that conversation is loaded
diff --git a/engines/sherlock/scalpel/scalpel_user_interface.cpp b/engines/sherlock/scalpel/scalpel_user_interface.cpp
index 62734421a01..31cd856d824 100644
--- a/engines/sherlock/scalpel/scalpel_user_interface.cpp
+++ b/engines/sherlock/scalpel/scalpel_user_interface.cpp
@@ -33,6 +33,8 @@
#include "common/config-manager.h"
#include "common/text-to-speech.h"
+#include "backends/keymapper/keymapper.h"
+
namespace Sherlock {
namespace Scalpel {
@@ -138,53 +140,34 @@ ScalpelUserInterface::ScalpelUserInterface(SherlockEngine *vm): UserInterface(vm
}
_keyPress = '\0';
+ _actionPress = kActionNone;
_lookHelp = 0;
_help = _oldHelp = 0;
- _key = _oldKey = '\0';
+ _key = '\0';
+ _action = _oldAction = kActionNone;
_temp = _oldTemp = 0;
_oldLook = 0;
_keyboardInput = false;
+ _actionInput = false;
_pause = false;
_cNum = 0;
_find = 0;
_oldUse = 0;
- // Set up hotkeys
- Common::String gameHotkeys = FIXED(Game_Hotkeys);
-
- memset(_hotkeysIndexed, 0, sizeof(_hotkeysIndexed));
- assert(gameHotkeys.size() <= sizeof(_hotkeysIndexed));
- memcpy(_hotkeysIndexed, gameHotkeys.c_str(), gameHotkeys.size());
-
- _hotkeyLook = gameHotkeys[0];
- _hotkeyMove = gameHotkeys[1];
- _hotkeyTalk = gameHotkeys[2];
- _hotkeyPickUp = gameHotkeys[3];
- _hotkeyOpen = gameHotkeys[4];
- _hotkeyClose = gameHotkeys[5];
- _hotkeyInventory = gameHotkeys[6];
- _hotkeyUse = gameHotkeys[7];
- _hotkeyGive = gameHotkeys[8];
- _hotkeyJournal = gameHotkeys[9];
- _hotkeyFiles = gameHotkeys[10];
- _hotkeySetUp = gameHotkeys[11];
- _hotkeyLoadGame = 0;
- _hotkeySaveGame = 0;
-
- if (IS_3DO) {
- // 3DO doesn't have a Journal nor a Files button
- // Instead it has the setup button in place of the journal
- // and also "Load" and "Save" buttons underneath it.
- _hotkeyJournal = 0;
- _hotkeyFiles = 0;
- _hotkeyLoadGame = 'A'; // "S" already used for SetUp
- _hotkeySaveGame = 'V'; // ditto
-
- _hotkeysIndexed[MAINBUTTON_JOURNAL] = 0;
- _hotkeysIndexed[MAINBUTTON_FILES] = 0;
- _hotkeysIndexed[MAINBUTTON_LOADGAME] = 'A';
- _hotkeysIndexed[MAINBUTTON_SAVEGAME] = 'V';
- }
+ _actionsIndexed[0] = kActionScalpelLook;
+ _actionsIndexed[1] = kActionScalpelMove;
+ _actionsIndexed[2] = kActionScalpelTalk;
+ _actionsIndexed[3] = kActionScalpelPickUp;
+ _actionsIndexed[4] = kActionScalpelOpen;
+ _actionsIndexed[5] = kActionScalpelClose;
+ _actionsIndexed[6] = kActionScalpelInventory;
+ _actionsIndexed[7] = kActionScalpelUse;
+ _actionsIndexed[8] = kActionScalpelGive;
+ _actionsIndexed[9] = kActionScalpelJournal;
+ _actionsIndexed[10] = kActionScalpelFiles;
+ _actionsIndexed[11] = kActionScalpelSetup;
+ _actionsIndexed[12] = kActionScalpelLoad;
+ _actionsIndexed[13] = kActionScalpelSave;
}
ScalpelUserInterface::~ScalpelUserInterface() {
@@ -235,6 +218,7 @@ void ScalpelUserInterface::handleInput() {
Scene &scene = *_vm->_scene;
Screen &screen = *_vm->_screen;
Talk &talk = *_vm->_talk;
+ Common::Keymapper *keymapper = _vm->getEventManager()->getKeymapper();
if (_menuCounter)
whileMenuCounter();
@@ -242,20 +226,27 @@ void ScalpelUserInterface::handleInput() {
Common::Point pt = events.mousePos();
_bgFound = scene.findBgShape(pt);
_keyPress = '\0';
+ _actionPress = kActionNone;
// Check kbd and set the mouse released flag if Enter or space is pressed.
// Otherwise, the pressed _key is stored for later use
- if (events.kbHit()) {
- Common::KeyState keyState = events.getKey();
- _keyPress = keyState.ascii;
- if (keyState.keycode == Common::KEYCODE_x && keyState.flags & Common::KBD_ALT) {
+ if (events.actionHit()) {
+ Common::CustomEventType action = events.getAction();
+ _actionPress = action;
+
+ if (action == kActionScalpelQuit) {
_vm->quitGame();
events.pollEvents();
return;
}
}
+ if (events.kbHit()) {
+ Common::KeyState keyState = events.getKey();
+ _keyPress = keyState.ascii;
+ }
+
// Do button highlighting check
if (!talk._scriptMoreFlag) { // Don't if scripts are running
if (((events._rightPressed || events._rightReleased) && _helpStyle) ||
@@ -332,7 +323,7 @@ void ScalpelUserInterface::handleInput() {
restoreButton(idx);
_menuMode = STD_MODE;
- _key = _oldKey = -1;
+ _action = _oldAction = kActionNone;
_temp = _oldTemp = _lookHelp = _invLookFlag = 0;
events.clearEvents();
}
@@ -377,8 +368,13 @@ void ScalpelUserInterface::handleInput() {
personFound = _bgFound != -1 && scene._bgShapes[_bgFound]._aType == PERSON;
}
- if (events._released && personFound)
+ if (events._released && personFound) {
+ keymapper->getKeymap("scalpel")->setEnabled(false);
+ keymapper->getKeymap("scalpel-quit")->setEnabled(false);
+ keymapper->getKeymap("scalpel-talk")->setEnabled(true);
+ keymapper->getKeymap("scalpel-scroll")->setEnabled(true);
talk.initTalk(_bgFound);
+ }
else if (personFound)
lookScreen(pt);
else if (_bgFound < 1000)
@@ -404,7 +400,7 @@ void ScalpelUserInterface::handleInput() {
//
// Do input processing
//
- if (events._pressed || events._released || events._rightPressed || _keyPress || _pause) {
+ if (events._pressed || events._released || events._rightPressed || _keyPress || _actionPress || _pause) {
if (((events._released && (_helpStyle || _help == -1)) || (events._rightReleased && !_helpStyle)) &&
(pt.y <= CONTROLS_Y) && (_menuMode == STD_MODE)) {
// The mouse was clicked in the playing area with no action buttons down.
@@ -420,9 +416,9 @@ void ScalpelUserInterface::handleInput() {
people[HOLMES].goAllTheWay();
}
- if (_oldKey != -1) {
+ if (_oldAction != kActionNone) {
restoreButton(_oldTemp);
- _oldKey = -1;
+ _oldAction = kActionNone;
}
}
@@ -471,12 +467,12 @@ void ScalpelUserInterface::handleInput() {
// As long as there isn't an open window, do main input processing.
// Windows are opened when in TALK, USE, INV, and GIVE modes
if ((!_windowOpen && !_menuCounter && pt.y > CONTROLS_Y) ||
- _keyPress) {
- if (events._pressed || events._released || _pause || _keyPress)
+ _keyPress || _actionPress) {
+ if (events._pressed || events._released || _pause || _keyPress || _actionPress)
doMainControl();
}
- if (pt.y < CONTROLS_Y && events._pressed && _oldTemp != (int)(_menuMode - 1) && _oldKey != -1)
+ if (pt.y < CONTROLS_Y && events._pressed && _oldTemp != (int)(_menuMode - 1) && _oldAction != kActionNone)
restoreButton(_oldTemp);
}
}
@@ -513,7 +509,7 @@ void ScalpelUserInterface::restoreButton(int num) {
void ScalpelUserInterface::pushButton(int num) {
Events &events = *_vm->_events;
- _oldKey = -1;
+ _oldAction = kActionNone;
if (!events._released) {
if (_oldHelp != -1)
@@ -533,17 +529,17 @@ void ScalpelUserInterface::toggleButton(uint16 num) {
if (_menuMode != (MenuMode)(num + 1)) {
_menuMode = (MenuMode)(num + 1);
- assert(num < sizeof(_hotkeysIndexed));
- _oldKey = _hotkeysIndexed[num];
+ assert(num < ARRAYSIZE(_actionsIndexed));
+ _oldAction = _actionsIndexed[num];
_oldTemp = num;
- if (_keyboardInput) {
+ if (_actionInput) {
if (_oldHelp != -1 && _oldHelp != num)
restoreButton(_oldHelp);
if (_help != -1 && _help != num)
restoreButton(_help);
- _keyboardInput = false;
+ _actionInput = false;
ImageFrame &frame = (*_controls)[num];
Common::Point pt = getTopLeftButtonPoint(num);
@@ -552,7 +548,7 @@ void ScalpelUserInterface::toggleButton(uint16 num) {
}
} else {
_menuMode = STD_MODE;
- _oldKey = -1;
+ _oldAction = kActionNone;
restoreButton(num);
}
}
@@ -798,12 +794,13 @@ void ScalpelUserInterface::doEnvControl() {
byte color;
- _key = _oldKey = -1;
- _keyboardInput = false;
+ _action = _oldAction = kActionNone;
+ _actionInput = false;
int found = saves.getHighlightedButton();
if (events._pressed || events._released) {
events.clearKeyboard();
+ events.clearActions();
// Check for a filename entry being highlighted
if ((events._pressed || events._released) && mousePos.y > (CONTROLS_Y + 10)) {
@@ -828,31 +825,29 @@ void ScalpelUserInterface::doEnvControl() {
saves._envMode = SAVEMODE_NONE;
}
- if (_keyPress) {
- _key = toupper(_keyPress);
+ if (_actionPress) {
+ _action = _actionPress;
- // Escape _key will close the dialog
- if (_key == Common::KEYCODE_ESCAPE)
- _key = saves._hotkeyExit;
+ int buttonIndex = saves.identifyUserButton(_action);
- int buttonIndex = saves.identifyUserButton(_key);
+ if ((buttonIndex >= 0)) {
+ if (buttonIndex < 6) {
+ saves.highlightButtons(buttonIndex);
+ _actionInput = true;
- if ((buttonIndex >= 0) || (_key >= '1' && _key <= '9')) {
- saves.highlightButtons(buttonIndex);
- _keyboardInput = true;
-
- if (_key == saves._hotkeyExit || _key == saves._hotkeyQuit) {
- saves._envMode = SAVEMODE_NONE;
- } else if (_key >= '1' && _key <= '9') {
- _keyboardInput = true;
- _selector = _key - '1';
+ if (_action == kActionScalpelFilesExit || _action == kActionScalpelFilesQuit) {
+ saves._envMode = SAVEMODE_NONE;
+ } else {
+ _selector = -1;
+ }
+ } else {
+ _actionInput = true;
+ _selector = buttonIndex - 6;
if (_selector >= MAX_SAVEGAME_SLOTS + (saves._envMode == SAVEMODE_LOAD ? 0 : 1))
_selector = -1;
if (saves.checkGameOnScreen(_selector))
_oldSelector = _selector;
- } else {
- _selector = -1;
}
}
}
@@ -875,19 +870,25 @@ void ScalpelUserInterface::doEnvControl() {
_oldSelector = _selector;
}
- if (events._released || _keyboardInput) {
- if ((found == 0 && events._released) || _key == saves._hotkeyExit) {
+ if (events._released || _actionPress) {
+ Common::Keymapper *keymapper = _vm->getEventManager()->getKeymapper();
+
+ if ((found == 0 && events._released) || _action == kActionScalpelFilesExit) {
banishWindow();
_windowBounds.top = CONTROLS_Y1;
- events._pressed = events._released = _keyboardInput = false;
- _keyPress = '\0';
- } else if ((found == 1 && events._released) || _key == saves._hotkeyLoad) {
+ events._pressed = events._released = _actionInput = false;
+ _actionPress = kActionNone;
+
+ keymapper->getKeymap("scalpel-files")->setEnabled(false);
+ keymapper->getKeymap("scalpel-scroll")->setEnabled(false);
+ keymapper->getKeymap("scalpel")->setEnabled(true);
+ } else if ((found == 1 && events._released) || _action == kActionScalpelFilesLoad) {
saves._envMode = SAVEMODE_LOAD;
if (_selector != -1) {
saves.loadGame(_selector);
}
- } else if ((found == 2 && events._released) || _key == saves._hotkeySave) {
+ } else if ((found == 2 && events._released) || _action == kActionScalpelFilesSave) {
saves._envMode = SAVEMODE_SAVE;
if (_selector != -1) {
if (saves.checkGameOnScreen(_selector))
@@ -898,9 +899,9 @@ void ScalpelUserInterface::doEnvControl() {
banishWindow();
_windowBounds.top = CONTROLS_Y1;
- _key = _oldKey = -1;
- _keyPress = '\0';
- _keyboardInput = false;
+ _action = _oldAction = kActionNone;
+ _actionPress = kActionNone;
+ _actionInput = false;
} else {
if (!talk._talkToAbort) {
screen._backBuffer1.fillRect(Common::Rect(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10,
@@ -915,8 +916,8 @@ void ScalpelUserInterface::doEnvControl() {
}
}
}
- } else if (((found == 3 && events._released) || _key == saves._hotkeyUp) && saves._savegameIndex) {
- bool moreKeys;
+ } else if (((found == 3 && events._released) || _action == kActionScalpelScrollUp) && saves._savegameIndex) {
+ bool moreActions;
do {
saves._savegameIndex--;
screen._backBuffer1.fillRect(Common::Rect(3, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2,
@@ -938,17 +939,16 @@ void ScalpelUserInterface::doEnvControl() {
color = (saves._savegameIndex == MAX_SAVEGAME_SLOTS - ONSCREEN_FILES_COUNT) ? COMMAND_NULL : COMMAND_FOREGROUND;
screen.buttonPrint(Common::Point(ENV_POINTS[4][2], CONTROLS_Y), color, true, saves._fixedTextDown);
- // Check whether there are more pending U keys pressed
- moreKeys = false;
- if (events.kbHit()) {
- Common::KeyState keyState = events.getKey();
+ // Check whether there are more pending Up actions
+ moreActions = false;
+ if (events.actionHit()) {
+ _action = events.getAction();
- _key = toupper(keyState.keycode);
- moreKeys = _key == saves._hotkeyUp;
+ moreActions = _action == kActionScalpelScrollUp;
}
- } while ((saves._savegameIndex) && moreKeys);
- } else if (((found == 4 && events._released) || _key == saves._hotkeyDown) && saves._savegameIndex < (MAX_SAVEGAME_SLOTS - ONSCREEN_FILES_COUNT)) {
- bool moreKeys;
+ } while ((saves._savegameIndex) && moreActions);
+ } else if (((found == 4 && events._released) || _action == kActionScalpelScrollDown) && saves._savegameIndex < (MAX_SAVEGAME_SLOTS - ONSCREEN_FILES_COUNT)) {
+ bool moreActions;
do {
saves._savegameIndex++;
screen._backBuffer1.fillRect(Common::Rect(3, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2,
@@ -974,16 +974,15 @@ void ScalpelUserInterface::doEnvControl() {
color = (saves._savegameIndex == MAX_SAVEGAME_SLOTS - ONSCREEN_FILES_COUNT) ? COMMAND_NULL : COMMAND_FOREGROUND;
screen.buttonPrint(Common::Point(ENV_POINTS[4][2], CONTROLS_Y), color, true, saves._fixedTextDown);
- // Check whether there are more pending D keys pressed
- moreKeys = false;
- if (events.kbHit()) {
- Common::KeyState keyState = events.getKey();
- _key = toupper(keyState.keycode);
+ // Check whether there are more pending Down actions
+ moreActions = false;
+ if (events.actionHit()) {
+ _action = events.getAction();
- moreKeys = _key == saves._hotkeyDown;
+ moreActions = _action == kActionScalpelScrollDown;
}
- } while (saves._savegameIndex < (MAX_SAVEGAME_SLOTS - ONSCREEN_FILES_COUNT) && moreKeys);
- } else if ((found == 5 && events._released) || _key == saves._hotkeyQuit) {
+ } while (saves._savegameIndex < (MAX_SAVEGAME_SLOTS - ONSCREEN_FILES_COUNT) && moreActions);
+ } else if ((found == 5 && events._released) || _action == kActionScalpelFilesQuit) {
clearWindow();
screen.print(Common::Point(0, CONTROLS_Y + 20), INV_FOREGROUND, "%s", saves._fixedTextQuitGameQuestion.c_str());
screen.vgaBar(Common::Rect(0, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH, CONTROLS_Y + 10), BORDER_COLOR);
@@ -992,6 +991,10 @@ void ScalpelUserInterface::doEnvControl() {
screen.makeButton(Common::Rect(161, CONTROLS_Y, 209, CONTROLS_Y + 10), 184, saves._fixedTextQuitGameNo);
screen.slamArea(112, CONTROLS_Y, 97, 10);
+ keymapper->getKeymap("scalpel-files")->setEnabled(false);
+ keymapper->getKeymap("scalpel-scroll")->setEnabled(false);
+ keymapper->getKeymap("scalpel-quit-dialog")->setEnabled(true);
+
do {
scene.doBgAnim();
@@ -1002,24 +1005,20 @@ void ScalpelUserInterface::doEnvControl() {
events.setButtonState();
mousePos = events.mousePos();
- if (events.kbHit()) {
- Common::KeyState keyState = events.getKey();
- _key = toupper(keyState.keycode);
+ if (events.actionHit()) {
+ _action = events.getAction();
- if (_key == 'X' && (keyState.flags & Common::KBD_ALT) != 0) {
+ if (_action == kActionScalpelQuit) {
_vm->quitGame();
events.pollEvents();
return;
}
- if (_key == Common::KEYCODE_ESCAPE)
- _key = saves._hotkeyQuitGameNo;
-
- if (_key == Common::KEYCODE_RETURN || _key == ' ') {
+ if (_action == kActionScalpelQuitDialogSelect) {
events._pressed = false;
events._released = true;
events._oldButtons = 0;
- _keyPress = '\0';
+ _actionPress = kActionNone;
}
}
@@ -1038,13 +1037,13 @@ void ScalpelUserInterface::doEnvControl() {
}
if (mousePos.x > 112 && mousePos.x < 159 && mousePos.y > CONTROLS_Y && mousePos.y < (CONTROLS_Y + 9) && events._released)
- _key = saves._hotkeyQuitGameYes;
+ _action = kActionScalpelQuitDialogYes;
if (mousePos.x > 161 && mousePos.x < 208 && mousePos.y > CONTROLS_Y && mousePos.y < (CONTROLS_Y + 9) && events._released)
- _key = saves._hotkeyQuitGameNo;
- } while (!_vm->shouldQuit() && _key != saves._hotkeyQuitGameYes && _key != saves._hotkeyQuitGameNo);
+ _action = kActionScalpelQuitDialogNo;
+ } while (!_vm->shouldQuit() && _action != kActionScalpelQuitDialogYes && _action != kActionScalpelQuitDialogNo);
- if (_key == saves._hotkeyQuitGameYes) {
+ if (_action == kActionScalpelQuitDialogYes) {
_vm->quitGame();
events.pollEvents();
return;
@@ -1052,7 +1051,9 @@ void ScalpelUserInterface::doEnvControl() {
screen.buttonPrint(Common::Point(184, CONTROLS_Y), COMMAND_HIGHLIGHTED, true, saves._fixedTextQuitGameNo);
banishWindow();
_windowBounds.top = CONTROLS_Y1;
- _key = -1;
+ _action = kActionNone;
+ keymapper->getKeymap("scalpel-quit-dialog")->setEnabled(false);
+ keymapper->getKeymap("scalpel")->setEnabled(true);
}
} else {
if (_selector != -1) {
@@ -1068,9 +1069,9 @@ void ScalpelUserInterface::doEnvControl() {
saves.saveGame(_selector, saves._savegames[_selector]);
banishWindow();
_windowBounds.top = CONTROLS_Y1;
- _key = _oldKey = -1;
- _keyPress = '\0';
- _keyboardInput = false;
+ _action = _oldAction = kActionNone;
+ _actionPress = kActionNone;
+ _actionInput = false;
} else {
if (!talk._talkToAbort) {
screen._backBuffer1.fillRect(Common::Rect(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10,
@@ -1098,8 +1099,8 @@ void ScalpelUserInterface::doInvControl() {
int colors[8];
Common::Point mousePos = events.mousePos();
- _key = _oldKey = -1;
- _keyboardInput = false;
+ _action = _oldAction = kActionNone;
+ _actionInput = false;
// Check whether any inventory slot is highlighted
int found = -1;
@@ -1115,6 +1116,7 @@ void ScalpelUserInterface::doInvControl() {
if (events._pressed || events._released) {
events.clearKeyboard();
+ events.clearActions();
if (found != -1)
// If a slot highlighted, set its color
@@ -1153,14 +1155,10 @@ void ScalpelUserInterface::doInvControl() {
_selector = -1;
}
- if (_keyPress) {
- _key = toupper(_keyPress);
-
- if (_key == Common::KEYCODE_ESCAPE)
- // Escape will also 'E'xit out of inventory display
- _key = inv._hotkeyExit;
+ if (_actionPress) {
+ _action = _actionPress;
- int buttonIndex = inv.identifyUserButton(_key);
+ int buttonIndex = inv.identifyUserButton(_action);
if ((buttonIndex >= 0) && (buttonIndex <= 5)) {
InvMode temp = inv._invMode;
@@ -1169,8 +1167,8 @@ void ScalpelUserInterface::doInvControl() {
inv.invCommands(true);
inv._invMode = temp;
- _keyboardInput = true;
- if (_key == inv._hotkeyExit)
+ _actionInput = true;
+ if (_action == kActionScalpelInvExit)
inv._invMode = INVMODE_EXIT;
_selector = -1;
} else {
@@ -1191,22 +1189,26 @@ void ScalpelUserInterface::doInvControl() {
_oldSelector = _selector;
}
- if (events._released || _keyboardInput) {
- if ((found == 0 && events._released) || _key == inv._hotkeyExit) {
+ if (events._released || _actionInput) {
+ Common::Keymapper *keymapper = _vm->getEventManager()->getKeymapper();
+
+ if ((found == 0 && events._released) || _action == kActionScalpelInvExit) {
inv.freeInv();
_infoFlag = true;
clearInfo();
banishWindow(false);
- _key = -1;
+ _action = kActionNone;
events.clearEvents();
events.setCursor(ARROW);
- } else if ((found == 1 && events._released) || (_key == inv._hotkeyLook)) {
+ keymapper->getKeymap("scalpel-inv")->setEnabled(false);
+ keymapper->getKeymap("scalpel")->setEnabled(true);
+ } else if ((found == 1 && events._released) || (_action == kActionScalpelInvLook)) {
inv._invMode = INVMODE_LOOK;
- } else if ((found == 2 && events._released) || (_key == inv._hotkeyUse)) {
+ } else if ((found == 2 && events._released) || (_action == kActionScalpelInvUse)) {
inv._invMode = INVMODE_USE;
- } else if ((found == 3 && events._released) || (_key == inv._hotkeyGive)) {
+ } else if ((found == 3 && events._released) || (_action == kActionScalpelInvGive)) {
inv._invMode = INVMODE_GIVE;
- } else if (((found == 4 && events._released) || _key == ',') && inv._invIndex) {
+ } else if (((found == 4 && events._released) || _action == kActionScalpelInvPageLeft) && inv._invIndex) {
if (inv._invIndex >= 6)
inv._invIndex -= 6;
else
@@ -1218,21 +1220,21 @@ void ScalpelUserInterface::doInvControl() {
inv.loadGraphics();
inv.putInv(SLAM_DISPLAY);
inv.invCommands(true);
- } else if (((found == 5 && events._released) || _key == '-') && inv._invIndex > 0) {
+ } else if (((found == 5 && events._released) || _action == kActionScalpelInvLeft) && inv._invIndex > 0) {
--inv._invIndex;
screen.print(Common::Point(INVENTORY_POINTS[4][2], CONTROLS_Y1 + 1), COMMAND_HIGHLIGHTED, "^");
inv.freeGraphics();
inv.loadGraphics();
inv.putInv(SLAM_DISPLAY);
inv.invCommands(true);
- } else if (((found == 6 && events._released) || _key == '+') && (inv._holdings - inv._invIndex) > 6) {
+ } else if (((found == 6 && events._released) || _action == kActionScalpelInvRight) && (inv._holdings - inv._invIndex) > 6) {
++inv._invIndex;
screen.print(Common::Point(INVENTORY_POINTS[6][2], CONTROLS_Y1 + 1), COMMAND_HIGHLIGHTED, "_");
inv.freeGraphics();
inv.loadGraphics();
inv.putInv(SLAM_DISPLAY);
inv.invCommands(true);
- } else if (((found == 7 && events._released) || _key == '.') && (inv._holdings - inv._invIndex) > 6) {
+ } else if (((found == 7 && events._released) || _action == kActionScalpelInvPageRight) && (inv._holdings - inv._invIndex) > 6) {
inv._invIndex += 6;
if ((inv._holdings - 6) < inv._invIndex)
inv._invIndex = inv._holdings - 6;
@@ -1293,10 +1295,13 @@ void ScalpelUserInterface::doInvControl() {
_infoFlag = true;
clearInfo();
banishWindow(false);
- _key = -1;
+ _action = kActionNone;
inv.freeInv();
+ keymapper->getKeymap("scalpel-inv")->setEnabled(false);
+ keymapper->getKeymap("scalpel")->setEnabled(true);
+
bool giveFl = (tempMode >= INVMODE_GIVE);
if (_selector >= 0)
// Use/Give inv object with scene object
@@ -1317,10 +1322,12 @@ void ScalpelUserInterface::doLookControl() {
ScalpelInventory &inv = *(ScalpelInventory *)_vm->_inventory;
Screen &screen = *_vm->_screen;
- _key = _oldKey = -1;
+ _key = -1;
_keyboardInput = (_keyPress != '\0');
+ _action = _oldAction = kActionNone;
+ _actionInput = (_actionPress != kActionNone);
- if (events._released || events._rightReleased || _keyboardInput) {
+ if (events._released || events._rightReleased || _actionInput || _keyboardInput) {
// Is there any remaining text to display?
if (!_descStr.empty()) {
printObjectDesc(_descStr, false);
@@ -1334,7 +1341,7 @@ void ScalpelUserInterface::doLookControl() {
banishWindow();
_windowBounds.top = CONTROLS_Y1;
- _key = _oldKey = _hotkeyLook;
+ _action = _oldAction = kActionScalpelLook;
_temp = _oldTemp = 0;
_menuMode = LOOK_MODE;
events.clearEvents();
@@ -1345,7 +1352,7 @@ void ScalpelUserInterface::doLookControl() {
events.setCursor(ARROW);
banishWindow();
_windowBounds.top = CONTROLS_Y1;
- _key = _oldKey = -1;
+ _action = _oldAction = kActionNone;
_temp = _oldTemp = 0;
_menuMode = STD_MODE;
events.clearEvents();
@@ -1364,7 +1371,7 @@ void ScalpelUserInterface::doLookControl() {
screen._backBuffer2.SHblitFrom(tempSurface, Common::Point(0, CONTROLS_Y1));
_windowBounds.top = CONTROLS_Y1;
- _key = _oldKey = _hotkeyLook;
+ _action = _oldAction = kActionScalpelLook;
_temp = _oldTemp = 0;
events.clearEvents();
_invLookFlag = false;
@@ -1384,7 +1391,8 @@ void ScalpelUserInterface::doMainControl() {
if ((events._pressed || events._released) && pt.y > CONTROLS_Y) {
events.clearKeyboard();
- _key = -1;
+ events.clearActions();
+ _action = kActionNone;
_temp = 12; // no button currently selected
// Check whether the mouse is in any of the command areas
@@ -1409,27 +1417,28 @@ void ScalpelUserInterface::doMainControl() {
break;
}
}
- // Get hotkey, that's assigned to it
- assert(buttonNr < sizeof(_hotkeysIndexed));
- _key = _hotkeysIndexed[buttonNr];
+ // Get action, that's assigned to it
+ assert(buttonNr < ARRAYSIZE(_actionsIndexed));
+ _action = _actionsIndexed[buttonNr];
break;
}
}
- } else if (_keyPress) {
+ } else if (_actionPress || _keyPress) {
// Keyboard control
- _keyboardInput = true;
+ _actionInput = true;
_temp = 12; // no button currently selected
- byte key = toupper(_keyPress);
+ Common::CustomEventType action = _actionPress;
- for (uint16 buttonId = 0; buttonId < sizeof(_hotkeysIndexed); buttonId++) {
- if (key == _hotkeysIndexed[buttonId]) {
+ for (uint16 buttonId = 0; buttonId < ARRAYSIZE(_actionsIndexed); buttonId++) {
+ if (action == _actionsIndexed[buttonId]) {
pressedButtonId = buttonId;
+ break;
}
}
if (pressedButtonId >= 0) {
_temp = pressedButtonId;
- _key = key;
+ _action = action;
if (IS_3DO) {
// Fix up button number for 3DO
switch (pressedButtonId) {
@@ -1447,40 +1456,41 @@ void ScalpelUserInterface::doMainControl() {
}
}
} else {
- _key = -1;
+ _action = kActionNone;
}
if (events._rightPressed) {
pressedButtonId = -1;
_temp = 12;
- _key = -1;
+ _action = kActionNone;
}
} else if (!events._released) {
- _key = -1;
+ _action = kActionNone;
}
// Check if the button being pointed to has changed
- if (_oldKey != _key && !_windowOpen) {
+ if (_oldAction != _action && !_windowOpen) {
// Clear the info line
_infoFlag = true;
clearInfo();
// If there was an old button selected, restore it
- if (_oldKey != -1) {
+ if (_oldAction != kActionNone) {
_menuMode = STD_MODE;
restoreButton(_oldTemp);
}
// If a new button is being pointed to, highlight it
- if (_key != -1 && _temp < 12 && !_keyboardInput)
+ if (_action != kActionNone && _temp < 12 && !_actionInput)
depressButton(_temp);
// Save the new button selection
- _oldKey = _key;
+ _oldAction = _action;
_oldTemp = _temp;
}
if (!events._pressed && !_windowOpen) {
+ Common::Keymapper *keymapper = _vm->getEventManager()->getKeymapper();
switch (pressedButtonId) {
case MAINBUTTON_LOOK:
toggleButton(0);
@@ -1501,18 +1511,24 @@ void ScalpelUserInterface::doMainControl() {
toggleButton(5);
break;
case MAINBUTTON_INVENTORY:
+ keymapper->getKeymap("scalpel")->setEnabled(false);
+ keymapper->getKeymap("scalpel-inv")->setEnabled(true);
pushButton(6);
_selector = _oldSelector = -1;
_menuMode = INV_MODE;
inv.drawInventory(LOOK_INVENTORY_MODE);
break;
case MAINBUTTON_USE:
+ keymapper->getKeymap("scalpel")->setEnabled(false);
+ keymapper->getKeymap("scalpel-inv")->setEnabled(true);
pushButton(7);
_selector = _oldSelector = -1;
_menuMode = USE_MODE;
inv.drawInventory(USE_INVENTORY_MODE);
break;
case MAINBUTTON_GIVE:
+ keymapper->getKeymap("scalpel")->setEnabled(false);
+ keymapper->getKeymap("scalpel-inv")->setEnabled(true);
pushButton(8);
_selector = _oldSelector = -1;
_menuMode = GIVE_MODE;
@@ -1540,6 +1556,10 @@ void ScalpelUserInterface::doMainControl() {
_menuMode = FILES_MODE;
saves.drawInterface();
_windowOpen = true;
+
+ keymapper->getKeymap("scalpel")->setEnabled(false);
+ keymapper->getKeymap("scalpel-files")->setEnabled(true);
+ keymapper->getKeymap("scalpel-scroll")->setEnabled(true);
} else {
// Show the ScummVM GMM instead
_vm->_canLoadSave = true;
@@ -1592,7 +1612,7 @@ void ScalpelUserInterface::doMiscControl(int allowed) {
if (_menuMode != TALK_MODE && !talk._talkToAbort) {
_menuMode = STD_MODE;
restoreButton(OPEN_MODE - 1);
- _key = _oldKey = -1;
+ _action = _oldAction = kActionNone;
}
break;
@@ -1601,7 +1621,7 @@ void ScalpelUserInterface::doMiscControl(int allowed) {
if (_menuMode != TALK_MODE && !talk._talkToAbort) {
_menuMode = STD_MODE;
restoreButton(CLOSE_MODE - 1);
- _key = _oldKey = -1;
+ _action = _oldAction = kActionNone;
}
break;
@@ -1610,7 +1630,7 @@ void ScalpelUserInterface::doMiscControl(int allowed) {
if (_menuMode != TALK_MODE && !talk._talkToAbort) {
_menuMode = STD_MODE;
restoreButton(MOVE_MODE - 1);
- _key = _oldKey = -1;
+ _action = _oldAction = kActionNone;
}
break;
@@ -1636,7 +1656,7 @@ void ScalpelUserInterface::doPickControl() {
scene._bgShapes[_bgFound].pickUpObject(kFixedTextAction_Pick);
if (!talk._talkToAbort && _menuMode != TALK_MODE) {
- _key = _oldKey = -1;
+ _action = _oldAction = kActionNone;
_menuMode = STD_MODE;
restoreButton(PICKUP_MODE - 1);
}
@@ -1653,12 +1673,16 @@ void ScalpelUserInterface::doTalkControl() {
Sound &sound = *_vm->_sound;
ScalpelTalk &talk = *(ScalpelTalk *)_vm->_talk;
Common::Point mousePos = events.mousePos();
+ Common::Keymapper *keymapper = _vm->getEventManager()->getKeymapper();
- _key = _oldKey = -1;
+ _key = -1;
_keyboardInput = false;
+ _action = _oldAction = kActionNone;
+ _actionInput = false;
if (events._pressed || events._released) {
events.clearKeyboard();
+ events.clearActions();
// Handle button printing
if (mousePos.x > 99 && mousePos.x < 138 && mousePos.y > CONTROLS_Y && mousePos.y < (CONTROLS_Y + 10) && !_endKeyActive)
@@ -1687,10 +1711,18 @@ void ScalpelUserInterface::doTalkControl() {
_selector = -1;
}
+ if (_actionPress) {
+ _action = _actionPress;
+
+ if (_action == kActionScalpelTalkExit || _action == kActionScalpelScrollUp || _action == kActionScalpelScrollDown) {
+ _actionInput = true;
+ } else {
+ _selector = -1;
+ }
+ }
+
if (_keyPress) {
_key = toupper(_keyPress);
- if (_key == Common::KEYCODE_ESCAPE)
- _key = talk._hotkeyWindowExit;
// Check for number press indicating reply line
if (_key >= '1' && _key <= ('1' + (int)talk._statements.size() - 1)) {
@@ -1703,10 +1735,6 @@ void ScalpelUserInterface::doTalkControl() {
break;
}
}
- } else if (_key == talk._hotkeyWindowExit || _key == talk._hotkeyWindowUp || _key == talk._hotkeyWindowDown) {
- _keyboardInput = true;
- } else {
- _selector = -1;
}
}
@@ -1729,17 +1757,20 @@ void ScalpelUserInterface::doTalkControl() {
_oldSelector = _selector;
}
- if (events._released || _keyboardInput) {
+ if (events._released || _keyboardInput || _actionInput) {
if (((Common::Rect(99, CONTROLS_Y, 138, CONTROLS_Y + 10).contains(mousePos) && events._released)
- || _key == talk._hotkeyWindowExit) && _endKeyActive) {
+ || _action == kActionScalpelTalkExit) && _endKeyActive) {
talk.freeTalkVars();
talk.pullSequence();
drawInterface(2);
banishWindow();
+ keymapper->getKeymap("scalpel-talk")->setEnabled(false);
+ keymapper->getKeymap("scalpel-scroll")->setEnabled(false);
+ keymapper->getKeymap("scalpel")->setEnabled(true);
_windowBounds.top = CONTROLS_Y1;
} else if (((Common::Rect(140, CONTROLS_Y, 179, CONTROLS_Y + 10).contains(mousePos) && events._released)
- || _key == talk._hotkeyWindowUp) && talk._moreTalkUp) {
+ || _action == kActionScalpelScrollUp) && talk._moreTalkUp) {
while (talk._statements[--talk._talkIndex]._talkMap == -1)
;
screen._backBuffer1.fillRect(Common::Rect(5, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2,
@@ -1748,7 +1779,7 @@ void ScalpelUserInterface::doTalkControl() {
screen.slamRect(Common::Rect(5, CONTROLS_Y, SHERLOCK_SCREEN_WIDTH - 5, SHERLOCK_SCREEN_HEIGHT - 2));
} else if (((Common::Rect(181, CONTROLS_Y, 220, CONTROLS_Y + 10).contains(mousePos) && events._released)
- || _key == talk._hotkeyWindowDown) && talk._moreTalkDown) {
+ || _action == kActionScalpelScrollDown) && talk._moreTalkDown) {
do {
++talk._talkIndex;
} while (talk._talkIndex < (int)talk._statements.size() && talk._statements[talk._talkIndex]._talkMap == -1);
@@ -1877,6 +1908,9 @@ void ScalpelUserInterface::doTalkControl() {
talk.pullSequence();
banishWindow();
_windowBounds.top = CONTROLS_Y1;
+ keymapper->getKeymap("scalpel-talk")->setEnabled(false);
+ keymapper->getKeymap("scalpel-scroll")->setEnabled(false);
+ keymapper->getKeymap("scalpel")->setEnabled(true);
break;
}
} else {
@@ -1906,39 +1940,50 @@ void ScalpelUserInterface::journalControl() {
Screen &screen = *_vm->_screen;
bool doneFlag = false;
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->getKeymap("sherlock-default")->setEnabled(false);
+ keymapper->getKeymap("scalpel")->setEnabled(false);
+ keymapper->getKeymap("scalpel-journal")->setEnabled(true);
+ keymapper->getKeymap("scalpel-scroll")->setEnabled(true);
+
// Draw the journal screen
journal.drawInterface();
// Handle journal events
do {
- _key = -1;
+ _action = kActionNone;
events.setButtonState();
- // Handle keypresses
- if (events.kbHit()) {
- Common::KeyState keyState = events.getKey();
- if (keyState.keycode == Common::KEYCODE_x && (keyState.flags & Common::KBD_ALT)) {
+ // Handle actions
+ if (events.actionHit()) {
+ Common::CustomEventType action = events.getAction();
+ if (action == kActionScalpelQuit) {
_vm->quitGame();
return;
- } else if (toupper(keyState.ascii) == journal._hotkeyExit || keyState.keycode == Common::KEYCODE_ESCAPE) {
+ } else if (action == kActionScalpelJournalExit) {
doneFlag = true;
} else {
- _key = toupper(keyState.keycode);
+ _action = action;
}
}
if (!doneFlag)
- doneFlag = journal.handleEvents(_key);
+ doneFlag = journal.handleEvents(_action);
} while (!_vm->shouldQuit() && !doneFlag);
// Finish up
- _infoFlag = _keyboardInput = false;
- _keyPress = '\0';
+ _infoFlag = _actionInput = false;
+ _actionPress = kActionNone;
_windowOpen = false;
_windowBounds.top = CONTROLS_Y1;
- _key = -1;
+ _action = kActionNone;
_menuMode = STD_MODE;
+ keymapper->getKeymap("scalpel-journal")->setEnabled(false);
+ keymapper->getKeymap("scalpel-scroll")->setEnabled(false);
+ keymapper->getKeymap("sherlock-default")->setEnabled(true);
+ keymapper->getKeymap("scalpel")->setEnabled(true);
+
// Reset the palette
screen.setPalette(screen._cMap);
@@ -1985,7 +2030,7 @@ void ScalpelUserInterface::printObjectDesc(const Common::String &str, bool first
banishWindow();
events.setCursor(MAGNIFY);
_windowBounds.top = CONTROLS_Y1;
- _key = _oldKey = _hotkeyLook;
+ _action = _oldAction = kActionScalpelLook;
_temp = _oldTemp = 0;
_menuMode = LOOK_MODE;
events.clearEvents();
@@ -1995,7 +2040,7 @@ void ScalpelUserInterface::printObjectDesc(const Common::String &str, bool first
events.setCursor(ARROW);
banishWindow();
_windowBounds.top = CONTROLS_Y1;
- _key = _oldKey = -1;
+ _action = _oldAction = kActionNone;
_temp = _oldTemp = 0;
_menuMode = STD_MODE;
_lookHelp = 0;
@@ -2012,7 +2057,7 @@ void ScalpelUserInterface::printObjectDesc(const Common::String &str, bool first
banishWindow();
_windowBounds.top = CONTROLS_Y1;
- _key = _oldKey = _hotkeyInventory;
+ _action = _oldAction = kActionScalpelInventory;
_temp = _oldTemp = 0;
events.clearEvents();
diff --git a/engines/sherlock/scalpel/scalpel_user_interface.h b/engines/sherlock/scalpel/scalpel_user_interface.h
index 5b00f4bf9b3..7a8430aa2a1 100644
--- a/engines/sherlock/scalpel/scalpel_user_interface.h
+++ b/engines/sherlock/scalpel/scalpel_user_interface.h
@@ -25,6 +25,8 @@
#include "common/scummsys.h"
#include "sherlock/user_interface.h"
+#include "common/events.h"
+
namespace Sherlock {
class Inventory;
@@ -60,12 +62,15 @@ class ScalpelUserInterface: public UserInterface {
friend class Sherlock::Talk;
private:
char _keyPress;
+ Common::CustomEventType _actionPress;
int _lookHelp;
int _help, _oldHelp;
- int _key, _oldKey;
+ int _key;
+ Common::CustomEventType _action, _oldAction;
int _temp, _oldTemp; // button number (0-11)
int _oldLook;
bool _keyboardInput;
+ bool _actionInput;
bool _pause;
int _cNum;
Common::String _cAnimStr;
@@ -159,22 +164,7 @@ public:
ImageFile *_controls;
int _oldUse;
- byte _hotkeyLook;
- byte _hotkeyMove;
- byte _hotkeyTalk;
- byte _hotkeyPickUp;
- byte _hotkeyOpen;
- byte _hotkeyClose;
- byte _hotkeyInventory;
- byte _hotkeyUse;
- byte _hotkeyGive;
- byte _hotkeyJournal; // not used for 3DO
- byte _hotkeyFiles; // not used for 3DO
- byte _hotkeySetUp; // SetUp-button is in the spot of Journal for 3DO
- byte _hotkeyLoadGame; // 3DO
- byte _hotkeySaveGame; // 3DO
-
- byte _hotkeysIndexed[14];
+ Common::CustomEventType _actionsIndexed[14];
public:
ScalpelUserInterface(SherlockEngine *vm);
diff --git a/engines/sherlock/scalpel/settings.cpp b/engines/sherlock/scalpel/settings.cpp
index 665b384810c..b4c658531fe 100644
--- a/engines/sherlock/scalpel/settings.cpp
+++ b/engines/sherlock/scalpel/settings.cpp
@@ -26,6 +26,8 @@
#include "sherlock/scalpel/scalpel_fixed_text.h"
#include "sherlock/scalpel/scalpel.h"
+#include "backends/keymapper/keymapper.h"
+
namespace Sherlock {
namespace Scalpel {
@@ -123,7 +125,7 @@ void Settings::drawInterface(bool flag) {
}
tempStr = FIXED(Settings_Exit);
- _hotkeyExit = toupper(tempStr.firstChar());
+ _actionExit = kActionScalpelSettingsExit;
makeButtonNum(0, tempStr);
if (music._musicOn) {
@@ -131,7 +133,7 @@ void Settings::drawInterface(bool flag) {
} else {
tempStr = FIXED(Settings_MusicOff);
}
- _hotkeyMusic = toupper(tempStr.firstChar());
+ _actionMusic = kActionScalpelSettingsToggleMusic;
makeButtonNum(1, tempStr);
if (people._portraitsOn) {
@@ -139,7 +141,7 @@ void Settings::drawInterface(bool flag) {
} else {
tempStr = FIXED(Settings_PortraitsOff);
}
- _hotkeyPortraits = toupper(tempStr.firstChar());
+ _actionPortraits = kActionScalpelSettingsTogglePortraits;
makeButtonNum(10, tempStr);
// WORKAROUND: We don't support the joystick in ScummVM, so draw the next two buttons as disabled
@@ -147,7 +149,7 @@ void Settings::drawInterface(bool flag) {
makeButtonNumDisabled(6, tempStr);
tempStr = FIXED(Settings_NewFontStyle);
- _hotkeyNewFontStyle = toupper(tempStr.firstChar());
+ _actionNewFontStyle = kActionScalpelSettingsChangeFontStyle;
makeButtonNum(5, tempStr);
if (sound._digitized) {
@@ -155,7 +157,7 @@ void Settings::drawInterface(bool flag) {
} else {
tempStr = FIXED(Settings_SoundEffectsOff);
}
- _hotkeySoundEffects = toupper(tempStr.firstChar());
+ _actionSoundEffects = kActionScalpelSettingsToggleSoundEffects;
makeButtonNum(3, tempStr);
if (ui._slideWindows) {
@@ -163,7 +165,7 @@ void Settings::drawInterface(bool flag) {
} else {
tempStr = FIXED(Settings_WindowsAppear);
}
- _hotkeyWindows = toupper(tempStr.firstChar());
+ _actionWindows = kActionScalpelSettingsToggleWindowsMode;
makeButtonNum(9, tempStr);
tempStr = FIXED(Settings_CalibrateJoystick);
@@ -174,7 +176,7 @@ void Settings::drawInterface(bool flag) {
} else {
tempStr = FIXED(Settings_AutoHelpLeft);
}
- _hotkeyAutoHelp = toupper(tempStr.firstChar());
+ _actionAutoHelp = kActionScalpelSettingsChangeAutohelpLoc;
makeButtonNum(4, tempStr);
if (sound._voices) {
@@ -182,7 +184,7 @@ void Settings::drawInterface(bool flag) {
} else {
tempStr = FIXED(Settings_VoicesOff);
}
- _hotkeyVoices = toupper(tempStr.firstChar());
+ _actionVoices = kActionScalpelSettingsToggleVoices;
makeButtonNum(2, tempStr);
if (screen._fadeStyle) {
@@ -190,21 +192,30 @@ void Settings::drawInterface(bool flag) {
} else {
tempStr = FIXED(Settings_FadeDirectly);
}
- _hotkeyFade = toupper(tempStr.firstChar());
+ _actionFade = kActionScalpelSettingsChangeFadeMode;
makeButtonNum(8, tempStr);
+ if (screen._fadeStyle) {
+ // German version uses a different action for fade modes
+ if (_vm->getLanguage() == Common::Language::DE_DEU)
+ _actionFade = kActionScalpelSettingsFadeByPixels;
+ } else {
+ if (_vm->getLanguage() == Common::Language::DE_DEU)
+ _actionFade = kActionScalpelSettingsFadeDirectly;
+ }
+
tempStr = FIXED(Settings_KeyPadSlow);
makeButtonNumDisabled(11, tempStr);
- _hotkeysIndexed[0] = _hotkeyExit;
- _hotkeysIndexed[1] = _hotkeyMusic;
- _hotkeysIndexed[2] = _hotkeyVoices;
- _hotkeysIndexed[3] = _hotkeySoundEffects;
- _hotkeysIndexed[4] = _hotkeyAutoHelp;
- _hotkeysIndexed[5] = _hotkeyNewFontStyle;
- _hotkeysIndexed[8] = _hotkeyFade;
- _hotkeysIndexed[9] = _hotkeyWindows;
- _hotkeysIndexed[10] = _hotkeyPortraits;
+ _actionsIndexed[0] = _actionExit;
+ _actionsIndexed[1] = _actionMusic;
+ _actionsIndexed[2] = _actionVoices;
+ _actionsIndexed[3] = _actionSoundEffects;
+ _actionsIndexed[4] = _actionAutoHelp;
+ _actionsIndexed[5] = _actionNewFontStyle;
+ _actionsIndexed[8] = _actionFade;
+ _actionsIndexed[9] = _actionWindows;
+ _actionsIndexed[10] = _actionPortraits;
// Show the window immediately, or slide it on-screen
if (!flag) {
@@ -220,7 +231,7 @@ void Settings::drawInterface(bool flag) {
}
}
-int Settings::drawButtons(const Common::Point &pt, int _key) {
+int Settings::drawButtons(const Common::Point &pt, Common::CustomEventType action) {
Events &events = *_vm->_events;
People &people = *_vm->_people;
ScalpelScreen &screen = *(ScalpelScreen *)_vm->_screen;
@@ -235,7 +246,7 @@ int Settings::drawButtons(const Common::Point &pt, int _key) {
if (!doesButtonExist(idx))
continue;
if ((getButtonRect(idx).contains(pt) && (events._pressed || events._released))
- || (_key == toupper(_hotkeysIndexed[idx]))) {
+ || (action == _actionsIndexed[idx])) {
found = idx;
color = COMMAND_HIGHLIGHTED;
} else {
@@ -332,12 +343,16 @@ void Settings::show(SherlockEngine *vm) {
Settings settings(vm);
settings.drawInterface(false);
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->getKeymap("scalpel")->setEnabled(false);
+ keymapper->getKeymap("scalpel-settings")->setEnabled(true);
+
do {
if (ui._menuCounter)
ui.whileMenuCounter();
int found = -1;
- ui._key = -1;
+ ui._action = kActionNone;
scene.doBgAnim();
if (talk._talkToAbort)
@@ -346,31 +361,30 @@ void Settings::show(SherlockEngine *vm) {
events.setButtonState();
Common::Point pt = events.mousePos();
- if (events._pressed || events._released || events.kbHit()) {
+ if (events._pressed || events._released || events.actionHit()) {
ui.clearInfo();
- ui._key = -1;
+ ui._action = kActionNone;
- if (events.kbHit()) {
- Common::KeyState keyState = events.getKey();
- ui._key = toupper(keyState.ascii);
+ if (events.actionHit()) {
+ ui._action = events.getAction();
- if (ui._key == Common::KEYCODE_RETURN || ui._key == Common::KEYCODE_SPACE) {
+ if (ui._action == kActionScalpelSettingsSelect) {
events._pressed = false;
events._oldButtons = 0;
- ui._keyPress = '\0';
+ ui._actionPress = kActionNone;
events._released = true;
}
}
// Handle highlighting button under mouse
- found = settings.drawButtons(pt, ui._key);
+ found = settings.drawButtons(pt, ui._action);
}
- if ((found == 0 && events._released) || (ui._key == settings._hotkeyExit || ui._key == Common::KEYCODE_ESCAPE))
+ if ((found == 0 && events._released) || (ui._action == settings._actionExit))
// Exit
break;
- if ((found == 1 && events._released) || ui._key == settings._hotkeyMusic) {
+ if ((found == 1 && events._released) || ui._action == settings._actionMusic) {
// Toggle music
music._musicOn = !music._musicOn;
if (!music._musicOn)
@@ -382,27 +396,27 @@ void Settings::show(SherlockEngine *vm) {
settings.drawInterface(true);
}
- if ((found == 2 && events._released) || ui._key == settings._hotkeyVoices) {
+ if ((found == 2 && events._released) || ui._action == settings._actionVoices) {
sound._voices = !sound._voices;
updateConfig = true;
settings.drawInterface(true);
}
- if ((found == 3 && events._released) || ui._key == settings._hotkeySoundEffects) {
+ if ((found == 3 && events._released) || ui._action == settings._actionSoundEffects) {
// Toggle sound effects
sound._digitized = !sound._digitized;
updateConfig = true;
settings.drawInterface(true);
}
- if ((found == 4 && events._released) || ui._key == settings._hotkeyAutoHelp) {
+ if ((found == 4 && events._released) || ui._action == settings._actionAutoHelp) {
// Help button style
ui._helpStyle = !ui._helpStyle;
updateConfig = true;
settings.drawInterface(true);
}
- if ((found == 5 && events._released) || ui._key == settings._hotkeyNewFontStyle) {
+ if ((found == 5 && events._released) || ui._action == settings._actionNewFontStyle) {
// New font style
int fontNum = screen.fontNumber() + 1;
if (fontNum == 3)
@@ -413,21 +427,21 @@ void Settings::show(SherlockEngine *vm) {
settings.drawInterface(true);
}
- if ((found == 8 && events._released) || ui._key == settings._hotkeyFade) {
+ if ((found == 8 && events._released) || ui._action == settings._actionFade) {
// Toggle fade style
screen._fadeStyle = !screen._fadeStyle;
updateConfig = true;
settings.drawInterface(true);
}
- if ((found == 9 && events._released) || ui._key == settings._hotkeyWindows) {
+ if ((found == 9 && events._released) || ui._action == settings._actionWindows) {
// Window style
ui._slideWindows = !ui._slideWindows;
updateConfig = true;
settings.drawInterface(true);
}
- if ((found == 10 && events._released) || ui._key == settings._hotkeyPortraits) {
+ if ((found == 10 && events._released) || ui._action == settings._actionPortraits) {
// Toggle portraits being shown
people._portraitsOn = !people._portraitsOn;
updateConfig = true;
@@ -437,13 +451,16 @@ void Settings::show(SherlockEngine *vm) {
ui.banishWindow();
+ keymapper->getKeymap("scalpel-settings")->setEnabled(false);
+ keymapper->getKeymap("scalpel")->setEnabled(true);
+
if (updateConfig)
vm->saveConfig();
- ui._keyPress = '\0';
- ui._keyboardInput = false;
+ ui._actionPress = kActionNone;
+ ui._actionInput = false;
ui._windowBounds.top = CONTROLS_Y1;
- ui._key = -1;
+ ui._action = -1;
}
} // End of namespace Scalpel
diff --git a/engines/sherlock/scalpel/settings.h b/engines/sherlock/scalpel/settings.h
index 925f0c258f2..8c948517638 100644
--- a/engines/sherlock/scalpel/settings.h
+++ b/engines/sherlock/scalpel/settings.h
@@ -22,8 +22,11 @@
#ifndef SHERLOCK_SETTINGS_H
#define SHERLOCK_SETTINGS_H
+#include "common/events.h"
#include "common/scummsys.h"
+#include "sherlock/sherlock.h"
+
namespace Sherlock {
class SherlockEngine;
@@ -35,30 +38,30 @@ private:
SherlockEngine *_vm;
Settings(SherlockEngine *vm) : _vm(vm) {
- _hotkeyExit = 0;
- _hotkeyMusic = 0;
- _hotkeyPortraits = 0;
- _hotkeyNewFontStyle = 0;
- _hotkeySoundEffects = 0;
- _hotkeyWindows = 0;
- _hotkeyAutoHelp = 0;
- _hotkeyVoices = 0;
- _hotkeyFade = 0;
-
- memset(_hotkeysIndexed, 0, sizeof(_hotkeysIndexed));
+ _actionExit = kActionNone;
+ _actionMusic = kActionNone;
+ _actionPortraits = kActionNone;
+ _actionNewFontStyle = kActionNone;
+ _actionSoundEffects = kActionNone;
+ _actionWindows = kActionNone;
+ _actionAutoHelp = kActionNone;
+ _actionVoices = kActionNone;
+ _actionFade = kActionNone;
+
+ memset(_actionsIndexed, kActionNone, sizeof(_actionsIndexed));
}
- byte _hotkeyExit;
- byte _hotkeyMusic;
- byte _hotkeyPortraits;
- byte _hotkeyNewFontStyle;
- byte _hotkeySoundEffects;
- byte _hotkeyWindows;
- byte _hotkeyAutoHelp;
- byte _hotkeyVoices;
- byte _hotkeyFade;
+ Common::CustomEventType _actionExit;
+ Common::CustomEventType _actionMusic;
+ Common::CustomEventType _actionPortraits;
+ Common::CustomEventType _actionNewFontStyle;
+ Common::CustomEventType _actionSoundEffects;
+ Common::CustomEventType _actionWindows;
+ Common::CustomEventType _actionAutoHelp;
+ Common::CustomEventType _actionVoices;
+ Common::CustomEventType _actionFade;
- byte _hotkeysIndexed[12];
+ Common::CustomEventType _actionsIndexed[12];
/**
* Draws the interface for the settings window
@@ -68,7 +71,7 @@ private:
/**
* Draws the buttons for the settings dialog
*/
- int drawButtons(const Common::Point &pt, int key);
+ int drawButtons(const Common::Point &pt, Common::CustomEventType action);
Common::Rect getButtonRect(int num) const;
Common::Point getButtonTextPoint(int num) const;
diff --git a/engines/sherlock/scalpel/tsage/logo.cpp b/engines/sherlock/scalpel/tsage/logo.cpp
index f2a88a91313..b83a9816a87 100644
--- a/engines/sherlock/scalpel/tsage/logo.cpp
+++ b/engines/sherlock/scalpel/tsage/logo.cpp
@@ -403,9 +403,9 @@ bool Logo::show(ScalpelEngine *vm) {
events.setButtonState();
++logo->_frameCounter;
- interrupted = vm->shouldQuit() || events.kbHit() || events._pressed;
+ interrupted = vm->shouldQuit() || events.kbHit() || events._pressed || events.actionHit();
if (interrupted) {
- // Keyboard or mouse button pressed, so break out of logo display
+ // Keyboard, mouse, or action button pressed, so break out of logo display
events.clearEvents();
break;
}
diff --git a/engines/sherlock/sherlock.h b/engines/sherlock/sherlock.h
index b84aa1dcbdf..64b7b031c46 100644
--- a/engines/sherlock/sherlock.h
+++ b/engines/sherlock/sherlock.h
@@ -60,6 +60,136 @@ enum {
kDebugLevelMusic,
};
+enum SHERLOCKActions {
+ kActionNone,
+ kActionSkipAnim,
+ // Scalpel specific actions
+ kActionScalpelQuit,
+ kActionScalpelScrollUp,
+ kActionScalpelScrollDown,
+ kActionScalpelDartsExit,
+ kActionScalpelSkipMovie,
+ kActionScalpelLook,
+ kActionScalpelMove,
+ kActionScalpelTalk,
+ kActionScalpelPickUp,
+ kActionScalpelOpen,
+ kActionScalpelClose,
+ kActionScalpelInventory,
+ kActionScalpelUse,
+ kActionScalpelGive,
+ kActionScalpelJournal,
+ kActionScalpelFiles,
+ kActionScalpelSetup,
+ kActionScalpelLoad,
+ kActionScalpelSave,
+ kActionScalpelJournalExit,
+ kActionScalpelJournalBack10,
+ kActionScalpelJournalAhead10,
+ kActionScalpelJournalSearch,
+ kActionScalpelJournalFirstPage,
+ kActionScalpelJournalLastPage,
+ kActionScalpelTalkExit,
+ kActionScalpelInvExit,
+ kActionScalpelInvLook,
+ kActionScalpelInvUse,
+ kActionScalpelInvGive,
+ kActionScalpelInvPageLeft,
+ kActionScalpelInvLeft,
+ kActionScalpelInvPageRight,
+ kActionScalpelInvRight,
+ kActionScalpelFilesExit,
+ kActionScalpelFilesLoad,
+ kActionScalpelFilesSave,
+ kActionScalpelFilesQuit,
+ kActionScalpelFiles1,
+ kActionScalpelFiles2,
+ kActionScalpelFiles3,
+ kActionScalpelFiles4,
+ kActionScalpelFiles5,
+ kActionScalpelFiles6,
+ kActionScalpelFiles7,
+ kActionScalpelFiles8,
+ kActionScalpelFiles9,
+ kActionScalpelQuitDialogYes,
+ kActionScalpelQuitDialogNo,
+ kActionScalpelQuitDialogSelect,
+ kActionScalpelMapSelect,
+ kActionScalpelSettingsSelect,
+ kActionScalpelSettingsExit,
+ kActionScalpelSettingsToggleMusic,
+ kActionScalpelSettingsTogglePortraits,
+ kActionScalpelSettingsChangeFontStyle,
+ kActionScalpelSettingsToggleSoundEffects,
+ kActionScalpelSettingsToggleWindowsMode,
+ kActionScalpelSettingsChangeAutohelpLoc,
+ kActionScalpelSettingsToggleVoices,
+ kActionScalpelSettingsChangeFadeMode,
+ kActionScalpelSettingsFadeByPixels,
+ kActionScalpelSettingsFadeDirectly,
+ // Tattoo specific actions
+ kActionTattooExit,
+ kActionTattooSkipProlog,
+ kActionTattooChangeSpeed,
+ kActionTattooLook,
+ kActionTattooSave,
+ kActionTattooLoad,
+ kActionTattooJournal,
+ kActionTattooInv,
+ kActionTattooOptions,
+ kActionTattooQuit,
+ kActionTattooJournalOptionsLeft,
+ kActionTattooJournalForward10,
+ kActionTattooJournalForward1,
+ kActionTattooJournalBack10,
+ kActionTattooJournalBack1,
+ kActionTattooJournalStart,
+ kActionTattooJournalEnd,
+ kActionTattooJournalSelect,
+ kActionTattooJournalOptionsRight,
+ kActionTattooJournalSearchOptionsLeft,
+ kActionTattooJournalSearchOptionsRight,
+ kActionTattooJournalSearch,
+ kActionTattooSkipDarts,
+ kActionTattooMapTopLeft,
+ kActionTattooMapBottomRight,
+ kActionTattooMapUp,
+ kActionTattooMapDown,
+ kActionTattooMapSelect,
+ kActionTattooWidgetScrollUp,
+ kActionTattooWidgetScrollPageUp,
+ kActionTattooWidgetScrollDown,
+ kActionTattooWidgetScrollPageDown,
+ kActionTattooWidgetScrollEnd,
+ kActionTattooWidgetScrollStart,
+ kActionTattooFilesNextSlot,
+ kActionTattooFilesNextPageSlot,
+ kActionTattooFilesSelect,
+ kActionTattooFilesNameLeft,
+ kActionTattooFilesNameRight,
+ kActionTattooFilesNameStart,
+ kActionTattooFilesNameEnd,
+ kActionTattooFilesNameToggleInsertMode,
+ kActionTattooFoolscapExit,
+ kActionTattooFoolscapUp,
+ kActionTattooFoolscapDown,
+ kActionTattooFoolscapLeft,
+ kActionTattooFoolscapRight,
+ kActionTattooInvExit,
+ kActionTattooOptionsSelect,
+ kActionTattooPasswordLeft,
+ kActionTattooPasswordRight,
+ kActionTattooPasswordStart,
+ kActionTattooPasswordEnd,
+ kActionTattooPasswordToggleInsertMode,
+ kActionTattooQuitDialogYes,
+ kActionTattooQuitDialogNo,
+ kActionTattooQuitDialogNextOption,
+ kActionTattooTalkNext,
+ kActionTattooTalkPrevious,
+};
+
+
#define SHERLOCK_SCREEN_WIDTH _vm->_screen->width()
#define SHERLOCK_SCREEN_HEIGHT _vm->_screen->height()
#define SHERLOCK_SCENE_WIDTH _vm->_screen->_backBuffer1.width()
diff --git a/engines/sherlock/sound.cpp b/engines/sherlock/sound.cpp
index a887e7cd27e..5789944654e 100644
--- a/engines/sherlock/sound.cpp
+++ b/engines/sherlock/sound.cpp
@@ -140,7 +140,7 @@ bool Sound::playSound(const Common::Path &name, WaitType waitType, int priority,
do {
_vm->_events->pollEvents();
g_system->delayMillis(10);
- if ((waitType == WAIT_KBD_OR_FINISH) && _vm->_events->kbHit()) {
+ if ((waitType == WAIT_KBD_OR_FINISH) && (_vm->_events->kbHit() || _vm->_events->actionHit())) {
retval = false;
break;
}
diff --git a/engines/sherlock/talk.cpp b/engines/sherlock/talk.cpp
index 60d90b926cb..706a7c34318 100644
--- a/engines/sherlock/talk.cpp
+++ b/engines/sherlock/talk.cpp
@@ -274,6 +274,7 @@ void Talk::talkTo(const Common::String &filename) {
ui.clearInfo();
ui.banishWindow(false);
ui._key = -1;
+ ui._action = kActionNone;
break;
case FILES_MODE:
@@ -299,7 +300,8 @@ void Talk::talkTo(const Common::String &filename) {
screen.resetDisplayBounds();
events._pressed = events._released = false;
loadTalkFile(filename);
- ui._selector = ui._oldSelector = ui._key = ui._oldKey = -1;
+ ui._selector = ui._oldSelector = ui._key = -1;
+ ui._action = ui._oldAction = kActionNone;
// Find the first statement that has the correct flags
int select = -1;
@@ -427,7 +429,7 @@ void Talk::talkTo(const Common::String &filename) {
_talkHistory[_converseNum][select] = true;
}
- ui._key = ui._oldKey = 'T'; // FIXME: I'm not sure what to do here, I need ScalpelUI->_hotkeyTalk
+ ui._action = ui._oldAction = kActionScalpelTalk;
ui._temp = ui._oldTemp = 0;
ui._menuMode = TALK_MODE;
_talkToFlag = 2;
@@ -453,6 +455,7 @@ void Talk::talkTo(const Common::String &filename) {
_talkStealth = 0;
events._pressed = events._released = events._oldButtons = 0;
events.clearKeyboard();
+ events.clearActions();
if (savedBounds.bottom == SHERLOCK_SCREEN_HEIGHT)
screen.resetDisplayBounds();
@@ -900,9 +903,9 @@ int Talk::waitForMore(int delay) {
events.pollEventsAndWait();
events.setButtonState();
- if (events.kbHit()) {
- Common::KeyState keyState = events.getKey();
- if (keyState.keycode == Common::KEYCODE_ESCAPE) {
+ if (events.actionHit()) {
+ Common::CustomEventType action = events.getAction();
+ if (action == kActionTattooSkipProlog) {
if (IS_ROSE_TATTOO && static_cast<Tattoo::TattooEngine *>(_vm)->_runningProlog) {
// Skip out of the introduction
_vm->setFlags(-76);
@@ -911,7 +914,13 @@ int Talk::waitForMore(int delay) {
}
break;
- } else if (Common::isPrint(keyState.ascii))
+ } else if (action != kActionNone)
+ key2 = action;
+ }
+
+ if (events.kbHit()) {
+ Common::KeyState keyState = events.getKey();
+ if (Common::isPrint(keyState.ascii))
key2 = keyState.keycode;
}
diff --git a/engines/sherlock/tattoo/tattoo.cpp b/engines/sherlock/tattoo/tattoo.cpp
index 9b0622a9607..8f5866c7cc9 100644
--- a/engines/sherlock/tattoo/tattoo.cpp
+++ b/engines/sherlock/tattoo/tattoo.cpp
@@ -29,6 +29,8 @@
#include "sherlock/tattoo/widget_base.h"
#include "sherlock/people.h"
+#include "backends/keymapper/keymapper.h"
+
namespace Sherlock {
namespace Tattoo {
@@ -60,6 +62,9 @@ void TattooEngine::initialize() {
_flags[1] = _flags[4] = _flags[76] = true;
_runningProlog = true;
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->getKeymap("tattoo-prolog")->setEnabled(true);
+
// Add some more files to the cache
_res->addToCache("walk.lib");
diff --git a/engines/sherlock/tattoo/tattoo_darts.cpp b/engines/sherlock/tattoo/tattoo_darts.cpp
index 476e9068e2b..f54035a3742 100644
--- a/engines/sherlock/tattoo/tattoo_darts.cpp
+++ b/engines/sherlock/tattoo/tattoo_darts.cpp
@@ -23,6 +23,8 @@
#include "sherlock/tattoo/tattoo_fixed_text.h"
#include "sherlock/tattoo/tattoo.h"
+#include "backends/keymapper/keymapper.h"
+
namespace Sherlock {
namespace Tattoo {
@@ -94,6 +96,10 @@ void Darts::playDarts(GameType gameType) {
initDarts();
events.hideCursor();
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->getKeymap("tattoo")->setEnabled(false);
+ keymapper->getKeymap("tattoo-darts")->setEnabled(true);
+
while (!done && !_vm->shouldQuit()) {
int roundStart, score;
roundStart = score = (playerNum == 0) ? _score1 : _score2;
@@ -262,7 +268,7 @@ void Darts::playDarts(GameType gameType) {
do {
events.pollEventsAndWait();
events.setButtonState();
- } while (!_vm->shouldQuit() && !events.kbHit() && !events._pressed);
+ } while (!_vm->shouldQuit() && !events.kbHit() && !events._pressed && !events.actionHit());
} else {
events.wait(40);
}
@@ -288,7 +294,7 @@ void Darts::playDarts(GameType gameType) {
do {
events.pollEventsAndWait();
events.setButtonState();
- } while (!_vm->shouldQuit() && !events.kbHit() && !events._pressed);
+ } while (!_vm->shouldQuit() && !events.kbHit() && !events._pressed && !events.actionHit());
events.clearEvents();
closeDarts();
@@ -296,6 +302,9 @@ void Darts::playDarts(GameType gameType) {
screen.setFont(oldFontType);
events.showCursor();
+ keymapper->getKeymap("tattoo-darts")->setEnabled(false);
+ keymapper->getKeymap("tattoo")->setEnabled(true);
+
// Flag to return to the Billard's Academy scene
scene._goToScene = 26;
}
@@ -468,8 +477,8 @@ bool Darts::dartHit() {
events.setButtonState();
// Keyboard check
- if (events.kbHit()) {
- if (events.getKey().keycode == Common::KEYCODE_ESCAPE)
+ if (events.kbHit() || events.actionHit()) {
+ if (events.getAction() == kActionTattooSkipDarts)
_escapePressed = true;
events.clearEvents();
diff --git a/engines/sherlock/tattoo/tattoo_journal.cpp b/engines/sherlock/tattoo/tattoo_journal.cpp
index 7ccd499ceca..97e110d9c31 100644
--- a/engines/sherlock/tattoo/tattoo_journal.cpp
+++ b/engines/sherlock/tattoo/tattoo_journal.cpp
@@ -26,6 +26,8 @@
#include "sherlock/tattoo/tattoo_user_interface.h"
#include "sherlock/tattoo/tattoo.h"
+#include "backends/keymapper/keymapper.h"
+
namespace Sherlock {
namespace Tattoo {
@@ -79,6 +81,11 @@ void TattooJournal::show() {
_exitJournal = false;
_scrollingTimer = 0;
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->getKeymap("tattoo")->setEnabled(false);
+ keymapper->getKeymap("tattoo-journal")->setEnabled(true);
+ keymapper->getKeymap("tattoo-exit")->setEnabled(true);
+
do {
events.pollEventsAndWait();
events.setButtonState();
@@ -94,6 +101,10 @@ void TattooJournal::show() {
} while (!_vm->shouldQuit() && !_exitJournal);
+ keymapper->getKeymap("tattoo-journal")->setEnabled(false);
+ keymapper->getKeymap("tattoo-exit")->setEnabled(false);
+ keymapper->getKeymap("tattoo")->setEnabled(true);
+
// Clear events
events.clearEvents();
@@ -110,12 +121,12 @@ void TattooJournal::handleKeyboardEvents() {
Screen &screen = *_vm->_screen;
Common::Point mousePos = events.mousePos();
- if (!events.kbHit())
+ if (!events.actionHit())
return;
- Common::KeyState keyState = events.getKey();
+ Common::CustomEventType action = events.getAction();
- if (keyState.keycode == Common::KEYCODE_TAB && (keyState.flags & Common::KBD_SHIFT)) {
+ if (action == kActionTattooJournalOptionsLeft) {
// Shift tab
Common::Rect r(JOURNAL_BAR_WIDTH, BUTTON_SIZE + screen.fontHeight() + 13);
r.moveTo((SHERLOCK_SCREEN_WIDTH - r.width()) / 2, SHERLOCK_SCREEN_HEIGHT - r.height());
@@ -137,57 +148,54 @@ void TattooJournal::handleKeyboardEvents() {
events.warpMouse(Common::Point(r.left + (r.width() / 3) * (_selector + 1) - 10, mousePos.y));
}
- } else if (keyState.keycode == Common::KEYCODE_PAGEUP) {
- // See if they have Shift held down to go forward 10 pages
- if (keyState.flags & Common::KBD_SHIFT) {
- if (_page > 1) {
- // Scroll Up 10 pages if possible
- if (_page < 11)
- drawJournal(1, (_page - 1) * LINES_PER_PAGE);
- else
- drawJournal(1, 10 * LINES_PER_PAGE);
+ } else if (action == kActionTattooJournalBack10) {
+ if (_page > 1) {
+ // Scroll Up 10 pages if possible
+ if (_page < 11)
+ drawJournal(1, (_page - 1) * LINES_PER_PAGE);
+ else
+ drawJournal(1, 10 * LINES_PER_PAGE);
- drawScrollBar();
- screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
- _wait = false;
- }
- } else {
- if (_page > 1) {
- // Scroll Up 1 page
- drawJournal(1, LINES_PER_PAGE);
- drawScrollBar();
- drawJournal(0, 0);
- screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
- _wait = false;
- }
+ drawScrollBar();
+ screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
+ _wait = false;
}
- } else if (keyState.keycode == Common::KEYCODE_PAGEDOWN) {
- if (keyState.flags & Common::KBD_SHIFT) {
- if (_down) {
- // Scroll down 10 Pages
- if (_page + 10 > _maxPage)
- drawJournal(2, (_maxPage - _page) * LINES_PER_PAGE);
- else
- drawJournal(2, 10 * LINES_PER_PAGE);
- drawScrollBar();
- screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
+ } else if (action == kActionTattooJournalBack1){
+ if (_page > 1) {
+ // Scroll Up 1 page
+ drawJournal(1, LINES_PER_PAGE);
+ drawScrollBar();
+ drawJournal(0, 0);
+ screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
+ _wait = false;
+ }
- _wait = false;
- }
- } else {
- if (_down) {
- // Scroll down 1 page
- drawJournal(2, LINES_PER_PAGE);
- drawScrollBar();
- drawJournal(0, 0);
- screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
-
- _wait = false;
- }
+ } else if (action == kActionTattooJournalForward10) {
+ if (_down) {
+ // Scroll down 10 Pages
+ if (_page + 10 > _maxPage)
+ drawJournal(2, (_maxPage - _page) * LINES_PER_PAGE);
+ else
+ drawJournal(2, 10 * LINES_PER_PAGE);
+ drawScrollBar();
+ screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
+
+ _wait = false;
}
- } else if (keyState.keycode == Common::KEYCODE_HOME) {
+ } else if (action == kActionTattooJournalForward1) {
+ if (_down) {
+ // Scroll down 1 page
+ drawJournal(2, LINES_PER_PAGE);
+ drawScrollBar();
+ drawJournal(0, 0);
+ screen.slamArea(0, 0, SHERLOCK_SCREEN_WIDTH, SHERLOCK_SCREEN_HEIGHT);
+
+ _wait = false;
+ }
+
+ } else if (action == kActionTattooJournalStart) {
// Scroll to start of journal
if (_page > 1) {
// Go to the beginning of the journal
@@ -203,7 +211,7 @@ void TattooJournal::handleKeyboardEvents() {
_wait = false;
}
- } else if (keyState.keycode == Common::KEYCODE_END) {
+ } else if (action == kActionTattooJournalEnd) {
// Scroll to end of journal
if (_down) {
// Go to the end of the journal
@@ -213,13 +221,13 @@ void TattooJournal::handleKeyboardEvents() {
_wait = false;
}
- } else if (keyState.keycode == Common::KEYCODE_RETURN) {
+ } else if (action == kActionTattooJournalSelect) {
events._pressed = false;
events._released = true;
events._oldButtons = 0;
- } else if (keyState.keycode == Common::KEYCODE_ESCAPE) {
+ } else if (action == kActionTattooExit) {
_exitJournal = true;
- } else if (keyState.keycode == Common::KEYCODE_TAB) {
+ } else if (action == kActionTattooJournalOptionsRight) {
Common::Rect r(JOURNAL_BAR_WIDTH, BUTTON_SIZE + screen.fontHeight() + 13);
r.moveTo((SHERLOCK_SCREEN_WIDTH - r.width()) / 2, SHERLOCK_SCENE_HEIGHT - r.height());
@@ -834,10 +842,15 @@ int TattooJournal::getFindName(bool printError) {
// Set the cursors X position
cursorX = r.left + screen.widestChar() + 3 + screen.stringWidth(name);
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->disableAllGameKeymaps();
+ keymapper->getKeymap("tattoo-journal-search")->setEnabled(true);
+ keymapper->getKeymap("tattoo-exit")->setEnabled(true);
+
do {
events._released = events._rightReleased = false;
- while (!events.kbHit() && !events._released && !events._rightReleased) {
+ while (!events.kbHit() && !events._released && !events._rightReleased && !events.actionHit()) {
if (talk._talkToAbort)
return 0;
@@ -871,20 +884,40 @@ int TattooJournal::getFindName(bool printError) {
if (events.kbHit()) {
Common::KeyState keyState = events.getKey();
- Common::Point mousePos = events.mousePos();
if (keyState.keycode == Common::KEYCODE_BACKSPACE && !name.empty()) {
cursorX -= screen.charWidth(name.lastChar());
name.deleteLastChar();
}
- if (keyState.keycode == Common::KEYCODE_RETURN)
+ if (Common::isPrint(keyState.ascii)) {
+ if (keyState.ascii >= ' ' && keyState.ascii != '@' && name.size() < 50) {
+ if ((cursorX + screen.charWidth(keyState.ascii)) < (r.right - screen.widestChar() * 3)) {
+ char c = toupper(keyState.ascii);
+ cursorX += screen.charWidth(c);
+ name += c;
+ }
+ }
+ }
+
+ // Redraw the text
+ screen._backBuffer1.SHblitFrom(bgSurface, Common::Point(r.left + 3, cursorY));
+ screen.gPrint(Common::Point(r.left + screen.widestChar() + 3, cursorY), COMMAND_HIGHLIGHTED,
+ "%s", name.c_str());
+ screen.slamArea(r.left + 3, cursorY, r.right - 3, screen.fontHeight());
+ }
+
+ if (events.actionHit()) {
+ Common::Point mousePos = events.mousePos();
+ Common::CustomEventType action = events.getAction();
+
+ if (action == kActionTattooJournalSearch)
done = 1;
- else if (keyState.keycode == Common::KEYCODE_ESCAPE)
+ else if (action == kActionTattooExit)
done = -1;
- if (keyState.keycode == Common::KEYCODE_TAB) {
+ if (action == kActionTattooJournalSearchOptionsLeft || action == kActionTattooJournalSearchOptionsRight) {
r = Common::Rect(JOURNAL_BAR_WIDTH, BUTTON_SIZE + screen.fontHeight() + 13);
r.moveTo((SHERLOCK_SCREEN_WIDTH - r.width()) / 2, (SHERLOCK_SCREEN_HEIGHT - r.height()) / 2);
@@ -897,7 +930,7 @@ int TattooJournal::getFindName(bool printError) {
if (_selector == JH_NONE) {
events.warpMouse(Common::Point(r.left + r.width() / 3, r.top + screen.fontHeight() + 2));
} else {
- if (keyState.keycode & Common::KBD_SHIFT) {
+ if (action == kActionTattooJournalSearchOptionsLeft) {
if (_selector == JH_CLOSE)
_selector = JH_SAVE;
else
@@ -913,14 +946,6 @@ int TattooJournal::getFindName(bool printError) {
}
}
- if (keyState.ascii >= ' ' && keyState.ascii != '@' && name.size() < 50) {
- if ((cursorX + screen.charWidth(keyState.ascii)) < (r.right - screen.widestChar() * 3)) {
- char c = toupper(keyState.ascii);
- cursorX += screen.charWidth(c);
- name += c;
- }
- }
-
// Redraw the text
screen._backBuffer1.SHblitFrom(bgSurface, Common::Point(r.left + 3, cursorY));
screen.gPrint(Common::Point(r.left + screen.widestChar() + 3, cursorY), COMMAND_HIGHLIGHTED,
@@ -945,6 +970,11 @@ int TattooJournal::getFindName(bool printError) {
}
} while (!done);
+ keymapper->getKeymap("tattoo-journal-search")->setEnabled(false);
+ keymapper->getKeymap("sherlock-default")->setEnabled(true);
+ keymapper->getKeymap("tattoo-journal")->setEnabled(true);
+ keymapper->getKeymap("tattoo-exit")->setEnabled(true);
+
if (done != -1) {
// Forwards or backwards search, so save the entered name
_find = name;
diff --git a/engines/sherlock/tattoo/tattoo_map.cpp b/engines/sherlock/tattoo/tattoo_map.cpp
index 75f3f7d9c75..d667a235a44 100644
--- a/engines/sherlock/tattoo/tattoo_map.cpp
+++ b/engines/sherlock/tattoo/tattoo_map.cpp
@@ -23,6 +23,8 @@
#include "sherlock/tattoo/tattoo_scene.h"
#include "sherlock/tattoo/tattoo.h"
+#include "backends/keymapper/keymapper.h"
+
namespace Sherlock {
namespace Tattoo {
@@ -120,6 +122,10 @@ int TattooMap::show() {
_targetScroll = _bigPos;
screen._currentScroll = Common::Point(-1, -1);
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->getKeymap("tattoo")->setEnabled(false);
+ keymapper->getKeymap("tattoo-map")->setEnabled(true);
+
do {
// Allow for event processing and get the current mouse position
events.pollEventsAndWait();
@@ -152,34 +158,34 @@ int TattooMap::show() {
if ((_targetScroll.y + SHERLOCK_SCREEN_HEIGHT) > screen._backBuffer1.height())
_targetScroll.y = screen._backBuffer1.height() - SHERLOCK_SCREEN_HEIGHT;
- // Check the keyboard
- if (events.kbHit()) {
- Common::KeyState keyState = events.getKey();
+ // Check the action
+ if (events.actionHit()) {
+ Common::CustomEventType action = events.getAction();
- switch (keyState.keycode) {
- case Common::KEYCODE_HOME:
+ switch (action) {
+ case kActionTattooMapTopLeft:
_targetScroll.x = 0;
_targetScroll.y = 0;
break;
- case Common::KEYCODE_END:
+ case kActionTattooMapBottomRight:
_targetScroll.x = screen._backBuffer1.width() - SHERLOCK_SCREEN_WIDTH;
_targetScroll.y = screen._backBuffer1.height() - SHERLOCK_SCREEN_HEIGHT;
break;
- case Common::KEYCODE_PAGEUP:
+ case kActionTattooMapUp:
_targetScroll.y -= SHERLOCK_SCREEN_HEIGHT;
if (_targetScroll.y < 0)
_targetScroll.y = 0;
break;
- case Common::KEYCODE_PAGEDOWN:
+ case kActionTattooMapDown:
_targetScroll.y += SHERLOCK_SCREEN_HEIGHT;
if (_targetScroll.y > (screen._backBuffer1.height() - SHERLOCK_SCREEN_HEIGHT))
_targetScroll.y = screen._backBuffer1.height() - SHERLOCK_SCREEN_HEIGHT;
break;
- case Common::KEYCODE_SPACE:
+ case kActionTattooMapSelect:
events._pressed = false;
events._oldButtons = 0;
events._released = true;
@@ -214,6 +220,9 @@ int TattooMap::show() {
}
} while (!result && !_vm->shouldQuit());
+ keymapper->getKeymap("tattoo-map")->setEnabled(false);
+ keymapper->getKeymap("tattoo")->setEnabled(true);
+
music.stopMusic();
events.clearEvents();
_mapTooltip.banishWindow();
diff --git a/engines/sherlock/tattoo/tattoo_people.cpp b/engines/sherlock/tattoo/tattoo_people.cpp
index e5ba5cc56e8..d142e8848f5 100644
--- a/engines/sherlock/tattoo/tattoo_people.cpp
+++ b/engines/sherlock/tattoo/tattoo_people.cpp
@@ -549,10 +549,10 @@ void TattooPerson::walkToCoords(const Point32 &destPos, int destDir) {
events.wait(1);
scene.doBgAnim();
- if (events.kbHit()) {
- Common::KeyState keyState = events.getKey();
+ if (events.actionHit()) {
+ Common::CustomEventType action = events.getAction();
- if (keyState.keycode == Common::KEYCODE_ESCAPE && vm._runningProlog) {
+ if (action == kActionTattooSkipProlog && vm._runningProlog) {
vm.setFlags(-76);
vm.setFlags(396);
scene._goToScene = 1;
@@ -593,10 +593,10 @@ void TattooPerson::walkToCoords(const Point32 &destPos, int destDir) {
}
}
- if (events.kbHit()) {
- Common::KeyState keyState = events.getKey();
+ if (events.actionHit()) {
+ Common::CustomEventType action = events.getAction();
- if (keyState.keycode == Common::KEYCODE_ESCAPE && vm._runningProlog) {
+ if (action == kActionTattooSkipProlog && vm._runningProlog) {
vm.setFlags(-76);
vm.setFlags(396);
scene._goToScene = 1;
diff --git a/engines/sherlock/tattoo/tattoo_scene.cpp b/engines/sherlock/tattoo/tattoo_scene.cpp
index 758d95c0db0..cae196258fc 100644
--- a/engines/sherlock/tattoo/tattoo_scene.cpp
+++ b/engines/sherlock/tattoo/tattoo_scene.cpp
@@ -27,6 +27,8 @@
#include "sherlock/events.h"
#include "sherlock/people.h"
+#include "backends/keymapper/keymapper.h"
+
namespace Sherlock {
namespace Tattoo {
@@ -77,6 +79,9 @@ bool TattooScene::loadScene(const Common::Path &filename) {
vm._runningProlog = false;
events.showCursor();
talk._talkToAbort = false;
+
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->getKeymap("tattoo-prolog")->setEnabled(false);
}
// Check if it's a scene we need to keep track of how many times we've visited
@@ -683,12 +688,12 @@ int TattooScene::startCAnim(int cAnimNum, int playRate) {
// Draw the frame
doBgAnim();
- // Check for Escape key being pressed to abort animation
+ // Check for skip prolog action being pressed to abort animation
events.pollEvents();
- if (events.kbHit()) {
- Common::KeyState keyState = events.getKey();
+ if (events.actionHit()) {
+ Common::CustomEventType action = events.getAction();
- if (keyState.keycode == Common::KEYCODE_ESCAPE && vm._runningProlog) {
+ if (action == kActionTattooSkipProlog && vm._runningProlog) {
_vm->setFlags(-76);
_vm->setFlags(396);
_goToScene = STARTING_GAME_SCENE;
@@ -823,6 +828,9 @@ void TattooScene::synchronize(Serializer &s) {
// In case we were showing the intro prologue or the ending credits, stop them
vm._runningProlog = false;
ui._creditsWidget.close();
+
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->getKeymap("tattoo-prolog")->setEnabled(false);
}
}
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.cpp b/engines/sherlock/tattoo/tattoo_user_interface.cpp
index 1b964a55313..c1bc208f3d0 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.cpp
+++ b/engines/sherlock/tattoo/tattoo_user_interface.cpp
@@ -25,6 +25,8 @@
#include "sherlock/tattoo/tattoo_scene.h"
#include "sherlock/tattoo/tattoo.h"
+#include "backends/keymapper/keymapper.h"
+
namespace Sherlock {
namespace Tattoo {
@@ -191,7 +193,8 @@ void TattooUserInterface::printObjectDesc(const Common::String &str, bool firstT
} else {
// Nope
events.setCursor(ARROW);
- _key = -1;
+ _action = kActionNone;
+ _keyState.keycode = Common::KEYCODE_INVALID;
_menuMode = scene._labTableScene ? LAB_MODE : STD_MODE;
events._pressed = events._released = events._rightReleased = false;
events._oldButtons = 0;
@@ -223,7 +226,8 @@ void TattooUserInterface::doJournal() {
_menuMode = STD_MODE;
_windowOpen = false;
- _key = -1;
+ _action = kActionNone;
+ _keyState.keycode = Common::KEYCODE_INVALID;
// Restore the old screen palette and greyscale lookup table
screen.clear();
@@ -252,6 +256,7 @@ void TattooUserInterface::handleInput() {
Common::Point mousePos = events.mousePos();
_keyState.keycode = Common::KEYCODE_INVALID;
+ _action = kActionNone;
// Check for credits starting
if (_vm->readFlags(3000) && !_creditsWidget.active())
@@ -266,27 +271,33 @@ void TattooUserInterface::handleInput() {
if (_lockoutTimer)
--_lockoutTimer;
- // Key handling
- if (events.kbHit()) {
- _keyState = events.getKey();
+ // Action handling
+ if (events.actionHit()) {
+ _action = events.getAction();
- if (_keyState.keycode == Common::KEYCODE_ESCAPE && vm._runningProlog && !_lockoutTimer) {
+ if (_action == kActionTattooSkipProlog && vm._runningProlog && !_lockoutTimer) {
vm.setFlags(-76);
vm.setFlags(396);
scene._goToScene = STARTING_GAME_SCENE;
} else if (_menuMode == STD_MODE) {
- if (_keyState.keycode == Common::KEYCODE_s && vm._allowFastMode) {
+ if (_action == kActionTattooChangeSpeed && vm._allowFastMode) {
events.toggleSpeed();
- } else if (_keyState.keycode == Common::KEYCODE_l && _bgFound != -1) {
+ } else if (_action == kActionTattooLook && _bgFound != -1) {
// Beging used for testing that Look dialogs work
lookAtObject();
}
}
}
- if (!events.isCursorVisible())
+ if (events.kbHit()) {
+ _keyState = events.getKey();
+ }
+
+ if (!events.isCursorVisible()) {
_keyState.keycode = Common::KEYCODE_INVALID;
+ _action = kActionNone;
+ }
// If there's any active widgets/windows, let the most recently open one do event processing
if (!_widgets.empty())
@@ -386,7 +397,7 @@ void TattooUserInterface::doStandardControl() {
// When the end credits are active, any press will open the ScummVM global main menu
if (_creditsWidget.active()) {
- if (_keyState.keycode || events._released || events._rightReleased) {
+ if (_keyState.keycode || _action || events._released || events._rightReleased) {
vm._canLoadSave = true;
vm.openMainMenuDialog();
vm._canLoadSave = false;
@@ -398,20 +409,20 @@ void TattooUserInterface::doStandardControl() {
// Display the names of any Objects the cursor is pointing at
displayObjectNames();
- switch (_keyState.keycode) {
- case Common::KEYCODE_F5:
+ switch (_action) {
+ case kActionTattooSave:
// Save game
events.warpMouse();
saveGame();
return;
- case Common::KEYCODE_F7:
+ case kActionTattooLoad:
// Load game
events.warpMouse();
loadGame();
return;
- case Common::KEYCODE_F1:
+ case kActionTattooJournal:
// Display journal
if (vm.readFlags(FLAG_PLAYER_IS_HOLMES)) {
freeMenu();
@@ -423,20 +434,19 @@ void TattooUserInterface::doStandardControl() {
}
break;
- case Common::KEYCODE_TAB:
- case Common::KEYCODE_F3:
+ case kActionTattooInv:
// Display inventory
freeMenu();
doInventory(3);
return;
- case Common::KEYCODE_F4:
+ case kActionTattooOptions:
// Display options
events.warpMouse();
_optionsWidget.load();
return;
- case Common::KEYCODE_F10:
+ case kActionTattooQuit:
// Quit menu
freeMenu();
events.warpMouse();
@@ -519,8 +529,8 @@ void TattooUserInterface::doLookControl() {
Events &events = *_vm->_events;
TattooScene &scene = *(TattooScene *)_vm->_scene;
- // See if a mouse button was released or a key pressed to close the active look dialog
- if (events._released || events._rightReleased || _keyState.keycode) {
+ // See if a mouse button was released, a key pressed or a action pressed to close the active look dialog
+ if (events._released || events._rightReleased || _keyState.keycode || _action) {
// See if we were looking at an inventory object
if (!_invLookFlag) {
// See if there is any more text to display
@@ -529,7 +539,8 @@ void TattooUserInterface::doLookControl() {
} else {
// Otherwise restore the background and go back into STD_MODE
freeMenu();
- _key = -1;
+ _action = kActionNone;
+ _keyState.keycode = Common::KEYCODE_INVALID;
_menuMode = scene._labTableScene ? LAB_MODE : STD_MODE;
events.setCursor(ARROW);
@@ -543,7 +554,8 @@ void TattooUserInterface::doLookControl() {
doInventory(0);
_invLookFlag = false;
- _key = -1;
+ _action = kActionNone;
+ _keyState.keycode = Common::KEYCODE_INVALID;
events.setCursor(ARROW);
events._pressed = events._released = events._rightReleased = false;
@@ -638,6 +650,7 @@ void TattooUserInterface::pickUpObject(int objNum) {
if (_menuMode != TALK_MODE && _menuMode != MESSAGE_MODE) {
_menuMode = STD_MODE;
_keyState.keycode = Common::KEYCODE_INVALID;
+ _action = kActionNone;
}
}
diff --git a/engines/sherlock/tattoo/tattoo_user_interface.h b/engines/sherlock/tattoo/tattoo_user_interface.h
index 68285694f0b..21d6599b4e5 100644
--- a/engines/sherlock/tattoo/tattoo_user_interface.h
+++ b/engines/sherlock/tattoo/tattoo_user_interface.h
@@ -100,6 +100,7 @@ public:
bool _personFound;
int _activeObj;
Common::KeyState _keyState;
+ Common::CustomEventType _action;
Common::Point _lookPos;
ScrollHighlight _scrollHighlight;
Common::SeekableReadStream *_mask, *_mask1;
diff --git a/engines/sherlock/tattoo/widget_base.cpp b/engines/sherlock/tattoo/widget_base.cpp
index 7587b722e22..6228907adf7 100644
--- a/engines/sherlock/tattoo/widget_base.cpp
+++ b/engines/sherlock/tattoo/widget_base.cpp
@@ -291,15 +291,15 @@ void WidgetBase::handleScrollbarEvents(int index, int pageSize, int count) {
void WidgetBase::handleScrolling(int &scrollIndex, int pageSize, int max) {
Events &events = *_vm->_events;
TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
- Common::KeyCode keycode = ui._keyState.keycode;
+ Common::CustomEventType action = ui._action;
Common::Point mousePos = events.mousePos();
Common::Rect r = getScrollBarBounds();
r.translate(_bounds.left, _bounds.top);
- if (ui._scrollHighlight != SH_NONE || keycode == Common::KEYCODE_HOME || keycode == Common::KEYCODE_END
- || keycode == Common::KEYCODE_PAGEUP || keycode == Common::KEYCODE_PAGEDOWN
- || keycode == Common::KEYCODE_UP || keycode == Common::KEYCODE_DOWN) {
+ if (ui._scrollHighlight != SH_NONE || action == kActionTattooWidgetScrollStart || action == kActionTattooWidgetScrollEnd
+ || action == kActionTattooWidgetScrollPageUp || action == kActionTattooWidgetScrollPageDown
+ || action == kActionTattooWidgetScrollUp || action == kActionTattooWidgetScrollDown) {
// Check for the scrollbar
if (ui._scrollHighlight == SH_THUMBNAIL) {
int yp = mousePos.y;
@@ -318,15 +318,15 @@ void WidgetBase::handleScrolling(int &scrollIndex, int pageSize, int max) {
_dialogTimer = (_dialogTimer == 0) ? frameNum + pageSize : frameNum + 1;
// Check for Scroll Up
- if ((ui._scrollHighlight == SH_SCROLL_UP || keycode == Common::KEYCODE_UP) && scrollIndex)
+ if ((ui._scrollHighlight == SH_SCROLL_UP || action == kActionTattooWidgetScrollUp) && scrollIndex)
--scrollIndex;
// Check for Page Up
- else if ((ui._scrollHighlight == SH_PAGE_UP || keycode == Common::KEYCODE_PAGEUP) && scrollIndex)
+ else if ((ui._scrollHighlight == SH_PAGE_UP || action == kActionTattooWidgetScrollPageUp) && scrollIndex)
scrollIndex -= pageSize;
// Check for Page Down
- else if ((ui._scrollHighlight == SH_PAGE_DOWN || keycode == Common::KEYCODE_PAGEDOWN)
+ else if ((ui._scrollHighlight == SH_PAGE_DOWN || action == kActionTattooWidgetScrollPageDown)
&& (scrollIndex + pageSize < max)) {
scrollIndex += pageSize;
if (scrollIndex + pageSize >max)
@@ -334,14 +334,14 @@ void WidgetBase::handleScrolling(int &scrollIndex, int pageSize, int max) {
}
// Check for Scroll Down
- else if ((ui._scrollHighlight == SH_SCROLL_DOWN || keycode == Common::KEYCODE_DOWN) && (scrollIndex + pageSize < max))
+ else if ((ui._scrollHighlight == SH_SCROLL_DOWN || action == kActionTattooWidgetScrollDown) && (scrollIndex + pageSize < max))
++scrollIndex;
}
- if (keycode == Common::KEYCODE_END)
+ if (action == kActionTattooWidgetScrollEnd)
scrollIndex = max - pageSize;
- if (scrollIndex < 0 || keycode == Common::KEYCODE_HOME)
+ if (scrollIndex < 0 || action == kActionTattooWidgetScrollStart)
scrollIndex = 0;
}
}
diff --git a/engines/sherlock/tattoo/widget_files.cpp b/engines/sherlock/tattoo/widget_files.cpp
index 7e12b3b1d5c..9482754c6e7 100644
--- a/engines/sherlock/tattoo/widget_files.cpp
+++ b/engines/sherlock/tattoo/widget_files.cpp
@@ -27,6 +27,8 @@
#include "sherlock/tattoo/tattoo_scene.h"
#include "sherlock/tattoo/tattoo_user_interface.h"
+#include "backends/keymapper/keymapper.h"
+
namespace Sherlock {
namespace Tattoo {
@@ -63,6 +65,11 @@ void WidgetFiles::show(SaveMode mode) {
summonWindow();
ui._menuMode = FILES_MODE;
+
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->getKeymap("tattoo")->setEnabled(false);
+ keymapper->getKeymap("tattoo-scrolling")->setEnabled(true);
+ keymapper->getKeymap("tattoo-files")->setEnabled(true);
} else if (mode == SAVEMODE_LOAD) {
showScummVMRestoreDialog();
} else {
@@ -166,7 +173,7 @@ void WidgetFiles::handleEvents() {
Events &events = *_vm->_events;
TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
Common::Point mousePos = events.mousePos();
- Common::KeyState keyState = ui._keyState;
+ Common::CustomEventType action = ui._action;
// Handle scrollbar events
ScrollHighlight oldHighlight = ui._scrollHighlight;
@@ -184,22 +191,22 @@ void WidgetFiles::handleEvents() {
_selector = -1;
}
- // Check for the Tab key
- if (keyState.keycode == Common::KEYCODE_TAB) {
+ // Check for the slot change actions
+ if (action == kActionTattooFilesNextSlot || action == kActionTattooFilesNextPageSlot) {
// If the mouse is not over any of the filenames, move the mouse so that it points to the first one
if (_selector == -1) {
events.warpMouse(Common::Point(_bounds.right - BUTTON_SIZE - 20,
_bounds.top + _surface.fontHeight() * 2 + 8));
} else {
- // See if we're doing Tab or Shift Tab
- if (keyState.flags & Common::KBD_SHIFT) {
+ // See if we're doing Next Page Slot action
+ if (action == kActionTattooFilesNextPageSlot) {
// We're doing Shift Tab
if (_selector == _savegameIndex)
_selector = _savegameIndex + 4;
else
--_selector;
} else {
- // We're doing Tab
+ // We're doing Next Slot action
++_selector;
if (_selector >= _savegameIndex + 5)
_selector = _savegameIndex;
@@ -218,10 +225,15 @@ void WidgetFiles::handleEvents() {
if (events._firstPress && !_bounds.contains(mousePos))
_outsideMenu = true;
- if (events._released || events._rightReleased || keyState.keycode == Common::KEYCODE_ESCAPE) {
+ if (events._released || events._rightReleased || action == kActionTattooFilesSelect) {
ui._scrollHighlight = SH_NONE;
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+
if (_outsideMenu && !_bounds.contains(mousePos)) {
+ keymapper->getKeymap("tattoo-scrolling")->setEnabled(false);
+ keymapper->getKeymap("tattoo-files")->setEnabled(false);
+ keymapper->getKeymap("tattoo")->setEnabled(true);
close();
} else {
_outsideMenu = false;
@@ -231,9 +243,17 @@ void WidgetFiles::handleEvents() {
// We're in Load Mode
_vm->loadGameState(_selector);
} else if (_fileMode == SAVEMODE_SAVE) {
+ keymapper->getKeymap("tattoo-scrolling")->setEnabled(false);
+ keymapper->getKeymap("tattoo-files")->setEnabled(false);
+ keymapper->getKeymap("tattoo-files-name")->setEnabled(true);
+ keymapper->getKeymap("tattoo-exit")->setEnabled(true);
// We're in Save Mode
if (getFilename())
_vm->saveGameState(_selector, _savegames[_selector]);
+
+ keymapper->getKeymap("tattoo-files-name")->setEnabled(false);
+ keymapper->getKeymap("tattoo-exit")->setEnabled(false);
+ keymapper->getKeymap("tattoo")->setEnabled(true);
close();
}
}
@@ -283,8 +303,8 @@ bool WidgetFiles::getFilename() {
Common::String charString = Common::String::format("%c", currentChar);
int width = screen.charWidth(currentChar);
- // Wait for keypress
- while (!events.kbHit()) {
+ // Wait for keypress or action
+ while (!events.kbHit() && !events.actionHit()) {
events.pollEventsAndWait();
events.setButtonState();
@@ -326,31 +346,63 @@ bool WidgetFiles::getFilename() {
_surface.fillRect(Common::Rect(pt.x, pt.y, _surface.width() - BUTTON_SIZE - 9, pt.y + _surface.fontHeight()), TRANSPARENCY);
_surface.writeString(filename.c_str() + index, pt, COMMAND_HIGHLIGHTED);
- } else if ((keyState.keycode == Common::KEYCODE_LEFT && index > 0)
- || (keyState.keycode == Common::KEYCODE_RIGHT && index < (int)filename.size() && pt.x < (_bounds.right - BUTTON_SIZE - 20))
- || (keyState.keycode == Common::KEYCODE_HOME && index > 0)
- || (keyState.keycode == Common::KEYCODE_END)) {
+ } else if (keyState.keycode == Common::KEYCODE_DELETE && index < (int)filename.size()) {
+ filename.deleteChar(index);
+
+ _surface.fillRect(Common::Rect(pt.x, pt.y, _bounds.width() - BUTTON_SIZE - 9, pt.y + _surface.fontHeight()), TRANSPARENCY);
+ _surface.writeString(Common::String(filename.c_str() + index), pt, COMMAND_HIGHLIGHTED);
+ } else if (keyState.keycode == Common::KEYCODE_RETURN) {
+ done = 1;
+ }
+
+ if ((keyState.ascii >= ' ') && (keyState.ascii <= 'z') && (index < 50)) {
+ if (pt.x + _surface.charWidth(keyState.ascii) < _surface.w - BUTTON_SIZE - 20) {
+ if (insert)
+ filename.insertChar(keyState.ascii, index);
+ else
+ filename.setChar(keyState.ascii, index);
+
+ _surface.fillRect(Common::Rect(pt.x, pt.y, _bounds.width() - BUTTON_SIZE - 9,
+ pt.y + _surface.fontHeight()), TRANSPARENCY);
+ _surface.writeString(filename.c_str() + index, pt, COMMAND_HIGHLIGHTED);
+ pt.x += _surface.charWidth(keyState.ascii);
+ ++index;
+ }
+ }
+
+ currentChar = (index == (int)filename.size()) ? ' ' : filename[index];
+ charString = Common::String::format("%c", currentChar);
+ width = screen.charWidth(currentChar);
+ }
+
+ while (events.actionHit()) {
+ Common::CustomEventType action = events.getAction();
+
+ if ((action == kActionTattooFilesNameLeft && index > 0)
+ || (action == kActionTattooFilesNameRight && index < (int)filename.size() && pt.x < (_bounds.right - BUTTON_SIZE - 20))
+ || (action == kActionTattooFilesNameStart && index > 0)
+ || (action == kActionTattooFilesNameEnd)) {
_surface.fillRect(Common::Rect(pt.x, pt.y, pt.x + width, pt.y + _surface.fontHeight()), TRANSPARENCY);
if (currentChar)
_surface.writeString(charString, pt, COMMAND_HIGHLIGHTED);
- switch (keyState.keycode) {
- case Common::KEYCODE_LEFT:
+ switch (action) {
+ case kActionTattooFilesNameLeft:
pt.x -= _surface.charWidth(filename[index - 1]);
--index;
break;
- case Common::KEYCODE_RIGHT:
+ case kActionTattooFilesNameRight:
pt.x += _surface.charWidth(filename[index]);
++index;
break;
- case Common::KEYCODE_HOME:
+ case kActionTattooFilesNameStart:
pt.x = _surface.stringWidth("00.") + _surface.widestChar() + 5;
index = 0;
break;
- case Common::KEYCODE_END:
+ case kActionTattooFilesNameEnd:
pt.x = _surface.stringWidth("00.") + _surface.stringWidth(filename) + _surface.widestChar() + 5;
index = filename.size();
@@ -363,44 +415,23 @@ bool WidgetFiles::getFilename() {
default:
break;
}
- } else if (keyState.keycode == Common::KEYCODE_INSERT) {
+ } else if (action == kActionTattooFilesNameToggleInsertMode) {
insert = !insert;
if (insert)
cursorColor = 192;
else
cursorColor = 200;
- } else if (keyState.keycode == Common::KEYCODE_DELETE && index < (int)filename.size()) {
- filename.deleteChar(index);
-
- _surface.fillRect(Common::Rect(pt.x, pt.y, _bounds.width() - BUTTON_SIZE - 9, pt.y + _surface.fontHeight()), TRANSPARENCY);
- _surface.writeString(Common::String(filename.c_str() + index), pt, COMMAND_HIGHLIGHTED);
- } else if (keyState.keycode == Common::KEYCODE_RETURN) {
- done = 1;
- } else if (keyState.keycode == Common::KEYCODE_ESCAPE) {
+ } else if (action == kActionTattooExit) {
_selector = -1;
render(RENDER_NAMES_AND_SCROLLBAR);
done = -1;
}
- if ((keyState.ascii >= ' ') && (keyState.ascii <= 'z') && (index < 50)) {
- if (pt.x + _surface.charWidth(keyState.ascii) < _surface.w - BUTTON_SIZE - 20) {
- if (insert)
- filename.insertChar(keyState.ascii, index);
- else
- filename.setChar(keyState.ascii, index);
-
- _surface.fillRect(Common::Rect(pt.x, pt.y, _bounds.width() - BUTTON_SIZE - 9,
- pt.y + _surface.fontHeight()), TRANSPARENCY);
- _surface.writeString(filename.c_str() + index, pt, COMMAND_HIGHLIGHTED);
- pt.x += _surface.charWidth(keyState.ascii);
- ++index;
- }
- }
-
currentChar = (index == (int)filename.size()) ? ' ' : filename[index];
charString = Common::String::format("%c", currentChar);
width = screen.charWidth(currentChar);
}
+
} while (!done && !_vm->shouldQuit());
scene.doBgAnim();
diff --git a/engines/sherlock/tattoo/widget_foolscap.cpp b/engines/sherlock/tattoo/widget_foolscap.cpp
index 749b51fc3fc..6073df8301b 100644
--- a/engines/sherlock/tattoo/widget_foolscap.cpp
+++ b/engines/sherlock/tattoo/widget_foolscap.cpp
@@ -25,6 +25,8 @@
#include "sherlock/tattoo/tattoo_user_interface.h"
#include "sherlock/tattoo/tattoo.h"
+#include "backends/keymapper/keymapper.h"
+
namespace Sherlock {
namespace Tattoo {
@@ -124,6 +126,10 @@ void WidgetFoolscap::show() {
// Show the window
summonWindow();
ui._menuMode = FOOLSCAP_MODE;
+
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->getKeymap("tattoo")->setEnabled(false);
+ keymapper->getKeymap("tattoo-foolscap")->setEnabled(true);
}
void WidgetFoolscap::handleEvents() {
@@ -138,7 +144,7 @@ void WidgetFoolscap::handleEvents() {
// If they have not solved the puzzle, let them solve it here
if (!_vm->readFlags(299)) {
- if (!ui._keyState.keycode) {
+ if (!ui._keyState.keycode && !ui._action) {
if (--_blinkCounter < 0) {
_blinkCounter = 3;
_blinkFlag = !_blinkFlag;
@@ -166,7 +172,7 @@ void WidgetFoolscap::handleEvents() {
}
}
} else {
- // Handle keyboard events
+ // Handle keyboard and action events
handleKeyboardEvents();
}
}
@@ -182,11 +188,12 @@ void WidgetFoolscap::handleKeyboardEvents() {
Screen &screen = *_vm->_screen;
TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
Common::KeyState keyState = ui._keyState;
+ Common::CustomEventType action = ui._action;
if ((toupper(keyState.ascii) >= 'A') && (toupper(keyState.ascii) <= 'Z')) {
// Visible key pressed, set it and set the keycode to move the caret to the right
_answers[_lineNum][_charNum] = keyState.ascii;
- keyState.keycode = Common::KEYCODE_RIGHT;
+ action = kActionTattooFoolscapRight;
}
// Restore background
@@ -199,11 +206,32 @@ void WidgetFoolscap::handleKeyboardEvents() {
}
switch (keyState.keycode) {
- case Common::KEYCODE_ESCAPE:
+ case Common::KEYCODE_BACKSPACE:
+ if (_charNum)
+ --_charNum;
+ else if (_lineNum) {
+ --_lineNum;
+
+ _charNum = strlen(_solutions[_lineNum]) - 1;
+ }
+
+ _answers[_lineNum][_charNum] = ' ';
+ break;
+
+ case Common::KEYCODE_DELETE:
+ _answers[_lineNum][_charNum] = ' ';
+ break;
+
+ default:
+ break;
+ }
+
+ switch (action) {
+ case kActionTattooFoolscapExit:
close();
break;
- case Common::KEYCODE_UP:
+ case kActionTattooFoolscapUp:
if (_lineNum) {
--_lineNum;
if (_charNum >= (int)strlen(_solutions[_lineNum]))
@@ -211,7 +239,7 @@ void WidgetFoolscap::handleKeyboardEvents() {
}
break;
- case Common::KEYCODE_DOWN:
+ case kActionTattooFoolscapDown:
if (_lineNum < 2) {
++_lineNum;
if (_charNum >= (int)strlen(_solutions[_lineNum]))
@@ -219,8 +247,7 @@ void WidgetFoolscap::handleKeyboardEvents() {
}
break;
- case Common::KEYCODE_BACKSPACE:
- case Common::KEYCODE_LEFT:
+ case kActionTattooFoolscapLeft:
if (_charNum)
--_charNum;
else if (_lineNum) {
@@ -228,12 +255,9 @@ void WidgetFoolscap::handleKeyboardEvents() {
_charNum = strlen(_solutions[_lineNum]) - 1;
}
-
- if (keyState.keycode == Common::KEYCODE_BACKSPACE)
- _answers[_lineNum][_charNum] = ' ';
break;
- case Common::KEYCODE_RIGHT:
+ case kActionTattooFoolscapRight:
if (_charNum < (int)strlen(_solutions[_lineNum]) - 1)
++_charNum;
else if (_lineNum < 2) {
@@ -242,10 +266,6 @@ void WidgetFoolscap::handleKeyboardEvents() {
}
break;
- case Common::KEYCODE_DELETE:
- _answers[_lineNum][_charNum] = ' ';
- break;
-
default:
break;
}
@@ -275,6 +295,10 @@ void WidgetFoolscap::close() {
delete _images;
_images = nullptr;
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->getKeymap("tattoo-foolscap")->setEnabled(false);
+ keymapper->getKeymap("tattoo")->setEnabled(true);
+
// Close the window
banishWindow();
ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE;
diff --git a/engines/sherlock/tattoo/widget_inventory.cpp b/engines/sherlock/tattoo/widget_inventory.cpp
index e4207aaa581..52a2dd7e2c5 100644
--- a/engines/sherlock/tattoo/widget_inventory.cpp
+++ b/engines/sherlock/tattoo/widget_inventory.cpp
@@ -26,6 +26,8 @@
#include "sherlock/tattoo/tattoo_user_interface.h"
#include "sherlock/tattoo/tattoo.h"
+#include "backends/keymapper/keymapper.h"
+
namespace Sherlock {
namespace Tattoo {
@@ -379,11 +381,11 @@ void WidgetInventoryVerbs::handleEvents() {
if (!innerBounds.contains(mousePos))
_outsideMenu = true;
- if (events._released || events._rightReleased || ui._keyState.keycode == Common::KEYCODE_ESCAPE) {
+ if (events._released || events._rightReleased || ui._action == kActionTattooInvExit) {
ui._scrollHighlight = SH_NONE;
banishWindow();
- if (_outsideMenu || ui._keyState.keycode == Common::KEYCODE_ESCAPE) {
+ if (_outsideMenu || ui._action == kActionTattooInvExit) {
_owner->_invVerbMode = 0;
} else if (innerBounds.contains(mousePos)) {
_outsideMenu = false;
@@ -506,6 +508,11 @@ void WidgetInventory::load(int mode) {
_bounds.moveTo(mousePos.x - _bounds.width() / 2, mousePos.y - _bounds.height() / 2);
}
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->getKeymap("tattoo")->setEnabled(false);
+ keymapper->getKeymap("tattoo-scrolling")->setEnabled(true);
+ keymapper->getKeymap("tattoo-inv")->setEnabled(true);
+
// Ensure menu will be on-screen
restrictToScreen();
@@ -623,7 +630,7 @@ void WidgetInventory::handleEvents() {
highlightControls();
// See if they released a mouse button button
- if (events._released || events._rightReleased || ui._keyState.keycode == Common::KEYCODE_ESCAPE) {
+ if (events._released || events._rightReleased || ui._action == kActionTattooInvExit) {
ui._scrollHighlight = SH_NONE;
// See if they have a Verb List open for an Inventry Item
@@ -635,7 +642,7 @@ void WidgetInventory::handleEvents() {
_tooltipWidget.banishWindow();
close();
- if (ui._keyState.keycode != Common::KEYCODE_ESCAPE) {
+ if (ui._action != kActionTattooInvExit) {
// If user pointed at an item, use the selected inventory item with this item
bool found = false;
if (ui._bgFound != -1) {
@@ -663,7 +670,7 @@ void WidgetInventory::handleEvents() {
if (!found)
ui.putMessage("%s", FIXED(NoEffect));
}
- } else if ((_outsideMenu && !_bounds.contains(mousePos)) || ui._keyState.keycode == Common::KEYCODE_ESCAPE) {
+ } else if ((_outsideMenu && !_bounds.contains(mousePos)) || ui._action == kActionTattooInvExit) {
// Want to close the window (clicked outside of it). So close the window and return to Standard
close();
@@ -758,6 +765,11 @@ void WidgetInventory::highlightControls() {
void WidgetInventory::banishWindow() {
WidgetBase::banishWindow();
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->getKeymap("tattoo-scrolling")->setEnabled(false);
+ keymapper->getKeymap("tattoo-inv")->setEnabled(false);
+ keymapper->getKeymap("tattoo")->setEnabled(true);
+
_verbList.banishWindow();
}
diff --git a/engines/sherlock/tattoo/widget_options.cpp b/engines/sherlock/tattoo/widget_options.cpp
index 46f2cd006c6..f23a4366252 100644
--- a/engines/sherlock/tattoo/widget_options.cpp
+++ b/engines/sherlock/tattoo/widget_options.cpp
@@ -25,6 +25,8 @@
#include "sherlock/tattoo/tattoo_scene.h"
#include "sherlock/tattoo/tattoo_user_interface.h"
+#include "backends/keymapper/keymapper.h"
+
namespace Sherlock {
namespace Tattoo {
@@ -43,6 +45,11 @@ void WidgetOptions::load() {
summonWindow();
ui._menuMode = OPTION_MODE;
+
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->getKeymap("tattoo")->setEnabled(false);
+ keymapper->getKeymap("tattoo-options")->setEnabled(true);
+ keymapper->getKeymap("tattoo-exit")->setEnabled(true);
}
void WidgetOptions::handleEvents() {
@@ -54,6 +61,8 @@ void WidgetOptions::handleEvents() {
Talk &talk = *_vm->_talk;
TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
Common::Point mousePos = events.mousePos();
+ Common::CustomEventType action = ui._action;
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
if (talk._talkToAbort) {
sound.stopSound();
@@ -64,14 +73,15 @@ void WidgetOptions::handleEvents() {
if (events._firstPress && !_bounds.contains(mousePos))
_outsideMenu = true;
- if (events.kbHit()) {
- ui._keyState = events.getKey();
-
+ if (action != kActionNone) {
// Emulate a mouse release if Enter or Space Bar is pressed
- if (ui._keyState.keycode == Common::KEYCODE_RETURN || ui._keyState.keycode == Common::KEYCODE_SPACE) {
+ if (ui._action == kActionTattooOptionsSelect) {
events._pressed = events._oldButtons = false;
events._released = true;
- } else if (ui._keyState.keycode == Common::KEYCODE_ESCAPE) {
+ } else if (ui._action == kActionTattooExit) {
+ keymapper->getKeymap("tattoo-options")->setEnabled(false);
+ keymapper->getKeymap("tattoo-exit")->setEnabled(false);
+ keymapper->getKeymap("tattoo")->setEnabled(true);
close();
return;
} else {
@@ -90,6 +100,9 @@ void WidgetOptions::handleEvents() {
_selector = -1;
if (_outsideMenu && (events._released || events._rightReleased)) {
events.clearEvents();
+ keymapper->getKeymap("tattoo-options")->setEnabled(false);
+ keymapper->getKeymap("tattoo-exit")->setEnabled(false);
+ keymapper->getKeymap("tattoo")->setEnabled(true);
close();
return;
}
@@ -153,12 +166,18 @@ void WidgetOptions::handleEvents() {
switch (temp) {
case 0:
// Load Game
+ keymapper->getKeymap("tattoo-options")->setEnabled(false);
+ keymapper->getKeymap("tattoo-exit")->setEnabled(false);
+ keymapper->getKeymap("tattoo")->setEnabled(true);
close();
ui.loadGame();
break;
case 1:
// Save Game
+ keymapper->getKeymap("tattoo-options")->setEnabled(false);
+ keymapper->getKeymap("tattoo-exit")->setEnabled(false);
+ keymapper->getKeymap("tattoo")->setEnabled(true);
close();
ui.saveGame();
break;
@@ -222,6 +241,9 @@ void WidgetOptions::handleEvents() {
case 10:
// Quit
+ keymapper->getKeymap("tattoo-options")->setEnabled(false);
+ keymapper->getKeymap("tattoo-exit")->setEnabled(false);
+ keymapper->getKeymap("tattoo")->setEnabled(true);
banishWindow();
ui.doQuitMenu();
break;
diff --git a/engines/sherlock/tattoo/widget_password.cpp b/engines/sherlock/tattoo/widget_password.cpp
index fd35a555ab3..b6f75cd8a3e 100644
--- a/engines/sherlock/tattoo/widget_password.cpp
+++ b/engines/sherlock/tattoo/widget_password.cpp
@@ -24,6 +24,8 @@
#include "sherlock/tattoo/tattoo_fixed_text.h"
#include "sherlock/tattoo/tattoo_user_interface.h"
+#include "backends/keymapper/keymapper.h"
+
namespace Sherlock {
namespace Tattoo {
@@ -67,6 +69,10 @@ void WidgetPassword::show() {
// Show the dialog
ui._menuMode = PASSWORD_MODE;
summonWindow();
+
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->getKeymap("tattoo")->setEnabled(false);
+ keymapper->getKeymap("tattoo-password")->setEnabled(true);
}
void WidgetPassword::handleEvents() {
@@ -74,10 +80,11 @@ void WidgetPassword::handleEvents() {
TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
Common::Point mousePos = events.mousePos();
const Common::KeyCode &keycode = ui._keyState.keycode;
+ Common::CustomEventType action = ui._action;
char currentChar = (_index == (int)_password.size()) ? ' ' : _password[_index];
int width = _surface.charWidth(currentChar);
- if (!keycode) {
+ if (!keycode && !action) {
// Nothing entered, so keep blinking the cursor
if (--_blinkCounter < 0) {
_blinkCounter = 3;
@@ -110,29 +117,29 @@ void WidgetPassword::handleEvents() {
_surface.fillRect(Common::Rect(_cursorPos.x, _cursorPos.y, _bounds.width() - 9, _cursorPos.y +
_surface.fontHeight() - 1), TRANSPARENCY);
_surface.writeString(_password.c_str() + _index, _cursorPos, COMMAND_HIGHLIGHTED);
- } else if ((keycode == Common::KEYCODE_LEFT && _index > 0)
- || (keycode == Common::KEYCODE_RIGHT && _index < (int)_password.size() && _cursorPos.x < (_bounds.width() - _surface.widestChar() - 3))
- || (keycode == Common::KEYCODE_HOME && _index > 0)
- || (keycode == Common::KEYCODE_END)) {
+ } else if ((action == kActionTattooPasswordLeft && _index > 0)
+ || (action == kActionTattooPasswordRight && _index < (int)_password.size() && _cursorPos.x < (_bounds.width() - _surface.widestChar() - 3))
+ || (action == kActionTattooPasswordStart && _index > 0)
+ || (action == kActionTattooPasswordEnd)) {
// Restore character the cursor was previously over
_surface.fillRect(Common::Rect(_cursorPos.x, _cursorPos.y, _cursorPos.x + width, _cursorPos.y + _surface.fontHeight()), TRANSPARENCY);
if (currentChar != ' ')
_surface.writeString(Common::String::format("%c", _password[_index]), _cursorPos, COMMAND_HIGHLIGHTED);
- switch (keycode) {
- case Common::KEYCODE_LEFT:
+ switch (action) {
+ case kActionTattooPasswordLeft:
_cursorPos.x -= _surface.charWidth(_password[_index - 1]);
--_index;
break;
- case Common::KEYCODE_RIGHT:
+ case kActionTattooPasswordRight:
_cursorPos.x += _surface.charWidth(_password[_index]);
++_index;
break;
- case Common::KEYCODE_HOME:
+ case kActionTattooPasswordStart:
_cursorPos.x = _surface.widestChar();
_index = 0;
break;
- case Common::KEYCODE_END:
+ case kActionTattooPasswordEnd:
_cursorPos.x = _surface.stringWidth(_password) + _surface.widestChar();
_index = _password.size();
@@ -144,7 +151,7 @@ void WidgetPassword::handleEvents() {
default:
break;
}
- } else if (keycode == Common::KEYCODE_INSERT) {
+ } else if (action == kActionTattooPasswordToggleInsertMode) {
_insert = !_insert;
_cursorColor = _insert ? 192 : 200;
} else if (keycode == Common::KEYCODE_DELETE) {
@@ -187,6 +194,10 @@ void WidgetPassword::handleEvents() {
void WidgetPassword::close() {
Talk &talk = *_vm->_talk;
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->getKeymap("tattoo-password")->setEnabled(false);
+ keymapper->getKeymap("tattoo")->setEnabled(true);
+
banishWindow();
if (talk._talkToAbort)
return;
diff --git a/engines/sherlock/tattoo/widget_quit.cpp b/engines/sherlock/tattoo/widget_quit.cpp
index e5c92dbf307..b8ca8ec6b0d 100644
--- a/engines/sherlock/tattoo/widget_quit.cpp
+++ b/engines/sherlock/tattoo/widget_quit.cpp
@@ -24,6 +24,8 @@
#include "sherlock/tattoo/tattoo_fixed_text.h"
#include "sherlock/tattoo/tattoo_user_interface.h"
+#include "backends/keymapper/keymapper.h"
+
namespace Sherlock {
namespace Tattoo {
@@ -71,16 +73,23 @@ void WidgetQuit::show() {
ui._menuMode = QUIT_MODE;
summonWindow();
+
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->getKeymap("tattoo")->setEnabled(false);
+ keymapper->getKeymap("tattoo-quit-dialog")->setEnabled(true);
}
void WidgetQuit::handleEvents() {
Events &events = *_vm->_events;
Talk &talk = *_vm->_talk;
+ TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
Common::Point mousePos = events.mousePos();
Common::Rect yesRect(_bounds.left, _bounds.top + (_surface.fontHeight() + 4) * 2 + 3, _bounds.right,
_bounds.top + (_surface.fontHeight() + 4) * 2 + 3 + _surface.fontHeight() + 7);
Common::Rect noRect(_bounds.left, _bounds.top + (_surface.fontHeight() + 4) * 2 + _surface.fontHeight() + 10,
_bounds.right, _bounds.top + (_surface.fontHeight() + 4) * 2 + 10 + _surface.fontHeight() * 2 + 7);
+ Common::CustomEventType action = ui._action;
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
if (talk._talkToAbort)
return;
@@ -92,11 +101,10 @@ void WidgetQuit::handleEvents() {
else if (noRect.contains(mousePos))
_select = 0;
- if (events.kbHit()) {
- Common::KeyState keyState = events.getKey();
+ if (action != kActionNone) {
- switch (keyState.keycode) {
- case Common::KEYCODE_TAB:
+ switch (action) {
+ case kActionTattooQuitDialogNextOption:
// If the mouse is not over any of the options, move the mouse so that it points to the first option
if (_select == -1)
events.warpMouse(Common::Point(_bounds.right - 10, _bounds.top + (_surface.fontHeight() + 4) * 2
@@ -109,12 +117,15 @@ void WidgetQuit::handleEvents() {
+ 3 + _surface.fontHeight() + 1));
break;
- case Common::KEYCODE_ESCAPE:
- case Common::KEYCODE_n:
+ case kActionTattooQuitDialogNo:
+ keymapper->getKeymap("tattoo-quit-dialog")->setEnabled(false);
+ keymapper->getKeymap("tattoo")->setEnabled(true);
close();
return;
- case Common::KEYCODE_y:
+ case kActionTattooQuitDialogYes:
+ keymapper->getKeymap("tattoo-quit-dialog")->setEnabled(false);
+ keymapper->getKeymap("tattoo")->setEnabled(true);
close();
_vm->quitGame();
break;
@@ -142,6 +153,9 @@ void WidgetQuit::handleEvents() {
if (events._released || events._rightReleased) {
events.clearEvents();
+ keymapper->getKeymap("tattoo-options")->setEnabled(false);
+ keymapper->getKeymap("tattoo-exit")->setEnabled(false);
+ keymapper->getKeymap("tattoo")->setEnabled(true);
close();
if (_select == 1)
// Yes selected
diff --git a/engines/sherlock/tattoo/widget_talk.cpp b/engines/sherlock/tattoo/widget_talk.cpp
index e7d07cc4359..281b7db2b0e 100644
--- a/engines/sherlock/tattoo/widget_talk.cpp
+++ b/engines/sherlock/tattoo/widget_talk.cpp
@@ -28,6 +28,8 @@
#include "sherlock/tattoo/tattoo_user_interface.h"
#include "sherlock/tattoo/tattoo.h"
+#include "backends/keymapper/keymapper.h"
+
namespace Sherlock {
namespace Tattoo {
@@ -105,6 +107,12 @@ void WidgetTalk::load() {
// Form the background for the new window
makeInfoArea();
+
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->getKeymap("tattoo")->setEnabled(false);
+ keymapper->getKeymap("tattoo-scrolling")->setEnabled(true);
+ keymapper->getKeymap("tattoo-talk")->setEnabled(true);
+ keymapper->getKeymap("tattoo-exit")->setEnabled(true);
}
void WidgetTalk::handleEvents() {
@@ -117,6 +125,7 @@ void WidgetTalk::handleEvents() {
TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
Common::Point mousePos = events.mousePos();
Common::KeyCode keycode = ui._keyState.keycode;
+ Common::CustomEventType action = ui._action;
bool hotkey = false;
bool callParrotFile = false;
@@ -157,13 +166,13 @@ void WidgetTalk::handleEvents() {
}
// Check for the tab keys
- if (keycode == Common::KEYCODE_TAB && ui._scrollHighlight == SH_NONE) {
+ if ((action == kActionTattooTalkNext || action == kActionTattooTalkPrevious) && ui._scrollHighlight == SH_NONE) {
if (_selector == -1) {
_selector = _statementLines[_scroll ? _talkScrollIndex : 0]._num;
events.warpMouse(Common::Point(_bounds.right - BUTTON_SIZE - 10, _bounds.top + _surface.fontHeight() + 2));
} else {
- if (ui._keyState.flags & Common::KBD_SHIFT) {
+ if (action == kActionTattooTalkPrevious) {
_selector = (mousePos.y - _bounds.top - 5) / (_surface.fontHeight() + 1) + _talkScrollIndex;
if (_statementLines[_selector]._num == _statementLines[_talkScrollIndex]._num) {
_selector = (_bounds.height() - 10) / (_surface.fontHeight() + 1) + _talkScrollIndex;
@@ -220,14 +229,16 @@ void WidgetTalk::handleEvents() {
_oldSelector = _selector;
}
- if (events._released || events._rightReleased || keycode == Common::KEYCODE_ESCAPE || hotkey) {
+ if (events._released || events._rightReleased || action == kActionTattooExit || hotkey) {
events.clearEvents();
_dialogTimer = 0;
ui._scrollHighlight = SH_NONE;
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+
// See if they want to close the menu (click outside the window or Escape pressed)
- if ((_outsideMenu && !_bounds.contains(mousePos)) || keycode == Common::KEYCODE_ESCAPE) {
- if (keycode == Common::KEYCODE_ESCAPE)
+ if ((_outsideMenu && !_bounds.contains(mousePos)) || action == kActionTattooExit) {
+ if (action == kActionTattooExit)
_selector = -1;
talk.freeTalkVars();
@@ -243,6 +254,11 @@ void WidgetTalk::handleEvents() {
banishWindow();
ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE;
+ keymapper->getKeymap("tattoo-scrolling")->setEnabled(false);
+ keymapper->getKeymap("tattoo-talk")->setEnabled(false);
+ keymapper->getKeymap("tattoo-exit")->setEnabled(false);
+ keymapper->getKeymap("tattoo")->setEnabled(true);
+
if (scene._currentScene == WEARY_PUNT)
callParrotFile = true;
}
@@ -255,6 +271,11 @@ void WidgetTalk::handleEvents() {
journal.record(talk._converseNum, _selector);
talk._talkHistory[talk._converseNum][_selector] = true;
+ keymapper->getKeymap("tattoo-scrolling")->setEnabled(false);
+ keymapper->getKeymap("tattoo-talk")->setEnabled(false);
+ keymapper->getKeymap("tattoo-exit")->setEnabled(false);
+ keymapper->getKeymap("tattoo")->setEnabled(true);
+
banishWindow();
talk._speaker = _vm->readFlags(FLAG_PLAYER_IS_HOLMES) ? HOLMES : WATSON;
_scroll = false;
diff --git a/engines/sherlock/tattoo/widget_text.cpp b/engines/sherlock/tattoo/widget_text.cpp
index aafe7993f7f..d72e21fc725 100644
--- a/engines/sherlock/tattoo/widget_text.cpp
+++ b/engines/sherlock/tattoo/widget_text.cpp
@@ -210,14 +210,14 @@ void WidgetMessage::handleEvents() {
// Check if a mouse or keypress has occurred, or the display counter has expired
if (events._pressed || events._released || events._rightPressed || events._rightReleased ||
- ui._keyState.keycode || !_menuCounter) {
+ ui._keyState.keycode || !_menuCounter || ui._action) {
// Close the window
banishWindow();
// Reset cursor and switch back to standard mode
events.setCursor(ARROW);
events.clearEvents();
- ui._key = -1;
+ ui._action = kActionNone;
ui._oldBgFound = -1;
ui._menuMode = STD_MODE;
}
diff --git a/engines/sherlock/tattoo/widget_verbs.cpp b/engines/sherlock/tattoo/widget_verbs.cpp
index a1fa658662e..a61e0879f7a 100644
--- a/engines/sherlock/tattoo/widget_verbs.cpp
+++ b/engines/sherlock/tattoo/widget_verbs.cpp
@@ -26,6 +26,8 @@
#include "sherlock/tattoo/tattoo_people.h"
#include "sherlock/tattoo/tattoo.h"
+#include "backends/keymapper/keymapper.h"
+
namespace Sherlock {
namespace Tattoo {
@@ -51,6 +53,10 @@ void WidgetVerbs::load(bool objectsOn) {
_verbCommands.clear();
_selector = _oldSelector = -1;
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
+ keymapper->getKeymap("tattoo")->setEnabled(false);
+ keymapper->getKeymap("tattoo-exit")->setEnabled(true);
+
// Check if we need to show options for the highlighted object
if (objectsOn) {
// Set the verb list accordingly, depending on the target being a
@@ -156,6 +162,7 @@ void WidgetVerbs::handleEvents() {
Talk &talk = *_vm->_talk;
TattooUserInterface &ui = *(TattooUserInterface *)_vm->_ui;
Common::Point mousePos = events.mousePos();
+ Common::Keymapper *keymapper = g_system->getEventManager()->getKeymapper();
Common::String strLook = fixedText.getText(kFixedText_Look);
Common::String strTalk = fixedText.getText(kFixedText_Talk);
@@ -199,6 +206,9 @@ void WidgetVerbs::handleEvents() {
banishWindow();
events.clearEvents();
+ keymapper->getKeymap("tattoo-exit")->setEnabled(false);
+ keymapper->getKeymap("tattoo")->setEnabled(true);
+
// Reset the active UI mode
ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE;
}
@@ -209,6 +219,9 @@ void WidgetVerbs::handleEvents() {
banishWindow();
events.clearEvents();
+ keymapper->getKeymap("tattoo-exit")->setEnabled(false);
+ keymapper->getKeymap("tattoo")->setEnabled(true);
+
// See if they are activating the Look Command
if (!_verbCommands[_selector].compareToIgnoreCase(strLook)) {
ui._bgFound = ui._activeObj;
@@ -275,10 +288,13 @@ void WidgetVerbs::handleEvents() {
}
}
}
- } else if (ui._keyState.keycode == Common::KEYCODE_ESCAPE) {
- // User closing the menu with the ESC key
+ } else if (ui._action == kActionTattooExit) {
+ // User closing the menu with the exit action
banishWindow();
ui._menuMode = scene._labTableScene ? LAB_MODE : STD_MODE;
+
+ keymapper->getKeymap("tattoo-exit")->setEnabled(false);
+ keymapper->getKeymap("tattoo")->setEnabled(true);
}
}
diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp
index d0ec2609b51..0d03ef9122c 100644
--- a/engines/sherlock/user_interface.cpp
+++ b/engines/sherlock/user_interface.cpp
@@ -48,7 +48,8 @@ UserInterface::UserInterface(SherlockEngine *vm) : _vm(vm) {
_exitZone = -1;
_bgFound = _oldBgFound = -1;
- _key = _oldKey = '\0';
+ _key = '\0';
+ _action = kActionNone;
_selector = _oldSelector = -1;
_temp = _oldTemp = 0;
_temp1 = 0;
@@ -199,7 +200,7 @@ void UserInterface::checkAction(ActionType &action, int objNum, FixedTextActionI
void UserInterface::reset() {
_bgFound = _oldBgFound = -1;
- _oldKey = -1;
+ _oldAction = kActionNone;
_oldTemp = _temp = -1;
_exitZone = -1;
}
diff --git a/engines/sherlock/user_interface.h b/engines/sherlock/user_interface.h
index 56e53ce07ee..a65b794c6f5 100644
--- a/engines/sherlock/user_interface.h
+++ b/engines/sherlock/user_interface.h
@@ -80,7 +80,8 @@ public:
// TODO: Not so sure these should be in the base class. May want to refactor them to SherlockEngine, or refactor
// various Scalpel dialogs to keep their own private state of key/selections
- signed char _key, _oldKey;
+ signed char _key;
+ Common::CustomEventType _action, _oldAction;
int _selector, _oldSelector;
int _temp, _oldTemp;
int _temp1;
More information about the Scummvm-git-logs
mailing list