Skip to content

Commit

Permalink
MOHAWK: RIVEN: Return to main menu after the credits
Browse files Browse the repository at this point in the history
Like the original the game loop returns to the main menu
after the credits end.

The variable states are reset and the player can start
a new game or load an old one.
  • Loading branch information
dafioram committed Sep 2, 2018
1 parent 3c8a0a3 commit cfdaa8b
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 5 deletions.
17 changes: 14 additions & 3 deletions engines/mohawk/riven.cpp
Expand Up @@ -94,6 +94,12 @@ MohawkEngine_Riven::MohawkEngine_Riven(OSystem *syst, const MohawkGameDescriptio
SearchMan.addSubDirectoryMatching(gameDataDir, "program");
}

void MohawkEngine_Riven::restart() {
startNewGame();
_menuTumbnail.reset();
goToMainMenu(false);
}

MohawkEngine_Riven::~MohawkEngine_Riven() {
delete _card;
delete _stack;
Expand Down Expand Up @@ -334,9 +340,14 @@ void MohawkEngine_Riven::processInput() {
}
}

void MohawkEngine_Riven::goToMainMenu() {
_menuSavedStack = _stack->getId();
_menuSavedCard = _card->getId();
void MohawkEngine_Riven::goToMainMenu(bool allowResume) {
if (allowResume) {
_menuSavedStack = _stack->getId();
_menuSavedCard = _card->getId();
} else {
_menuSavedStack = -1;
_menuSavedCard = -1;
}

// If we are already in menu, do not call again
if (_menuSavedStack == kStackAspit && _menuSavedCard == 1) {
Expand Down
3 changes: 2 additions & 1 deletion engines/mohawk/riven.h
Expand Up @@ -106,6 +106,7 @@ class MohawkEngine_Riven : public MohawkEngine {
bool hasFeature(EngineFeature f) const override;

void doFrame();
void restart(); //restart the game and go to the main menu
void processInput();

private:
Expand Down Expand Up @@ -178,7 +179,7 @@ class MohawkEngine_Riven : public MohawkEngine {
void setGameEnded();

// Main menu handling
void goToMainMenu();
void goToMainMenu(bool allowResume = true);
void resumeFromMainMenu();
bool isGameStarted() const;
void startNewGame();
Expand Down
3 changes: 3 additions & 0 deletions engines/mohawk/riven_graphics.cpp
Expand Up @@ -656,6 +656,9 @@ void RivenGraphics::beginCredits() {
// Clear the old cache
clearCache();

_creditsImage = kRivenCreditsZeroImage;
_creditsPos = 0;

// Now cache all the credits images
for (uint16 i = kRivenCreditsZeroImage; i <= kRivenCreditsLastImage; i++) {
MohawkSurface *surface = _bitmapDecoder->decodeImage(_vm->getExtrasResource(ID_TBMP, i));
Expand Down
4 changes: 3 additions & 1 deletion engines/mohawk/riven_stack.cpp
Expand Up @@ -258,7 +258,9 @@ void RivenStack::runCredits(uint16 video, uint32 delay, uint32 videoFrameCountOv
_vm->doFrame();
}

_vm->setGameEnded();
videoPtr->stop();
_vm->_cursor->showCursor();
_vm->restart();
}

void RivenStack::installCardTimer() {
Expand Down

0 comments on commit cfdaa8b

Please sign in to comment.