void BladeRunnerEngine::handleKeyUp(Common::Event &event) { if (event.kbd.keycode == Common::KEYCODE_RETURN) { _speechSkipped = true; } if (_vqaIsPlaying) { _vqaStopIsRequested = true; _vqaIsPlaying = false; return; } // TODO: if (!playerHasControl() /*|| ActorInWalkingLoop*/) { return; } if (_kia->isOpen()) { _kia->handleKeyUp(event.kbd); return; } if (_spinner->isOpen()) { return; } if (_elevator->isOpen()) { return; } if (_esper->isOpen()) { return; } if (_vk->isOpen()) { return; } if (_dialogueMenu->isOpen()) { return; } if (_scores->isOpen()) { return; } switch (event.kbd.keycode) { case Common::KEYCODE_TAB: _kia->openLastOpened(); break; case Common::KEYCODE_ESCAPE: _kia->open(kKIASectionSettings); break; case Common::KEYCODE_SPACE: // TODO: combat::switchCombatMode(&Combat); break; default: break; } }
bool BladeRunnerEngine::saveGame(Common::WriteStream &stream, const Graphics::Surface &thumbnail) { if (!playerHasControl() || _sceneScript->isInsideScript() || _aiScripts->isInsideScript()) { return false; } Common::MemoryWriteStreamDynamic memoryStream(DisposeAfterUse::YES); SaveFileWriteStream s(memoryStream); s.write(thumbnail.getPixels(), SaveFileManager::kThumbnailSize); s.writeFloat(1.0f); _settings->save(s); _scene->save(s); _scene->_exits->save(s); _scene->_regions->save(s); _scene->_set->save(s); for (uint i = 0; i != _gameInfo->getGlobalVarCount(); ++i) { s.writeInt(_gameVars[i]); } _music->save(s); // _audioPlayer->save(s) // zero func // _audioSpeech->save(s) // zero func _combat->save(s); _gameFlags->save(s); _items->save(s); _sceneObjects->save(s); _ambientSounds->save(s); _overlays->save(s); _spinner->save(s); _scores->save(s); _dialogueMenu->save(s); _obstacles->save(s); _actorDialogueQueue->save(s); _waypoints->save(s); for (uint i = 0; i != _gameInfo->getActorCount(); ++i) { _actors[i]->save(s); int animationState, animationFrame, animationStateNext, nextAnimation; _aiScripts->queryAnimationState(i, &animationState, &animationFrame, &animationStateNext, &nextAnimation); s.writeInt(animationState); s.writeInt(animationFrame); s.writeInt(animationStateNext); s.writeInt(nextAnimation); } _actors[kActorVoiceOver]->save(s); _policeMaze->save(s); _crimesDatabase->save(s); s.finalize(); stream.writeUint32LE(memoryStream.size() + 4); stream.write(memoryStream.getData(), memoryStream.size()); stream.flush(); return true; }
bool BladeRunnerEngine::canSaveGameStateCurrently() { return playerHasControl() && !_sceneScript->isInsideScript() && !_aiScripts->isInsideScript() && !_kia->isOpen() && !_spinner->isOpen() && !_vk->isOpen() && !_elevator->isOpen(); }
bool BladeRunnerEngine::loadGame(Common::SeekableReadStream &stream) { if (!playerHasControl() || _sceneScript->isInsideScript() || _aiScripts->isInsideScript()) { return false; } SaveFileReadStream s(stream); _ambientSounds->removeAllNonLoopingSounds(true); _ambientSounds->removeAllLoopingSounds(1); _music->stop(2); _audioSpeech->stopSpeech(); _actorDialogueQueue->flush(true, false); _screenEffects->_entries.clear(); int size = s.readInt(); if (size != s.size() - s.pos() + 4) { _gameIsLoading = false; return false; } _gameIsLoading = true; _settings->setLoadingGame(); s.skip(SaveFileManager::kThumbnailSize); // skip the thumbnail s.skip(4);// always float 1.0, but never used _settings->load(s); _scene->load(s); _scene->_exits->load(s); _scene->_regions->load(s); _scene->_set->load(s); for (uint i = 0; i != _gameInfo->getGlobalVarCount(); ++i) { _gameVars[i] = s.readInt(); } _music->load(s); // _audioPlayer->load(s) // zero func // _audioSpeech->load(s) // zero func _combat->load(s); _gameFlags->load(s); _items->load(s); _sceneObjects->load(s); _ambientSounds->load(s); _overlays->load(s); _spinner->load(s); _scores->load(s); _dialogueMenu->load(s); _obstacles->load(s); _actorDialogueQueue->load(s); _waypoints->load(s); for (uint i = 0; i != _gameInfo->getActorCount(); ++i) { _actors[i]->load(s); int animationState = s.readInt(); int animationFrame = s.readInt(); int animationStateNext = s.readInt(); int nextAnimation = s.readInt(); _aiScripts->setAnimationState(i, animationState, animationFrame, animationStateNext, nextAnimation); } _actors[kActorVoiceOver]->load(s); _policeMaze->load(s); _crimesDatabase->load(s); _gameIsLoading = false; _settings->setNewSetAndScene(_settings->getSet(), _settings->getScene()); _settings->setChapter(_settings->getChapter()); return true; }
void BladeRunnerEngine::handleMouseAction(int x, int y, bool mainButton, bool buttonDown) { x = CLIP(x, 0, 639); y = CLIP(y, 0, 479); int timeNow = getTotalPlayTime(); if (buttonDown) { _mouseClickTimeDiff = timeNow - _mouseClickTimeLast; _mouseClickTimeLast = timeNow; } if (!playerHasControl() || _mouse->isDisabled()) { return; } if (_kia->isOpen()) { if (buttonDown) { _kia->handleMouseDown(x, y, mainButton); } else { _kia->handleMouseUp(x, y, mainButton); } return; } if (_spinner->isOpen()) { if (buttonDown) { _spinner->handleMouseDown(x, y); } else { _spinner->handleMouseUp(x, y); } return; } if (_esper->isOpen()) { if (buttonDown) { _esper->handleMouseDown(x, y, mainButton); } else { _esper->handleMouseUp(x, y, mainButton); } return; } if (_vk->isOpen()) { if (buttonDown) { _vk->handleMouseDown(x, y, mainButton); } else { _vk->handleMouseUp(x, y, mainButton); } return; } if (_elevator->isOpen()) { if (buttonDown) { _elevator->handleMouseDown(x, y); } else { _elevator->handleMouseUp(x, y); } return; } if (_scores->isOpen()) { if (buttonDown) { _scores->handleMouseDown(x, y); } else { _scores->handleMouseUp(x, y); } return; } if (_dialogueMenu->waitingForInput()) { if (mainButton && !buttonDown) { _dialogueMenu->mouseUp(); } return; } if (mainButton) { Vector3 scenePosition = _mouse->getXYZ(x, y); bool isClickable; bool isObstacle; bool isTarget; int sceneObjectId = _sceneObjects->findByXYZ(&isClickable, &isObstacle, &isTarget, scenePosition, true, false, true); int exitIndex = _scene->_exits->getRegionAtXY(x, y); int regionIndex = _scene->_regions->getRegionAtXY(x, y); if ((sceneObjectId < kSceneObjectOffsetActors || sceneObjectId >= kSceneObjectOffsetItems) && exitIndex >= 0) { handleMouseClickExit(exitIndex, x, y, buttonDown); } else if (regionIndex >= 0) { handleMouseClickRegion(regionIndex, x, y, buttonDown); } else if (sceneObjectId == -1) { handleMouseClickEmpty(x, y, scenePosition, buttonDown); } else if (sceneObjectId >= kSceneObjectOffsetActors && sceneObjectId < kSceneObjectOffsetItems) { handleMouseClickActor(sceneObjectId - kSceneObjectOffsetActors, mainButton, buttonDown, scenePosition, x, y); } else if (sceneObjectId >= kSceneObjectOffsetItems && sceneObjectId < kSceneObjectOffsetObjects) { handleMouseClickItem(sceneObjectId - kSceneObjectOffsetItems, buttonDown); } else if (sceneObjectId >= kSceneObjectOffsetObjects && sceneObjectId <= 293) { handleMouseClick3DObject(sceneObjectId - kSceneObjectOffsetObjects, buttonDown, isClickable, isTarget); } } else if (buttonDown) { if (_playerActor->inWalkLoop()) { _playerActor->stopWalking(false); } _combat->change(); } }
void BladeRunnerEngine::handleKeyDown(Common::Event &event) { if ((event.kbd.keycode == Common::KEYCODE_d) && (event.kbd.flags & Common::KBD_CTRL)) { getDebugger()->attach(); getDebugger()->onFrame(); return; } //TODO: if (!playerHasControl() /* || ActorWalkingLoop || ActorSpeaking || VqaIsPlaying */) { return; } if (_kia->isOpen()) { _kia->handleKeyDown(event.kbd); return; } if (_spinner->isOpen()) { return; } if (_elevator->isOpen()) { return; } if (_esper->isOpen()) { return; } if (_dialogueMenu->isOpen()) { return; } if (_scores->isOpen()) { _scores->handleKeyDown(event.kbd); return; } switch (event.kbd.keycode) { case Common::KEYCODE_F1: _kia->open(kKIASectionHelp); break; case Common::KEYCODE_F2: _kia->open(kKIASectionSave); break; case Common::KEYCODE_F3: _kia->open(kKIASectionLoad); break; case Common::KEYCODE_F4: _kia->open(kKIASectionCrimes); break; case Common::KEYCODE_F5: _kia->open(kKIASectionSuspects); break; case Common::KEYCODE_F6: _kia->open(kKIASectionClues); break; case Common::KEYCODE_F10: _kia->open(kKIASectionQuit); break; default: break; } }
void BladeRunnerEngine::loadGame(const Common::String &filename, byte *thumbnail) { warning("BladeRunnerEngine::loadGame not finished"); if (!playerHasControl() || _sceneScript->isInsideScript() || _aiScripts->isInsideScript()) { return; } Common::InSaveFile *commonSaveFile = getSaveFileManager()->openForLoading(filename); if (commonSaveFile->err()) { return; } void *buf = malloc(commonSaveFile->size()); int dataSize = commonSaveFile->read(buf, commonSaveFile->size()); SaveFileReadStream s((const byte*)buf, dataSize); _ambientSounds->removeAllNonLoopingSounds(true); _ambientSounds->removeAllLoopingSounds(1); _music->stop(2); _audioSpeech->stopSpeech(); _actorDialogueQueue->flush(true, false); int size = s.readInt(); if (size != dataSize) { return; } s.skip(9600); // thumbnail _settings->load(s); _scene->load(s); _scene->_exits->load(s); _scene->_regions->load(s); _scene->_set->load(s); for (uint i = 0; i != _gameInfo->getGlobalVarCount(); ++i) { _gameVars[i] = s.readInt(); } _music->load(s); // _audioPlayer->load(s) // zero func // _audioSpeech->load(s) // zero func _combat->load(s); _gameFlags->load(s); _items->load(s); _sceneObjects->load(s); _ambientSounds->load(s); _overlays->load(s); _spinner->load(s); _scores->load(s); _dialogueMenu->load(s); _obstacles->load(s); _actorDialogueQueue->load(s); _waypoints->load(s); for (uint i = 0; i != _gameInfo->getActorCount(); ++i) { _actors[i]->load(s); int animationState = s.readInt(); int animationFrame = s.readInt(); int animationStateNext = s.readInt(); int nextAnimation = s.readInt(); _aiScripts->setAnimationState(i, animationState, animationFrame, animationStateNext, nextAnimation); } _actors[kActorVoiceOver]->load(s); _policeMaze->load(s); _crimesDatabase->load(s); _settings->setNewSetAndScene(_settings->getSet(), _settings->getScene()); _settings->setChapter(_settings->getChapter()); }
bool BladeRunnerEngine::saveGame(const Common::String &filename, byte *thumbnail) { warning("BladeRunnerEngine::saveGame not finished"); if (!playerHasControl() || _sceneScript->isInsideScript() || _aiScripts->isInsideScript()) { return false; } Common::OutSaveFile *commonSaveFile = getSaveFileManager()->openForSaving(filename, false); if (commonSaveFile->err()) { return false; } SaveFileWriteStream s; s.padBytes(9600); // TODO: thumbnail s.writeFloat(-1.0f); _settings->save(s); _scene->save(s); _scene->_exits->save(s); _scene->_regions->save(s); _scene->_set->save(s); for (uint i = 0; i != _gameInfo->getGlobalVarCount(); ++i) { s.writeInt(_gameVars[i]); } _music->save(s); // _audioPlayer->save(s) // zero func // _audioSpeech->save(s) // zero func _combat->save(s); _gameFlags->save(s); _items->save(s); _sceneObjects->save(s); _ambientSounds->save(s); _overlays->save(s); _spinner->save(s); _scores->save(s); _dialogueMenu->save(s); _obstacles->save(s); _actorDialogueQueue->save(s); _waypoints->save(s); for (uint i = 0; i != _gameInfo->getActorCount(); ++i) { _actors[i]->save(s); int animationState, animationFrame, animationStateNext, nextAnimation; _aiScripts->queryAnimationState(i, &animationState, &animationFrame, &animationStateNext, &nextAnimation); s.writeInt(animationState); s.writeInt(animationFrame); s.writeInt(animationStateNext); s.writeInt(nextAnimation); } _actors[kActorVoiceOver]->save(s); _policeMaze->save(s); _crimesDatabase->save(s); s.finalize(); assert(0 && "ok"); commonSaveFile->writeUint32LE(s.size() + 4); commonSaveFile->write(s.getData(), s.size()); return !commonSaveFile->err(); }