From 2196916b62777e9c2b3ad87d1e542ec11a8c3d4b Mon Sep 17 00:00:00 2001 From: Eugene Sandulenko Date: Sun, 15 Sep 2013 22:29:00 +0300 Subject: FULLPIPE: Implement FullpipeEngine::defHandleKeyDown() --- engines/fullpipe/constants.h | 1 + engines/fullpipe/fullpipe.cpp | 8 ++++- engines/fullpipe/fullpipe.h | 7 +++++ engines/fullpipe/input.cpp | 66 +++++++++++++++++++++++++++++++++++++++++- engines/fullpipe/inventory.cpp | 17 +++++++++++ engines/fullpipe/inventory.h | 2 ++ 6 files changed, 99 insertions(+), 2 deletions(-) diff --git a/engines/fullpipe/constants.h b/engines/fullpipe/constants.h index 4f389f80a8..796764d0a9 100644 --- a/engines/fullpipe/constants.h +++ b/engines/fullpipe/constants.h @@ -30,6 +30,7 @@ namespace Fullpipe { #define ANI_INV_MAP 5321 #define ANI_LIFTBUTTON 2751 #define ANI_MAN 322 +#define MSG_CMN_WINARCADE 4778 #define MSG_DISABLESAVES 5201 #define MSG_ENABLESAVES 5202 #define MSG_HMRKICK_METAL 4764 diff --git a/engines/fullpipe/fullpipe.cpp b/engines/fullpipe/fullpipe.cpp index 11808e95c2..6a4a587ff7 100644 --- a/engines/fullpipe/fullpipe.cpp +++ b/engines/fullpipe/fullpipe.cpp @@ -71,6 +71,11 @@ FullpipeEngine::FullpipeEngine(OSystem *syst, const ADGameDescription *gameDesc) _inputController = 0; _inputDisabled = false; + _normalSpeed = true; + + _currentCheat = -1; + _currentCheatPos = 0; + _modalObject = 0; _gameContinue = true; @@ -201,7 +206,8 @@ Common::Error FullpipeEngine::run() { _needRestart = false; } - _system->delayMillis(10); + if (_normalSpeed) + _system->delayMillis(10); _system->updateScreen(); } diff --git a/engines/fullpipe/fullpipe.h b/engines/fullpipe/fullpipe.h index f688151267..348ac2c9c5 100644 --- a/engines/fullpipe/fullpipe.h +++ b/engines/fullpipe/fullpipe.h @@ -127,6 +127,9 @@ public: CInputController *_inputController; bool _inputDisabled; + int _currentCheat; + int _currentCheatPos; + void defHandleKeyDown(int key); SoundList *_currSoundList1[11]; @@ -171,6 +174,7 @@ public: bool _needRestart; bool _flgPlayIntro; int _musicAllowed; + bool _normalSpeed; void enableSaves() { _isSaveAllowed = true; } void disableSaves(ExCommand *ex); @@ -222,6 +226,9 @@ public: void openHelp(); void openMainMenu(); + void winArcade(); + void getAllInventory(); + int lift_getButtonIdP(int objid); public: diff --git a/engines/fullpipe/input.cpp b/engines/fullpipe/input.cpp index 8cc7654f52..c4af54ddc3 100644 --- a/engines/fullpipe/input.cpp +++ b/engines/fullpipe/input.cpp @@ -145,8 +145,72 @@ void FullpipeEngine::setCursor(int id) { _inputController->setCursor(id); } +const char *input_cheats[] = { + "HELP", + "STUFF", + "FASTER", + "OHWAIT", + "MUSOFF", + "" +}; + void FullpipeEngine::defHandleKeyDown(int key) { - warning("STUB: FullpipeEngine::defHandleKeyDown(%d)", key); + if (_currentCheat == -1) { + for (int i = 0; input_cheats[i][0]; i++) + if (toupper(key) == input_cheats[i][0]) { + _currentCheat = i; + _currentCheatPos = 1; + } + + return; + } + + warning("%d %d", _currentCheat, _currentCheatPos); + if (toupper(key) != input_cheats[_currentCheat][_currentCheatPos]) { + _currentCheat = -1; + + return; + } + + _currentCheatPos++; + warning("%d %d", _currentCheat, _currentCheatPos); + + if (!input_cheats[_currentCheat][_currentCheatPos]) { + switch (_currentCheat) { + case 0: // HELP + winArcade(); + break; + case 1: // STUFF + getAllInventory(); + break; + case 2: // FASTER + _normalSpeed = !_normalSpeed; + break; + case 3: // OHWAIT + _gamePaused = 1; + _flgGameIsRunning = 0; + break; + case 4: // MUSOFF + if (_musicAllowed & 2) + setMusicAllowed(_musicAllowed & 0xFFFFFFFD); + else + setMusicAllowed(_musicAllowed | 2); + break; + default: + break; + } + + _currentCheatPos = 0; + _currentCheat = -1; + } +} + +void FullpipeEngine::winArcade() { + ExCommand *ex = new ExCommand(0, 17, MSG_CMN_WINARCADE, 0, 0, 0, 1, 0, 0, 0); + ex->_excFlags |= 3; + + ex->postMessage(); + } void FullpipeEngine::updateCursorsCommon() { diff --git a/engines/fullpipe/inventory.cpp b/engines/fullpipe/inventory.cpp index 1e229f3408..ccedb57ce2 100644 --- a/engines/fullpipe/inventory.cpp +++ b/engines/fullpipe/inventory.cpp @@ -138,6 +138,10 @@ int CInventory2::getInventoryItemIndexById(int itemId) { return -1; } +int CInventory2::getInventoryPoolItemIdAtIndex(int itemId) { + return _itemsPool[itemId]->id; +} + int CInventory2::getInventoryPoolItemFieldCById(int itemId) { for (uint i = 0; i < _itemsPool.size(); i++) { if (_itemsPool[i]->id == itemId) @@ -417,4 +421,17 @@ int CInventory2::getHoveredItem(Common::Point *point) { return 0; } +void FullpipeEngine::getAllInventory() { + CInventory2 *inv = getGameLoaderInventory(); + + for (uint i = 0; i < inv->getItemsPoolCount(); ++i ) { + int id = inv->getInventoryPoolItemIdAtIndex(i); + + if (inv->getCountItemsWithId(id) < 1) + inv->addItem(id, 1); + } + + inv->rebuildItemRects(); +} + } // End of namespace Fullpipe diff --git a/engines/fullpipe/inventory.h b/engines/fullpipe/inventory.h index f84d27dde5..5f1030398c 100644 --- a/engines/fullpipe/inventory.h +++ b/engines/fullpipe/inventory.h @@ -52,6 +52,7 @@ class CInventory : public CObject { virtual bool load(MfcArchive &file); int getInventoryPoolItemIndexById(int itemId); + uint getItemsPoolCount() { return _itemsPool.size(); } bool setItemFlags(int itemId, int flags); }; @@ -102,6 +103,7 @@ class CInventory2 : public CInventory { void removeItem2(Scene *sceneObj, int itemId, int x, int y, int priority); int getInventoryItemIndexById(int itemId); + int getInventoryPoolItemIdAtIndex(int itemId); int getInventoryPoolItemFieldCById(int itemId); int getCountItemsWithId(int itemId); int getItemFlags(int itemId); -- cgit v1.2.3