diff options
author | Paul Gilbert | 2015-04-22 04:44:55 -0500 |
---|---|---|
committer | Paul Gilbert | 2015-04-22 04:44:55 -0500 |
commit | 27938653a5cd05856da88142f52de44f30e26eef (patch) | |
tree | d0c1e0fed90fd9a5aacd41f3de16c52403f3d7d6 | |
parent | e08520cca94f33cb69ee8058cb08e400e5443016 (diff) | |
download | scummvm-rg350-27938653a5cd05856da88142f52de44f30e26eef.tar.gz scummvm-rg350-27938653a5cd05856da88142f52de44f30e26eef.tar.bz2 scummvm-rg350-27938653a5cd05856da88142f52de44f30e26eef.zip |
SHERLOCK: Further fixes for entering savegame names
-rw-r--r-- | engines/sherlock/events.cpp | 12 | ||||
-rw-r--r-- | engines/sherlock/events.h | 2 | ||||
-rw-r--r-- | engines/sherlock/saveload.cpp | 18 | ||||
-rw-r--r-- | engines/sherlock/user_interface.cpp | 10 | ||||
-rw-r--r-- | engines/sherlock/user_interface.h | 2 |
5 files changed, 32 insertions, 12 deletions
diff --git a/engines/sherlock/events.cpp b/engines/sherlock/events.cpp index 1a827eda3b..f7b473ff7a 100644 --- a/engines/sherlock/events.cpp +++ b/engines/sherlock/events.cpp @@ -197,6 +197,18 @@ bool Events::checkForNextFrameCounter() { } /** + * Get a pending keypress + */ +Common::KeyState Events::getKey() { + Common::KeyState keyState = _pendingKeys.pop(); + if ((keyState.flags & Common::KBD_SHIFT) != 0) + keyState.ascii = toupper(keyState.ascii); + + return keyState; +} + + +/** * Clear any current keypress or mouse click */ void Events::clearEvents() { diff --git a/engines/sherlock/events.h b/engines/sherlock/events.h index ccf6eb1c59..015c39580d 100644 --- a/engines/sherlock/events.h +++ b/engines/sherlock/events.h @@ -85,7 +85,7 @@ public: bool kbHit() const { return !_pendingKeys.empty(); } - Common::KeyState getKey() { return _pendingKeys.pop(); } + Common::KeyState getKey(); void clearEvents(); void clearKeyboard(); diff --git a/engines/sherlock/saveload.cpp b/engines/sherlock/saveload.cpp index 57a4a65b21..cd7627a768 100644 --- a/engines/sherlock/saveload.cpp +++ b/engines/sherlock/saveload.cpp @@ -118,8 +118,11 @@ void SaveManager::createSavegameList() { _savegames.push_back("-EMPTY-"); SaveStateList saveList = getSavegameList(_target); - for (uint idx = 0; idx < saveList.size(); ++idx) - _savegames[saveList[idx].getSaveSlot()] = saveList[idx].getDescription(); + for (uint idx = 0; idx < saveList.size(); ++idx) { + int slot = saveList[idx].getSaveSlot() - 1; + if (slot >= 0 && slot < MAX_SAVEGAME_SLOTS) + _savegames[slot] = saveList[idx].getDescription(); + } // Ensure the names will fit on the screen for (uint idx = 0; idx < _savegames.size(); ++idx) { @@ -312,6 +315,9 @@ void SaveManager::highlightButtons(int btnIndex) { void SaveManager::loadGame(int slot) { Common::InSaveFile *saveFile = g_system->getSavefileManager()->openForLoading( generateSaveName(slot)); + if (!saveFile) + return; + Common::Serializer s(saveFile, nullptr); // Load the savaegame header @@ -492,11 +498,13 @@ bool SaveManager::getFilename(int slot) { if (keyState.keycode >= ' ' && keyState.keycode <= 'z' && saveName.size() < 50 && (xp + screen.charWidth(keyState.keycode)) < 308) { + char c = (char)keyState.ascii; + screen.vgaBar(Common::Rect(xp, yp - 1, xp + 8, yp + 9), INV_BACKGROUND); - screen.print(Common::Point(xp, yp), TALK_FOREGROUND, "%c", (char)keyState.keycode); - xp += screen.charWidth((char)keyState.keycode); + screen.print(Common::Point(xp, yp), TALK_FOREGROUND, "%c", c); + xp += screen.charWidth(c); screen.vgaBar(Common::Rect(xp, yp - 1, xp + 8, yp + 9), INV_FOREGROUND); - saveName += (char)keyState.keycode; + saveName += c; } } while (!done); diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index f95277df91..cb10606562 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -331,7 +331,7 @@ void UserInterface::handleInput() { // Otherwise, the pressed _key is stored for later use if (events.kbHit()) { Common::KeyState keyState = events.getKey(); - _keycode = keyState.keycode; + _keycode = keyState.ascii; if (keyState.keycode == Common::KEYCODE_x && keyState.flags & Common::KBD_ALT) { _vm->quitGame(); @@ -968,7 +968,7 @@ void UserInterface::doEnvControl() { screen.print(Common::Point(6, CONTROLS_Y + 12 + (_oldSelector - saves._savegameIndex) * 10), INV_FOREGROUND, "%d.", _oldSelector + 1); screen.print(Common::Point(24, CONTROLS_Y + 12 + (_oldSelector - saves._savegameIndex) * 10), - INV_FOREGROUND, "%s", saves._savegames[_oldSelector]); + INV_FOREGROUND, "%s", saves._savegames[_oldSelector].c_str()); } if (_selector != -1) { @@ -1014,7 +1014,7 @@ void UserInterface::doEnvControl() { screen.gPrint(Common::Point(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10), INV_FOREGROUND, "%d.", _selector + 1); screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10), INV_FOREGROUND, - "%s", saves._savegames[_selector]); + "%s", saves._savegames[_selector].c_str()); screen.slamArea(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10, 311, 10); _selector = _oldSelector = -1; @@ -1180,9 +1180,9 @@ void UserInterface::doEnvControl() { screen._backBuffer1.fillRect(Common::Rect(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10, 317, CONTROLS_Y + 20 + (_selector - saves._savegameIndex) * 10), INV_BACKGROUND); screen.gPrint(Common::Point(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10), - INV_FOREGROUND, 0, "%d.", _selector + 1); + INV_FOREGROUND, "%d.", _selector + 1); screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10), - INV_FOREGROUND, 0, "%s", saves._savegames[_selector]); + INV_FOREGROUND, "%s", saves._savegames[_selector].c_str()); screen.slamArea(6, CONTROLS_Y + 11 + (_selector - saves._savegameIndex) * 10, 311, 10); _selector = _oldSelector = -1; } diff --git a/engines/sherlock/user_interface.h b/engines/sherlock/user_interface.h index 12470357e5..99612b218b 100644 --- a/engines/sherlock/user_interface.h +++ b/engines/sherlock/user_interface.h @@ -84,7 +84,7 @@ private: ImageFile *_controls; int _bgFound; int _oldBgFound; - Common::KeyCode _keycode; + int _keycode; int _helpStyle; int _lookHelp; int _help, _oldHelp; |