Permalink
Browse files

MOHAWK: RIVEN: Return to main menu after the credits

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 1, 2018
1 parent 3c8a0a3 commit a24960e4c32247f000cb3f519a215747b5a4bf6d
@@ -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;
@@ -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) {
@@ -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:
@@ -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();
@@ -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));
@@ -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() {
@@ -142,7 +142,6 @@ void OSpit::xbookclick(const ArgumentArray &args) {
// use the trap book, he will shoot the player. Dead on arrival.
// Run the credits from here.
if (_vm->_vars["agehn"] == 3) {
_vm->_scriptMan->stopAllScripts();
runCredits(args[0], 5000, 995);
return;
}

0 comments on commit a24960e

Please sign in to comment.