[Scummvm-cvs-logs] scummvm master -> a2eaf78255d6a92f8d93e2a3e8907f60c2e6e699

bluegr bluegr at gmail.com
Mon Dec 8 00:10:28 CET 2014


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

Summary:
ec1fdeb25a ZVISION: Implement several advanced engine features and ScummVM dialogs
9ebfa3e4f9 ZVISION: Add some spacing
a2eaf78255 ZVISION: Remove unused code


Commit: ec1fdeb25ad6b2d9aae69a544f45eb7fc5e189b8
    https://github.com/scummvm/scummvm/commit/ec1fdeb25ad6b2d9aae69a544f45eb7fc5e189b8
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-12-08T01:08:27+02:00

Commit Message:
ZVISION: Implement several advanced engine features and ScummVM dialogs

The functionality to return to launcher, list saves, delete saves, load
games from the launcher and load and save games during runtime has been
implemented. Also, ScummVM save/load dialogs have been implemented.
Saved games now have three numbers in their file extension, bumping the
possible save game slots up to 999

Changed paths:
    engines/zvision/core/save_manager.cpp
    engines/zvision/core/save_manager.h
    engines/zvision/detection.cpp
    engines/zvision/scripting/script_manager.cpp
    engines/zvision/video/video.cpp
    engines/zvision/zvision.cpp
    engines/zvision/zvision.h



diff --git a/engines/zvision/core/save_manager.cpp b/engines/zvision/core/save_manager.cpp
index 11d3dd3..20bd39f 100644
--- a/engines/zvision/core/save_manager.cpp
+++ b/engines/zvision/core/save_manager.cpp
@@ -23,22 +23,60 @@
 #include "common/scummsys.h"
 
 #include "zvision/core/save_manager.h"
-
 #include "zvision/zvision.h"
 #include "zvision/scripting/script_manager.h"
 #include "zvision/graphics/render_manager.h"
 
 #include "common/system.h"
+#include "common/translation.h"
 
 #include "graphics/surface.h"
 #include "graphics/thumbnail.h"
 
 #include "gui/message.h"
+#include "gui/saveload.h"
 
 namespace ZVision {
 
 const uint32 SaveManager::SAVEGAME_ID = MKTAG('Z', 'E', 'N', 'G');
 
+bool SaveManager::scummVMSaveLoadDialog(bool isSave) {
+	GUI::SaveLoadChooser *dialog;
+	Common::String desc;
+	int slot;
+
+	if (isSave) {
+		dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
+
+		slot = dialog->runModalWithCurrentTarget();
+		desc = dialog->getResultString();
+
+		if (desc.empty()) {
+			// create our own description for the saved game, the user didnt enter it
+			desc = dialog->createDefaultSaveDescription(slot);
+		}
+
+		if (desc.size() > 28)
+			desc = Common::String(desc.c_str(), 28);
+	} else {
+		dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
+		slot = dialog->runModalWithCurrentTarget();
+	}
+
+	delete dialog;
+
+	if (slot < 0)
+		return false;
+
+	if (isSave) {
+		saveGame(slot, desc);
+		return true;
+	} else {
+		Common::ErrorCode result = loadGame(slot).getCode();
+		return (result == Common::kNoError);
+	}
+}
+
 void SaveManager::saveGame(uint slot, const Common::String &saveName) {
 	// The games only support 20 slots
 	//assert(slot <= 1 && slot <= 20);
diff --git a/engines/zvision/core/save_manager.h b/engines/zvision/core/save_manager.h
index 5cd61c7..7584133 100644
--- a/engines/zvision/core/save_manager.h
+++ b/engines/zvision/core/save_manager.h
@@ -96,6 +96,7 @@ public:
 
 	void prepareSaveBuffer();
 	void flushSaveBuffer();
+	bool scummVMSaveLoadDialog(bool isSave);
 private:
 	void writeSaveGameHeader(Common::OutSaveFile *file, const Common::String &saveName);
 };
diff --git a/engines/zvision/detection.cpp b/engines/zvision/detection.cpp
index 4d210ab..a60ef60 100644
--- a/engines/zvision/detection.cpp
+++ b/engines/zvision/detection.cpp
@@ -26,6 +26,8 @@
 
 #include "zvision/zvision.h"
 #include "zvision/detection.h"
+#include "zvision/core/save_manager.h"
+#include "zvision/scripting/script_manager.h"
 
 #include "common/translation.h"
 #include "common/savefile.h"
@@ -178,24 +180,40 @@ public:
 };
 
 bool ZVisionMetaEngine::hasFeature(MetaEngineFeature f) const {
-	return false;
-	/*
+	return
 	(f == kSupportsListSaves) ||
 	(f == kSupportsLoadingDuringStartup) ||
-	(f == kSupportsDeleteSave) ||
-	(f == kSavesSupportMetaInfo) ||
-	(f == kSavesSupportThumbnail) ||
-	(f == kSavesSupportCreationDate) ||
-	(f == kSavesSupportPlayTime);
-	*/
+	(f == kSupportsDeleteSave);
+	//(f == kSavesSupportMetaInfo) ||
+	//(f == kSavesSupportThumbnail) ||
+	//(f == kSavesSupportCreationDate) ||
+	//(f == kSavesSupportPlayTime);
 }
 
