diff options
author | Paul Gilbert | 2015-04-22 02:32:25 -0500 |
---|---|---|
committer | Paul Gilbert | 2015-04-22 02:32:25 -0500 |
commit | e08520cca94f33cb69ee8058cb08e400e5443016 (patch) | |
tree | 0a24c469075b9facf4b57273dbcf971e81f8e60a /engines/sherlock | |
parent | 0984405a0dbe718522117507d7c75dc619c586a8 (diff) | |
download | scummvm-rg350-e08520cca94f33cb69ee8058cb08e400e5443016.tar.gz scummvm-rg350-e08520cca94f33cb69ee8058cb08e400e5443016.tar.bz2 scummvm-rg350-e08520cca94f33cb69ee8058cb08e400e5443016.zip |
SHERLOCK: Fix Files saves listing and save name entry
Diffstat (limited to 'engines/sherlock')
-rw-r--r-- | engines/sherlock/saveload.cpp | 96 | ||||
-rw-r--r-- | engines/sherlock/user_interface.cpp | 17 |
2 files changed, 102 insertions, 11 deletions
diff --git a/engines/sherlock/saveload.cpp b/engines/sherlock/saveload.cpp index 0cdf1d228f..57a4a65b21 100644 --- a/engines/sherlock/saveload.cpp +++ b/engines/sherlock/saveload.cpp @@ -45,6 +45,7 @@ SaveManager::SaveManager(SherlockEngine *vm, const Common::String &target) : _saveThumb = nullptr; _envMode = SAVEMODE_NONE; _justLoaded = false; + _savegameIndex = 0; } SaveManager::~SaveManager() { @@ -94,7 +95,7 @@ void SaveManager::drawInterface() { screen.gPrint(Common::Point(6, CONTROLS_Y + 11 + (idx - _savegameIndex) * 10), INV_FOREGROUND, "%d.", idx + 1); screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (idx - _savegameIndex) * 10), - INV_FOREGROUND, "%s", _savegames[idx]); + INV_FOREGROUND, "%s", _savegames[idx].c_str()); } if (!ui._windowStyle) { @@ -114,7 +115,7 @@ void SaveManager::createSavegameList() { _savegames.clear(); for (int idx = 0; idx < MAX_SAVEGAME_SLOTS; ++idx) - _savegames.push_back("-EMPTY"); + _savegames.push_back("-EMPTY-"); SaveStateList saveList = getSavegameList(_target); for (uint idx = 0; idx < saveList.size(); ++idx) @@ -420,8 +421,95 @@ bool SaveManager::checkGameOnScreen(int slot) { } bool SaveManager::getFilename(int slot) { - // TODO - return false; + Events &events = *_vm->_events; + Scene &scene = *_vm->_scene; + Screen &screen = *_vm->_screen; + Talk &talk = *_vm->_talk; + int xp, yp; + bool flag = false; + + screen.buttonPrint(Common::Point(ENV_POINTS[0][2], CONTROLS_Y), COMMAND_NULL, true, "Exit"); + screen.buttonPrint(Common::Point(ENV_POINTS[1][2], CONTROLS_Y), COMMAND_NULL, true, "Load"); + screen.buttonPrint(Common::Point(ENV_POINTS[2][2], CONTROLS_Y), COMMAND_NULL, true, "Save"); + screen.buttonPrint(Common::Point(ENV_POINTS[3][2], CONTROLS_Y), COMMAND_NULL, true, "Up"); + screen.buttonPrint(Common::Point(ENV_POINTS[4][2], CONTROLS_Y), COMMAND_NULL, true, "Down"); + screen.buttonPrint(Common::Point(ENV_POINTS[5][2], CONTROLS_Y), COMMAND_NULL, true, "Quit"); + + Common::String saveName = _savegames[slot]; + if (scumm_stricmp(saveName.c_str(), "-EMPTY-") == 0) { + // It's an empty slot, so start off with an empty save name + saveName = ""; + + yp = CONTROLS_Y + 12 + (slot - _savegameIndex) * 10; + screen.vgaBar(Common::Rect(24, yp, 85, yp + 9), INV_BACKGROUND); + } + + screen.print(Common::Point(6, CONTROLS_Y + 12 + (slot - _savegameIndex) * 10), TALK_FOREGROUND, "%d.", slot + 1); + screen.print(Common::Point(24, CONTROLS_Y + 12 + (slot - _savegameIndex) * 10), TALK_FOREGROUND, "%s", saveName.c_str()); + xp = 24 + screen.stringWidth(saveName); + yp = CONTROLS_Y + 12 + (slot - _savegameIndex) * 10; + + int done = 0; + do { + while (!_vm->shouldQuit() && !events.kbHit()) { + scene.doBgAnim(); + + if (talk._talkToAbort) + return false; + + // Allow event processing + events.pollEventsAndWait(); + events.setButtonState(); + + flag = !flag; + if (flag) + screen.vgaBar(Common::Rect(xp, yp - 1, xp + 8, yp + 9), INV_FOREGROUND); + else + screen.vgaBar(Common::Rect(xp, yp - 1, xp + 8, yp + 9), INV_BACKGROUND); + } + if (_vm->shouldQuit()) + return false; + + // Get the next keypress + Common::KeyState keyState = events.getKey(); + + if (keyState.keycode == Common::KEYCODE_BACKSPACE && saveName.size() > 0) { + // Delete character of save name + screen.vgaBar(Common::Rect(xp - screen.charWidth(saveName.lastChar()), yp - 1, + xp + 8, yp + 9), INV_BACKGROUND); + xp -= screen.charWidth(saveName.lastChar()); + screen.vgaBar(Common::Rect(xp, yp - 1, xp + 8, yp + 9), INV_FOREGROUND); + saveName.deleteLastChar(); + } + + if (keyState.keycode == Common::KEYCODE_RETURN) + done = 1; + + if (keyState.keycode == Common::KEYCODE_ESCAPE) { + screen.vgaBar(Common::Rect(xp, yp - 1, xp + 8, yp + 9), INV_BACKGROUND); + done = -1; + } + + if (keyState.keycode >= ' ' && keyState.keycode <= 'z' && saveName.size() < 50 + && (xp + screen.charWidth(keyState.keycode)) < 308) { + 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.vgaBar(Common::Rect(xp, yp - 1, xp + 8, yp + 9), INV_FOREGROUND); + saveName += (char)keyState.keycode; + } + } while (!done); + + if (done == 1) { + // Enter key perssed + _savegames[slot] = saveName; + } else { + done = 0; + _envMode = SAVEMODE_NONE; + highlightButtons(-1); + } + + return done == 1; } } // End of namespace Sherlock diff --git a/engines/sherlock/user_interface.cpp b/engines/sherlock/user_interface.cpp index f7f387e9ad..f95277df91 100644 --- a/engines/sherlock/user_interface.cpp +++ b/engines/sherlock/user_interface.cpp @@ -331,13 +331,16 @@ void UserInterface::handleInput() { // Otherwise, the pressed _key is stored for later use if (events.kbHit()) { Common::KeyState keyState = events.getKey(); + _keycode = keyState.keycode; if (keyState.keycode == Common::KEYCODE_x && keyState.flags & Common::KBD_ALT) { _vm->quitGame(); + events.pollEvents(); return; } else if (keyState.keycode == Common::KEYCODE_SPACE || keyState.keycode == Common::KEYCODE_RETURN) { - events._pressed = events._oldButtons = 0; + events._pressed = false; + events._oldButtons = 0; _keycode = Common::KEYCODE_INVALID; } } @@ -963,16 +966,16 @@ void UserInterface::doEnvControl() { if (_selector != _oldSelector) { if (_oldSelector != -1 && _oldSelector >= saves._savegameIndex && _oldSelector < (saves._savegameIndex + 5)) { screen.print(Common::Point(6, CONTROLS_Y + 12 + (_oldSelector - saves._savegameIndex) * 10), - INV_FOREGROUND, 0, "%d.", _oldSelector + 1); + INV_FOREGROUND, "%d.", _oldSelector + 1); screen.print(Common::Point(24, CONTROLS_Y + 12 + (_oldSelector - saves._savegameIndex) * 10), - INV_FOREGROUND, 0, "%s", saves._savegames[_oldSelector]); + INV_FOREGROUND, "%s", saves._savegames[_oldSelector]); } if (_selector != -1) { screen.print(Common::Point(6, CONTROLS_Y + 12 + (_selector - saves._savegameIndex) * 10), - TALK_FOREGROUND, 0, "%d.", _selector + 1); + TALK_FOREGROUND, "%d.", _selector + 1); screen.print(Common::Point(24, CONTROLS_Y + 12 + (_selector - saves._savegameIndex) * 10), - TALK_FOREGROUND, 0, "%s", saves._savegames[_selector]); + TALK_FOREGROUND, "%s", saves._savegames[_selector].c_str()); } _oldSelector = _selector; @@ -1031,7 +1034,7 @@ void UserInterface::doEnvControl() { color = TALK_FOREGROUND; screen.gPrint(Common::Point(6, CONTROLS_Y + 11 + (idx - saves._savegameIndex) * 10), color, "%d.", idx + 1); - screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (idx - saves._savegameIndex) * 10), color, "%s", saves._savegames[idx]); + screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (idx - saves._savegameIndex) * 10), color, "%s", saves._savegames[idx].c_str()); } screen.slamRect(Common::Rect(3, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, SHERLOCK_SCREEN_HEIGHT)); @@ -1066,7 +1069,7 @@ void UserInterface::doEnvControl() { screen.gPrint(Common::Point(6, CONTROLS_Y + 11 + (idx - saves._savegameIndex) * 10), color, "%d.", idx + 1); screen.gPrint(Common::Point(24, CONTROLS_Y + 11 + (idx - saves._savegameIndex) * 10), color, - "%s", saves._savegames[idx]); + "%s", saves._savegames[idx].c_str()); } screen.slamRect(Common::Rect(3, CONTROLS_Y + 11, SHERLOCK_SCREEN_WIDTH - 2, SHERLOCK_SCREEN_HEIGHT)); |