mirror of
https://github.com/libretro/scummvm.git
synced 2025-05-13 17:46:22 +00:00
MOHAWK: Riven: Improve save load error handling
A GUI error message is now displayed if an error occurs when loading a save.
This commit is contained in:
parent
e5ab09d7e5
commit
c3bbae041a
@ -27,6 +27,7 @@
|
|||||||
#include "common/translation.h"
|
#include "common/translation.h"
|
||||||
#include "common/system.h"
|
#include "common/system.h"
|
||||||
#include "gui/saveload.h"
|
#include "gui/saveload.h"
|
||||||
|
#include "gui/message.h"
|
||||||
|
|
||||||
#include "mohawk/cursors.h"
|
#include "mohawk/cursors.h"
|
||||||
#include "mohawk/installer_archive.h"
|
#include "mohawk/installer_archive.h"
|
||||||
@ -173,10 +174,10 @@ Common::Error MohawkEngine_Riven::run() {
|
|||||||
// Load game from launcher/command line if requested
|
// Load game from launcher/command line if requested
|
||||||
int gameToLoad = ConfMan.getInt("save_slot");
|
int gameToLoad = ConfMan.getInt("save_slot");
|
||||||
|
|
||||||
// Attempt to load the game. On failure, just send us to the main menu.
|
// Attempt to load the game.
|
||||||
if (_saveLoad->loadGame(gameToLoad).getCode() != Common::kNoError) {
|
Common::Error loadError = _saveLoad->loadGame(gameToLoad);
|
||||||
changeToStack(kStackAspit);
|
if (loadError.getCode() != Common::kNoError) {
|
||||||
changeToCard(1);
|
return loadError;
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
// Otherwise, start us off at aspit's card 1 (the main menu)
|
// Otherwise, start us off at aspit's card 1 (the main menu)
|
||||||
@ -227,7 +228,7 @@ void MohawkEngine_Riven::doFrame() {
|
|||||||
case Common::KEYCODE_F5:
|
case Common::KEYCODE_F5:
|
||||||
runDialog(*_optionsDialog);
|
runDialog(*_optionsDialog);
|
||||||
if (_optionsDialog->getLoadSlot() >= 0)
|
if (_optionsDialog->getLoadSlot() >= 0)
|
||||||
loadGameState(_optionsDialog->getLoadSlot());
|
loadGameStateAndDisplayError(_optionsDialog->getLoadSlot());
|
||||||
_gfx->setTransitionMode((RivenTransitionMode) _vars["transitionmode"]);
|
_gfx->setTransitionMode((RivenTransitionMode) _vars["transitionmode"]);
|
||||||
_card->initializeZipMode();
|
_card->initializeZipMode();
|
||||||
break;
|
break;
|
||||||
@ -433,14 +434,26 @@ void MohawkEngine_Riven::runLoadDialog() {
|
|||||||
GUI::SaveLoadChooser slc(_("Load game:"), _("Load"), false);
|
GUI::SaveLoadChooser slc(_("Load game:"), _("Load"), false);
|
||||||
|
|
||||||
int slot = slc.runModalWithCurrentTarget();
|
int slot = slc.runModalWithCurrentTarget();
|
||||||
if (slot >= 0)
|
if (slot >= 0) {
|
||||||
loadGameState(slot);
|
loadGameStateAndDisplayError(slot);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Common::Error MohawkEngine_Riven::loadGameState(int slot) {
|
Common::Error MohawkEngine_Riven::loadGameState(int slot) {
|
||||||
return _saveLoad->loadGame(slot);
|
return _saveLoad->loadGame(slot);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
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) {
|
Common::Error MohawkEngine_Riven::saveGameState(int slot, const Common::String &desc) {
|
||||||
return _saveLoad->saveGame(slot, desc);
|
return _saveLoad->saveGame(slot, desc);
|
||||||
}
|
}
|
||||||
|
@ -99,6 +99,7 @@ public:
|
|||||||
bool canLoadGameStateCurrently();
|
bool canLoadGameStateCurrently();
|
||||||
bool canSaveGameStateCurrently();
|
bool canSaveGameStateCurrently();
|
||||||
Common::Error loadGameState(int slot);
|
Common::Error loadGameState(int slot);
|
||||||
|
void loadGameStateAndDisplayError(int slot);
|
||||||
Common::Error saveGameState(int slot, const Common::String &desc);
|
Common::Error saveGameState(int slot, const Common::String &desc);
|
||||||
bool hasFeature(EngineFeature f) const;
|
bool hasFeature(EngineFeature f) const;
|
||||||
|
|
||||||
|
@ -180,9 +180,9 @@ Common::Error RivenSaveLoad::loadGame(const int slot) {
|
|||||||
delete vers;
|
delete vers;
|
||||||
if ((saveGameVersion == kCDSaveGameVersion && (_vm->getFeatures() & GF_DVD))
|
if ((saveGameVersion == kCDSaveGameVersion && (_vm->getFeatures() & GF_DVD))
|
||||||
|| (saveGameVersion == kDVDSaveGameVersion && !(_vm->getFeatures() & GF_DVD))) {
|
|| (saveGameVersion == kDVDSaveGameVersion && !(_vm->getFeatures() & GF_DVD))) {
|
||||||
warning("Incompatible saved game versions. No support for this yet");
|
warning("Unable to load: Saved game created using an incompatible game version - CD vs DVD");
|
||||||
delete mhk;
|
delete mhk;
|
||||||
return Common::Error(Common::kUnknownError, "Incompatible save version");
|
return Common::Error(Common::kUnknownError, "Saved game created using an incompatible game version - CD vs DVD");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Now, we'll read in the variable values.
|
// Now, we'll read in the variable values.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user