-/*bool ZVision::ZVision::hasFeature(EngineFeature f) const {
+bool ZVision::ZVision::hasFeature(EngineFeature f) const {
     return
         (f == kSupportsRTL) ||
         (f == kSupportsLoadingDuringRuntime) ||
         (f == kSupportsSavingDuringRuntime);
-}*/
+}
+
+Common::Error ZVision::ZVision::loadGameState(int slot) {
+	return _saveManager->loadGame(slot);
+}
+
+Common::Error ZVision::ZVision::saveGameState(int slot, const Common::String &desc) {
+	_saveManager->saveGame(slot, desc);
+	return Common::kNoError;
+}
+
+bool ZVision::ZVision::canLoadGameStateCurrently() {
+	return !_videoIsPlaying;
+}
+
+bool ZVision::ZVision::canSaveGameStateCurrently() {
+	Location currentLocation = _scriptManager->getCurrentLocation();
+	return !_videoIsPlaying && currentLocation.world != 'g' && !(currentLocation.room == 'j' || currentLocation.room == 'a');
+}
 
 bool ZVisionMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
 	const ZVision::ZVisionGameDescription *gd = (const ZVision::ZVisionGameDescription *)desc;
@@ -213,8 +231,8 @@ const ExtraGuiOptions ZVisionMetaEngine::getExtraGuiOptions(const Common::String
 }
 
 SaveStateList ZVisionMetaEngine::listSaves(const char *target) const {
-	//Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
-	/*ZVision::ZVision::SaveHeader header;
+	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
+	ZVision::SaveGameHeader header;
 	Common::String pattern = target;
 	pattern += ".???";
 
@@ -223,20 +241,25 @@ SaveStateList ZVisionMetaEngine::listSaves(const char *target) const {
 	Common::sort(filenames.begin(), filenames.end());   // Sort (hopefully ensuring we are sorted numerically..)*/
 
 	SaveStateList saveList;
-	/*  for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); file++) {
+	// We only use readSaveGameHeader() here, which doesn't need an engine callback
+	ZVision::SaveManager *zvisionSaveMan = new ZVision::SaveManager(NULL);
+
+	for (Common::StringArray::const_iterator file = filenames.begin(); file != filenames.end(); file++) {
 	        // Obtain the last 3 digits of the filename, since they correspond to the save slot
 	        int slotNum = atoi(file->c_str() + file->size() - 3);
 
 	        if (slotNum >= 0 && slotNum <= 999) {
 	            Common::InSaveFile *in = saveFileMan->openForLoading(file->c_str());
 	            if (in) {
-	                if (ZVision::ZVision::readSaveHeader(in, false, header) == ZVision::ZVision::kRSHENoError) {
-	                    saveList.push_back(SaveStateDescriptor(slotNum, header.description));
+	                if (zvisionSaveMan->readSaveGameHeader(in, header)) {
+	                    saveList.push_back(SaveStateDescriptor(slotNum, header.saveName));
 	                }
 	                delete in;
 	            }
 	        }
-	    }*/
+	}
+
+	delete zvisionSaveMan;
 
 	return saveList;
 }
