[Scummvm-cvs-logs] SF.net SVN: scummvm:[35316] scummvm/trunk/engines/tinsel

thebluegr at users.sourceforge.net thebluegr at users.sourceforge.net
Fri Dec 12 16:48:39 CET 2008


Revision: 35316
          http://scummvm.svn.sourceforge.net/scummvm/?rev=35316&view=rev
Author:   thebluegr
Date:     2008-12-12 15:48:38 +0000 (Fri, 12 Dec 2008)

Log Message:
-----------
- Save games are now listed from oldest to newest in the GMM load dialog for tinsel games, like in other engines
- Added some disabled code for saving through the GMM (still incomplete)

Modified Paths:
--------------
    scummvm/trunk/engines/tinsel/cursor.cpp
    scummvm/trunk/engines/tinsel/cursor.h
    scummvm/trunk/engines/tinsel/detection.cpp
    scummvm/trunk/engines/tinsel/saveload.cpp
    scummvm/trunk/engines/tinsel/savescn.cpp
    scummvm/trunk/engines/tinsel/savescn.h
    scummvm/trunk/engines/tinsel/tinsel.cpp
    scummvm/trunk/engines/tinsel/tinsel.h

Modified: scummvm/trunk/engines/tinsel/cursor.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/cursor.cpp	2008-12-12 14:28:06 UTC (rev 35315)
+++ scummvm/trunk/engines/tinsel/cursor.cpp	2008-12-12 15:48:38 UTC (rev 35316)
@@ -689,4 +689,8 @@
 	bTempHide = false;
 }
 
+bool isCursorShown() {
+	return !(bTempHide || bHiddenCursor);
+}
+
 } // end of namespace Tinsel

Modified: scummvm/trunk/engines/tinsel/cursor.h
===================================================================
--- scummvm/trunk/engines/tinsel/cursor.h	2008-12-12 14:28:06 UTC (rev 35315)
+++ scummvm/trunk/engines/tinsel/cursor.h	2008-12-12 15:48:38 UTC (rev 35316)
@@ -36,6 +36,7 @@
 void SetCursorScreenXY(int newx, int newy);
 void GetCursorXY(int *x, int *y, bool absolute);
 bool GetCursorXYNoWait(int *x, int *y, bool absolute);
+bool isCursorShown();
 
 void RestoreMainCursor(void);
 void SetTempCursor(SCNHANDLE pScript);

Modified: scummvm/trunk/engines/tinsel/detection.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/detection.cpp	2008-12-12 14:28:06 UTC (rev 35315)
+++ scummvm/trunk/engines/tinsel/detection.cpp	2008-12-12 15:48:38 UTC (rev 35316)
@@ -29,6 +29,7 @@
 #include "common/file.h"
 #include "common/savefile.h"
 
+#include "tinsel/cursor.h"
 #include "tinsel/tinsel.h"
 #include "tinsel/savescn.h"	// needed by TinselMetaEngine::listSaves
 
