From dd88f39bc7078f96fd06170260bf2ff332b4ca82 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Mon, 21 Mar 2011 13:07:23 +0100 Subject: HUGO: Replace Utils::Box by Utils::notifyBox + Common::String::format --- engines/hugo/display.cpp | 2 +- engines/hugo/file.cpp | 2 +- engines/hugo/file_v1d.cpp | 2 +- engines/hugo/file_v2w.cpp | 2 +- engines/hugo/hugo.cpp | 6 +++--- engines/hugo/hugo.h | 5 ----- engines/hugo/intro.cpp | 12 +++++------ engines/hugo/mouse.cpp | 6 +++--- engines/hugo/object.cpp | 4 ++-- engines/hugo/parser.cpp | 2 +- engines/hugo/parser_v1d.cpp | 30 +++++++++++++------------- engines/hugo/parser_v1w.cpp | 12 +++++------ engines/hugo/parser_v2d.cpp | 10 ++++----- engines/hugo/parser_v3d.cpp | 38 ++++++++++++++++----------------- engines/hugo/schedule.cpp | 6 +++--- engines/hugo/util.cpp | 51 ++++++++------------------------------------- engines/hugo/util.h | 24 ++++++++++++++++++--- 17 files changed, 97 insertions(+), 117 deletions(-) (limited to 'engines') diff --git a/engines/hugo/display.cpp b/engines/hugo/display.cpp index aa4d4384c1..333eb59707 100644 --- a/engines/hugo/display.cpp +++ b/engines/hugo/display.cpp @@ -479,7 +479,7 @@ void Screen::shadowStr(int16 sx, const int16 sy, const char *s, const byte color * present in the DOS versions */ void Screen::userHelp() const { - Utils::Box(kBoxAny , "%s", + Utils::notifyBox( "F1 - Press F1 again\n" " for instructions\n" "F2 - Sound on/off\n" diff --git a/engines/hugo/file.cpp b/engines/hugo/file.cpp index 94e1756a0d..f4eada456d 100644 --- a/engines/hugo/file.cpp +++ b/engines/hugo/file.cpp @@ -550,7 +550,7 @@ void FileManager::printBootText() { buf[i] ^= cypher[i % strlen(cypher)]; buf[i] = '\0'; - Utils::Box(kBoxOk, "%s", buf); + Utils::notifyBox(buf); } free(buf); diff --git a/engines/hugo/file_v1d.cpp b/engines/hugo/file_v1d.cpp index d8b3fa494f..48f274e88a 100644 --- a/engines/hugo/file_v1d.cpp +++ b/engines/hugo/file_v1d.cpp @@ -121,7 +121,7 @@ void FileManager_v1d::instructions() const { f.read(wrkLine, 1); } while (*wrkLine++ != '#'); // '#' is EOP wrkLine[-2] = '\0'; // Remove EOP and previous CR - Utils::Box(kBoxAny, "%s", line); + Utils::notifyBox(line); wrkLine = line; f.read(readBuf, 2); // Remove CRLF after EOP } diff --git a/engines/hugo/file_v2w.cpp b/engines/hugo/file_v2w.cpp index b917d81bd5..245d4d017e 100644 --- a/engines/hugo/file_v2w.cpp +++ b/engines/hugo/file_v2w.cpp @@ -48,7 +48,7 @@ FileManager_v2w::~FileManager_v2w() { * Same comment than in SCI: maybe in the future we can implement this, but for now this message should suffice */ void FileManager_v2w::instructions() const { - Utils::Box(kBoxAny, "Please use an external viewer to open the game's help file: HUGOWIN%d.HLP", _vm->_gameVariant + 1); + Utils::notifyBox(Common::String::format("Please use an external viewer to open the game's help file: HUGOWIN%d.HLP", _vm->_gameVariant + 1)); } } // End of namespace Hugo diff --git a/engines/hugo/hugo.cpp b/engines/hugo/hugo.cpp index ec624dd61d..6ba9e8eaa8 100644 --- a/engines/hugo/hugo.cpp +++ b/engines/hugo/hugo.cpp @@ -165,7 +165,7 @@ bool HugoEngine::isPacked() const { * Print options for user when dead */ void HugoEngine::gameOverMsg() { - Utils::Box(kBoxOk, "%s", _text->getTextUtil(kGameOver)); + Utils::notifyBox(_text->getTextUtil(kGameOver)); } Common::Error HugoEngine::run() { @@ -678,8 +678,8 @@ void HugoEngine::endGame() { debugC(1, kDebugEngine, "endGame"); if (_boot.registered != kRegRegistered) - Utils::Box(kBoxAny, "%s", _text->getTextEngine(kEsAdvertise)); - Utils::Box(kBoxAny, "%s\n%s", _episode, getCopyrightString()); + Utils::notifyBox(_text->getTextEngine(kEsAdvertise)); + Utils::notifyBox(Common::String::format("%s\n%s", _episode, getCopyrightString())); _status.viewState = kViewExit; } diff --git a/engines/hugo/hugo.h b/engines/hugo/hugo.h index a6a939f366..ed021f5cd6 100644 --- a/engines/hugo/hugo.h +++ b/engines/hugo/hugo.h @@ -131,11 +131,6 @@ enum HugoRegistered { kRegFreeware }; -/** - * Ways to dismiss a text/prompt box - */ -enum box_t {kBoxAny, kBoxOk}; - /** * Inventory icon bar states */ diff --git a/engines/hugo/intro.cpp b/engines/hugo/intro.cpp index 7551476300..7cd5a0fd17 100644 --- a/engines/hugo/intro.cpp +++ b/engines/hugo/intro.cpp @@ -337,13 +337,13 @@ bool intro_v3d::introPlay() { // Text boxes at various times switch (introTicks) { case 4: - Utils::Box(kBoxOk, "%s", _vm->_text->getTextIntro(kIntro1)); + Utils::notifyBox(_vm->_text->getTextIntro(kIntro1)); break; case 9: - Utils::Box(kBoxOk, "%s", _vm->_text->getTextIntro(kIntro2)); + Utils::notifyBox(_vm->_text->getTextIntro(kIntro2)); break; case 35: - Utils::Box(kBoxOk, "%s", _vm->_text->getTextIntro(kIntro3)); + Utils::notifyBox(_vm->_text->getTextIntro(kIntro3)); break; } } @@ -429,13 +429,13 @@ bool intro_v3w::introPlay() { // Text boxes at various times switch (introTicks) { case 4: - Utils::Box(kBoxOk, "%s", _vm->_text->getTextIntro(kIntro1)); + Utils::notifyBox(_vm->_text->getTextIntro(kIntro1)); break; case 9: - Utils::Box(kBoxOk, "%s", _vm->_text->getTextIntro(kIntro2)); + Utils::notifyBox(_vm->_text->getTextIntro(kIntro2)); break; case 35: - Utils::Box(kBoxOk, "%s", _vm->_text->getTextIntro(kIntro3)); + Utils::notifyBox(_vm->_text->getTextIntro(kIntro3)); break; } } diff --git a/engines/hugo/mouse.cpp b/engines/hugo/mouse.cpp index 73805dcfba..1b2dd588b8 100644 --- a/engines/hugo/mouse.cpp +++ b/engines/hugo/mouse.cpp @@ -187,7 +187,7 @@ void MouseHandler::processRightClick(const int16 objId, const int16 cx, const in if (_vm->_hero->cycling == kCycleInvisible) // If invisible do _vm->_object->useObject(objId); // immediate use else - Utils::Box(kBoxAny, "%s", _vm->_text->getTextMouse(kMsNoWayText)); // Can't get there + Utils::notifyBox(_vm->_text->getTextMouse(kMsNoWayText)); // Can't get there } break; } @@ -241,7 +241,7 @@ void MouseHandler::processLeftClick(const int16 objId, const int16 cx, const int else if (_hotspots[i].direction == Common::KEYCODE_LEFT) x += kHeroMaxWidth; if (!_vm->_route->startRoute(kRouteExit, i, x, y)) - Utils::Box(kBoxAny, "%s", _vm->_text->getTextMouse(kMsNoWayText)); // Can't get there + Utils::notifyBox(_vm->_text->getTextMouse(kMsNoWayText)); // Can't get there } // Get rid of any attached icon @@ -271,7 +271,7 @@ void MouseHandler::processLeftClick(const int16 objId, const int16 cx, const int if (_vm->_hero->cycling == kCycleInvisible) // If invisible do _vm->_object->lookObject(obj); // immediate decription else - Utils::Box(kBoxAny, "%s", _vm->_text->getTextMouse(kMsNoWayText)); // Can't get there + Utils::notifyBox(_vm->_text->getTextMouse(kMsNoWayText)); // Can't get there } break; } diff --git a/engines/hugo/object.cpp b/engines/hugo/object.cpp index f82a6a53c6..0a52a0f62d 100644 --- a/engines/hugo/object.cpp +++ b/engines/hugo/object.cpp @@ -175,7 +175,7 @@ void ObjectHandler::useObject(int16 objId) { // Deselect dragged icon if inventory not active if (_vm->_inventory->getInventoryState() != kInventoryActive) _vm->_screen->resetInventoryObjId(); - Utils::Box(kBoxAny, "%s", _vm->_text->getTextData(use->dataIndex)); + Utils::notifyBox(_vm->_text->getTextData(use->dataIndex)); return; } } @@ -353,7 +353,7 @@ void ObjectHandler::showTakeables() { if ((obj->cycling != kCycleInvisible) && (obj->screenIndex == *_vm->_screen_p) && (((TAKE & obj->genericCmd) == TAKE) || obj->objValue)) { - Utils::Box(kBoxAny, "You can also see:\n%s.", _vm->_text->getNoun(obj->nounIndex, LOOK_NAME)); + Utils::notifyBox(Common::String::format("You can also see:\n%s.", _vm->_text->getNoun(obj->nounIndex, LOOK_NAME))); } } } diff --git a/engines/hugo/parser.cpp b/engines/hugo/parser.cpp index 685cbc02fa..feee4cbadd 100644 --- a/engines/hugo/parser.cpp +++ b/engines/hugo/parser.cpp @@ -485,7 +485,7 @@ void Parser::showDosInventory() const { if (index & 1) buffer += "\n"; buffer += Common::String(_vm->_text->getTextParser(kTBOutro)); - Utils::Box(kBoxAny, "%s", buffer.c_str()); + Utils::notifyBox(buffer.c_str()); } } // End of namespace Hugo diff --git a/engines/hugo/parser_v1d.cpp b/engines/hugo/parser_v1d.cpp index 36b56a6521..de18427d93 100644 --- a/engines/hugo/parser_v1d.cpp +++ b/engines/hugo/parser_v1d.cpp @@ -151,25 +151,25 @@ bool Parser_v1d::isGenericVerb_v1(const char *word, object_t *obj) { // Following is equivalent to switch, but couldn't do one if (word == _vm->_text->getVerb(_vm->_look, 0)) { if ((LOOK & obj->genericCmd) == LOOK) - Utils::Box(kBoxAny, "%s", _vm->_text->getTextData(obj->dataIndex)); + Utils::notifyBox(_vm->_text->getTextData(obj->dataIndex)); else - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBUnusual_1d)); + Utils::notifyBox(_vm->_text->getTextParser(kTBUnusual_1d)); } else if (word == _vm->_text->getVerb(_vm->_take, 0)) { if (obj->carriedFl) - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBHave)); + Utils::notifyBox(_vm->_text->getTextParser(kTBHave)); else if ((TAKE & obj->genericCmd) == TAKE) takeObject(obj); else if (!obj->verbOnlyFl) // Make sure not taking object in context! - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBNoUse)); + Utils::notifyBox(_vm->_text->getTextParser(kTBNoUse)); else return false; } else if (word == _vm->_text->getVerb(_vm->_drop, 0)) { if (!obj->carriedFl) - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBDontHave)); + Utils::notifyBox(_vm->_text->getTextParser(kTBDontHave)); else if ((DROP & obj->genericCmd) == DROP) dropObject(obj); else - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBNeed)); + Utils::notifyBox(_vm->_text->getTextParser(kTBNeed)); } else { // It was not a generic cmd return false; } @@ -206,7 +206,7 @@ bool Parser_v1d::isObjectVerb_v1(const char *word, object_t *obj) { uint16 *reqs = _arrayReqs[cmnd->reqIndex]; // ptr to list of required objects for (i = 0; reqs[i]; i++) { // for each obj if (!_vm->_object->isCarrying(reqs[i])) { - Utils::Box(kBoxAny, "%s", _vm->_text->getTextData(cmnd->textDataNoCarryIndex)); + Utils::notifyBox(_vm->_text->getTextData(cmnd->textDataNoCarryIndex)); return true; } } @@ -214,14 +214,14 @@ bool Parser_v1d::isObjectVerb_v1(const char *word, object_t *obj) { // Required objects are present, now check state is correct if ((obj->state != cmnd->reqState) && (cmnd->reqState != kStateDontCare)){ - Utils::Box(kBoxAny, "%s", _vm->_text->getTextData(cmnd->textDataWrongIndex)); + Utils::notifyBox(_vm->_text->getTextData(cmnd->textDataWrongIndex)); return true; } // Everything checked. Change the state and carry out any actions if (cmnd->reqState != kStateDontCare) // Don't change new state if required state didn't care obj->state = cmnd->newState; - Utils::Box(kBoxAny, "%s", _vm->_text->getTextData(cmnd->textDataDoneIndex)); + Utils::notifyBox(_vm->_text->getTextData(cmnd->textDataDoneIndex)); _vm->_scheduler->insertActionList(cmnd->actIndex); // Special case if verb is Take or Drop. Assume additional generic actions if ((word == _vm->_text->getVerb(_vm->_take, 0)) || (word == _vm->_text->getVerb(_vm->_drop, 0))) @@ -241,7 +241,7 @@ bool Parser_v1d::isBackgroundWord_v1(const char *noun, const char *verb, objectL for (int i = 0; obj[i].verbIndex; i++) { if ((verb == _vm->_text->getVerb(obj[i].verbIndex, 0)) && (noun == _vm->_text->getNoun(obj[i].nounIndex, 0))) { - Utils::Box(kBoxAny, "%s", _vm->_file->fetchString(obj[i].commentIndex)); + Utils::notifyBox(_vm->_file->fetchString(obj[i].commentIndex)); return true; } } @@ -260,7 +260,7 @@ void Parser_v1d::takeObject(object_t *obj) { _vm->adjustScore(obj->objValue); - Utils::Box(kBoxAny, TAKE_TEXT, _vm->_text->getNoun(obj->nounIndex, TAKE_NAME)); + Utils::notifyBox(Common::String::format(TAKE_TEXT, _vm->_text->getNoun(obj->nounIndex, TAKE_NAME))); } /** @@ -276,7 +276,7 @@ void Parser_v1d::dropObject(object_t *obj) { obj->x = _vm->_hero->x - 1; obj->y = _vm->_hero->y + _vm->_hero->currImagePtr->y2 - 1; _vm->adjustScore(-obj->objValue); - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBOk)); + Utils::notifyBox(_vm->_text->getTextParser(kTBOk)); } /** @@ -294,7 +294,7 @@ bool Parser_v1d::isCatchallVerb_v1(bool testNounFl, const char *noun, const char for (int i = 0; obj[i].verbIndex; i++) { if ((verb == _vm->_text->getVerb(obj[i].verbIndex, 0)) && ((noun == _vm->_text->getNoun(obj[i].nounIndex, 0)) || (obj[i].nounIndex == 0))) { - Utils::Box(kBoxAny, "%s", _vm->_file->fetchString(obj[i].commentIndex)); + Utils::notifyBox(_vm->_file->fetchString(obj[i].commentIndex)); return true; } } @@ -418,11 +418,11 @@ void Parser_v1d::lineHandler() { } noun = findNextNoun(noun); if (*farComment != '\0') // An object matched but not near enough - Utils::Box(kBoxAny, "%s", farComment); + Utils::notifyBox(farComment); else if (!isCatchallVerb_v1(true, noun, verb, _catchallList) && !isCatchallVerb_v1(false, noun, verb, _backgroundObjects[*_vm->_screen_p]) && !isCatchallVerb_v1(false, noun, verb, _catchallList)) - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBEh_1d)); + Utils::notifyBox(_vm->_text->getTextParser(kTBEh_1d)); } void Parser_v1d::showInventory() const { diff --git a/engines/hugo/parser_v1w.cpp b/engines/hugo/parser_v1w.cpp index 3490c437aa..305fb995e1 100644 --- a/engines/hugo/parser_v1w.cpp +++ b/engines/hugo/parser_v1w.cpp @@ -182,7 +182,7 @@ void Parser_v1w::lineHandler() { // If a not-near comment was generated, print it if (*farComment != '\0') { - Utils::Box(kBoxAny, "%s", farComment); + Utils::notifyBox(farComment); return; } @@ -190,16 +190,16 @@ void Parser_v1w::lineHandler() { const char *verb = findVerb(); const char *noun = findNoun(); if (verb == _vm->_text->getVerb(_vm->_look, 0) && _vm->_maze.enabledFl) { - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBMaze)); + Utils::notifyBox(_vm->_text->getTextParser(kTBMaze)); _vm->_object->showTakeables(); } else if (verb && noun) { // A combination I didn't think of - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBNoPoint)); + Utils::notifyBox(_vm->_text->getTextParser(kTBNoPoint)); } else if (noun) { - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBNoun)); + Utils::notifyBox(_vm->_text->getTextParser(kTBNoun)); } else if (verb) { - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBVerb)); + Utils::notifyBox(_vm->_text->getTextParser(kTBVerb)); } else { - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBEh)); + Utils::notifyBox(_vm->_text->getTextParser(kTBEh)); } } diff --git a/engines/hugo/parser_v2d.cpp b/engines/hugo/parser_v2d.cpp index 50d2e5f493..d6f2adfedc 100644 --- a/engines/hugo/parser_v2d.cpp +++ b/engines/hugo/parser_v2d.cpp @@ -175,16 +175,16 @@ void Parser_v2d::lineHandler() { && !isCatchallVerb_v1(false, noun, verb, _backgroundObjects[*_vm->_screen_p]) && !isCatchallVerb_v1(false, noun, verb, _catchallList)) { if (*farComment != '\0') { // An object matched but not near enough - Utils::Box(kBoxAny, "%s", farComment); + Utils::notifyBox(farComment); } else if (_vm->_maze.enabledFl && (verb == _vm->_text->getVerb(_vm->_look, 0))) { - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBMaze)); + Utils::notifyBox(_vm->_text->getTextParser(kTBMaze)); _vm->_object->showTakeables(); } else if (verb && noun) { // A combination I didn't think of - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBNoUse_2d)); + Utils::notifyBox(_vm->_text->getTextParser(kTBNoUse_2d)); } else if (verb || noun) { - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBNoun)); + Utils::notifyBox(_vm->_text->getTextParser(kTBNoun)); } else { - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBEh_2d)); + Utils::notifyBox(_vm->_text->getTextParser(kTBEh_2d)); } } } diff --git a/engines/hugo/parser_v3d.cpp b/engines/hugo/parser_v3d.cpp index 88ff980d65..f08d472240 100644 --- a/engines/hugo/parser_v3d.cpp +++ b/engines/hugo/parser_v3d.cpp @@ -184,7 +184,7 @@ void Parser_v3d::lineHandler() { // If a not-near comment was generated, print it if (*farComment != '\0') { - Utils::Box(kBoxAny, "%s", farComment); + Utils::notifyBox(farComment); return; } @@ -193,13 +193,13 @@ void Parser_v3d::lineHandler() { const char *noun = findNoun(); if (verb && noun) { // A combination I didn't think of - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBNoPoint)); + Utils::notifyBox(_vm->_text->getTextParser(kTBNoPoint)); } else if (noun) { - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBNoun)); + Utils::notifyBox(_vm->_text->getTextParser(kTBNoun)); } else if (verb) { - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBVerb)); + Utils::notifyBox(_vm->_text->getTextParser(kTBVerb)); } else { - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBEh)); + Utils::notifyBox(_vm->_text->getTextParser(kTBEh)); } } @@ -236,7 +236,7 @@ bool Parser_v3d::isObjectVerb_v3(object_t *obj, char *comment) { uint16 *reqs = _arrayReqs[cmnd->reqIndex]; // ptr to list of required objects for (i = 0; reqs[i]; i++) { // for each obj if (!_vm->_object->isCarrying(reqs[i])) { - Utils::Box(kBoxAny, "%s", _vm->_text->getTextData(cmnd->textDataNoCarryIndex)); + Utils::notifyBox(_vm->_text->getTextData(cmnd->textDataNoCarryIndex)); return true; } } @@ -244,14 +244,14 @@ bool Parser_v3d::isObjectVerb_v3(object_t *obj, char *comment) { // Required objects are present, now check state is correct if ((obj->state != cmnd->reqState) && (cmnd->reqState != kStateDontCare)) { - Utils::Box(kBoxAny, "%s", _vm->_text->getTextData(cmnd->textDataWrongIndex)); + Utils::notifyBox(_vm->_text->getTextData(cmnd->textDataWrongIndex)); return true; } // Everything checked. Change the state and carry out any actions if (cmnd->reqState != kStateDontCare) // Don't change new state if required state didn't care obj->state = cmnd->newState; - Utils::Box(kBoxAny, "%s", _vm->_text->getTextData(cmnd->textDataDoneIndex)); + Utils::notifyBox(_vm->_text->getTextData(cmnd->textDataDoneIndex)); _vm->_scheduler->insertActionList(cmnd->actIndex); // See if any additional generic actions @@ -273,35 +273,35 @@ bool Parser_v3d::isGenericVerb_v3(object_t *obj, char *comment) { if (isWordPresent(_vm->_text->getVerbArray(_vm->_look)) && isNear_v3(obj, _vm->_text->getVerb(_vm->_look, 0), comment)) { // Test state-dependent look before general look if ((obj->genericCmd & LOOK_S) == LOOK_S) { - Utils::Box(kBoxAny, "%s", _vm->_text->getTextData(obj->stateDataIndex[obj->state])); + Utils::notifyBox(_vm->_text->getTextData(obj->stateDataIndex[obj->state])); } else { if ((LOOK & obj->genericCmd) == LOOK) { if (obj->dataIndex != 0) - Utils::Box(kBoxAny, "%s", _vm->_text->getTextData(obj->dataIndex)); + Utils::notifyBox(_vm->_text->getTextData(obj->dataIndex)); else return false; } else { - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBUnusual)); + Utils::notifyBox(_vm->_text->getTextParser(kTBUnusual)); } } } else if (isWordPresent(_vm->_text->getVerbArray(_vm->_take)) && isNear_v3(obj, _vm->_text->getVerb(_vm->_take, 0), comment)) { if (obj->carriedFl) - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBHave)); + Utils::notifyBox(_vm->_text->getTextParser(kTBHave)); else if ((TAKE & obj->genericCmd) == TAKE) takeObject(obj); else if (obj->cmdIndex) // No comment if possible commands return false; else if (!obj->verbOnlyFl && (TAKE & obj->genericCmd) == TAKE) // Make sure not taking object in context! - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBNoUse)); + Utils::notifyBox(_vm->_text->getTextParser(kTBNoUse)); else return false; } else if (isWordPresent(_vm->_text->getVerbArray(_vm->_drop))) { if (!obj->carriedFl && ((DROP & obj->genericCmd) == DROP)) - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBDontHave)); + Utils::notifyBox(_vm->_text->getTextParser(kTBDontHave)); else if (obj->carriedFl && ((DROP & obj->genericCmd) == DROP)) dropObject(obj); else if (obj->cmdIndex == 0) - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBNeed)); + Utils::notifyBox(_vm->_text->getTextParser(kTBNeed)); else return false; } else { // It was not a generic cmd @@ -383,7 +383,7 @@ void Parser_v3d::takeObject(object_t *obj) { if (obj->seqNumb > 0) // If object has an image, force walk to dropped obj->viewx = -1; // (possibly moved) object next time taken! - Utils::Box(kBoxAny, TAKE_TEXT, _vm->_text->getNoun(obj->nounIndex, TAKE_NAME)); + Utils::notifyBox(Common::String::format(TAKE_TEXT, _vm->_text->getNoun(obj->nounIndex, TAKE_NAME))); } /** @@ -402,7 +402,7 @@ void Parser_v3d::dropObject(object_t *obj) { obj->y = _vm->_hero->y + _vm->_hero->currImagePtr->y2 - 1; obj->y = (obj->y + obj->currImagePtr->y2 < kYPix) ? obj->y : kYPix - obj->currImagePtr->y2 - 10; _vm->adjustScore(-obj->objValue); - Utils::Box(kBoxAny, "%s", _vm->_text->getTextParser(kTBOk)); + Utils::notifyBox(_vm->_text->getTextParser(kTBOk)); } /** @@ -422,7 +422,7 @@ bool Parser_v3d::isCatchallVerb_v3(objectList_t obj) const { (!obj[i].matchFl || !findNoun()) && ((obj[i].roomState == kStateDontCare) || (obj[i].roomState == _vm->_screenStates[*_vm->_screen_p]))) { - Utils::Box(kBoxAny, "%s", _vm->_file->fetchString(obj[i].commentIndex)); + Utils::notifyBox(_vm->_file->fetchString(obj[i].commentIndex)); _vm->_scheduler->processBonus(obj[i].bonusIndex); // If this is LOOK (without a noun), show any takeable objects @@ -450,7 +450,7 @@ bool Parser_v3d::isBackgroundWord_v3(objectList_t obj) const { isWordPresent(_vm->_text->getNounArray(obj[i].nounIndex)) && ((obj[i].roomState == kStateDontCare) || (obj[i].roomState == _vm->_screenStates[*_vm->_screen_p]))) { - Utils::Box(kBoxAny, "%s", _vm->_file->fetchString(obj[i].commentIndex)); + Utils::notifyBox(_vm->_file->fetchString(obj[i].commentIndex)); _vm->_scheduler->processBonus(obj[i].bonusIndex); return true; } diff --git a/engines/hugo/schedule.cpp b/engines/hugo/schedule.cpp index 48427c2a92..45a2b77826 100644 --- a/engines/hugo/schedule.cpp +++ b/engines/hugo/schedule.cpp @@ -1242,7 +1242,7 @@ event_t *Scheduler::doAction(event_t *curEvent) { insertActionList(action->a11.actFailIndex); break; case TEXT: // act12: Text box (CF WARN) - Utils::Box(kBoxAny, "%s", _vm->_file->fetchString(action->a12.stringIndex)); // Fetch string from file + Utils::notifyBox(_vm->_file->fetchString(action->a12.stringIndex)); // Fetch string from file break; case SWAP_IMAGES: // act13: Swap 2 object images _vm->_object->swapImages(action->a13.objIndex1, action->a13.objIndex2); @@ -1367,7 +1367,7 @@ event_t *Scheduler::doAction(event_t *curEvent) { gameStatus.storyModeFl = action->a39.storyModeFl; break; case WARN: // act40: Text box (CF TEXT) - Utils::Box(kBoxOk, "%s", _vm->_file->fetchString(action->a40.stringIndex)); + Utils::notifyBox(_vm->_file->fetchString(action->a40.stringIndex)); break; case COND_BONUS: // act41: Perform action if got bonus if (_points[action->a41.BonusIndex].scoredFl) @@ -1376,7 +1376,7 @@ event_t *Scheduler::doAction(event_t *curEvent) { insertActionList(action->a41.actFailIndex); break; case TEXT_TAKE: // act42: Text box with "take" message - Utils::Box(kBoxAny, TAKE_TEXT, _vm->_text->getNoun(_vm->_object->_objects[action->a42.objIndex].nounIndex, TAKE_NAME)); + Utils::notifyBox(Common::String::format(TAKE_TEXT, _vm->_text->getNoun(_vm->_object->_objects[action->a42.objIndex].nounIndex, TAKE_NAME))); break; case YESNO: // act43: Prompt user for Yes or No if (Utils::yesNoBox(_vm->_file->fetchString(action->a43.promptIndex))) diff --git a/engines/hugo/util.cpp b/engines/hugo/util.cpp index 88a3be8a75..044b58e986 100644 --- a/engines/hugo/util.cpp +++ b/engines/hugo/util.cpp @@ -43,11 +43,6 @@ namespace Hugo { namespace Utils { -enum { - kMaxStrLength = 1024 -}; - - /** * Returns index (0 to 7) of first 1 in supplied byte, or 8 if not found */ @@ -96,52 +91,24 @@ void reverseByte(byte *data) { *data = result; } -void Box(box_t dismiss, const char *s, ...) { - static char buffer[kMaxStrLength + 1]; // Format text into this - - if (!s) - return; // NULL strings catered for - - if (s[0] == '\0') +void notifyBox(const Common::String &msg) { + if (msg.empty()) return; - if (strlen(s) > kMaxStrLength - 100) { // Test length - warning("String too long: '%s'", s); - return; - } - - va_list marker; - va_start(marker, s); - vsprintf(buffer, s, marker); // Format string into buffer - va_end(marker); - - if (buffer[0] == '\0') - return; - - switch(dismiss) { - case kBoxAny: - case kBoxOk: { - GUI::MessageDialog dialog(buffer, "OK"); - dialog.runModal(); - break; - } - default: - error("Unknown BOX Type %d", dismiss); - } - - return; + GUI::MessageDialog dialog(msg, "OK"); + dialog.runModal(); } -Common::String promptBox(const char *msg) { - if (!msg || !*msg) - return 0; +Common::String promptBox(const Common::String &msg) { + if (msg.empty()) + return Common::String(); EntryDialog dialog(msg, "OK", ""); return dialog.getEditString(); } -bool yesNoBox(const char *msg) { - if (!msg || !*msg) +bool yesNoBox(const Common::String &msg) { + if (msg.empty()) return 0; GUI::MessageDialog dialog(msg, "YES", "NO"); diff --git a/engines/hugo/util.h b/engines/hugo/util.h index 12ec58ff86..85fef01a6e 100644 --- a/engines/hugo/util.h +++ b/engines/hugo/util.h @@ -46,9 +46,27 @@ int lastBit(byte data); void reverseByte(byte *data); -void Box(box_t, const char *, ...) GCC_PRINTF(2, 3); -Common::String promptBox(const char *msg); -bool yesNoBox(const char *msg); +/** + * Show a dialog notifying the user about something, with + * only a simple "OK" button to dismiss it. + */ +void notifyBox(const Common::String &msg); + +/** + * Show a dialog prompting the player to input some text. + */ +Common::String promptBox(const Common::String &msg); + +/** + * Show a dialog prompting the player for a "yes"/"no" choice. + */ +bool yesNoBox(const Common::String &msg); + +/** + * Convert a string to lower case, in place. + * @param buffer string to convert to lower case + * @return the string which was passed in + */ char *strlwr(char *buffer); } // End of namespace Utils -- cgit v1.2.3