diff options
author | Alyssa Milburn | 2011-01-22 21:22:49 +0000 |
---|---|---|
committer | Alyssa Milburn | 2011-01-22 21:22:49 +0000 |
commit | 49c3cab2e86743212e831e31caecbc18aefbaccd (patch) | |
tree | 131bf3e1d7fcb6d69ed0b1aa665beb9925dd6a82 | |
parent | bbfbb7e74a8a5db2a808e03df8076125371300f7 (diff) | |
download | scummvm-rg350-49c3cab2e86743212e831e31caecbc18aefbaccd.tar.gz scummvm-rg350-49c3cab2e86743212e831e31caecbc18aefbaccd.tar.bz2 scummvm-rg350-49c3cab2e86743212e831e31caecbc18aefbaccd.zip |
MOHAWK: Implement CSTime help system.
svn-id: r55447
-rw-r--r-- | engines/mohawk/cstime.cpp | 11 | ||||
-rw-r--r-- | engines/mohawk/cstime_ui.cpp | 170 | ||||
-rw-r--r-- | engines/mohawk/cstime_ui.h | 23 |
3 files changed, 196 insertions, 8 deletions
diff --git a/engines/mohawk/cstime.cpp b/engines/mohawk/cstime.cpp index f4eeb99020..955e0e5af6 100644 --- a/engines/mohawk/cstime.cpp +++ b/engines/mohawk/cstime.cpp @@ -501,6 +501,10 @@ void MohawkEngine_CSTime::triggerEvent(CSTimeEvent &event) { _case->getCurrConversation()->setAsked(qar, entry); break; + case kCSTimeEventStartHelp: + _interface->getHelp()->start(); + break; + case kCSTimeEventShowBigNote: _interface->getCarmenNote()->drawBigNote(); break; @@ -583,11 +587,10 @@ void MohawkEngine_CSTime::triggerEvent(CSTimeEvent &event) { break; case kCSTimeEventUnknown70: - if (_case->getCurrConversation()->getState() != 0xffff && _case->getCurrConversation()->getState()) { + if (_case->getCurrConversation()->getState() != (uint)~0 && _case->getCurrConversation()->getState()) { _case->getCurrConversation()->finishProcessingQaR(); - } else { - // FIXME: handle help stuff - warning("ignoring unknown 70"); + } else if (_interface->getHelp()->getState() != (uint)~0 && _interface->getHelp()->getState()) { + _interface->getHelp()->cleanupAfterFlapping(); } break; diff --git a/engines/mohawk/cstime_ui.cpp b/engines/mohawk/cstime_ui.cpp index bfb62a0c49..a21ed49647 100644 --- a/engines/mohawk/cstime_ui.cpp +++ b/engines/mohawk/cstime_ui.cpp @@ -27,6 +27,7 @@ #include "mohawk/cstime_ui.h" #include "mohawk/cstime_view.h" #include "mohawk/resource.h" +#include "common/algorithm.h" // find #include "common/events.h" namespace Mohawk { @@ -265,7 +266,7 @@ void CSTimeInterface::mouseDown(Common::Point pos) { } if (_help->getState() != (uint)~0) { - // FIXME: _help->mouseDown(pos); + _help->mouseDown(pos); return; } @@ -369,7 +370,7 @@ void CSTimeInterface::mouseMove(Common::Point pos) { } if (_help->getState() != (uint)~0) { - // FIXME: _help->mouseMove(pos); + _help->mouseMove(pos); return; } @@ -446,7 +447,7 @@ void CSTimeInterface::mouseUp(Common::Point pos) { } if (_help->getState() != (uint)~0) { - // FIXME: _help->mouseUp(pos); + _help->mouseUp(pos); return; } @@ -831,13 +832,174 @@ void CSTimeInterface::dropItemInInventory(uint16 id) { CSTimeHelp::CSTimeHelp(MohawkEngine_CSTime *vm) : _vm(vm) { _state = (uint)~0; + _currEntry = 0xffff; + _currHover = 0xffff; + _nextToProcess = 0xffff; } CSTimeHelp::~CSTimeHelp() { } +void CSTimeHelp::addQaR(uint16 text, uint16 speech) { + CSTimeHelpQaR qar; + qar.text = text; + qar.speech = speech; + _qars.push_back(qar); +} + +void CSTimeHelp::start() { + if (_vm->getInterface()->getInventoryDisplay()->getState() == 4) + return; + + _state = 2; + + uint16 speech = 5900 + _vm->_rnd->getRandomNumberRng(0, 2); + _vm->addEvent(CSTimeEvent(kCSTimeEventCharStartFlapping, _vm->getCase()->getCurrScene()->getHelperId(), speech)); + + if (noHelperChanges()) + return; + + // Play a NIS, making sure the Good Guide is disabled. + _vm->addEvent(CSTimeEvent(kCSTimeEventCharSetState, _vm->getCase()->getCurrScene()->getHelperId(), 0)); + _vm->addEvent(CSTimeEvent(kCSTimeEventCharPlayNIS, _vm->getCase()->getCurrScene()->getHelperId(), 0)); + _vm->addEvent(CSTimeEvent(kCSTimeEventCharSetState, _vm->getCase()->getCurrScene()->getHelperId(), 0)); +} + void CSTimeHelp::end(bool runEvents) { - // FIXME + _state = (uint)~0; + _currHover = 0xffff; + + _vm->getInterface()->clearDialogArea(); + _vm->getInterface()->getInventoryDisplay()->show(); + + if (noHelperChanges()) + return; + + _vm->addEvent(CSTimeEvent(kCSTimeEventCharSetState, _vm->getCase()->getCurrScene()->getHelperId(), 1)); + _vm->addEvent(CSTimeEvent(kCSTimeEventCharSomeNIS55, _vm->getCase()->getCurrScene()->getHelperId(), 1)); +} + +void CSTimeHelp::cleanupAfterFlapping() { + if (_state == 2) { + // Startup. + _vm->getInterface()->getInventoryDisplay()->hide(); + selectStrings(); + display(); + _state = 1; + return; + } + + if (_nextToProcess == 0xffff) + return; + + unhighlightLine(_nextToProcess); + _nextToProcess = 0xffff; + + // TODO: case 18 hard-coding +} + +void CSTimeHelp::mouseDown(Common::Point &pos) { + for (uint i = 0; i < _qars.size(); i++) { + Common::Rect thisRect = _vm->getInterface()->_dialogTextRect; + thisRect.top += 1 + i*15; + thisRect.bottom = thisRect.top + 15; + if (!thisRect.contains(pos)) + continue; + + _currEntry = i; + highlightLine(i); + _vm->getInterface()->cursorSetShape(5); + } +} + +void CSTimeHelp::mouseMove(Common::Point &pos) { + bool mouseIsDown = _vm->getEventManager()->getButtonState() & 1; + + for (uint i = 0; i < _qars.size(); i++) { + Common::Rect thisRect = _vm->getInterface()->_dialogTextRect; + thisRect.top += 1 + i*15; + thisRect.bottom = thisRect.top + 15; + if (!thisRect.contains(pos)) + continue; + + if (mouseIsDown) { + if (i != _currEntry) + break; + highlightLine(i); + } + + _vm->getInterface()->cursorOverHotspot(); + _currHover = i; + return; + } + + if (_currHover != 0xffff) { + if (_vm->getInterface()->cursorGetShape() != 3) { + unhighlightLine(_currHover); + _vm->getInterface()->cursorSetShape(1); + } + _currHover = 0xffff; + } +} + +void CSTimeHelp::mouseUp(Common::Point &pos) { + if (_currEntry == 0xffff || _qars[_currEntry].speech == 0) { + _vm->getInterface()->cursorSetShape(1); + end(); + return; + } + + Common::Rect thisRect = _vm->getInterface()->_dialogTextRect; + thisRect.top += 1 + _currEntry*15; + thisRect.bottom = thisRect.top + 15; + if (!thisRect.contains(pos)) + return; + + _vm->addEvent(CSTimeEvent(kCSTimeEventCharStartFlapping, _vm->getCase()->getCurrScene()->getHelperId(), 5900 + _qars[_currEntry].speech)); + _nextToProcess = _currEntry; + _askedAlready.push_back(_qars[_currEntry].text); +} + +void CSTimeHelp::display() { + _vm->getInterface()->clearDialogArea(); + + for (uint i = 0; i < _qars.size(); i++) { + uint16 text = _qars[i].text; + bool askedAlready = Common::find(_askedAlready.begin(), _askedAlready.end(), text) != _askedAlready.end(); + + _vm->getInterface()->displayDialogLine(5900 + text, i, askedAlready ? 13 : 32); + } +} + +void CSTimeHelp::highlightLine(uint line) { + uint16 text = _qars[line].text; + _vm->getInterface()->displayDialogLine(5900 + text, line, 244); +} + +void CSTimeHelp::unhighlightLine(uint line) { + uint16 text = _qars[line].text; + bool askedAlready = Common::find(_askedAlready.begin(), _askedAlready.end(), text) != _askedAlready.end(); + _vm->getInterface()->displayDialogLine(5900 + text, line, askedAlready ? 13 : 32); +} + + +void CSTimeHelp::selectStrings() { + _qars.clear(); + _vm->getCase()->selectHelpStrings(); +} + +bool CSTimeHelp::noHelperChanges() { + // These are hardcoded. + if (_vm->getCase()->getId() == 4 && _vm->getCase()->getCurrScene()->getId() == 5) + return true; + if (_vm->getCase()->getId() == 5) + return true; + if (_vm->getCase()->getId() == 14 && _vm->getCase()->getCurrScene()->getId() == 4) + return true; + if (_vm->getCase()->getId() == 17 && _vm->getCase()->getCurrScene()->getId() == 2) + return true; + + return false; } CSTimeInventoryDisplay::CSTimeInventoryDisplay(MohawkEngine_CSTime *vm, Common::Rect baseRect) : _vm(vm) { diff --git a/engines/mohawk/cstime_ui.h b/engines/mohawk/cstime_ui.h index 8a029876b7..b849ddbdfb 100644 --- a/engines/mohawk/cstime_ui.h +++ b/engines/mohawk/cstime_ui.h @@ -31,12 +31,25 @@ namespace Mohawk { +struct CSTimeHelpQaR { + uint16 text, speech; +}; + class CSTimeHelp { public: CSTimeHelp(MohawkEngine_CSTime *vm); ~CSTimeHelp(); + void addQaR(uint16 text, uint16 speech); + void start(); void end(bool runEvents = true); + void cleanupAfterFlapping(); + + void mouseDown(Common::Point &pos); + void mouseMove(Common::Point &pos); + void mouseUp(Common::Point &pos); + + void reset(); uint getState() { return _state; } @@ -44,6 +57,16 @@ protected: MohawkEngine_CSTime *_vm; uint _state; + uint16 _currHover, _currEntry, _nextToProcess; + Common::Array<CSTimeHelpQaR> _qars; + Common::Array<uint16> _askedAlready; + + void display(); + void highlightLine(uint line); + void unhighlightLine(uint line); + void selectStrings(); + + bool noHelperChanges(); }; class CSTimeOptions { |