diff options
author | Matthew Hoops | 2011-09-27 12:21:05 -0400 |
---|---|---|
committer | Matthew Hoops | 2011-09-27 12:21:05 -0400 |
commit | 96198e7bdd01c4ef642c148db4bd567fb12b9519 (patch) | |
tree | aaf627225a1d7391765d511f4720829ef759b817 /engines/pegasus | |
parent | d205ac2e2737b97741f1cde09b320538dcbef98e (diff) | |
download | scummvm-rg350-96198e7bdd01c4ef642c148db4bd567fb12b9519.tar.gz scummvm-rg350-96198e7bdd01c4ef642c148db4bd567fb12b9519.tar.bz2 scummvm-rg350-96198e7bdd01c4ef642c148db4bd567fb12b9519.zip |
PEGASUS: Import the remainder of the Neighborhood code
Diffstat (limited to 'engines/pegasus')
-rwxr-xr-x | engines/pegasus/constants.h | 8 | ||||
-rw-r--r-- | engines/pegasus/neighborhood/neighborhood.cpp | 432 | ||||
-rw-r--r-- | engines/pegasus/neighborhood/neighborhood.h | 52 | ||||
-rw-r--r-- | engines/pegasus/pegasus.cpp | 40 | ||||
-rw-r--r-- | engines/pegasus/pegasus.h | 35 |
5 files changed, 530 insertions, 37 deletions
diff --git a/engines/pegasus/constants.h b/engines/pegasus/constants.h index 6678b70b2d..406122582f 100755 --- a/engines/pegasus/constants.h +++ b/engines/pegasus/constants.h @@ -728,6 +728,14 @@ static const tDirectionConstant kSouth = 1; static const tDirectionConstant kEast = 2; static const tDirectionConstant kWest = 3; +///////////////////////////////////////////// +// +// Mode constants. + +static const tGameMode kModeInventoryPick = kLastGameShellMode + 1; +static const tGameMode kModeBiochipPick = kModeInventoryPick + 1; +static const tGameMode kModeInfoScreen = kModeBiochipPick + 1; + // TODO: Remove me const tRoomID kTSA37 = 42; const tRoomID kTinyTSA37 = 0; diff --git a/engines/pegasus/neighborhood/neighborhood.cpp b/engines/pegasus/neighborhood/neighborhood.cpp index 936f4ff44f..60668a7dde 100644 --- a/engines/pegasus/neighborhood/neighborhood.cpp +++ b/engines/pegasus/neighborhood/neighborhood.cpp @@ -57,8 +57,14 @@ Neighborhood::Neighborhood(InputHandler *nextHandler, PegasusEngine *vm, const C _turnPush(kTurnPushID), _croppedMovie(kCroppedMovieID) { GameState.setOpenDoorLocation(kNoRoomID, kNoDirection); _currentAlternate = 0; + _currentActivation = kActivateHotSpotAlways; _interruptionFilter = kFilterAllInput; + allowInput(true); + resetLastExtra(); g_neighborhood = this; + _currentInteraction = 0; + _doneWithInteraction = false; + _croppedMovie.setDisplayOrder(kCroppedMovieLayer); } Neighborhood::~Neighborhood() { @@ -400,15 +406,15 @@ void Neighborhood::popActionQueue() { tQueueRequest topRequest = _actionQueue.pop(); switch (topRequest.requestType) { - case kNavExtraRequest: - // TODO - break; - case kSpotSoundRequest: - _spotSounds.stopSound(); - break; - case kDelayRequest: - // TODO - break; + case kNavExtraRequest: + _navMovie.stop(); + break; + case kSpotSoundRequest: + _spotSounds.stopSound(); + break; + case kDelayRequest: + _delayTimer.stop(); + break; } serviceActionQueue(); @@ -423,7 +429,7 @@ void Neighborhood::serviceActionQueue() { topRequest.playing = true; switch (topRequest.requestType) { case kNavExtraRequest: - // TODO + startExtraSequence(topRequest.extra, topRequest.flags, topRequest.interruptionFilter); break; case kSpotSoundRequest: _spotSounds.stopSound(); @@ -432,7 +438,13 @@ void Neighborhood::serviceActionQueue() { // TODO: stop trigger break; case kDelayRequest: - // TODO + _delayTimer.stop(); + _delayCallBack.setCallBackFlag(topRequest.flags); + _delayTimer.setSegment(0, topRequest.start, topRequest.stop); + _delayTimer.setTime(0); + _delayCallBack.scheduleCallBack(kTriggerAtStop, 0, 0); + _interruptionFilter = topRequest.interruptionFilter; + _delayTimer.start(); break; } } @@ -453,9 +465,7 @@ void Neighborhood::requestAction(const tQueueRequestType requestType, const tExt request.interruptionFilter = interruptionFilter; request.playing = false; request.flags = flags | kActionRequestCompletedFlag; - - // TODO: notification - + request.notification = &_neighborhoodNotification; _actionQueue.push(request); if (_actionQueue.size() == 1) serviceActionQueue(); @@ -1350,27 +1360,152 @@ void Neighborhood::getExtraCompassMove(const ExtraTable::Entry &, FaderMoveSpec } void Neighborhood::setUpAIRules() { - // TODO + // Set up default rules here: + // -- Energy warning rules. + + if (g_AIArea) { + g_AIArea->forceAIUnlocked(); + + if (getObjectID() == kPrehistoricID || getObjectID() == kNoradAlphaID || + getObjectID() == kNoradDeltaID || getObjectID() == kMarsID || getObjectID() == kWSCID) { + + AIEnergyMonitorCondition *condition50 = new AIEnergyMonitorCondition(kWorriedEnergy); + AIPlayMessageAction *message = new AIPlayMessageAction("Images/AI/Globals/XGLOB4A", false); + AIRule *rule50 = new AIRule(condition50, message); + + AIEnergyMonitorCondition *condition25 = new AIEnergyMonitorCondition(kNervousEnergy); + AICompoundAction *compound = new AICompoundAction(); + message = new AIPlayMessageAction("Images/AI/Globals/XGLOB4B", false); + compound->addAction(message); + AIDeactivateRuleAction *deactivate = new AIDeactivateRuleAction(rule50); + compound->addAction(deactivate); + AIRule *rule25 = new AIRule(condition25, compound); + + AIEnergyMonitorCondition *condition5 = new AIEnergyMonitorCondition(kPanicStrickenEnergy); + compound = new AICompoundAction(); + message = new AIPlayMessageAction("Images/AI/Globals/XGLOB4C", false); + compound->addAction(message); + deactivate = new AIDeactivateRuleAction(rule50); + compound->addAction(deactivate); + deactivate = new AIDeactivateRuleAction(rule25); + compound->addAction(deactivate); + AIRule *rule5 = new AIRule(condition5, compound); + + g_AIArea->addAIRule(rule5); + g_AIArea->addAIRule(rule25); + g_AIArea->addAIRule(rule50); + } + } +} + +GameInteraction *Neighborhood::makeInteraction(const tInteractionID interactionID) { + if (interactionID == kNoInteractionID) + return 0; + + return new GameInteraction(interactionID, this); } void Neighborhood::newInteraction(const tInteractionID interactionID) { - // TODO + GameInteraction *interaction = makeInteraction(interactionID); + _doneWithInteraction = false; + + if (_currentInteraction) { + _currentInteraction->stopInteraction(); + delete _currentInteraction; + } + + _currentInteraction = interaction; + + if (_currentInteraction) + _currentInteraction->startInteraction(); + + if (g_AIArea) + g_AIArea->checkMiddleArea(); } void Neighborhood::bumpIntoWall() { // TODO + warning("bump"); } void Neighborhood::zoomUpOrBump() { - // TODO + Hotspot *zoomSpot = 0; + + for (HotspotList::iterator it = g_allHotspots.begin(); it != g_allHotspots.end(); it++) { + Hotspot *hotspot = *it; + + if ((hotspot->getHotspotFlags() & (kNeighborhoodSpotFlag | kZoomInSpotFlag)) == (kNeighborhoodSpotFlag | kZoomInSpotFlag)) { + HotspotInfoTable::Entry *entry = findHotspotEntry(hotspot->getObjectID()); + + if (entry && entry->hotspotRoom == GameState.getCurrentRoom() && entry->hotspotDirection == GameState.getCurrentDirection()) { + if (zoomSpot) { + zoomSpot = 0; + break; + } else { + zoomSpot = hotspot; + } + } + } + } + + if (zoomSpot) + zoomTo(zoomSpot); + else + bumpIntoWall(); } void Neighborhood::loadLoopSound1(const Common::String &soundName, uint16 volume, TimeValue fadeOut, TimeValue fadeIn, TimeScale fadeScale) { - // TODO + FaderMoveSpec faderMove; + + if (!loop1Loaded(soundName)) { + _loop1SoundString = soundName; + + if (_soundLoop1.isSoundLoaded()) { + faderMove.makeTwoKnotFaderSpec(fadeScale, 0, _loop1Fader.getFaderValue(), fadeOut, 0); + _loop1Fader.startFaderSync(faderMove); + } + + if (!_loop1SoundString.empty()) { + _soundLoop1.initFromAIFFFile(_loop1SoundString); + _soundLoop1.loopSound(); + _loop1Fader.setMasterVolume(_vm->getAmbienceLevel()); + _loop1Fader.setFaderValue(0); + faderMove.makeTwoKnotFaderSpec(fadeScale, 0, 0, fadeIn, volume); + _loop1Fader.startFaderSync(faderMove); + } else { + _soundLoop1.disposeSound(); + } + } else if (_loop1Fader.getFaderValue() != volume) { + faderMove.makeTwoKnotFaderSpec(fadeScale, 0, _loop1Fader.getFaderValue(), fadeIn, volume); + _loop1Fader.startFaderSync(faderMove); + } } void Neighborhood::loadLoopSound2(const Common::String &soundName, uint16 volume, TimeValue fadeOut, TimeValue fadeIn, TimeScale fadeScale) { - // TODO + FaderMoveSpec faderMove; + + if (!loop2Loaded(soundName)) { + _loop2SoundString = soundName; + + if (_soundLoop2.isSoundLoaded()) { + faderMove.makeTwoKnotFaderSpec(fadeScale, 0, _loop2Fader.getFaderValue(), fadeOut, 0); + _loop2Fader.startFaderSync(faderMove); + } + + if (!_loop2SoundString.empty()) { + _soundLoop2.initFromAIFFFile(_loop2SoundString); + _soundLoop2.loopSound(); + _loop2Fader.setMasterVolume(_vm->getAmbienceLevel()); + _loop2Fader.setFaderValue(0); + faderMove.makeTwoKnotFaderSpec(fadeScale, 0, 0, fadeIn, volume); + _loop2Fader.startFaderSync(faderMove); + } else { + _soundLoop2.disposeSound(); + } + } else if (_loop2Fader.getFaderValue() != volume) { + faderMove.makeTwoKnotFaderSpec(fadeScale, 0, _loop2Fader.getFaderValue(), fadeIn, volume); + _loop2Fader.startFaderSync(faderMove); + } } void Neighborhood::takeItemFromRoom(Item *item) { @@ -1380,4 +1515,263 @@ void Neighborhood::takeItemFromRoom(Item *item) { updateViewFrame(); } +void Neighborhood::dropItemIntoRoom(Item *item, Hotspot *) { + item->setItemRoom(getObjectID(), GameState.getCurrentRoom(), GameState.getCurrentDirection()); + // Also set the taken item flag. Do this before updating the view frame. + GameState.setTakenItem(item, false); + updateViewFrame(); +} + +void Neighborhood::makeContinuePoint() { + _vm->makeContinuePoint(); +} + +void Neighborhood::startLoop1Fader(const FaderMoveSpec &faderMove) { + _loop1Fader.startFader(faderMove); +} + +void Neighborhood::startLoop2Fader(const FaderMoveSpec &faderMove) { + _loop2Fader.startFader(faderMove); +} + +// *** Revised 6/13/96 to use the last frame of the extra sequence. +// Necessary for Cinepak buildup. +void Neighborhood::showExtraView(uint32 extraID) { + ExtraTable::Entry entry; + getExtraEntry(extraID, entry); + + if (entry.movieEnd != 0xffffffff) + showViewFrame(entry.movieEnd - 1); +} + +void Neighborhood::startExtraLongSequence(const uint32 firstExtra, const uint32 lastExtra, tNotificationFlags flags, + const tInputBits interruptionFilter) { + ExtraTable::Entry firstEntry, lastEntry; + getExtraEntry(firstExtra, firstEntry); + + if (firstEntry.movieStart != 0xffffffff) { + getExtraEntry(lastExtra, lastEntry); + _lastExtra = firstExtra; + _turnPush.hide(); + startMovieSequence(firstEntry.movieStart, lastEntry.movieEnd, flags, kFilterNoInput, interruptionFilter); + } +} + +void Neighborhood::openCroppedMovie(const Common::String &movieName, tCoordType left, tCoordType top) { + if (_croppedMovie.isMovieValid()) + closeCroppedMovie(); + + _croppedMovie.initFromMovieFile(movieName); + _croppedMovie.moveElementTo(left, top); + _croppedMovie.startDisplaying(); + _croppedMovie.show(); +} + +void Neighborhood::loopCroppedMovie(const Common::String &movieName, tCoordType left, tCoordType top) { + openCroppedMovie(movieName, left, top); + _croppedMovie.redrawMovieWorld(); + _croppedMovie.setFlags(kLoopTimeBase); + _croppedMovie.start(); +} + +void Neighborhood::closeCroppedMovie() { + _croppedMovie.releaseMovie(); +} + +void Neighborhood::playCroppedMovieOnce(const Common::String &movieName, tCoordType left, tCoordType top, const tInputBits interruptionFilter) { + openCroppedMovie(movieName, left, top); + _croppedMovie.redrawMovieWorld(); + _croppedMovie.start(); + + tInputBits oldInterruptionFilter = _interruptionFilter; + if (oldInterruptionFilter != kFilterNoInput) + _interruptionFilter = kFilterNoInput; + + bool saveAllowed = _vm->swapSaveAllowed(false); + bool openAllowed = _vm->swapLoadAllowed(false); + + Input input; + while (_croppedMovie.isRunning() && !_vm->shouldQuit()) { + _vm->processShell(); + InputHandler::getCurrentInputDevice()->getInput(input, interruptionFilter); + if (input.anyInput() || _vm->shouldQuit()) // TODO: Save/Load request + break; + _vm->_system->delayMillis(10); + } + + if (oldInterruptionFilter != kFilterNoInput) + _interruptionFilter = oldInterruptionFilter; + + closeCroppedMovie(); + _vm->swapSaveAllowed(saveAllowed); + _vm->swapLoadAllowed(openAllowed); +} + +void Neighborhood::playMovieSegment(Movie *movie, TimeValue startTime, TimeValue stopTime) { + TimeValue oldStart, oldStop; + movie->getSegment(oldStart, oldStop); + + if (stopTime == 0xffffffff) + stopTime = movie->getDuration(); + + movie->setSegment(startTime, stopTime); + movie->setTime(startTime); + movie->start(); + + while (movie->isRunning()) { + _vm->checkCallBacks(); + _vm->refreshDisplay(); + _vm->_system->delayMillis(10); + } + + movie->stop(); + movie->setSegment(oldStart, oldStop); +} + +void Neighborhood::recallToTSASuccess() { + if (GameState.allTimeZonesFinished()) + _vm->jumpToNewEnvironment(kFullTSAID, kTSA37, kNorth); + else + _vm->jumpToNewEnvironment(kTinyTSAID, kTinyTSA37, kNorth); +} + +void Neighborhood::recallToTSAFailure() { + _vm->jumpToNewEnvironment(kTinyTSAID, kTinyTSA37, kNorth); +} + +void Neighborhood::handleInput(const Input &input, const Hotspot *cursorSpot) { + if (_vm->getGameMode() == kModeNavigation) { + if (input.upButtonAnyDown()) + upButton(input); + else if (input.downButtonAnyDown()) + downButton(input); + else if (input.leftButtonAnyDown()) + leftButton(input); + else if (input.rightButtonAnyDown()) + rightButton(input); + } + + InputHandler::handleInput(input, cursorSpot); +} + +void Neighborhood::setHotspotFlags(const tHotSpotID id, const tHotSpotFlags flags) { + Hotspot *hotspot = g_allHotspots.findHotspotByID(id); + hotspot->setMaskedHotspotFlags(flags, flags); +} + +void Neighborhood::setIsItemTaken(const tItemID id) { + GameState.setTakenItemID(id, _vm->playerHasItemID(id)); +} + +void Neighborhood::upButton(const Input &) { + moveForward(); +} + +void Neighborhood::leftButton(const Input &) { + turnLeft(); +} + +void Neighborhood::rightButton(const Input &) { + turnRight(); +} + +void Neighborhood::downButton(const Input &) { + if (_inputHandler->wantsCursor()) { + g_allHotspots.deactivateAllHotspots(); + _inputHandler->activateHotspots(); + + for (HotspotList::iterator it = g_allHotspots.begin(); it != g_allHotspots.end(); it++) { + Hotspot *hotspot = *it; + + if (hotspot->isSpotActive() && (hotspot->getHotspotFlags() & (kNeighborhoodSpotFlag | kZoomOutSpotFlag)) == (kNeighborhoodSpotFlag | kZoomOutSpotFlag)) { + HotspotInfoTable::Entry *entry = findHotspotEntry(hotspot->getObjectID()); + + if (entry && entry->hotspotRoom == GameState.getCurrentRoom() && entry->hotspotDirection == GameState.getCurrentDirection()) { + Input scratch; + _inputHandler->clickInHotspot(scratch, hotspot); + return; + } + } + } + } +} + +void Neighborhood::initOnePicture(Picture *picture, const Common::String &pictureName, tDisplayOrder order, tCoordType left, tCoordType top, bool show) { + picture->initFromPICTFile(pictureName); + picture->setDisplayOrder(order); + picture->moveElementTo(left, top); + picture->startDisplaying(); + if (show) + picture->show(); +} + +void Neighborhood::initOneMovie(Movie *movie, const Common::String &movieName, tDisplayOrder order, tCoordType left, tCoordType top, bool show) { + movie->initFromMovieFile(movieName); + movie->setDisplayOrder(order); + movie->moveElementTo(left, top); + movie->startDisplaying(); + + if (show) + movie->show(); + + movie->redrawMovieWorld(); +} + +void Neighborhood::reinstateMonocleInterface() { + // TODO: Disable erase? + + _vm->createInterface(); + + if (g_AIArea) + setNextHandler(g_AIArea); + + init(); + + moveNavTo(kNavAreaLeft, kNavAreaTop); + + if (g_interface) + g_interface->setDate(getDateResID()); + + if (g_AIArea) + g_AIArea->restoreAIState(); +} + +void Neighborhood::useIdleTime() { + if (_doneWithInteraction) { + newInteraction(kNoInteractionID); + loadAmbientLoops(); + } +} + +void timerFunction(FunctionPtr *, void *neighborhood) { + ((Neighborhood *)neighborhood)->timerExpired(((Neighborhood *)neighborhood)->getTimerEvent()); +} + +void Neighborhood::scheduleEvent(const TimeValue time, const TimeScale scale, const uint32 eventType) { + _eventTimer.stopFuse(); + _eventTimer.primeFuse(time, scale); + _timerEvent = eventType; + _eventTimer.setFunctionPtr(&timerFunction, this); + _eventTimer.lightFuse(); +} + +void Neighborhood::cancelEvent() { + _eventTimer.stopFuse(); +} + +void Neighborhood::pauseTimer() { + _eventTimer.pauseFuse(); +} + +void Neighborhood::resumeTimer() { + // NOTE: Yes, this function calls pauseFuse! + // Looks like an original game bug, will need + // to investigate how this affects gameplay. + _eventTimer.pauseFuse(); +} + +bool Neighborhood::timerPaused() { + return _eventTimer.isFusePaused(); +} + } // End of namespace Pegasus diff --git a/engines/pegasus/neighborhood/neighborhood.h b/engines/pegasus/neighborhood/neighborhood.h index 805d8a2fd2..46f0f665a7 100644 --- a/engines/pegasus/neighborhood/neighborhood.h +++ b/engines/pegasus/neighborhood/neighborhood.h @@ -109,6 +109,7 @@ typedef Common::Queue<tQueueRequest> NeighborhoodActionQueue; class Neighborhood : public IDObject, public NotificationReceiver, public InputHandler, public Idler { friend class StriderCallBack; +friend void timerFunction(FunctionPtr *, void *); public: Neighborhood(InputHandler *nextHandler, PegasusEngine *vm, const Common::String &resName, tNeighborhoodID id); @@ -118,6 +119,7 @@ public: void start(); virtual void moveNavTo(const tCoordType, const tCoordType); virtual void checkContinuePoint(const tRoomID, const tDirectionConstant) = 0; + void makeContinuePoint(); virtual void activateHotspots(); virtual void clickInHotspot(const Input &, const Hotspot *); @@ -217,9 +219,36 @@ public: virtual void loadLoopSound2(const Common::String &, const uint16 volume = 0x100, const TimeValue fadeOut = kDefaultLoopFadeOut, const TimeValue fadeIn = kDefaultLoopFadeIn, const TimeScale fadeScale = kDefaultLoopFadeScale); + bool loop1Loaded(const Common::String &soundName) { return _loop1SoundString == soundName; } + bool loop2Loaded(const Common::String &soundName) { return _loop2SoundString == soundName; } + void startLoop1Fader(const FaderMoveSpec &); + void startLoop2Fader(const FaderMoveSpec &); virtual void takeItemFromRoom(Item *); + virtual void dropItemIntoRoom(Item *, Hotspot *); + virtual Hotspot *getItemScreenSpot(Item *, DisplayElement *) { return 0; } + virtual GameInteraction *makeInteraction(const tInteractionID); + virtual void requestDeleteCurrentInteraction() { _doneWithInteraction = true; } + + virtual uint16 getDateResID() const = 0; + + virtual void showExtraView(uint32); + virtual void startExtraLongSequence(const uint32, const uint32, tNotificationFlags, const tInputBits interruptionFilter); + + void openCroppedMovie(const Common::String &, tCoordType, tCoordType); + void loopCroppedMovie(const Common::String &, tCoordType, tCoordType); + void closeCroppedMovie(); + void playCroppedMovieOnce(const Common::String &, tCoordType, tCoordType, const tInputBits interruptionFilter = kFilterNoInput); + + void playMovieSegment(Movie *, TimeValue = 0, TimeValue = 0xffffffff); + + virtual void recallToTSASuccess(); + virtual void recallToTSAFailure(); + + virtual void pickedUpItem(Item *) {} + + virtual void handleInput(const Input &, const Hotspot *); protected: PegasusEngine *_vm; Common::String _resName; @@ -281,11 +310,34 @@ protected: virtual void getExtraCompassMove(const ExtraTable::Entry &, FaderMoveSpec&); virtual void setUpAIRules(); + virtual void setHotspotFlags(const tHotSpotID, const tHotSpotFlags); + virtual void setIsItemTaken(const tItemID); + + virtual void upButton(const Input &); + virtual void leftButton(const Input &); + virtual void rightButton(const Input &); + virtual void downButton(const Input &); + + void initOnePicture(Picture *, const Common::String &, tDisplayOrder, tCoordType, tCoordType, bool); + void initOneMovie(Movie *, const Common::String &, tDisplayOrder, tCoordType, tCoordType, bool); + + void reinstateMonocleInterface(); virtual void newInteraction(const tInteractionID); + virtual void useIdleTime(); virtual void bumpIntoWall(); virtual void zoomUpOrBump(); + void scheduleEvent(const TimeValue, const TimeScale, const uint32); + void cancelEvent(); + virtual void timerExpired(const uint32) {} + bool isEventTimerRunning() { return _eventTimer.isFuseLit(); } + uint32 getTimerEvent() { return _timerEvent; } + + void pauseTimer(); + void resumeTimer(); + bool timerPaused(); + // Navigation Data DoorTable _doorTable; ExitTable _exitTable; diff --git a/engines/pegasus/pegasus.cpp b/engines/pegasus/pegasus.cpp index 60d5b9aa39..d6a4ce1aed 100644 --- a/engines/pegasus/pegasus.cpp +++ b/engines/pegasus/pegasus.cpp @@ -65,6 +65,7 @@ PegasusEngine::PegasusEngine(OSystem *syst, const PegasusGameDescription *gamede _neighborhood = 0; _FXLevel = 0x80; _ambientLevel = 0x80; + _gameMode = kNoMode; } PegasusEngine::~PegasusEngine() { @@ -125,12 +126,8 @@ Common::Error PegasusEngine::run() { _returnHotspot.setHotspotFlags(kInfoReturnSpotFlag); g_allHotspots.push_back(&_returnHotspot); - while (!shouldQuit()) { - checkCallBacks(); - checkNotifications(); - InputHandler::pollForInput(); - refreshDisplay(); - } + while (!shouldQuit()) + processShell(); return Common::kNoError; } @@ -1043,6 +1040,37 @@ void PegasusEngine::dragItem(const Input &, Item *, tDragType) { // TODO } +void PegasusEngine::processShell() { + checkCallBacks(); + checkNotifications(); + InputHandler::pollForInput(); + refreshDisplay(); +} + +void PegasusEngine::createInterface() { + if (!g_interface) + new Interface(); + g_interface->createInterface(); +} + +void PegasusEngine::setGameMode(const tGameMode newMode) { + if (newMode != _gameMode && canSwitchGameMode(newMode, _gameMode)) { + switchGameMode(newMode, _gameMode); + _gameMode = newMode; + } +} + +void PegasusEngine::switchGameMode(const tGameMode newMode, const tGameMode oldMode) { + // TODO +} + +bool PegasusEngine::canSwitchGameMode(const tGameMode newMode, const tGameMode oldMode) { + if (newMode == kModeInventoryPick && oldMode == kModeBiochipPick) + return false; + if (newMode == kModeBiochipPick && oldMode == kModeInventoryPick) + return false; + return true; +} } // End of namespace Pegasus diff --git a/engines/pegasus/pegasus.h b/engines/pegasus/pegasus.h index 550761f4f5..988b6a53f0 100644 --- a/engines/pegasus/pegasus.h +++ b/engines/pegasus/pegasus.h @@ -88,20 +88,15 @@ public: void removeIdler(Idler *idler); void addTimeBase(TimeBase *timeBase); void removeTimeBase(TimeBase *timeBase); - bool swapSaveAllowed(bool allow) { - bool old = _saveAllowed; - _saveAllowed = allow; - return old; - } - bool swapLoadAllowed(bool allow) { - bool old = _loadAllowed; - _loadAllowed = allow; - return old; - } void delayShell(TimeValue time, TimeScale scale); void resetIntroTimer(); void refreshDisplay(); bool playerAlive(); + void processShell(); + void checkCallBacks(); + void createInterface(); + void setGameMode(const tGameMode); + tGameMode getGameMode() const { return _gameMode; } // Energy void setLastEnergyValue(const int32 value) { _savedEnergyValue = value; } @@ -151,6 +146,19 @@ public: tDragType getDragType() const { return (tDragType)0; } // TODO Item *getDraggingItem() const { return 0; } // TODO + // Save/Load + void makeContinuePoint(); + bool swapSaveAllowed(bool allow) { + bool old = _saveAllowed; + _saveAllowed = allow; + return old; + } + bool swapLoadAllowed(bool allow) { + bool old = _loadAllowed; + _loadAllowed = allow; + return old; + } + protected: Common::Error run(); @@ -180,12 +188,10 @@ private: // TimeBases Common::List<TimeBase *> _timeBases; - void checkCallBacks(); // Save/Load bool loadFromStream(Common::ReadStream *stream); bool writeToStream(Common::WriteStream *stream, int saveType); - void makeContinuePoint(); void loadFromContinuePoint(); Common::ReadStream *_continuePoint; bool _saveAllowed, _loadAllowed; // It's so nice that this was in the original code already :P @@ -215,6 +221,11 @@ private: // Sound uint16 _ambientLevel; uint16 _FXLevel; + + // Game Mode + tGameMode _gameMode; + void switchGameMode(const tGameMode, const tGameMode); + bool canSwitchGameMode(const tGameMode, const tGameMode); }; } // End of namespace Pegasus |