From dc93e5bb6a220773add19bd0eb04f0ffca685279 Mon Sep 17 00:00:00 2001
From: Bastien Bouclet
Date: Mon, 18 Jun 2018 21:33:56 +0200
Subject: MOHAWK: RIVEN: Add more options to the main menu

---
 engines/mohawk/riven.cpp              | 30 +++++++++++++++++-------------
 engines/mohawk/riven.h                |  1 +
 engines/mohawk/riven_card.cpp         | 20 ++++++++++++++++++--
 engines/mohawk/riven_card.h           |  2 +-
 engines/mohawk/riven_stacks/aspit.cpp | 35 +++++++++++++++++++++++------------
 engines/mohawk/riven_stacks/aspit.h   |  8 +++++++-
 6 files changed, 67 insertions(+), 29 deletions(-)

(limited to 'engines')

diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index 1a2e0c3b60..7a8dcbef1f 100644
--- a/engines/mohawk/riven.cpp
+++ b/engines/mohawk/riven.cpp
@@ -243,19 +243,7 @@ void MohawkEngine_Riven::doFrame() {
 				pauseGame();
 				break;
 			case Common::KEYCODE_F5:
-				runDialog(*_optionsDialog);
-				if (_optionsDialog->getLoadSlot() >= 0)
-					loadGameStateAndDisplayError(_optionsDialog->getLoadSlot());
-				if (_optionsDialog->getSaveSlot() >= 0)
-					saveGameStateAndDisplayError(_optionsDialog->getSaveSlot(), _optionsDialog->getSaveDescription());
-
-				if (hasGameEnded()) {
-					// Attempt to autosave before exiting
-					tryAutoSaving();
-				}
-
-				_gfx->setTransitionMode((RivenTransitionMode) _vars["transitionmode"]);
-				_card->initializeZipMode();
+				runOptionsDialog();
 				break;
 			case Common::KEYCODE_r:
 				// Return to the main menu in the demo on ctrl+r
@@ -703,6 +691,22 @@ void MohawkEngine_Riven::setGameEnded() {
 	_gameEnded = true;
 }
 
+void MohawkEngine_Riven::runOptionsDialog() {
+	runDialog(*_optionsDialog);
+	if (_optionsDialog->getLoadSlot() >= 0)
+		loadGameStateAndDisplayError(_optionsDialog->getLoadSlot());
+	if (_optionsDialog->getSaveSlot() >= 0)
+		saveGameStateAndDisplayError(_optionsDialog->getSaveSlot(), _optionsDialog->getSaveDescription());
+
+	if (hasGameEnded()) {
+		// Attempt to autosave before exiting
+		tryAutoSaving();
+	}
+
+	_gfx->setTransitionMode((RivenTransitionMode) _vars["transitionmode"]);
+	_card->initializeZipMode();
+}
+
 bool ZipMode::operator== (const ZipMode &z) const {
 	return z.name == name && z.id == id;
 }
diff --git a/engines/mohawk/riven.h b/engines/mohawk/riven.h
index 1cddd323d0..74cbcd1305 100644
--- a/engines/mohawk/riven.h
+++ b/engines/mohawk/riven.h
@@ -151,6 +151,7 @@ public:
 	bool _activatedPLST;
 	bool _activatedSLST;
 	void delay(uint32 ms);
+	void runOptionsDialog();
 
 	// Save / Load
 	void runLoadDialog();
diff --git a/engines/mohawk/riven_card.cpp b/engines/mohawk/riven_card.cpp
index ffbbc69cae..304f596780 100644
--- a/engines/mohawk/riven_card.cpp
+++ b/engines/mohawk/riven_card.cpp
@@ -396,15 +396,31 @@ void RivenCard::applyPropertiesPatchE2E(uint32 globalId) {
 	// The main menu in the Myst 25th anniversary version is patched to include new items:
 	//   - Save game
 	if (globalId == 0xE2E) {
-		addMenuHotspot(23, Common::Rect(485, 283, 602, 300), 3, RivenStacks::ASpit::kExternalRestoreGame, "xarestoregame");
-		addMenuHotspot(24, Common::Rect(485, 311, 602, 326), 4, RivenStacks::ASpit::kExternalSaveGame,    "xaSaveGame");
+		moveHotspot(   22, Common::Rect(485, 175, 602, 190)); // Setup
+		moveHotspot(   16, Common::Rect(485, 201, 602, 216)); // New game
+		addMenuHotspot(23, Common::Rect(485, 227, 602, 242), 3, RivenStacks::ASpit::kExternalRestoreGame, "xarestoregame");
+		addMenuHotspot(24, Common::Rect(485, 256, 602, 271), 4, RivenStacks::ASpit::kExternalSaveGame,    "xaSaveGame");
+		addMenuHotspot(25, Common::Rect(485, 283, 602, 300), 5, RivenStacks::ASpit::kExternalResume,      "xaResumeGame");
+		addMenuHotspot(26, Common::Rect(485, 309, 602, 326), 6, RivenStacks::ASpit::kExternalOptions,     "xaOptions");
+		addMenuHotspot(27, Common::Rect(485, 335, 602, 352), 7, RivenStacks::ASpit::kExternalQuit,        "xademoquit");
 	}
 }
 
+void RivenCard::moveHotspot(uint16 blstId, const Common::Rect &position) {
+	RivenHotspot *hotspot = getHotspotByBlstId(blstId);
+	if (!hotspot) {
+		warning("Could not find hotspot with blstId %d", blstId);
+		return;
+	}
+
+	hotspot->setRect(position);
+}
+
 void RivenCard::addMenuHotspot(uint16 blstId, const Common::Rect &position, uint16 index,
                                uint16 externalCommandNameId, const char *externalCommandName) {
 	RivenHotspot *existingHotspot = getHotspotByBlstId(blstId);
 	if (existingHotspot) {
+		moveHotspot(blstId, position);
 		return; // Don't add the hotspot if it already exists
 	}
 
diff --git a/engines/mohawk/riven_card.h b/engines/mohawk/riven_card.h
index acf20faee8..5eae4c0179 100644
--- a/engines/mohawk/riven_card.h
+++ b/engines/mohawk/riven_card.h
@@ -158,6 +158,7 @@ private:
 	void applyPropertiesPatch22118(uint32 globalId);
 	void setCurrentCardVariable();
 
+	void moveHotspot(uint16 blstId, const Common::Rect &position);
 	void addMenuHotspot(uint16 blstId, const Common::Rect &position, uint16 index,
 	                    uint16 externalCommandNameId, const char *externalCommandName);
 
@@ -196,7 +197,6 @@ private:
 	Common::Array<MLSTRecord> _movieList;
 	Common::Array<HotspotEnableRecord> _hotspotEnableList;
 	Common::Array<WaterEffectRecord> _waterEffectList;
-
 };
 
 struct MLSTRecord {
diff --git a/engines/mohawk/riven_stacks/aspit.cpp b/engines/mohawk/riven_stacks/aspit.cpp
index de5747cbc2..ae346cdfea 100644
--- a/engines/mohawk/riven_stacks/aspit.cpp
+++ b/engines/mohawk/riven_stacks/aspit.cpp
@@ -66,20 +66,22 @@ ASpit::ASpit(MohawkEngine_Riven *vm) :
 	REGISTER_COMMAND(ASpit, xaexittomain);
 
 	REGISTER_COMMAND(ASpit, xaSaveGame);
+	REGISTER_COMMAND(ASpit, xaResumeGame);
+	REGISTER_COMMAND(ASpit, xaOptions);
 }
 
 struct MenuItemText {
 	int language;
-	const char *items[4];
+	const char *items[7];
 } static const menuItems[] = {
-	{ Common::EN_ANY, { "SETUP",      "START NEW GAME", "START SAVED GAME",  "SAVE GAME" }  },
-	{ Common::DE_DEU, { "SETUP",      "SPIELEN",        "SPIELSTAND LADEN",  "SPIEL SPEICHERN" } },
-	{ Common::ES_ESP, { "IMAGEN",     "IR A RIVEN",     "CARGAR JUEGO",      "GUARDAR JUEGO" } },
-	{ Common::FR_FRA, { "CONFIG",     "JOUER RIVEN",    "CHARGEMENT DU JEU", "JEU SAUVEGARDER" } },
-	{ Common::IT_ITA, { "CONF.",      "GIOCA",          "CARICA GIOCO",      "SALVA IL GIOCO" } },
-	{ Common::RU_RUS, { "УСТАНОВКИ",  "СТАРТ",          "ПРОДОЛЖИТЬ ИГРУ",   "СОХРАНИТЬ ИГРУ" } },
-	{ Common::JA_JPN, { "SETUP",      "PLAY RIVEN",     "START SAVED GAME",  "SAVE GAME" } },
-	{ Common::PL_POL, { "USTAWIENIA", "GRAJ W RIVEN",   "ZAŁADUJ GRĘ",       "ZAPISZ GRĘ" } },
+	{ Common::EN_ANY, { "SETUP",      "START NEW GAME", "START SAVED GAME",  "SAVE GAME",       "RESUME",  "OPTIONS",  "QUIT" } },
+	{ Common::DE_DEU, { "SETUP",      "SPIELEN",        "SPIELSTAND LADEN",  "SPIEL SPEICHERN", "RESUME",  "OPTIONS",  "QUIT" } },
+	{ Common::ES_ESP, { "IMAGEN",     "IR A RIVEN",     "CARGAR JUEGO",      "GUARDAR JUEGO",   "RESUME",  "OPTIONS",  "QUIT" } },
+	{ Common::FR_FRA, { "CONFIG",     "JOUER RIVEN",    "CHARGEMENT DU JEU", "JEU SAUVEGARDER", "RESUME",  "OPTIONS",  "QUIT" } },
+	{ Common::IT_ITA, { "CONF.",      "GIOCA",          "CARICA GIOCO",      "SALVA IL GIOCO",  "RESUME",  "OPTIONS",  "QUIT" } },
+	{ Common::RU_RUS, { "УСТАНОВКИ",  "СТАРТ",          "ПРОДОЛЖИТЬ ИГРУ",   "СОХРАНИТЬ ИГРУ",  "RESUME",  "OPTIONS",  "QUIT" } },
+	{ Common::JA_JPN, { "SETUP",      "PLAY RIVEN",     "START SAVED GAME",  "SAVE GAME",       "RESUME",  "OPTIONS",  "QUIT" } },
+	{ Common::PL_POL, { "USTAWIENIA", "GRAJ W RIVEN",   "ZAŁADUJ GRĘ",       "ZAPISZ GRĘ",      "RESUME",  "OPTIONS",  "QUIT" } },
 	{ -1, { 0 } }
 };
 
@@ -87,8 +89,6 @@ void ASpit::xastartupbtnhide(const ArgumentArray &args) {
 	// The original game hides the start/setup buttons depending on an ini entry.
 	// It's safe to ignore this command.
 
-	warning("xastartupbtnhide");
-
 	Common::File file;
 
 	const char *fontname = "FreeSans.ttf";
@@ -131,7 +131,10 @@ void ASpit::xastartupbtnhide(const ArgumentArray &args) {
 		{ 22 },
 		{ 16 },
 		{ 23 },
-		{ 24 }
+		{ 24 },
+		{ 25 },
+		{ 26 },
+		{ 27 }
 	};
 
 	for (uint i = 0; i < ARRAYSIZE(items); i++) {
@@ -373,6 +376,14 @@ void ASpit::xaSaveGame(const ArgumentArray &args) {
 	_vm->runSaveDialog();
 }
 
+void ASpit::xaResumeGame(const ArgumentArray &args) {
+
+}
+
+void ASpit::xaOptions(const ArgumentArray &args) {
+	_vm->runOptionsDialog();
+}
+
 void ASpit::xadisablemenureturn(const ArgumentArray &args) {
 	// This function would normally enable the Windows menu item for
 	// returning to the main menu. Ctrl+r will do this instead.
diff --git a/engines/mohawk/riven_stacks/aspit.h b/engines/mohawk/riven_stacks/aspit.h
index ba6f3c31f2..3ab02d7c17 100644
--- a/engines/mohawk/riven_stacks/aspit.h
+++ b/engines/mohawk/riven_stacks/aspit.h
@@ -37,7 +37,11 @@ public:
 
 	enum PatchedExternalCommandNameId {
 		kExternalSaveGame    = 20,
-		kExternalRestoreGame = 21
+		kExternalRestoreGame = 21,
+		kExternalResume      = 22,
+		kExternalOptions     = 23,
+		kExternalQuit        = 24
+
 	};
 
 	// External commands - Main Menu
@@ -66,6 +70,8 @@ public:
 
 	// External commands - ScummVM 25th anniversary specific
 	void xaSaveGame(const ArgumentArray &args);
+	void xaResumeGame(const ArgumentArray &args);
+	void xaOptions(const ArgumentArray &args);
 
 	// External commands - Demo-specific
 	void xadisablemenureturn(const ArgumentArray &args);
-- 
cgit v1.2.3