diff options
author | Nipun Garg | 2019-08-03 10:42:07 +0530 |
---|---|---|
committer | Eugene Sandulenko | 2019-09-03 17:17:31 +0200 |
commit | 7ad5cf9d30ca24ace6709b43fe4549897505c8ab (patch) | |
tree | 8b806a3b359ac1b2f83470ad048e456868a842d0 | |
parent | 878eefceb5e2937512c060385a3464a1c38b2def (diff) | |
download | scummvm-rg350-7ad5cf9d30ca24ace6709b43fe4549897505c8ab.tar.gz scummvm-rg350-7ad5cf9d30ca24ace6709b43fe4549897505c8ab.tar.bz2 scummvm-rg350-7ad5cf9d30ca24ace6709b43fe4549897505c8ab.zip |
HDB: Add new PPC-specific code
-rw-r--r-- | engines/hdb/ai-funcs.cpp | 34 | ||||
-rw-r--r-- | engines/hdb/hdb.cpp | 14 | ||||
-rw-r--r-- | engines/hdb/input.cpp | 162 | ||||
-rw-r--r-- | engines/hdb/menu.cpp | 7 | ||||
-rw-r--r-- | engines/hdb/window.cpp | 5 |
5 files changed, 214 insertions, 8 deletions
diff --git a/engines/hdb/ai-funcs.cpp b/engines/hdb/ai-funcs.cpp index 7faa8880c3..73e0b8e203 100644 --- a/engines/hdb/ai-funcs.cpp +++ b/engines/hdb/ai-funcs.cpp @@ -784,6 +784,11 @@ void AI::killPlayer(Death method) { g_hdb->_window->closeDialogChoice(); g_hdb->_window->stopPanicZone(); + if (g_hdb->isPPC()) { + g_hdb->_window->closeDlvs(); + g_hdb->_window->closeInv(); + } + switch (method) { case DEATH_NORMAL: _player->state = STATE_DYING; @@ -811,8 +816,10 @@ void AI::killPlayer(Death method) { g_hdb->_sound->playSound(SND_PANIC_DEATH); break; case DEATH_PLUMMET: - _player->state = STATE_PLUMMET; - g_hdb->_sound->playSound(SND_GUY_PLUMMET); + if (!g_hdb->isDemo()) { + _player->state = STATE_PLUMMET; + g_hdb->_sound->playSound(SND_GUY_PLUMMET); + } break; } @@ -2312,6 +2319,15 @@ void AI::movePlayer(uint16 buttons) { // Just trying to put away a dialog? if (buttons & kButtonB) { + if (g_hdb->isPPC()) { + if (g_hdb->_window->deliveriesActive()) { + g_hdb->_window->closeDlvs(); + return; + } else if (g_hdb->_window->inventoryActive()) { + g_hdb->_window->closeInv(); + return; + } + } if (g_hdb->_window->dialogActive()) { g_hdb->_window->closeDialog(); return; @@ -2471,6 +2487,13 @@ void AI::movePlayer(uint16 buttons) { if (_player->touchpWait > kPlayerTouchPWait / 4) return; + if (g_hdb->isPPC()) { + // Are the Deliveries active? + if (g_hdb->_window->deliveriesActive()) + if (!g_hdb->_ai->cinematicsActive()) + return; + } + // Is a dialog active? if (g_hdb->_window->dialogActive()) { if (!cinematicsActive()) @@ -2483,6 +2506,13 @@ void AI::movePlayer(uint16 buttons) { return; } + if (g_hdb->isPPC()) { + // Is the Inventory active? + if (g_hdb->_window->inventoryActive()) + if (!g_hdb->_ai->cinematicsActive()) + return; + } + // In a cinematic? if (_playerLock || _numWaypoints) return; diff --git a/engines/hdb/hdb.cpp b/engines/hdb/hdb.cpp index 5cd561542c..f1ff789010 100644 --- a/engines/hdb/hdb.cpp +++ b/engines/hdb/hdb.cpp @@ -393,8 +393,18 @@ void HDBGame::setTargetXY(int x, int y) { return; // Double-Clicking on the player to open inventory? - if (g_hdb->isPPC()) - warning("STUB: Add double-click to inventory functionality for PPC version"); + if (g_hdb->isPPC()) { + if (x == px && y == py) { + static uint32 dblClickTimer = 0; + + if (dblClickTimer && ((int)(g_system->getMillis() - dblClickTimer) < (int)(kGameFPS * 5))) { + g_hdb->_window->openInventory(); + dblClickTimer = 0; + } else + dblClickTimer = g_system->getMillis(); + return; + } + } // If we're attacking...don't do anything else AIState stateList[] = { diff --git a/engines/hdb/input.cpp b/engines/hdb/input.cpp index be34fad5b6..505948c057 100644 --- a/engines/hdb/input.cpp +++ b/engines/hdb/input.cpp @@ -77,6 +77,20 @@ void Input::setButtons(uint16 b) { g_hdb->changeGameState(); } + if (g_hdb->isPPC()) { + if (_buttons & kButtonD) { + if (g_hdb->_window->inventoryActive()) { + g_hdb->_window->closeInv(); + g_hdb->_window->openDeliveries(false); + } else if (g_hdb->_window->deliveriesActive()) { + g_hdb->_window->closeDlvs(); + } else { + g_hdb->_window->openInventory(); + } + return; + } + } + // Debug Mode Cycling if ((_buttons & kButtonExit) && g_hdb->getCheatingOn()) { int debugFlag = g_hdb->getDebug(); @@ -108,6 +122,138 @@ void Input::setButtons(uint16 b) { return; } + if (g_hdb->isPPC()) { + // Deliveries screen? + if (g_hdb->_window->deliveriesActive() && !g_hdb->_window->animatingDelivery()) { + if (_buttons & kButtonLeft) { + int amount = g_hdb->_ai->getDeliveriesAmount(); + int current = g_hdb->_window->getSelectedDelivery(); + + if (!current) + current = amount - 1; + else + current--; + + g_hdb->_window->setSelectedDelivery(current); + } else if (_buttons & kButtonRight) { + int amount = g_hdb->_ai->getDeliveriesAmount(); + int current = g_hdb->_window->getSelectedDelivery(); + + current++; + if (current == amount) + current = 0; + + g_hdb->_window->setSelectedDelivery(current); + } else if (_buttons & kButtonB) + g_hdb->_window->closeDlvs(); + return; + } + + // + // Resources screen? Move select cursor around + // + if (g_hdb->_window->inventoryActive()) { + // select weapon? + if (_buttons & kButtonB) { + static AIType lastWeaponSelected = AI_NONE; + Tile *gfx; + + if (!g_hdb->getActionMode()) { + g_hdb->_window->closeInv(); + return; + } + + AIType t = g_hdb->_ai->getInvItemType(g_hdb->_window->getInvSelect()); + gfx = g_hdb->_ai->getInvItemGfx(g_hdb->_window->getInvSelect()); + + switch (t) { + case ITEM_CLUB: + case ITEM_ROBOSTUNNER: + case ITEM_SLUGSLINGER: + g_hdb->_ai->setPlayerWeapon(t, gfx); + if (t == lastWeaponSelected) { + g_hdb->_window->closeInv(); + return; + } + lastWeaponSelected = t; + g_hdb->_sound->playSound(SND_MENU_ACCEPT); + return; + } + g_hdb->_sound->playSound(SND_CELLHOLDER_USE_REJECT); + return; + } + + + if (_buttons & kButtonLeft) { + int amount = g_hdb->_ai->getInvMax(); + int current = g_hdb->_window->getInvSelect(); + + if (!amount) + return; + + if (current == 5) + current = amount - 1; + else if (!current && amount > 5) + current = 4; + else if (!current) + current = amount - 1; + else + current--; + + g_hdb->_sound->playSound(SND_MENU_SLIDER); + g_hdb->_window->setInvSelect(current); + } else if (_buttons & kButtonRight) { + int amount = g_hdb->_ai->getInvMax(); + int current = g_hdb->_window->getInvSelect(); + + if (!amount) + return; + + if (amount > 5) { + if (current == amount - 1) + current = 5; + else if (current == 4) + current = 0; + else + current++; + } else if (current == amount - 1) + current = 0; + else + current++; + + g_hdb->_sound->playSound(SND_MENU_SLIDER); + g_hdb->_window->setInvSelect(current); + } else if (_buttons & kButtonUp) { + int amount = g_hdb->_ai->getInvMax(); + int current = g_hdb->_window->getInvSelect(); + + if (!amount || amount < 6) + return; + + if (current - 5 >= 0) + current -= 5; + + g_hdb->_sound->playSound(SND_MENU_SLIDER); + g_hdb->_window->setInvSelect(current); + } else if (_buttons & kButtonDown) { + int amount = g_hdb->_ai->getInvMax(); + int current = g_hdb->_window->getInvSelect(); + + if (!amount || amount < 6) + return; + + if (current + 5 < amount) + current += 5; + else if (current < 5) + current = amount - 1; + + g_hdb->_sound->playSound(SND_MENU_SLIDER); + g_hdb->_window->setInvSelect(current); + } + return; + } + } + // Choose from DialogChoice if (g_hdb->_window->dialogChoiceActive()) { if (_buttons & kButtonUp) @@ -165,7 +311,21 @@ void Input::stylusDown(int x, int y) { } if (g_hdb->isPPC()) { - warning("STUB: Add PPC code for Deliveries\\Inventory"); + // is Deliveries active? + if (g_hdb->_window->deliveriesActive()) { + if (!g_hdb->_window->checkDlvsClose(x, y)) + return; + if (!g_hdb->_ai->cinematicsActive()) + return; + } + + // is Inventory active? + if (g_hdb->_window->inventoryActive()) { + if (!g_hdb->_window->checkInvClose(x, y)) + return; + if (!g_hdb->_ai->cinematicsActive()) + return; + } } // Is Dialog Active? diff --git a/engines/hdb/menu.cpp b/engines/hdb/menu.cpp index 136d6b5fa9..1094b46958 100644 --- a/engines/hdb/menu.cpp +++ b/engines/hdb/menu.cpp @@ -915,8 +915,10 @@ void Menu::freeMenu() { delete _demoPlaqueGfx; _demoPlaqueGfx = NULL; - if (g_hdb->isPPC()) { - warning("FIXME: When handangoGfx is added, free it here"); + if (g_hdb->isPPC() && g_hdb->isHandango()) { + if (_handangoGfx) + delete _handangoGfx; + _handangoGfx = NULL; } if (_nebulaGfx[0]) { @@ -1454,7 +1456,6 @@ void Menu::processInput(int x, int y) { return; } } - } int i = 0; diff --git a/engines/hdb/window.cpp b/engines/hdb/window.cpp index 0d74c59926..f0aefdbb0c 100644 --- a/engines/hdb/window.cpp +++ b/engines/hdb/window.cpp @@ -567,6 +567,11 @@ void Window::closeAll() { closeDialogChoice(); closeMsg(); closeTextOut(); + + if (g_hdb->isPPC()) { + g_hdb->_window->closeDlvs(); + g_hdb->_window->closeInv(); + } } void Window::openDialog(const char *title, int tileIndex, const char *string, int more, const char *luaMore) { |