aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--engines/tinsel/cursor.cpp4
-rw-r--r--engines/tinsel/cursor.h1
-rw-r--r--engines/tinsel/detection.cpp54
-rw-r--r--engines/tinsel/saveload.cpp15
-rw-r--r--engines/tinsel/savescn.cpp6
-rw-r--r--engines/tinsel/savescn.h6
-rw-r--r--engines/tinsel/tinsel.cpp3
-rw-r--r--engines/tinsel/tinsel.h6
8 files changed, 71 insertions, 24 deletions
diff --git a/engines/tinsel/cursor.cpp b/engines/tinsel/cursor.cpp
index 719b55d1bb..3fc3b974e9 100644
--- a/engines/tinsel/cursor.cpp
+++ b/engines/tinsel/cursor.cpp
@@ -689,4 +689,8 @@ void EndCursorFollowed(void) {
bTempHide = false;
}
+bool isCursorShown() {
+ return !(bTempHide || bHiddenCursor);
+}
+
} // end of namespace Tinsel
diff --git a/engines/tinsel/cursor.h b/engines/tinsel/cursor.h
index bf1f0d064b..2648bca1ed 100644
--- a/engines/tinsel/cursor.h
+++ b/engines/tinsel/cursor.h
@@ -36,6 +36,7 @@ void SetCursorXY(int x, int y);
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);
diff --git a/engines/tinsel/detection.cpp b/engines/tinsel/detection.cpp
index 5ccb94ce59..95429dddea 100644
--- a/engines/tinsel/detection.cpp
+++ b/engines/tinsel/detection.cpp
@@ -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 @@ bool Tinsel::TinselEngine::hasFeature(EngineFeature f) const {
}
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 @@ void TinselMetaEngine::removeSaveState(const char *target, int slot) const {
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
diff --git a/engines/tinsel/saveload.cpp b/engines/tinsel/saveload.cpp
index 83d5df1262..5693e31caa 100644
--- a/engines/tinsel/saveload.cpp
+++ b/engines/tinsel/saveload.cpp
@@ -429,11 +429,15 @@ static void DoSync(Serializer &s) {
/**
* 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 @@ save_failure:
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 @@ void RequestSaveGame(char *name, char *desc, SAVED_DATA *sd, int *pSsCount, SAVE
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 @@ void RequestRestoreGame(int num, SAVED_DATA *sd, int *pSsCount, SAVED_DATA *pSsD
SaveSceneSsCount = pSsCount;
SaveSceneSsData = (char *)pSsData;
srsd = sd;
- SRstate = SR_DORESTORE;
+ SRstate = (!fromGMM) ? SR_DORESTORE : SR_DORESTORE_GMM;
}
/**
diff --git a/engines/tinsel/savescn.cpp b/engines/tinsel/savescn.cpp
index 418868aa74..93b81051f5 100644
--- a/engines/tinsel/savescn.cpp
+++ b/engines/tinsel/savescn.cpp
@@ -404,11 +404,11 @@ static int DoRestoreSceneFrame(SAVED_DATA *sd, int n) {
* 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
}
diff --git a/engines/tinsel/savescn.h b/engines/tinsel/savescn.h
index e7a4f18adf..7bc4faefd0 100644
--- a/engines/tinsel/savescn.h
+++ b/engines/tinsel/savescn.h
@@ -83,7 +83,7 @@ struct SAVED_DATA {
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 @@ char *ListEntry(int i, letype which);
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);
diff --git a/engines/tinsel/tinsel.cpp b/engines/tinsel/tinsel.cpp
index 33d1d9a96d..a7906a3ed1 100644
--- a/engines/tinsel/tinsel.cpp
+++ b/engines/tinsel/tinsel.cpp
@@ -995,8 +995,7 @@ Common::Error TinselEngine::go() {
// 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
diff --git a/engines/tinsel/tinsel.h b/engines/tinsel/tinsel.h
index 6870896f06..93afc18104 100644
--- a/engines/tinsel/tinsel.h
+++ b/engines/tinsel/tinsel.h
@@ -144,7 +144,13 @@ protected:
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: