aboutsummaryrefslogtreecommitdiff
path: root/engines/hugo/parser.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'engines/hugo/parser.cpp')
-rw-r--r--engines/hugo/parser.cpp147
1 files changed, 147 insertions, 0 deletions
diff --git a/engines/hugo/parser.cpp b/engines/hugo/parser.cpp
index 9836861bca..8db43e7ef3 100644
--- a/engines/hugo/parser.cpp
+++ b/engines/hugo/parser.cpp
@@ -31,12 +31,15 @@
*/
#include "common/system.h"
+#include "common/events.h"
#include "hugo/hugo.h"
+#include "hugo/display.h"
#include "hugo/parser.h"
#include "hugo/file.h"
#include "hugo/schedule.h"
#include "hugo/util.h"
+#include "hugo/route.h"
#include "hugo/sound.h"
#include "hugo/object.h"
@@ -53,6 +56,10 @@ Parser::Parser(HugoEngine *vm) :
Parser::~Parser() {
}
+void Parser::switchTurbo() {
+ _config.turboFl = !_config.turboFl;
+}
+
/**
* Add any new chars to line buffer and display them.
* If CR pressed, pass line to LineHandler()
@@ -121,6 +128,146 @@ void Parser::charHandler() {
}
}
+void Parser::keyHandler(Common::Event event) {
+ debugC(1, kDebugParser, "keyHandler(%d)", event.kbd.keycode);
+
+ status_t &gameStatus = _vm->getGameStatus();
+ uint16 nChar = event.kbd.keycode;
+
+ // Process key down event - called from OnKeyDown()
+ switch (nChar) { // Set various toggle states
+ case Common::KEYCODE_ESCAPE: // Escape key, may want to QUIT
+ if (gameStatus.inventoryState == I_ACTIVE) // Remove inventory, if displayed
+ gameStatus.inventoryState = I_UP;
+ gameStatus.inventoryObjId = -1; // Deselect any dragged icon
+ break;
+ case Common::KEYCODE_END:
+ case Common::KEYCODE_HOME:
+ case Common::KEYCODE_PAGEUP:
+ case Common::KEYCODE_PAGEDOWN:
+ case Common::KEYCODE_KP1:
+ case Common::KEYCODE_KP7:
+ case Common::KEYCODE_KP9:
+ case Common::KEYCODE_KP3:
+ case Common::KEYCODE_LEFT:
+ case Common::KEYCODE_RIGHT:
+ case Common::KEYCODE_UP:
+ case Common::KEYCODE_DOWN:
+ case Common::KEYCODE_KP4:
+ case Common::KEYCODE_KP6:
+ case Common::KEYCODE_KP8:
+ case Common::KEYCODE_KP2:
+ gameStatus.routeIndex = -1; // Stop any automatic route
+ _vm->_route->setWalk(nChar); // Direction of hero travel
+ break;
+ case Common::KEYCODE_F1: // User Help (DOS)
+ if (_checkDoubleF1Fl)
+ _vm->_file->instructions();
+ else
+ _vm->_screen->userHelp();
+ _checkDoubleF1Fl = !_checkDoubleF1Fl;
+ break;
+ case Common::KEYCODE_F2: // Toggle sound
+ _vm->_sound->toggleSound();
+ _vm->_sound->toggleMusic();
+ break;
+ case Common::KEYCODE_F3: // Repeat last line
+ gameStatus.recallFl = true;
+ break;
+ case Common::KEYCODE_F4: // Save game
+ if (gameStatus.viewState == V_PLAY) {
+ if (gameStatus.gameOverFl)
+ Utils::gameOverMsg();
+ else
+ _vm->_file->saveGame(-1, Common::String());
+ }
+ break;
+ case Common::KEYCODE_F5: // Restore game
+ _vm->_file->restoreGame(-1);
+ _vm->_scheduler->restoreScreen(*_vm->_screen_p);
+ gameStatus.viewState = V_PLAY;
+ break;
+ case Common::KEYCODE_F6: // Inventory
+ showInventory();
+ break;
+ case Common::KEYCODE_F8: // Turbo mode
+ switchTurbo();
+ break;
+ case Common::KEYCODE_F9: // Boss button
+ warning("STUB: F9 (DOS) - BossKey");
+ break;
+ case Common::KEYCODE_l:
+ if (event.kbd.hasFlags(Common::KBD_CTRL)) {
+ _vm->_file->restoreGame(-1);
+ _vm->_scheduler->restoreScreen(*_vm->_screen_p);
+ gameStatus.viewState = V_PLAY;
+ } else {
+ if (!gameStatus.storyModeFl) { // Keyboard disabled
+ // Add printable keys to ring buffer
+ uint16 bnext = _putIndex + 1;
+ if (bnext >= sizeof(_ringBuffer))
+ bnext = 0;
+ if (bnext != _getIndex) {
+ _ringBuffer[_putIndex] = event.kbd.ascii;
+ _putIndex = bnext;
+ }
+ }
+ }
+ break;
+ case Common::KEYCODE_n:
+ if (event.kbd.hasFlags(Common::KBD_CTRL)) {
+ warning("STUB: CTRL-N (WIN) - New Game");
+ } else {
+ if (!gameStatus.storyModeFl) { // Keyboard disabled
+ // Add printable keys to ring buffer
+ uint16 bnext = _putIndex + 1;
+ if (bnext >= sizeof(_ringBuffer))
+ bnext = 0;
+ if (bnext != _getIndex) {
+ _ringBuffer[_putIndex] = event.kbd.ascii;
+ _putIndex = bnext;
+ }
+ }
+ }
+ break;
+ case Common::KEYCODE_s:
+ if (event.kbd.hasFlags(Common::KBD_CTRL)) {
+ if (gameStatus.viewState == V_PLAY) {
+ if (gameStatus.gameOverFl)
+ Utils::gameOverMsg();
+ else
+ _vm->_file->saveGame(-1, Common::String());
+ }
+ } else {
+ if (!gameStatus.storyModeFl) { // Keyboard disabled
+ // Add printable keys to ring buffer
+ uint16 bnext = _putIndex + 1;
+ if (bnext >= sizeof(_ringBuffer))
+ bnext = 0;
+ if (bnext != _getIndex) {
+ _ringBuffer[_putIndex] = event.kbd.ascii;
+ _putIndex = bnext;
+ }
+ }
+ }
+ break;
+ default: // Any other key
+ if (!gameStatus.storyModeFl) { // Keyboard disabled
+ // Add printable keys to ring buffer
+ uint16 bnext = _putIndex + 1;
+ if (bnext >= sizeof(_ringBuffer))
+ bnext = 0;
+ if (bnext != _getIndex) {
+ _ringBuffer[_putIndex] = event.kbd.ascii;
+ _putIndex = bnext;
+ }
+ }
+ break;
+ }
+ if (_checkDoubleF1Fl && (nChar != Common::KEYCODE_F1))
+ _checkDoubleF1Fl = false;
+}
+
/**
* Perform an immediate command. Takes parameters a la sprintf
* Assumes final string will not overrun line[] length