@@ -453,22 +454,36 @@
 }
 
 namespace Tinsel {
-
 extern int getList(Common::SaveFileManager *saveFileMan, const Common::String &target);
-extern void setNeedLoad();
-extern bool MoviePlaying(void);
-
+extern bool MoviePlaying();
 }
 
 SaveStateList TinselMetaEngine::listSaves(const char *target) const {
-	Tinsel::setNeedLoad();
-	int numStates = Tinsel::getList(g_system->getSavefileManager(), target);
+	Common::String pattern = target;
+	pattern = pattern + ".???";
+	Common::StringList files = g_system->getSavefileManager()->listSavefiles(pattern.c_str());
+	sort(files.begin(), files.end());	// Sort (hopefully ensuring we are sorted numerically..)
 
 	SaveStateList saveList;
-	for (int i = 0; i < numStates; i++) {
-		SaveStateDescriptor sd(i, Tinsel::ListEntry(i, Tinsel::LE_DESC));
-		// TODO: Also add savedFiles[i].dateTime to the SaveStateDescriptor
-		saveList.push_back(sd);
+	int slotNum = 0;
+	for (Common::StringList::const_iterator file = files.begin(); file != files.end(); ++file) {
+		// Obtain the last 2 digits of the filename, since they correspond to the save slot
+		slotNum = atoi(file->c_str() + file->size() - 2);
+
+		const Common::String &fname = *file;
+		Common::InSaveFile *in = g_system->getSavefileManager()->openForLoading(fname.c_str());
+		if (in) {
+			in->readUint32LE();		// skip id
+			in->readUint32LE();		// skip size
+			in->readUint32LE();		// skip version
+			char saveDesc[Tinsel::SG_DESC_LEN];
+			in->read(saveDesc, sizeof(saveDesc));
+
+			saveDesc[Tinsel::SG_DESC_LEN - 1] = 0;
+
+			saveList.push_back(SaveStateDescriptor(slotNum, saveDesc));
+			delete in;
+		}
 	}
 
 	return saveList;
@@ -502,10 +517,27 @@
 namespace Tinsel {
 
 Common::Error TinselEngine::loadGameState(int slot) {
-	RestoreGame(slot);
+	RestoreGame(slot, true);
 	return Common::kNoError;	// TODO: return success/failure
 }
 
+#if 0
+Common::Error TinselEngine::saveGameState(int slot, const char *desc) {
+	Common::String saveName = _vm->getSavegameFilename((int16)(slot + 1));
+	char saveDesc[SG_DESC_LEN];
+	strncpy(saveDesc, desc, SG_DESC_LEN);
+	// Make sure that saveDesc is 0-terminated
+	saveDesc[SG_DESC_LEN - 1] = '\0';
+	SaveGame((char *)saveName.c_str(), saveDesc);
+	ProcessSRQueue();			// This shouldn't be needed, but for some reason it is...
+	return Common::kNoError;	// TODO: return success/failure
+}
+#endif
+
 bool TinselEngine::canLoadGameStateCurrently() { return !MoviePlaying(); }
 
+#if 0
+bool TinselEngine::canSaveGameStateCurrently() { return isCursorShown(); }
+#endif
+
 } // End of namespace Tinsel

Modified: scummvm/trunk/engines/tinsel/saveload.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/saveload.cpp	2008-12-12 14:28:06 UTC (rev 35315)
+++ scummvm/trunk/engines/tinsel/saveload.cpp	2008-12-12 15:48:38 UTC (rev 35316)
@@ -429,11 +429,15 @@
 /**
  * DoRestore
  */
-static bool DoRestore(void) {
+static bool DoRestore(bool fromGMM) {
 	Common::InSaveFile *f;
 	uint32 id;
 
-	f = _vm->getSaveFileMan()->openForLoading(savedFiles[RestoreGameNumber].name);
+	if (!fromGMM)
+		f = _vm->getSaveFileMan()->openForLoading(savedFiles[RestoreGameNumber].name);
+	else
+		f = _vm->getSaveFileMan()->openForLoading(_vm->getSavegameFilename(RestoreGameNumber).c_str());
+		
 	if (f == NULL) {
 		return false;
 	}
@@ -515,7 +519,8 @@
 void ProcessSRQueue(void) {
 	switch (SRstate) {
 	case SR_DORESTORE:
-		if (DoRestore()) {
+	case SR_DORESTORE_GMM:
+		if (DoRestore(SRstate == SR_DORESTORE_GMM)) {
 			DoRestoreScene(srsd, false);
 		}
 		SRstate = SR_IDLE;
@@ -542,7 +547,7 @@
 	SRstate = SR_DOSAVE;
 }
 
-void RequestRestoreGame(int num, SAVED_DATA *sd, int *pSsCount, SAVED_DATA *pSsData) {
+void RequestRestoreGame(int num, SAVED_DATA *sd, int *pSsCount, SAVED_DATA *pSsData, bool fromGMM) {
 	if (TinselV2) {
 		if (num == -1)
 			return;
@@ -558,7 +563,7 @@
 	SaveSceneSsCount = pSsCount;
 	SaveSceneSsData = (char *)pSsData;
 	srsd = sd;
-	SRstate = SR_DORESTORE;
+	SRstate = (!fromGMM) ? SR_DORESTORE : SR_DORESTORE_GMM;
 }
 
 /**

Modified: scummvm/trunk/engines/tinsel/savescn.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/savescn.cpp	2008-12-12 14:28:06 UTC (rev 35315)
+++ scummvm/trunk/engines/tinsel/savescn.cpp	2008-12-12 15:48:38 UTC (rev 35316)
@@ -404,11 +404,11 @@
  * Restore game
  * @param num			num
  */
-void RestoreGame(int num) {
+void RestoreGame(int num, bool fromGMM) {
 	KillInventory();
 
-	RequestRestoreGame(num, &sgData, &savedSceneCount, ssData);
-	
+	RequestRestoreGame(num, &sgData, &savedSceneCount, ssData, fromGMM);
+
 	// Actual restoring is performed by ProcessSRQueue
 }
 

Modified: scummvm/trunk/engines/tinsel/savescn.h
===================================================================
--- scummvm/trunk/engines/tinsel/savescn.h	2008-12-12 14:28:06 UTC (rev 35315)
+++ scummvm/trunk/engines/tinsel/savescn.h	2008-12-12 15:48:38 UTC (rev 35316)
@@ -83,7 +83,7 @@
 
 
 enum SRSTATE {
-	SR_IDLE, SR_DORESTORE, SR_DONERESTORE,
+	SR_IDLE, SR_DORESTORE, SR_DORESTORE_GMM, SR_DONERESTORE,
 	SR_DOSAVE, SR_DONESAVE,	SR_ABORTED
 };
 
@@ -103,13 +103,13 @@
 int getList(void);
 void setNeedLoad(void);
 
-void RestoreGame(int num);
+void RestoreGame(int num, bool fromGMM = false);
 void SaveGame(char *name, char *desc);
 
 void ProcessSRQueue(void);
 
 void RequestSaveGame(char *name, char *desc, SAVED_DATA *sd, int *ssCount, SAVED_DATA *ssData);
-void RequestRestoreGame(int num, SAVED_DATA *sd, int *ssCount, SAVED_DATA *ssData);
+void RequestRestoreGame(int num, SAVED_DATA *sd, int *ssCount, SAVED_DATA *ssData, bool fromGMM);
 
 void InitialiseSaveScenes(void);
 void FreeSaveScenes(void);

Modified: scummvm/trunk/engines/tinsel/tinsel.cpp
===================================================================
--- scummvm/trunk/engines/tinsel/tinsel.cpp	2008-12-12 14:28:06 UTC (rev 35315)
+++ scummvm/trunk/engines/tinsel/tinsel.cpp	2008-12-12 15:48:38 UTC (rev 35316)
@@ -995,8 +995,7 @@
 	// Load game from specified slot, if any
 	// FIXME: Not working correctly right now
 	if (ConfMan.hasKey("save_slot")) {
-		getList();
-		RestoreGame(ConfMan.getInt("save_slot"));
+		RestoreGame(ConfMan.getInt("save_slot"), true);
 	}
 #endif
 

Modified: scummvm/trunk/engines/tinsel/tinsel.h
===================================================================
--- scummvm/trunk/engines/tinsel/tinsel.h	2008-12-12 14:28:06 UTC (rev 35315)
+++ scummvm/trunk/engines/tinsel/tinsel.h	2008-12-12 15:48:38 UTC (rev 35316)
@@ -144,7 +144,13 @@
 	virtual Common::Error go();
 	virtual bool hasFeature(EngineFeature f) const;
 	Common::Error loadGameState(int slot);
+#if 0
+	Common::Error saveGameState(int slot, const char *desc);
+#endif
 	bool canLoadGameStateCurrently();
+#if 0
+	bool canSaveGameStateCurrently();
+#endif
 	virtual void syncSoundSettings();
 
 public:


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