[Scummvm-git-logs] scummvm master -> bbd861f3ca9dd2e7814a3c9b2e159504b8ba99ce

bgK bastien.bouclet at gmail.com
Thu Apr 16 05:35:09 UTC 2020


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
bbd861f3ca MOHAWK: RIVEN: Use the shared save/load dialog code


Commit: bbd861f3ca9dd2e7814a3c9b2e159504b8ba99ce
    https://github.com/scummvm/scummvm/commit/bbd861f3ca9dd2e7814a3c9b2e159504b8ba99ce
Author: Bastien Bouclet (bastien.bouclet at gmail.com)
Date: 2020-04-16T07:34:02+02:00

Commit Message:
MOHAWK: RIVEN: Use the shared save/load dialog code

Changed paths:
    engines/mohawk/riven.cpp
    engines/mohawk/riven.h
    engines/mohawk/riven_stacks/aspit.cpp


diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index 542e72eb24..122e820425 100644
--- a/engines/mohawk/riven.cpp
+++ b/engines/mohawk/riven.cpp
@@ -292,12 +292,12 @@ void MohawkEngine_Riven::processInput() {
 				break;
 			case kRivenActionLoadGameState:
 				if (canLoadGameStateCurrently()) {
-					runLoadDialog();
+					loadGameDialog();
 				}
 				break;
 			case kRivenActionSaveGameState:
 				if (canSaveGameStateCurrently()) {
-					runSaveDialog();
+					saveGameDialog();
 				}
 				break;
 			default:
@@ -686,36 +686,6 @@ void MohawkEngine_Riven::startNewGame() {
 	setTotalPlayTime(0);
 }
 
-void MohawkEngine_Riven::runLoadDialog() {
-	GUI::SaveLoadChooser slc(_("Load game:"), _("Load"), false);
-
-	pauseEngine(true);
-	int slot = slc.runModalWithCurrentTarget();
-	pauseEngine(false);
-
-	if (slot >= 0) {
-		loadGameStateAndDisplayError(slot);
-	}
-}
-
-void MohawkEngine_Riven::runSaveDialog() {
-	GUI::SaveLoadChooser slc(_("Save game:"), _("Save"), true);
-
-	pauseEngine(true);
-	int slot = slc.runModalWithCurrentTarget();
-	pauseEngine(false);
-
-	if (slot >= 0) {
-		Common::String result(slc.getResultString());
-		if (result.empty()) {
-			// If the user was lazy and entered no save name, come up with a default name.
-			result = slc.createDefaultSaveDescription(slot);
-		}
-
-		saveGameStateAndDisplayError(slot, result);
-	}
-}
-
 Common::Error MohawkEngine_Riven::loadGameState(int slot) {
 	Common::Error loadError = _saveLoad->loadGame(slot);
 
@@ -728,17 +698,6 @@ Common::Error MohawkEngine_Riven::loadGameState(int slot) {
 	return loadError;
 }
 
-void MohawkEngine_Riven::loadGameStateAndDisplayError(int slot) {
-	assert(slot >= 0);
-
-	Common::Error loadError = loadGameState(slot);
-
-	if (loadError.getCode() != Common::kNoError) {
-		GUI::MessageDialog dialog(loadError.getDesc());
-		dialog.runModal();
-	}
-}
-
 Common::Error MohawkEngine_Riven::saveGameState(int slot, const Common::String &desc, bool isAutosave) {
 	if (_menuSavedStack != -1) {
 		_vars["CurrentStackID"] = _menuSavedStack;
@@ -771,17 +730,6 @@ Common::Language MohawkEngine_Riven::getLanguage() const {
 	return language;
 }
 
-void MohawkEngine_Riven::saveGameStateAndDisplayError(int slot, const Common::String &desc) {
-	assert(slot >= 0 && !desc.empty());
-
-	Common::Error saveError = saveGameState(slot, desc);
-
-	if (saveError.getCode() != Common::kNoError) {
-		GUI::MessageDialog dialog(saveError.getDesc());
-		dialog.runModal();
-	}
-}
-
 bool MohawkEngine_Riven::canSaveAutosaveCurrently() {
 	return canSaveGameStateCurrently() && !_gameEnded;
 }
@@ -815,7 +763,7 @@ bool MohawkEngine_Riven::canLoadGameStateCurrently() {
 		return false;
 	}
 
-	if (_scriptMan->hasQueuedScripts()) {
+	if (_scriptMan->hasQueuedScripts() && !isInMainMenu()) {
 		return false;
 	}
 
diff --git a/engines/mohawk/riven.h b/engines/mohawk/riven.h
index f7ebba1f7f..f916465f4a 100644
--- a/engines/mohawk/riven.h
+++ b/engines/mohawk/riven.h
@@ -182,11 +182,7 @@ public:
 	void runOptionsDialog();
 
 	// Save / Load
-	void runLoadDialog();
-	void runSaveDialog();
 	virtual bool canSaveAutosaveCurrently() override;
-	void loadGameStateAndDisplayError(int slot);
-	void saveGameStateAndDisplayError(int slot, const Common::String &desc);
 
 	/**
 	 * Has the game ended, or has the user requested to quit?
diff --git a/engines/mohawk/riven_stacks/aspit.cpp b/engines/mohawk/riven_stacks/aspit.cpp
index 922bbd9345..8bc95b4e66 100644
--- a/engines/mohawk/riven_stacks/aspit.cpp
+++ b/engines/mohawk/riven_stacks/aspit.cpp
@@ -352,11 +352,11 @@ void ASpit::xarestoregame(const ArgumentArray &args) {
 	}
 
 	// Launch the load game dialog
-	_vm->runLoadDialog();
+	_vm->loadGameDialog();
 }
 
 void ASpit::xaSaveGame(const ArgumentArray &args) {
-	_vm->runSaveDialog();
+	_vm->saveGameDialog();
 }
 
 void ASpit::xaResumeGame(const ArgumentArray &args) {




More information about the Scummvm-git-logs mailing list