diff options
Diffstat (limited to 'engines/hugo')
29 files changed, 156 insertions, 81 deletions
diff --git a/engines/hugo/detection.cpp b/engines/hugo/detection.cpp index e862e339ce..95302c9235 100644 --- a/engines/hugo/detection.cpp +++ b/engines/hugo/detection.cpp @@ -26,6 +26,7 @@ #include "engines/advancedDetector.h" #include "common/system.h" #include "common/savefile.h" +#include "common/textconsole.h" #include "graphics/thumbnail.h" #include "graphics/surface.h" diff --git a/engines/hugo/dialogs.cpp b/engines/hugo/dialogs.cpp index ead432c5df..f0dc84eae8 100644 --- a/engines/hugo/dialogs.cpp +++ b/engines/hugo/dialogs.cpp @@ -26,6 +26,7 @@ #include "common/substream.h" #include "graphics/imagedec.h" #include "gui/gui-manager.h" +#include "gui/ThemeEval.h" #include "hugo/hugo.h" #include "hugo/display.h" @@ -132,7 +133,7 @@ void TopMenu::loadBmpArr(Common::SeekableReadStream &in) { Common::SeekableSubReadStream stream(&in, filPos, filPos + bmpSize); arrayBmp[i * 2] = Graphics::ImageDecoder::loadFile(stream, g_system->getOverlayFormat()); arrayBmp[i * 2 + 1] = new Graphics::Surface(); - arrayBmp[i * 2 + 1]->create(arrayBmp[i * 2]->w * 2, arrayBmp[i * 2]->h * 2, arrayBmp[i * 2]->bytesPerPixel); + arrayBmp[i * 2 + 1]->create(arrayBmp[i * 2]->w * 2, arrayBmp[i * 2]->h * 2, g_system->getOverlayFormat()); byte *src = (byte *)arrayBmp[i * 2]->pixels; byte *dst = (byte *)arrayBmp[i * 2 + 1]->pixels; @@ -140,12 +141,12 @@ void TopMenu::loadBmpArr(Common::SeekableReadStream &in) { src = (byte *)arrayBmp[i * 2]->getBasePtr(0, j); dst = (byte *)arrayBmp[i * 2 + 1]->getBasePtr(0, j * 2); for (int k = arrayBmp[i * 2]->w; k > 0; k--) { - for (int m = arrayBmp[i * 2]->bytesPerPixel; m > 0; m--) { + for (int m = arrayBmp[i * 2]->format.bytesPerPixel; m > 0; m--) { *dst++ = *src++; } - src -= arrayBmp[i * 2]->bytesPerPixel; + src -= arrayBmp[i * 2]->format.bytesPerPixel; - for (int m = arrayBmp[i * 2]->bytesPerPixel; m > 0; m--) { + for (int m = arrayBmp[i * 2]->format.bytesPerPixel; m > 0; m--) { *dst++ = *src++; } } @@ -164,7 +165,8 @@ void TopMenu::handleCommand(GUI::CommandSender *sender, uint32 command, uint32 d switch (command) { case kCmdWhat: close(); - _vm->_file->instructions(); + _vm->getGameStatus().helpFl = true; + break; case kCmdMusic: _vm->_sound->toggleMusic(); @@ -231,12 +233,52 @@ void TopMenu::handleMouseUp(int x, int y, int button, int clickCount) { } EntryDialog::EntryDialog(const Common::String &title, const Common::String &buttonLabel, const Common::String &defaultValue) : GUI::Dialog(20, 20, 100, 50) { - new GUI::StaticTextWidget(this, 0, 0, 10, 10, title, Graphics::kTextAlignCenter); - - _text = new GUI::EditTextWidget(this, 0, 0, 50, 10, ""); + const int screenW = g_system->getOverlayWidth(); + const int screenH = g_system->getOverlayHeight(); + + int buttonWidth = g_gui.xmlEval()->getVar("Globals.Button.Width", 0); + int buttonHeight = g_gui.xmlEval()->getVar("Globals.Button.Height", 0); + + // First, determine the size the dialog needs. For this we have to break + // down the string into lines, and taking the maximum of their widths. + // Using this, and accounting for the space the button(s) need, we can set + // the real size of the dialog + Common::Array<Common::String> lines; + int lineCount, buttonPos; + int maxlineWidth = g_gui.getFont().wordWrapText(title, screenW - 2 * 30, lines); + + // Calculate the desired dialog size (maxing out at 300*180 for now) + _w = MAX(maxlineWidth, buttonWidth) + 20; + + lineCount = lines.size(); + + _h = 16 + buttonHeight + 8; + + // Limit the number of lines so that the dialog still fits on the screen. + if (lineCount > (screenH - 20 - _h) / kLineHeight) { + lineCount = (screenH - 20 - _h) / kLineHeight; + } + _h += lineCount * kLineHeight; + + // Center the dialog + _x = (screenW - _w) / 2; + _y = (screenH - _h) / 2; + + // Each line is represented by one static text item. + for (int i = 0; i < lineCount; i++) { + new GUI::StaticTextWidget(this, 10, 10 + i * kLineHeight, maxlineWidth, kLineHeight, + lines[i], Graphics::kTextAlignCenter); + } + + _text = new GUI::EditTextWidget(this, 10, 10 + lineCount * (kLineHeight + 1), _w - 20, kLineHeight, "", "", 0, kCmdFinishEdit); _text->setEditString(defaultValue); - new GUI::ButtonWidget(this, 20, 20, 30, 10, buttonLabel, 0, kCmdButton); + _h += kLineHeight + 5; + + buttonPos = (_w - buttonWidth) / 2; + + new GUI::ButtonWidget(this, buttonPos, _h - buttonHeight - 8, buttonWidth, buttonHeight, buttonLabel, 0, kCmdButton, Common::ASCII_RETURN); // Confirm dialog + } EntryDialog::~EntryDialog() { @@ -245,6 +287,7 @@ EntryDialog::~EntryDialog() { void EntryDialog::handleCommand(GUI::CommandSender *sender, uint32 command, uint32 data) { switch (command) { case kCmdButton: + case kCmdFinishEdit: close(); break; default: @@ -252,11 +295,4 @@ void EntryDialog::handleCommand(GUI::CommandSender *sender, uint32 command, uint } } -void EntryDialog::reflowLayout() { -} - -void EntryDialog::init() { -} - - } // End of namespace Hugo diff --git a/engines/hugo/dialogs.h b/engines/hugo/dialogs.h index f870414a93..56dbd41f81 100644 --- a/engines/hugo/dialogs.h +++ b/engines/hugo/dialogs.h @@ -67,7 +67,8 @@ enum { kCmdInvent = 'INVT', // EntryDialog commands - kCmdButton = 'BTNP' + kCmdButton = 'BTNP', + kCmdFinishEdit = 'FNSH' }; class TopMenu : public GUI::Dialog { @@ -105,14 +106,11 @@ public: EntryDialog(const Common::String &title, const Common::String &buttonLabel, const Common::String &defaultValue); virtual ~EntryDialog(); - void reflowLayout(); void handleCommand(GUI::CommandSender *sender, uint32 command, uint32 data); const Common::String &getEditString() const { return _text->getEditString(); } protected: - void init(); - GUI::EditTextWidget *_text; }; diff --git a/engines/hugo/display.cpp b/engines/hugo/display.cpp index 333eb59707..af4d094ceb 100644 --- a/engines/hugo/display.cpp +++ b/engines/hugo/display.cpp @@ -32,8 +32,11 @@ // Display.c - DIB related code for HUGOWIN +#include "common/debug.h" #include "common/system.h" +#include "common/textconsole.h" #include "graphics/cursorman.h" +#include "graphics/palette.h" #include "hugo/hugo.h" #include "hugo/display.h" @@ -507,6 +510,9 @@ void Screen::drawStatusText() { sdx = stringLength(_vm->_scoreLine); posY = 0; + + //Display a black behind the score line + _vm->_screen->drawRectangle(true, 0, 0, kXPix, 8, _TBLACK); writeStr(posX, posY, _vm->_scoreLine, _TCYAN); displayList(kDisplayAdd, posX, posY, sdx, sdy); } diff --git a/engines/hugo/file.cpp b/engines/hugo/file.cpp index a0e3ff05ce..ba4e420111 100644 --- a/engines/hugo/file.cpp +++ b/engines/hugo/file.cpp @@ -30,8 +30,10 @@ * */ +#include "common/debug.h" #include "common/system.h" #include "common/savefile.h" +#include "common/textconsole.h" #include "common/config-manager.h" #include "graphics/thumbnail.h" #include "gui/saveload.h" @@ -298,7 +300,11 @@ sound_pt FileManager::getSound(const int16 sound, uint16 *size) { } if (!has_read_header) { - if (fp.read(s_hdr, sizeof(s_hdr)) != sizeof(s_hdr)) + for (int i = 0; i < kMaxSounds; i++) { + s_hdr[i].size = fp.readUint16LE(); + s_hdr[i].offset = fp.readUint32LE(); + } + if (fp.err()) error("Wrong sound file format"); has_read_header = true; } @@ -400,7 +406,7 @@ bool FileManager::saveGame(const int16 slot, const Common::String &descrip) { out->writeByte((gameStatus.gameOverFl) ? 1 : 0); // Save screen states - for (int i = 0; i < _vm->_numScreens; i++) + for (int i = 0; i < _vm->_numStates; i++) out->writeByte(_vm->_screenStates[i]); _vm->_scheduler->saveSchedulerData(out); @@ -497,7 +503,7 @@ bool FileManager::restoreGame(const int16 slot) { gameStatus.storyModeFl = (in->readByte() == 1); _vm->_mouse->setJumpExitFl(in->readByte() == 1); gameStatus.gameOverFl = (in->readByte() == 1); - for (int i = 0; i < _vm->_numScreens; i++) + for (int i = 0; i < _vm->_numStates; i++) _vm->_screenStates[i] = in->readByte(); _vm->_scheduler->restoreSchedulerData(in); diff --git a/engines/hugo/file_v1d.cpp b/engines/hugo/file_v1d.cpp index 48f274e88a..021969f306 100644 --- a/engines/hugo/file_v1d.cpp +++ b/engines/hugo/file_v1d.cpp @@ -30,7 +30,9 @@ * */ +#include "common/debug.h" #include "common/system.h" +#include "common/textconsole.h" #include "hugo/hugo.h" #include "hugo/file.h" diff --git a/engines/hugo/file_v1w.cpp b/engines/hugo/file_v1w.cpp index dbb093752a..4f327b3095 100644 --- a/engines/hugo/file_v1w.cpp +++ b/engines/hugo/file_v1w.cpp @@ -30,7 +30,9 @@ * */ +#include "common/debug.h" #include "common/system.h" +#include "common/textconsole.h" #include "hugo/hugo.h" #include "hugo/file.h" diff --git a/engines/hugo/file_v2d.cpp b/engines/hugo/file_v2d.cpp index ffadd17481..0ad89e987e 100644 --- a/engines/hugo/file_v2d.cpp +++ b/engines/hugo/file_v2d.cpp @@ -30,7 +30,9 @@ * */ +#include "common/debug.h" #include "common/system.h" +#include "common/textconsole.h" #include "hugo/hugo.h" #include "hugo/file.h" @@ -167,10 +169,10 @@ const char *FileManager_v2d::fetchString(const int index) { // Get offset to string[index] (and next for length calculation) _stringArchive.seek((uint32)index * sizeof(uint32), SEEK_SET); - uint32 off1, off2; - if (_stringArchive.read((char *)&off1, sizeof(uint32)) == 0) - error("An error has occurred: bad String offset"); - if (_stringArchive.read((char *)&off2, sizeof(uint32)) == 0) + + uint32 off1 = _stringArchive.readUint32LE(); + uint32 off2 = _stringArchive.readUint32LE(); + if (!off1 || !off2) error("An error has occurred: bad String offset"); // Check size of string diff --git a/engines/hugo/file_v3d.cpp b/engines/hugo/file_v3d.cpp index 2f3e5af3f0..6370fffa4d 100644 --- a/engines/hugo/file_v3d.cpp +++ b/engines/hugo/file_v3d.cpp @@ -30,7 +30,9 @@ * */ +#include "common/debug.h" #include "common/system.h" +#include "common/textconsole.h" #include "hugo/hugo.h" #include "hugo/file.h" diff --git a/engines/hugo/hugo.cpp b/engines/hugo/hugo.cpp index ba87f58150..a872a97bae 100644 --- a/engines/hugo/hugo.cpp +++ b/engines/hugo/hugo.cpp @@ -25,13 +25,14 @@ #include "common/system.h" #include "common/random.h" +#include "common/error.h" #include "common/events.h" #include "common/EventRecorder.h" #include "common/debug-channels.h" #include "common/config-manager.h" +#include "common/textconsole.h" #include "hugo/hugo.h" -#include "hugo/game.h" #include "hugo/file.h" #include "hugo/schedule.h" #include "hugo/display.h" @@ -53,7 +54,7 @@ HugoEngine *HugoEngine::s_Engine = 0; HugoEngine::HugoEngine(OSystem *syst, const HugoGameDescription *gd) : Engine(syst), _gameDescription(gd), _hero(0), _heroImage(0), _defltTunes(0), _numScreens(0), _tunesNbr(0), _soundSilence(0), _soundTest(0), - _screenStates(0), _score(0), _maxscore(0), _lastTime(0), _curTime(0), _episode(0) + _screenStates(0), _numStates(0), _score(0), _maxscore(0), _lastTime(0), _curTime(0), _episode(0) { _system = syst; DebugMan.addDebugChannel(kDebugSchedule, "Schedule", "Script Schedule debug level"); @@ -298,6 +299,10 @@ Common::Error HugoEngine::run() { break; } } + if (_status.helpFl) { + _status.helpFl = false; + _file->instructions(); + } _mouse->mouseHandler(); // Mouse activity - adds to display list _screen->displayList(kDisplayDisplay); // Blit the display list to screen @@ -323,9 +328,6 @@ void HugoEngine::initMachine() { */ void HugoEngine::runMachine() { status_t &gameStatus = getGameStatus(); - // Don't process if we're in a textbox - if (gameStatus.textBoxFl) - return; // Don't process if gameover if (gameStatus.gameOverFl) @@ -463,6 +465,7 @@ bool HugoEngine::loadHugoDat() { for (int varnt = 0; varnt < _numVariant; varnt++) { numElem = in.readUint16BE(); if (varnt == _gameVariant) { + _numStates = numElem; _screenStates = (byte *)malloc(sizeof(byte) * numElem); memset(_screenStates, 0, sizeof(_screenStates)); } @@ -530,13 +533,13 @@ void HugoEngine::initStatus() { debugC(1, kDebugEngine, "initStatus"); _status.storyModeFl = false; // Not in story mode _status.gameOverFl = false; // Hero not knobbled yet - _status.textBoxFl = false; // Not processing a text box _status.lookFl = false; // Toolbar "look" button _status.recallFl = false; // Toolbar "recall" button _status.newScreenFl = false; // Screen not just loaded _status.godModeFl = false; // No special cheats allowed _status.doQuitFl = false; _status.skipIntroFl = false; + _status.helpFl = false; // Initialize every start of new game _status.tick = 0; // Tick count @@ -553,6 +556,7 @@ void HugoEngine::initStatus() { // _status.screenWidth = 0; // Desktop screen width // _status.saveTick = 0; // Time of last save // _status.saveSlot = 0; // Slot to save/restore game +// _status.textBoxFl = false; // Not processing a text box } /** diff --git a/engines/hugo/hugo.h b/engines/hugo/hugo.h index ed021f5cd6..b2d241f241 100644 --- a/engines/hugo/hugo.h +++ b/engines/hugo/hugo.h @@ -176,13 +176,13 @@ struct HugoGameDescription; struct status_t { // Game status (not saved) bool storyModeFl; // Game is telling story - no commands bool gameOverFl; // Game is over - hero knobbled - bool textBoxFl; // Game is (halted) in text box bool lookFl; // Toolbar "look" button pressed bool recallFl; // Toolbar "recall" button pressed bool newScreenFl; // New screen just loaded in dib_a bool godModeFl; // Allow DEBUG features in live version bool doQuitFl; bool skipIntroFl; + bool helpFl; uint32 tick; // Current time in ticks vstate_t viewState; // View state machine int16 song; // Current song @@ -194,6 +194,7 @@ struct status_t { // Game status (not saved) // bool helpFl; // Calling WinHelp (don't disable music) // bool mmtimeFl; // Multimedia timer supported // bool demoFl; // Game is in demo mode +// bool textBoxFl; // Game is (halted) in text box // int16 screenWidth; // Desktop screen width // int16 saveSlot; // Current slot to save/restore game // int16 cx, cy; // Cursor position (dib coords) @@ -238,6 +239,7 @@ public: int8 _soundTest; int8 _tunesNbr; uint16 _numScreens; + uint16 _numStates; int8 _normalTPS; // Number of ticks (frames) per second. // 8 for Win versions, 9 for DOS versions object_t *_hero; diff --git a/engines/hugo/intro.cpp b/engines/hugo/intro.cpp index 63e81924c4..c31d76abd0 100644 --- a/engines/hugo/intro.cpp +++ b/engines/hugo/intro.cpp @@ -31,6 +31,7 @@ */ #include "common/system.h" +#include "common/textconsole.h" #include "hugo/hugo.h" #include "hugo/intro.h" @@ -93,7 +94,7 @@ void intro_v1d::introInit() { surf.h = 200; surf.pixels = _vm->_screen->getFrontBuffer(); surf.pitch = 320; - surf.bytesPerPixel = 1; + surf.format = Graphics::PixelFormat::createFormatCLUT8(); _vm->_screen->displayList(kDisplayInit); } @@ -247,7 +248,7 @@ void intro_v2d::introInit() { surf.h = 200; surf.pixels = _vm->_screen->getFrontBuffer(); surf.pitch = 320; - surf.bytesPerPixel = 1; + surf.format = Graphics::PixelFormat::createFormatCLUT8(); char buffer[128]; @@ -293,7 +294,7 @@ void intro_v3d::introInit() { surf.h = 200; surf.pixels = _vm->_screen->getFrontBuffer(); surf.pitch = 320; - surf.bytesPerPixel = 1; + surf.format = Graphics::PixelFormat::createFormatCLUT8(); char buffer[128]; if (_vm->_boot.registered) diff --git a/engines/hugo/inventory.cpp b/engines/hugo/inventory.cpp index ab58e386ba..45893f6965 100644 --- a/engines/hugo/inventory.cpp +++ b/engines/hugo/inventory.cpp @@ -30,6 +30,7 @@ * */ +#include "common/debug.h" #include "common/system.h" #include "hugo/hugo.h" diff --git a/engines/hugo/mouse.cpp b/engines/hugo/mouse.cpp index 1b2dd588b8..c02908e579 100644 --- a/engines/hugo/mouse.cpp +++ b/engines/hugo/mouse.cpp @@ -32,6 +32,7 @@ // mouse.cpp : Handle all mouse activity +#include "common/debug.h" #include "common/system.h" #include "hugo/hugo.h" @@ -363,6 +364,7 @@ void MouseHandler::readHotspot(Common::ReadStream &in, hotspot_t &hotspot) { void MouseHandler::loadHotspots(Common::ReadStream &in) { hotspot_t *wrkHotspots = 0; hotspot_t tmp; + memset(&tmp, 0, sizeof(tmp)); for (int varnt = 0; varnt < _vm->_numVariant; varnt++) { int numRows = in.readUint16BE(); if (varnt == _vm->_gameVariant) diff --git a/engines/hugo/object.cpp b/engines/hugo/object.cpp index 0a52a0f62d..acf9f6e50c 100644 --- a/engines/hugo/object.cpp +++ b/engines/hugo/object.cpp @@ -30,8 +30,7 @@ * */ -#include "common/system.h" -#include "common/random.h" +#include "common/debug.h" #include "hugo/hugo.h" #include "hugo/game.h" diff --git a/engines/hugo/object_v1d.cpp b/engines/hugo/object_v1d.cpp index a8edb45746..95bedf4fa2 100644 --- a/engines/hugo/object_v1d.cpp +++ b/engines/hugo/object_v1d.cpp @@ -30,6 +30,7 @@ * */ +#include "common/debug.h" #include "common/system.h" #include "common/random.h" diff --git a/engines/hugo/object_v1w.cpp b/engines/hugo/object_v1w.cpp index f3ba793a3b..54becd8234 100644 --- a/engines/hugo/object_v1w.cpp +++ b/engines/hugo/object_v1w.cpp @@ -30,6 +30,7 @@ * */ +#include "common/debug.h" #include "common/system.h" #include "common/random.h" diff --git a/engines/hugo/object_v2d.cpp b/engines/hugo/object_v2d.cpp index b3c49262ad..7c47bf4f92 100644 --- a/engines/hugo/object_v2d.cpp +++ b/engines/hugo/object_v2d.cpp @@ -30,6 +30,7 @@ * */ +#include "common/debug.h" #include "common/system.h" #include "common/random.h" diff --git a/engines/hugo/object_v3d.cpp b/engines/hugo/object_v3d.cpp index 2c6fc5d99d..3ff6c56ad3 100644 --- a/engines/hugo/object_v3d.cpp +++ b/engines/hugo/object_v3d.cpp @@ -30,6 +30,7 @@ * */ +#include "common/debug.h" #include "common/system.h" #include "common/random.h" diff --git a/engines/hugo/parser.cpp b/engines/hugo/parser.cpp index feee4cbadd..29a1d5efa3 100644 --- a/engines/hugo/parser.cpp +++ b/engines/hugo/parser.cpp @@ -30,12 +30,8 @@ * */ -#include "common/system.h" #include "common/events.h" - -#include "common/random.h" -#include "common/EventRecorder.h" -#include "common/debug-channels.h" +#include "common/textconsole.h" #include "hugo/hugo.h" #include "hugo/display.h" @@ -87,6 +83,7 @@ void Parser::readCmd(Common::ReadStream &in, cmd &curCmd) { */ void Parser::loadCmdList(Common::ReadStream &in) { cmd tmpCmd; + memset(&tmpCmd, 0, sizeof(tmpCmd)); for (int varnt = 0; varnt < _vm->_numVariant; varnt++) { uint16 numElem = in.readUint16BE(); if (varnt == _vm->_gameVariant) { @@ -119,6 +116,7 @@ void Parser::readBG(Common::ReadStream &in, background_t &curBG) { */ void Parser::loadBackgroundObjects(Common::ReadStream &in) { background_t tmpBG; + memset(&tmpBG, 0, sizeof(tmpBG)); for (int varnt = 0; varnt < _vm->_numVariant; varnt++) { uint16 numElem = in.readUint16BE(); @@ -145,6 +143,7 @@ void Parser::loadBackgroundObjects(Common::ReadStream &in) { void Parser::loadCatchallList(Common::ReadStream &in) { background_t *wrkCatchallList = 0; background_t tmpBG; + memset(&tmpBG, 0, sizeof(tmpBG)); for (int varnt = 0; varnt < _vm->_numVariant; varnt++) { uint16 numElem = in.readUint16BE(); @@ -337,7 +336,7 @@ void Parser::keyHandler(Common::Event event) { break; case Common::KEYCODE_F1: // User Help (DOS) if (_checkDoubleF1Fl) - _vm->_file->instructions(); + gameStatus.helpFl = true; else _vm->_screen->userHelp(); _checkDoubleF1Fl = !_checkDoubleF1Fl; diff --git a/engines/hugo/parser.h b/engines/hugo/parser.h index dd9244ba93..b00b8d5c43 100644 --- a/engines/hugo/parser.h +++ b/engines/hugo/parser.h @@ -32,6 +32,11 @@ #ifndef HUGO_PARSER_H #define HUGO_PARSER_H + +namespace Common { +struct Event; +} + namespace Hugo { enum seqTextParser { diff --git a/engines/hugo/parser_v1d.cpp b/engines/hugo/parser_v1d.cpp index de18427d93..b2e515fd42 100644 --- a/engines/hugo/parser_v1d.cpp +++ b/engines/hugo/parser_v1d.cpp @@ -32,6 +32,7 @@ // parser.c - handles all keyboard/command input +#include "common/debug.h" #include "common/system.h" #include "hugo/hugo.h" diff --git a/engines/hugo/parser_v1w.cpp b/engines/hugo/parser_v1w.cpp index 305fb995e1..a39063357b 100644 --- a/engines/hugo/parser_v1w.cpp +++ b/engines/hugo/parser_v1w.cpp @@ -32,8 +32,7 @@ // parser.c - handles all keyboard/command input -#include "common/system.h" -#include "common/events.h" +#include "common/debug.h" #include "hugo/hugo.h" #include "hugo/parser.h" diff --git a/engines/hugo/parser_v2d.cpp b/engines/hugo/parser_v2d.cpp index d6f2adfedc..6233f11c29 100644 --- a/engines/hugo/parser_v2d.cpp +++ b/engines/hugo/parser_v2d.cpp @@ -32,6 +32,7 @@ // parser.c - handles all keyboard/command input +#include "common/debug.h" #include "common/system.h" #include "hugo/hugo.h" @@ -121,7 +122,6 @@ void Parser_v2d::lineHandler() { // SAVE/RESTORE if (!strcmp("save", _vm->_line)) { - _vm->_config.soundFl = false; if (gameStatus.gameOverFl) _vm->gameOverMsg(); else @@ -130,7 +130,6 @@ void Parser_v2d::lineHandler() { } if (!strcmp("restore", _vm->_line)) { - _vm->_config.soundFl = false; _vm->_file->restoreGame(-1); return; } diff --git a/engines/hugo/parser_v3d.cpp b/engines/hugo/parser_v3d.cpp index f08d472240..8c4946c534 100644 --- a/engines/hugo/parser_v3d.cpp +++ b/engines/hugo/parser_v3d.cpp @@ -32,6 +32,7 @@ // parser.c - handles all keyboard/command input +#include "common/debug.h" #include "common/system.h" #include "hugo/hugo.h" @@ -123,7 +124,6 @@ void Parser_v3d::lineHandler() { // SAVE/RESTORE if (!strcmp("save", _vm->_line)) { - _vm->_config.soundFl = false; if (gameStatus.gameOverFl) _vm->gameOverMsg(); else @@ -132,7 +132,6 @@ void Parser_v3d::lineHandler() { } if (!strcmp("restore", _vm->_line)) { - _vm->_config.soundFl = false; _vm->_file->restoreGame(-1); return; } diff --git a/engines/hugo/route.cpp b/engines/hugo/route.cpp index 76ec583857..68b659cd3f 100644 --- a/engines/hugo/route.cpp +++ b/engines/hugo/route.cpp @@ -32,6 +32,7 @@ // Find shortest route from hero to destination +#include "common/debug.h" #include "common/system.h" #include "hugo/hugo.h" diff --git a/engines/hugo/schedule.cpp b/engines/hugo/schedule.cpp index 45a2b77826..0e91124a7e 100644 --- a/engines/hugo/schedule.cpp +++ b/engines/hugo/schedule.cpp @@ -32,7 +32,9 @@ // This module contains all the scheduling and timing stuff +#include "common/debug.h" #include "common/system.h" +#include "common/textconsole.h" #include "hugo/hugo.h" #include "hugo/schedule.h" @@ -1143,6 +1145,10 @@ void Scheduler::insertAction(act *action) { case AGSCHEDULE: curEvent->localActionFl = false; // Lasts over a new screen break; + // Workaround: When dying, switch to storyMode in order to block the keyboard. + case GAMEOVER: + _vm->getGameStatus().storyModeFl = true; + // No break on purpose default: curEvent->localActionFl = true; // Rest are for current screen only break; @@ -1529,28 +1535,22 @@ void Scheduler_v1d::runScheduler() { } void Scheduler_v1d::promptAction(act *action) { - Utils::promptBox(_vm->_file->fetchString(action->a3.promptIndex)); - - warning("STUB: doAction(act3)"); - // TODO: The answer of the player is not handled currently! Once it'll be read in the messageBox, uncomment this block -#if 0 - char response[256]; - // TODO: Put user input in response - - Utils::strlwr(response); - if (action->a3.encodedFl) { - warning("Encrypted flag set"); - decodeString(response); - } + Common::String response; + + response = Utils::promptBox(_vm->_file->fetchString(action->a3.promptIndex)); + + response.toLowercase(); + + char resp[256]; + strncpy(resp, response.c_str(), 256); + + if (action->a3.encodedFl) + decodeString(resp); - if (strstr(response, _vm->_file->fetchString(action->a3.responsePtr[0])) + if (strstr(resp, _vm->_file->fetchString(action->a3.responsePtr[0]))) insertActionList(action->a3.actPassIndex); else insertActionList(action->a3.actFailIndex); -#endif - - // HACK: As the answer is not read, currently it's always considered correct - insertActionList(action->a3.actPassIndex); } /** @@ -1578,19 +1578,22 @@ const char *Scheduler_v2d::getCypher() const { } void Scheduler_v2d::promptAction(act *action) { - Utils::promptBox(_vm->_file->fetchString(action->a3.promptIndex)); - warning("STUB: doAction(act3), expecting answer %s", _vm->_file->fetchString(action->a3.responsePtr[0])); + Common::String response; + + response = Utils::promptBox(_vm->_file->fetchString(action->a3.promptIndex)); + response.toLowercase(); - // TODO: The answer of the player is not handled currently! Once it'll be read in the messageBox, uncomment this block -#if 0 - char *response = Utils::Box(BOX_PROMPT, "%s", _vm->_file->fetchString(action->a3.promptIndex)); + debug(1, "doAction(act3), expecting answer %s", _vm->_file->fetchString(action->a3.responsePtr[0])); bool found = false; - char *tmpStr; // General purpose string ptr + const char *tmpStr; // General purpose string ptr - for (dx = 0; !found && (action->a3.responsePtr[dx] != -1); dx++) { + char resp[256]; + strncpy(resp, response.c_str(), 256); + + for (int dx = 0; !found && (action->a3.responsePtr[dx] != -1); dx++) { tmpStr = _vm->_file->fetchString(action->a3.responsePtr[dx]); - if (strstr(Utils::strlwr(response) , tmpStr)) + if (strstr(Utils::strlwr(resp), tmpStr)) found = true; } @@ -1598,10 +1601,6 @@ void Scheduler_v2d::promptAction(act *action) { insertActionList(action->a3.actPassIndex); else insertActionList(action->a3.actFailIndex); -#endif - - // HACK: As the answer is not read, currently it's always considered correct - insertActionList(action->a3.actPassIndex); } /** diff --git a/engines/hugo/sound.cpp b/engines/hugo/sound.cpp index 24359a2c54..d657eb96a6 100644 --- a/engines/hugo/sound.cpp +++ b/engines/hugo/sound.cpp @@ -32,7 +32,9 @@ // sound.c - sound effects and music support +#include "common/debug.h" #include "common/system.h" +#include "common/textconsole.h" #include "common/config-manager.h" #include "audio/decoders/raw.h" diff --git a/engines/hugo/util.cpp b/engines/hugo/util.cpp index 044b58e986..6846bc98af 100644 --- a/engines/hugo/util.cpp +++ b/engines/hugo/util.cpp @@ -104,6 +104,9 @@ Common::String promptBox(const Common::String &msg) { return Common::String(); EntryDialog dialog(msg, "OK", ""); + + dialog.runModal(); + return dialog.getEditString(); } |