Permalink
Browse files

STARTREK: Implement keybindings on away missions

  • Loading branch information...
Drenn1 authored and sev- committed Jun 25, 2018
1 parent 37e6a88 commit 62cd8e4730582f35c42f7f3eb79394325042137e
Showing with 72 additions and 9 deletions.
  1. +71 −8 engines/startrek/awaymission.cpp
  2. +1 −1 engines/startrek/startrek.cpp
@@ -164,6 +164,7 @@ void StarTrekEngine::initAwayCrewPositions(int warpEntryIndex) {

void StarTrekEngine::handleAwayMissionEvents() {
TrekEvent event;
int clickedObject = -1;

if (popNextEvent(&event)) {
switch (event.type) {
@@ -184,6 +185,7 @@ void StarTrekEngine::handleAwayMissionEvents() {
break;

case TREKEVENT_LBUTTONDOWN:
lclick:
if (_awayMission.disableInput)
break;

@@ -196,7 +198,7 @@ void StarTrekEngine::handleAwayMissionEvents() {
_mccoyActor->sprite.drawMode = 1;
_redshirtActor->sprite.drawMode = 1;

int clickedObject = findObjectAt(_gfx->getMousePos());
clickedObject = findObjectAt(_gfx->getMousePos());

_kirkActor->sprite.drawMode = 0;
_spockActor->sprite.drawMode = 0;
@@ -223,12 +225,13 @@ void StarTrekEngine::handleAwayMissionEvents() {
break;
}

int clickedObject = findObjectAt(_gfx->getMousePos());
clickedObject = findObjectAt(_gfx->getMousePos());
hideInventoryIcons();

if (clickedObject == OBJECT_INVENTORY_ICON) {
clickedObject = showInventoryMenu(50, 50, false);

useInventory:
// -1 means "clicked on something unknown"; -2 means "clicked on
// nothing". In the case of the inventory, either one clicks on an
// inventory item, or no action is performed.
@@ -295,12 +298,13 @@ void StarTrekEngine::handleAwayMissionEvents() {
case ACTION_GET:
case ACTION_LOOK:
case ACTION_TALK: {
int clickedObject = findObjectAt(_gfx->getMousePos());
// if (!sub_23611(clickedObject, _awayMission.activeAction)) // TODO
{
clickedObject = findObjectAt(_gfx->getMousePos());
if (!isObjectUnusable(clickedObject, _awayMission.activeAction)) {
hideInventoryIcons();

if (clickedObject == OBJECT_INVENTORY_ICON) {
clickedObject = showInventoryMenu(50, 50, false);
lookInventory:
if (clickedObject == -1)
clickedObject = -2;
}
@@ -325,14 +329,17 @@ void StarTrekEngine::handleAwayMissionEvents() {
case TREKEVENT_MOUSEMOVE:
break;

case TREKEVENT_RBUTTONDOWN: // TODO: also triggered by key press?
case TREKEVENT_RBUTTONDOWN:
rclick:
if (_awayMission.disableInput)
break;
hideInventoryIcons();
playSoundEffectIndex(0x07);
_awayMission.activeAction = showActionMenu();

checkSelectedAction:
if (_awayMission.activeAction == ACTION_USE) {
int16 clickedObject = selectObjectForUseAction();
clickedObject = selectObjectForUseAction();
if (clickedObject == -1)
break;
else
@@ -352,7 +359,63 @@ void StarTrekEngine::handleAwayMissionEvents() {
showInventoryIcons(true);
break;

case TREKEVENT_KEYDOWN: // TODO
case TREKEVENT_KEYDOWN:
if (_awayMission.disableInput)
break;

switch (event.kbd.keycode) {
case Common::KEYCODE_ESCAPE:
case Common::KEYCODE_SPACE:
case Common::KEYCODE_F2:
goto rclick;

case Common::KEYCODE_w:
hideInventoryIcons();
_awayMission.activeAction = ACTION_WALK;
break;

case Common::KEYCODE_t:
hideInventoryIcons();
_awayMission.activeAction = ACTION_TALK;
goto checkSelectedAction;

case Common::KEYCODE_u:
hideInventoryIcons();
_awayMission.activeAction = ACTION_USE;
goto checkSelectedAction;

case Common::KEYCODE_i:
if (_awayMission.activeAction == ACTION_USE) {
hideInventoryIcons();
clickedObject = showInventoryMenu(50, 50, true);
goto useInventory;
}
else if (_awayMission.activeAction == ACTION_LOOK) {
hideInventoryIcons();
clickedObject = showInventoryMenu(50, 50, true);
goto lookInventory;
}
break;

case Common::KEYCODE_RETURN:
case Common::KEYCODE_KP_ENTER:
case Common::KEYCODE_F1:
goto lclick;

case Common::KEYCODE_g:
hideInventoryIcons();
_awayMission.activeAction = ACTION_GET;
goto checkSelectedAction;

case Common::KEYCODE_l:
hideInventoryIcons();
_awayMission.activeAction = ACTION_LOOK;
goto checkSelectedAction;


default:
break;
}
break;

default:
@@ -1238,7 +1238,7 @@ void StarTrekEngine::showInventoryIcons(bool showItem) {
}

/**
* Return true if an object is unselectable with use?
* Return true if an object is unselectable with the given action?
*/
bool StarTrekEngine::isObjectUnusable(int object, int action) {
if (action == ACTION_LOOK)

0 comments on commit 62cd8e4

Please sign in to comment.