mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-30 07:23:05 +00:00
- 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) svn-id: r35316
This commit is contained in:
parent
63ddc1ba6f
commit
cbdb105d8e
@ -689,4 +689,8 @@ void EndCursorFollowed(void) {
|
||||
bTempHide = false;
|
||||
}
|
||||
|
||||
bool isCursorShown() {
|
||||
return !(bTempHide || bHiddenCursor);
|
||||
}
|
||||
|
||||
} // end of namespace Tinsel
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
@ -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;
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -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
|
||||
}
|
||||
|
||||
|
@ -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);
|
||||
|
@ -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
|
||||
|
||||
|
@ -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:
|
||||
|
Loading…
x
Reference in New Issue
Block a user