@@ -246,9 +269,8 @@ int ZVisionMetaEngine::getMaximumSaveSlot() const {
 }
 
 void ZVisionMetaEngine::removeSaveState(const char *target, int slot) const {
-	/*
 	Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
-	Common::String filename = ZVision::ZVision::getSavegameFilename(target, slot);
+	Common::String filename = Common::String::format("%s.%03u", target, slot);
 
 	saveFileMan->removeSavefile(filename.c_str());
 
@@ -265,10 +287,9 @@ void ZVisionMetaEngine::removeSaveState(const char *target, int slot) const {
 	    // Rename every slot greater than the deleted slot,
 	    if (slotNum > slot) {
 	        saveFileMan->renameSavefile(file->c_str(), filename.c_str());
-	        filename = ZVision::ZVision::getSavegameFilename(target, ++slot);
+	        filename = Common::String::format("%s.%03u", target, ++slot);
 	    }
 	}
-	*/
 }
 
 SaveStateDescriptor ZVisionMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
diff --git a/engines/zvision/scripting/script_manager.cpp b/engines/zvision/scripting/script_manager.cpp
index 79048171..c532a2b 100644
--- a/engines/zvision/scripting/script_manager.cpp
+++ b/engines/zvision/scripting/script_manager.cpp
@@ -36,6 +36,7 @@
 #include "common/hashmap.h"
 #include "common/debug.h"
 #include "common/stream.h"
