[Scummvm-cvs-logs] SF.net SVN: scummvm:[52305] scummvm/trunk/engines/sci/engine

m_kiewitz at users.sourceforge.net m_kiewitz at users.sourceforge.net
Mon Aug 23 21:10:07 CEST 2010


Revision: 52305
          http://scummvm.svn.sourceforge.net/scummvm/?rev=52305&view=rev
Author:   m_kiewitz
Date:     2010-08-23 19:10:06 +0000 (Mon, 23 Aug 2010)

Log Message:
-----------
SCI: some work on replacing sierra restore dialog

Modified Paths:
--------------
    scummvm/trunk/engines/sci/engine/kfile.cpp
    scummvm/trunk/engines/sci/engine/state.h

Modified: scummvm/trunk/engines/sci/engine/kfile.cpp
===================================================================
--- scummvm/trunk/engines/sci/engine/kfile.cpp	2010-08-23 18:52:10 UTC (rev 52304)
+++ scummvm/trunk/engines/sci/engine/kfile.cpp	2010-08-23 19:10:06 UTC (rev 52305)
@@ -24,10 +24,13 @@
  */
 
 #include "common/archive.h"
+#include "common/config-manager.h"
 #include "common/file.h"
 #include "common/str.h"
 #include "common/savefile.h"
 
+#include "gui/saveload.h"
+
 #include "sci/sci.h"
 #include "sci/engine/state.h"
 #include "sci/engine/kernel.h"
@@ -37,7 +40,7 @@
 namespace Sci {
 
 struct SavegameDesc {
-	uint id;
+	int16 id;
 	int virtualId; // straight numbered, according to id but w/o gaps
 	int date;
 	int time;
@@ -269,7 +272,7 @@
 }
 
 static void listSavegames(Common::Array<SavegameDesc> &saves);
-static int findSavegame(Common::Array<SavegameDesc> &saves, uint saveId);
+static int findSavegame(Common::Array<SavegameDesc> &saves, int16 saveId);
 
 enum {
 	K_DEVICE_INFO_GET_DEVICE = 0,
@@ -452,7 +455,7 @@
 }
 
 // Find a savedgame according to virtualId and return the position within our array
-static int findSavegame(Common::Array<SavegameDesc> &saves, uint savegameId) {
+static int findSavegame(Common::Array<SavegameDesc> &saves, int16 savegameId) {
 	for (uint saveNr = 0; saveNr < saves.size(); saveNr++) {
 		if (saves[saveNr].id == savegameId)
 			return saveNr;
@@ -549,7 +552,7 @@
 
 reg_t kSaveGame(EngineState *s, int argc, reg_t *argv) {
 	Common::String game_id = s->_segMan->getString(argv[0]);
-	uint virtualId = argv[1].toUint16();
+	int16 virtualId = argv[1].toSint16();
 	Common::String game_description = s->_segMan->getString(argv[2]);
 	Common::String version;
 	if (argc > 3)
@@ -566,7 +569,7 @@
 	Common::Array<SavegameDesc> saves;
 	listSavegames(saves);
 
-	uint savegameId;
+	int16 savegameId;
 	if ((virtualId >= SAVEGAMEID_OFFICIALRANGE_START) && (virtualId <= SAVEGAMEID_OFFICIALRANGE_END)) {
 		// savegameId is an actual Id, so search for it just to make sure
 		savegameId = virtualId - SAVEGAMEID_OFFICIALRANGE_START;
@@ -628,13 +631,26 @@
 
 reg_t kRestoreGame(EngineState *s, int argc, reg_t *argv) {
 	Common::String game_id = !argv[0].isNull() ? s->_segMan->getString(argv[0]) : "";
-	uint savegameId = argv[1].toUint16();
+	int16 savegameId = argv[1].toSint16();
 
 	debug(3, "kRestoreGame(%s,%d)", game_id.c_str(), savegameId);
 
 	if (argv[0].isNull()) {
-		// Loading from the launcher, don't adjust the ID of the saved game
+		// Direct call, either from launcher or from a patched Game::restore call
+		if (savegameId == -1) {
+			// we are supposed to show a dialog for the user and let him choose a saved game
+			const EnginePlugin *plugin = NULL;
+			EngineMan.findGame(g_sci->getGameIdStr(), &plugin);
+			GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser("Restore game:", "Restore");
+			dialog->setSaveMode(false);
+			savegameId = dialog->runModal(plugin, ConfMan.getActiveDomainName());
+			delete dialog;
+			if (savegameId < 0)
+				return s->r_acc;
+		}
+		// don't adjust ID of the saved game, it's already correct
 	} else {
+		// Real call from script, we need to adjust ID
 		if ((savegameId < SAVEGAMEID_OFFICIALRANGE_START) || (savegameId > SAVEGAMEID_OFFICIALRANGE_END)) {
 			warning("Savegame ID %d is not allowed", savegameId);
 			return TRUE_REG;

Modified: scummvm/trunk/engines/sci/engine/state.h
===================================================================
--- scummvm/trunk/engines/sci/engine/state.h	2010-08-23 18:52:10 UTC (rev 52304)
+++ scummvm/trunk/engines/sci/engine/state.h	2010-08-23 19:10:06 UTC (rev 52305)
@@ -136,8 +136,8 @@
 
 	DirSeeker _dirseeker;
 
-	uint _lastSaveVirtualId; // last virtual id fed to kSaveGame, if no kGetSaveFiles was called inbetween
-	uint _lastSaveNewId;    // last newly created filename-id by kSaveGame
+	int16 _lastSaveVirtualId; // last virtual id fed to kSaveGame, if no kGetSaveFiles was called inbetween
+	int16 _lastSaveNewId;    // last newly created filename-id by kSaveGame
 
 public:
 	/* VM Information */


This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.




More information about the Scummvm-git-logs mailing list