diff options
Diffstat (limited to 'engines')
-rw-r--r-- | engines/supernova2/ms2_def.h | 6 | ||||
-rw-r--r-- | engines/supernova2/state.cpp | 118 | ||||
-rw-r--r-- | engines/supernova2/state.h | 4 |
3 files changed, 124 insertions, 4 deletions
diff --git a/engines/supernova2/ms2_def.h b/engines/supernova2/ms2_def.h index 7a6e75b700..1891e36db1 100644 --- a/engines/supernova2/ms2_def.h +++ b/engines/supernova2/ms2_def.h @@ -132,9 +132,9 @@ kString10, kStringStatusCommandGo, kStringStatusCommandLook, kStringStatusComman kStringStatusCommandClose, kStringStatusCommandPress, kStringStatusCommandPull, kStringStatusCommandUse, kStringStatusCommandTalk, kStringStatusCommandGive, kPhrasalVerbParticleGiveTo, kPhrasalVerbParticleUseWith, kString23, kString24, kString25, kString26, kString27, kStringTextSpeed, kString29, -kString30, kString31, kString32, kString33, kString34, -kString35, kString36, kString37, kString38, kString39, -kString40, kString41, kString42, kString43, kString44, +kString30, kString31, kStringGenericInteract1, kStringGenericInteract2, kStringGenericInteract3, +kStringGenericInteract4, kStringGenericInteract5, kStringGenericInteract6, kStringGenericInteract7, kStringGenericInteract8, +kStringGenericInteract9, kStringGenericInteract10, kStringGenericInteract11, kStringGenericInteract12, kStringGenericInteract13, kStringIntro1, kStringIntro2, kStringIntro3, kStringIntro4, kStringIntro5, kString50, kString51, kString52, kString53, kString54, kString55, kString56, kString57, kString58, kString59, diff --git a/engines/supernova2/state.cpp b/engines/supernova2/state.cpp index 6a4c855d19..00b54c147e 100644 --- a/engines/supernova2/state.cpp +++ b/engines/supernova2/state.cpp @@ -557,6 +557,16 @@ void GameManager::drawStatus() { } } +void GameManager::takeObject(Object &obj) { + if (obj.hasProperty(CARRIED)) + return; + + if (obj._section != 0) + _vm->renderImage(obj._section); + obj._click = obj._click2 = 255; + _inventory.add(obj); +} + void GameManager::drawCommandBox() { for (int i = 0; i < ARRAYSIZE(_guiCommandButton); ++i) { _vm->renderBox(_guiCommandButton[i]); @@ -667,9 +677,115 @@ bool GameManager::waitOnInput(int ticks, Common::KeyCode &keycode) { return false; } +int GameManager::invertSection(int section) { + if (section < 128) + section += 128; + else + section -= 128; + + return section; +} + +bool GameManager::genericInteract(Action verb, Object &obj1, Object &obj2) { + return false; +} + +void GameManager::handleInput() { + bool validCommand = genericInteract(_inputVerb, *_inputObject[0], *_inputObject[1]); + if (!validCommand) + validCommand = _currentRoom->interact(_inputVerb, *_inputObject[0], *_inputObject[1]); + if (!validCommand) { + switch (_inputVerb) { + case ACTION_LOOK: + _vm->renderMessage(_inputObject[0]->_description); + break; + + case ACTION_WALK: + if (_inputObject[0]->hasProperty(CARRIED)) { + // You already carry this. + _vm->renderMessage(kStringGenericInteract1); + } else if (!_inputObject[0]->hasProperty(EXIT)) { + // You're already there. + _vm->renderMessage(kStringGenericInteract2); + } else if (_inputObject[0]->hasProperty(OPENABLE) && !_inputObject[0]->hasProperty(OPENED)) { + // This is closed + _vm->renderMessage(kStringGenericInteract3); + } else + changeRoom(_inputObject[0]->_exitRoom); + + break; + + case ACTION_TAKE: + if (_inputObject[0]->hasProperty(OPENED)) { + // You already have that + _vm->renderMessage(kStringGenericInteract4); + } else if (_inputObject[0]->hasProperty(UNNECESSARY)) { + // You do not need that. + _vm->renderMessage(kStringGenericInteract5); + } else if (!_inputObject[0]->hasProperty(TAKE)) { + // You can't take that. + _vm->renderMessage(kStringGenericInteract6); + } else + takeObject(*_inputObject[0]); + + break; + + case ACTION_OPEN: + if (!_inputObject[0]->hasProperty(OPENABLE)) { + // This can't be opened + _vm->renderMessage(kStringGenericInteract7); + } else if (_inputObject[0]->hasProperty(OPENED)) { + // This is already opened. + _vm->renderMessage(kStringGenericInteract8); + } else if (_inputObject[0]->hasProperty(CLOSED)) { + // This is locked. + _vm->renderMessage(kStringGenericInteract9); + } else { + _vm->renderImage(_inputObject[0]->_section); + _inputObject[0]->setProperty(OPENED); + byte i = _inputObject[0]->_click; + _inputObject[0]->_click = _inputObject[0]->_click2; + _inputObject[0]->_click2 = i; + //_sound->play(kAudioDoorOpen); + } + break; + + case ACTION_CLOSE: + if (!_inputObject[0]->hasProperty(OPENABLE) || + (_inputObject[0]->hasProperty(CLOSED) && + _inputObject[0]->hasProperty(OPENED))) { + // This can't be closed. + _vm->renderMessage(kStringGenericInteract10); + } else if (!_inputObject[0]->hasProperty(OPENED)) { + // This is already closed. + _vm->renderMessage(kStringGenericInteract11); + } else { + _vm->renderImage(invertSection(_inputObject[0]->_section)); + _inputObject[0]->disableProperty(OPENED); + byte i = _inputObject[0]->_click; + _inputObject[0]->_click = _inputObject[0]->_click2; + _inputObject[0]->_click2 = i; + //_sound->play(kAudioDoorClose); + } + break; + + case ACTION_GIVE: + if (_inputObject[0]->hasProperty(CARRIED)) { + // Better keep it! + _vm->renderMessage(kStringGenericInteract12); + } + break; + + default: + // This is not possible. + _vm->renderMessage(kStringGenericInteract13); + } + } +} + void GameManager::executeRoom() { if (_processInput && !_vm->_screen->isMessageShown() && _guiEnabled) { -// handleInput(); + handleInput(); if (_mouseClicked) { Common::Event event; event.type = Common::EVENT_MOUSEMOVE; diff --git a/engines/supernova2/state.h b/engines/supernova2/state.h index 4569b24ad9..27e56315f9 100644 --- a/engines/supernova2/state.h +++ b/engines/supernova2/state.h @@ -145,6 +145,7 @@ public: byte _rows[6]; byte _rowsStart[6]; + void takeObject(Object &obj); void setObjectNull(Object *&obj); bool isNullObject(Object *obj); @@ -152,18 +153,21 @@ public: void initRooms(); void destroyRooms(); void initGui(); + bool genericInteract(Action verb, Object &obj1, Object &obj2); uint16 getKeyInput(bool blockForPrintChar = false); void getInput(); void wait(int ticks); void waitOnInput(int ticks); bool waitOnInput(int ticks, Common::KeyCode &keycode); void showMenu(); + int invertSection(int section); void drawMapExits(); void drawStatus(); void drawCommandBox(); void drawInventory(); void changeRoom(RoomId id); void resetInputState(); + void handleInput(); private: int _prevImgId; |