+#include "common/config-manager.h"
 
 namespace ZVision {
 
@@ -521,6 +522,28 @@ void ScriptManager::ChangeLocationReal() {
 	assert(_nextLocation.world != 0);
 	debug(1, "Changing location to: %c %c %c %c %u", _nextLocation.world, _nextLocation.room, _nextLocation.node, _nextLocation.view, _nextLocation.offset);
 
+	if (_nextLocation.world == 'g' && _nextLocation.room == 'j' && !ConfMan.getBool("originalsaveload")) {
+		if ((_nextLocation.node == 's' || _nextLocation.node == 'r') && _nextLocation.view == 'e') {
+			// Hook up the ScummVM save/restore dialog
+			bool isSave = (_nextLocation.node == 's');
+			bool gameSavedOrLoaded = _engine->getSaveManager()->scummVMSaveLoadDialog(isSave);
+			if (!gameSavedOrLoaded || isSave) {
+				// Reload the current room
+				_nextLocation.world = _currentLocation.world;
+				_nextLocation.room = _currentLocation.room;
+				_nextLocation.node = _currentLocation.node;
+				_nextLocation.view = _currentLocation.view;
+				_nextLocation.offset = _currentLocation.offset;
+				_currentLocation.world = '0';
+				_currentLocation.room = '0';
+				_currentLocation.node = '0';
+				_currentLocation.view = '0';
+				_currentLocation.offset = 0;
+			} else
+				return;
+		}
+	}
+
 	_engine->setRenderDelay(2);
 
 	if (getStateValue(StateKey_World) != 'g' || getStateValue(StateKey_Room) != 'j') {
diff --git a/engines/zvision/video/video.cpp b/engines/zvision/video/video.cpp
index 36b5f9b..db6161b 100644
--- a/engines/zvision/video/video.cpp
+++ b/engines/zvision/video/video.cpp
@@ -53,6 +53,7 @@ void ZVision::playVideo(Video::VideoDecoder &vid, const Common::Rect &destRect,
 
 	_clock.stop();
 	vid.start();
+	_videoIsPlaying = true;
 
 	// Only continue while the video is still playing
 	while (!shouldQuit() && !vid.endOfVideo() && vid.isPlaying()) {
@@ -99,6 +100,7 @@ void ZVision::playVideo(Video::VideoDecoder &vid, const Common::Rect &destRect,
 		_system->delayMillis(vid.getTimeToNextFrame() / 2);
 	}
 
+	_videoIsPlaying = false;
 	_clock.start();
 
 	if (scaled) {
diff --git a/engines/zvision/zvision.cpp b/engines/zvision/zvision.cpp
index af9d26a..8a44cce 100644
--- a/engines/zvision/zvision.cpp
+++ b/engines/zvision/zvision.cpp
@@ -96,7 +96,8 @@ ZVision::ZVision(OSystem *syst, const ZVisionGameDescription *gameDesc)
 	  _audioId(0),
 	  _rendDelay(2),
 	  _kbdVelocity(0),
-	  _mouseVelocity(0) {
+	  _mouseVelocity(0),
+	  _videoIsPlaying(false) {
 
 	debug(1, "ZVision::ZVision");
 
@@ -205,6 +206,10 @@ void ZVision::initialize() {
 Common::Error ZVision::run() {
 	initialize();
 
+	// Check if a saved game is to be loaded from the launcher
+	if (ConfMan.hasKey("save_slot"))
+		_saveManager->loadGame(ConfMan.getInt("save_slot"));
+
 	// Main loop
 	while (!shouldQuit()) {
 		_clock.update();
@@ -327,7 +332,7 @@ void ZVision::pauseEngineIntern(bool pause) {
 }
 
 Common::String ZVision::generateSaveFileName(uint slot) {
-	return Common::String::format("%s.%02u", _targetName.c_str(), slot);
+	return Common::String::format("%s.%03u", _targetName.c_str(), slot);
 }
 
 Common::String ZVision::generateAutoSaveFileName() {
diff --git a/engines/zvision/zvision.h b/engines/zvision/zvision.h
index ca6c8e1..5850bf6 100644
--- a/engines/zvision/zvision.h
+++ b/engines/zvision/zvision.h
@@ -124,6 +124,7 @@ private:
 	int16 _mouseVelocity;
 	int16 _kbdVelocity;
 	bool _halveDelay;
+	bool _videoIsPlaying;
 
 	uint8 _cheatBuff[KEYBUF_SIZE];
 public:
@@ -198,6 +199,13 @@ public:
 
 	void checkBorders();
 	void showDebugMsg(const Common::String &msg, int16 delay = 3000);
+
+	// Engine features
+	bool hasFeature(EngineFeature f) const;
+	bool canLoadGameStateCurrently();
+	bool canSaveGameStateCurrently();
+	Common::Error loadGameState(int slot);
+	Common::Error saveGameState(int slot, const Common::String &desc);
 private:
 	void initialize();
 	void initFonts();


Commit: 9ebfa3e4f93bd3af0b8170bbb718e4e9a120e776
    https://github.com/scummvm/scummvm/commit/9ebfa3e4f93bd3af0b8170bbb718e4e9a120e776
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-12-08T01:09:04+02:00

Commit Message:
ZVISION: Add some spacing

Changed paths:
    engines/zvision/utility/clock.h



diff --git a/engines/zvision/utility/clock.h b/engines/zvision/utility/clock.h
index 9a50116..cbf52be 100644
--- a/engines/zvision/utility/clock.h
+++ b/engines/zvision/utility/clock.h
@@ -47,6 +47,7 @@ public:
 	 * when the last update() was called.
 	 */
 	void update();
+
 	/**
 	 * Get the delta time since the last frame. (The time between update() calls)
 	 *
@@ -55,6 +56,7 @@ public:
 	uint32 getDeltaTime() const {
 		return _deltaTime;
 	}
+
 	/**
 	 * Get the time from the program starting to the last update() call
 	 *
@@ -69,6 +71,7 @@ public:
 	 * Has no effect if the clock is already paused.
 	 */
 	void start();
+
 	/**
 	 * Un-pause the clock.
 	 * Has no effect if the clock is already un-paused.


Commit: a2eaf78255d6a92f8d93e2a3e8907f60c2e6e699
    https://github.com/scummvm/scummvm/commit/a2eaf78255d6a92f8d93e2a3e8907f60c2e6e699
Author: Filippos Karapetis (bluegr at gmail.com)
Date: 2014-12-08T01:09:27+02:00

Commit Message:
ZVISION: Remove unused code

Changed paths:
    engines/zvision/utility/utility.cpp



diff --git a/engines/zvision/utility/utility.cpp b/engines/zvision/utility/utility.cpp
index 2388fe8..e09545a 100644
--- a/engines/zvision/utility/utility.cpp
+++ b/engines/zvision/utility/utility.cpp
@@ -42,19 +42,4 @@ void trimCommentsAndWhiteSpace(Common::String *string) {
 	string->trim();
 }
 
-void tryToDumpLine(const Common::String &key,
-                   Common::String &line,
-                   Common::HashMap<Common::String, byte> *count,
-                   Common::HashMap<Common::String, bool> *fileAlreadyUsed,
-                   Common::DumpFile &output) {
-	const byte numberOfExamplesPerType = 8;
-
-	if ((*count)[key] < numberOfExamplesPerType && !(*fileAlreadyUsed)[key]) {
-		output.writeString(line);
-		output.writeByte('\n');
-		(*count)[key]++;
-		(*fileAlreadyUsed)[key] = true;
-	}
-}
-
 } // End of namespace ZVision






More information about the Scummvm-git-logs mailing list