aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorBastien Bouclet2018-06-21 21:16:25 +0200
committerBastien Bouclet2018-06-29 13:31:54 +0200
commite7cb40dde57f5331db014eb61ff115baa7917148 (patch)
tree7d464d13f8141696d692d10977bb20eacfaa52c2 /engines
parent45ab57209f965a4804286e072f181bf98b3af6b4 (diff)
downloadscummvm-rg350-e7cb40dde57f5331db014eb61ff115baa7917148.tar.gz
scummvm-rg350-e7cb40dde57f5331db014eb61ff115baa7917148.tar.bz2
scummvm-rg350-e7cb40dde57f5331db014eb61ff115baa7917148.zip
MOHAWK: RIVEN: Use an in-game thumbnail when saving from the menu
Instead of a thumbnail of the menu itself.
Diffstat (limited to 'engines')
-rw-r--r--engines/mohawk/riven.cpp15
-rw-r--r--engines/mohawk/riven.h3
-rw-r--r--engines/mohawk/riven_saveload.cpp13
-rw-r--r--engines/mohawk/riven_saveload.h5
4 files changed, 28 insertions, 8 deletions
diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp
index 9b9080da8a..5faebf8f1e 100644
--- a/engines/mohawk/riven.cpp
+++ b/engines/mohawk/riven.cpp
@@ -26,6 +26,7 @@
#include "common/keyboard.h"
#include "common/translation.h"
#include "common/system.h"
+#include "graphics/scaler.h"
#include "gui/saveload.h"
#include "gui/message.h"
@@ -337,6 +338,9 @@ void MohawkEngine_Riven::goToMainMenu() {
return;
}
+ _menuTumbnail.reset(new Graphics::Surface());
+ createThumbnailFromScreen(_menuTumbnail.get());
+
changeToStack(kStackAspit);
changeToCard(1);
}
@@ -348,6 +352,7 @@ void MohawkEngine_Riven::resumeFromMainMenu() {
changeToCard(_menuSavedCard);
_menuSavedStack = -1;
_menuSavedCard = -1;
+ _menuTumbnail.reset();
}
bool MohawkEngine_Riven::isGameStarted() const {
@@ -584,11 +589,14 @@ void MohawkEngine_Riven::startNewGame() {
// Clear all the state data
_menuSavedStack = -1;
_menuSavedCard = -1;
+ _menuTumbnail.reset();
_vars.clear();
initVars();
_zipModeData.clear();
+
+ setTotalPlayTime(0);
}
void MohawkEngine_Riven::runLoadDialog() {
@@ -627,6 +635,7 @@ Common::Error MohawkEngine_Riven::loadGameState(int slot) {
if (loadError.getCode() == Common::kNoError) {
_menuSavedStack = -1;
_menuSavedCard = -1;
+ _menuTumbnail.reset();
}
return loadError;
@@ -649,7 +658,8 @@ Common::Error MohawkEngine_Riven::saveGameState(int slot, const Common::String &
_vars["CurrentCardID"] = _menuSavedCard;
}
- Common::Error error = _saveLoad->saveGame(slot, desc, false);
+ const Graphics::Surface *thumbnail = _menuSavedStack != -1 ? _menuTumbnail.get() : nullptr;
+ Common::Error error = _saveLoad->saveGame(slot, desc, thumbnail, false);
if (_menuSavedStack != -1) {
_vars["CurrentStackID"] = 1;
@@ -681,7 +691,8 @@ void MohawkEngine_Riven::tryAutoSaving() {
return; // Can't autosave ever, try again after the next autosave delay
}
- Common::Error saveError = _saveLoad->saveGame(RivenSaveLoad::kAutoSaveSlot, "Autosave", true);
+ const Graphics::Surface *thumbnail = _menuSavedStack != -1 ? _menuTumbnail.get() : nullptr;
+ Common::Error saveError = _saveLoad->saveGame(RivenSaveLoad::kAutoSaveSlot, "Autosave", thumbnail, true);
if (saveError.getCode() != Common::kNoError)
warning("Attempt to autosave has failed.");
}
diff --git a/engines/mohawk/riven.h b/engines/mohawk/riven.h
index 548ee6ee58..57a3d2b180 100644
--- a/engines/mohawk/riven.h
+++ b/engines/mohawk/riven.h
@@ -31,6 +31,8 @@
#include "common/random.h"
#include "common/rect.h"
+#include "graphics/surface.h"
+
namespace Mohawk {
struct MohawkGameDescription;
@@ -122,6 +124,7 @@ private:
int _menuSavedCard;
int _menuSavedStack;
+ Common::ScopedPtr<Graphics::Surface, Graphics::SurfaceDeleter> _menuTumbnail;
bool _gameEnded;
uint32 _lastSaveTime;
diff --git a/engines/mohawk/riven_saveload.cpp b/engines/mohawk/riven_saveload.cpp
index e8d29a0c24..7a156ad9c9 100644
--- a/engines/mohawk/riven_saveload.cpp
+++ b/engines/mohawk/riven_saveload.cpp
@@ -413,10 +413,14 @@ Common::MemoryWriteStreamDynamic *RivenSaveLoad::genZIPSSection() {
return stream;
}
-Common::MemoryWriteStreamDynamic *RivenSaveLoad::genTHMBSection() const {
+Common::MemoryWriteStreamDynamic *RivenSaveLoad::genTHMBSection(const Graphics::Surface *thumbnail) const {
Common::MemoryWriteStreamDynamic *stream = new Common::MemoryWriteStreamDynamic(DisposeAfterUse::YES);
- Graphics::saveThumbnail(*stream);
+ if (thumbnail) {
+ Graphics::saveThumbnail(*stream, *thumbnail);
+ } else {
+ Graphics::saveThumbnail(*stream);
+ }
return stream;
}
@@ -442,7 +446,8 @@ Common::MemoryWriteStreamDynamic *RivenSaveLoad::genMETASection(const Common::St
return stream;
}
-Common::Error RivenSaveLoad::saveGame(const int slot, const Common::String &description, bool autoSave) {
+Common::Error RivenSaveLoad::saveGame(const int slot, const Common::String &description,
+ const Graphics::Surface *thumbnail, bool autoSave) {
// NOTE: This code is designed to only output a Mohawk archive
// for a Riven saved game. It's hardcoded to do this because
// (as of right now) this is the only place in the engine
@@ -460,7 +465,7 @@ Common::Error RivenSaveLoad::saveGame(const int slot, const Common::String &desc
Common::MemoryWriteStreamDynamic *metaSection = genMETASection(description, autoSave);
Common::MemoryWriteStreamDynamic *nameSection = genNAMESection();
- Common::MemoryWriteStreamDynamic *thmbSection = genTHMBSection();
+ Common::MemoryWriteStreamDynamic *thmbSection = genTHMBSection(thumbnail);
Common::MemoryWriteStreamDynamic *varsSection = genVARSSection();
Common::MemoryWriteStreamDynamic *versSection = genVERSSection();
Common::MemoryWriteStreamDynamic *zipsSection = genZIPSSection();
diff --git a/engines/mohawk/riven_saveload.h b/engines/mohawk/riven_saveload.h
index 1432505b02..1682db3e95 100644
--- a/engines/mohawk/riven_saveload.h
+++ b/engines/mohawk/riven_saveload.h
@@ -65,7 +65,8 @@ public:
~RivenSaveLoad();
Common::Error loadGame(const int slot);
- Common::Error saveGame(const int slot, const Common::String &description, bool autoSave);
+ Common::Error saveGame(const int slot, const Common::String &description,
+ const Graphics::Surface *thumbnail, bool autoSave);
bool isAutoSaveAllowed();
static void deleteSave(const int slot);
@@ -80,7 +81,7 @@ private:
Common::MemoryWriteStreamDynamic *genNAMESection();
Common::MemoryWriteStreamDynamic *genMETASection(const Common::String &desc, bool autoSave) const;
- Common::MemoryWriteStreamDynamic *genTHMBSection() const;
+ Common::MemoryWriteStreamDynamic *genTHMBSection(const Graphics::Surface *thumbnail) const;
Common::MemoryWriteStreamDynamic *genVARSSection();
Common::MemoryWriteStreamDynamic *genVERSSection();
Common::MemoryWriteStreamDynamic *genZIPSSection();