HDB: Add new PPC-specific code

This commit is contained in:
Nipun Garg 2019-08-03 10:42:07 +05:30 committed by Eugene Sandulenko
parent 878eefceb5
commit 7ad5cf9d30
5 changed files with 214 additions and 8 deletions

View File

@ -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;

View File

@ -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[] = {

View File

@ -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?

View File

@ -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;

View File

@ -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) {