mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-03 17:33:05 +00:00
Implement a beginning of savegame handling for remastered, this has the side effect of breaking the savegame menu, unless GetTextObjectDimesnions returns bitmapWidth (but that breaks Special Features). Leaving it broken for now. (Save game format is modified for remastered from this commit).
This commit is contained in:
parent
7ff408def0
commit
9acbc7c6cc
@ -181,6 +181,10 @@ GrimEngine::GrimEngine(OSystem *syst, uint32 gameFlags, GrimGameType gameType, C
|
||||
for (int i = 0; i < kNumConcepts; i++) {
|
||||
_conceptEnabled[i] = false;
|
||||
}
|
||||
|
||||
_saveMeta1 = "";
|
||||
_saveMeta2 = 0;
|
||||
_saveMeta3 = "";
|
||||
}
|
||||
|
||||
GrimEngine::~GrimEngine() {
|
||||
@ -1039,6 +1043,17 @@ void GrimEngine::restoreGRIM() {
|
||||
_savedState->endSection();
|
||||
}
|
||||
|
||||
void GrimEngine::storeSaveGameMetadata(SaveGame *state) {
|
||||
if (!g_grim->getGameFlags() & ADGF_REMASTERED) {
|
||||
return;
|
||||
}
|
||||
state->beginSection('META');
|
||||
state->writeString(_saveMeta1);
|
||||
state->writeLEUint32(_saveMeta2);
|
||||
state->writeString(_saveMeta3);
|
||||
state->endSection();
|
||||
}
|
||||
|
||||
void GrimEngine::storeSaveGameImage(SaveGame *state) {
|
||||
int width = 250, height = 188;
|
||||
Bitmap *screenshot;
|
||||
@ -1085,6 +1100,7 @@ void GrimEngine::savegameSave() {
|
||||
GUI::displayErrorDialog("Error: the game could not be saved.");
|
||||
return;
|
||||
}
|
||||
storeSaveGameMetadata(_savedState);
|
||||
|
||||
storeSaveGameImage(_savedState);
|
||||
|
||||
@ -1432,4 +1448,10 @@ void GrimEngine::enableCutscene(uint32 number) {
|
||||
_cutsceneEnabled[number] = true;
|
||||
}
|
||||
|
||||
void GrimEngine::setSaveMetaData(const char *meta1, int meta2, const char *meta3) {
|
||||
_saveMeta1 = meta1;
|
||||
_saveMeta2 = meta2;
|
||||
_saveMeta3 = meta3;
|
||||
}
|
||||
|
||||
} // end of namespace Grim
|
||||
|
@ -181,6 +181,9 @@ public:
|
||||
|
||||
bool isCutsceneEnabled(uint32 number) const;
|
||||
void enableCutscene(uint32 number);
|
||||
|
||||
// TODO: Refactor.
|
||||
void setSaveMetaData(const char*, int, const char*);
|
||||
|
||||
void saveGame(const Common::String &file);
|
||||
void loadGame(const Common::String &file);
|
||||
@ -225,6 +228,7 @@ protected:
|
||||
void savegameRestore();
|
||||
void restoreGRIM();
|
||||
|
||||
virtual void storeSaveGameMetadata(SaveGame *state);
|
||||
virtual void storeSaveGameImage(SaveGame *savedState);
|
||||
|
||||
bool _savegameLoadRequest;
|
||||
@ -281,6 +285,10 @@ protected:
|
||||
static const uint32 kNumCutscenes = 40;
|
||||
bool _cutsceneEnabled[kNumCutscenes]; // TODO, could probably use a different data structure
|
||||
bool _conceptEnabled[kNumConcepts];
|
||||
|
||||
Common::String _saveMeta1;
|
||||
int _saveMeta2;
|
||||
Common::String _saveMeta3;
|
||||
};
|
||||
|
||||
extern GrimEngine *g_grim;
|
||||
|
@ -330,6 +330,136 @@ void Lua_Remastered::GlobalSaveResolved() {
|
||||
lua_pushnumber(1);
|
||||
}
|
||||
|
||||
void Lua_Remastered::FindSaveGames() {
|
||||
warning("Stub function: FindSaveGames()");
|
||||
|
||||
Common::SaveFileManager *saveMan = g_grim->getSaveFileManager();
|
||||
Common::StringArray saveFiles = saveMan->listSavefiles("grim_r???.sav");
|
||||
|
||||
if (saveFiles.empty()) {
|
||||
lua_pushnil();
|
||||
return;
|
||||
}
|
||||
|
||||
lua_Object result = lua_createtable();
|
||||
|
||||
Common::StringArray::iterator it = saveFiles.begin();
|
||||
for (int i = 0; it != saveFiles.end(); ++it) {
|
||||
const char *filename = (*it).c_str();
|
||||
warning("Savefile: %s", filename);
|
||||
SaveGame *savedState = SaveGame::openForLoading(filename);
|
||||
|
||||
if (!savedState || !savedState->isCompatible()) {
|
||||
if (!savedState) {
|
||||
error("Savegame %s is invalid", filename);
|
||||
} else {
|
||||
error("Savegame %s is incompatible with this ResidualVM build. Save version: %d.%d; current version: %d.%d",
|
||||
filename, savedState->saveMajorVersion(), savedState->saveMinorVersion(),
|
||||
SaveGame::SAVEGAME_MAJOR_VERSION, SaveGame::SAVEGAME_MINOR_VERSION);
|
||||
}
|
||||
delete savedState;
|
||||
return;
|
||||
}
|
||||
int slot = atoi((*it).c_str() + 6);
|
||||
Common::String str1;
|
||||
Common::String str2;
|
||||
int x;
|
||||
int32 dataSize = savedState->beginSection('META');
|
||||
char str[200] = {};
|
||||
int32 strSize = 0;
|
||||
|
||||
strSize = savedState->readLESint32();
|
||||
savedState->read(str, strSize);
|
||||
str1 = str;
|
||||
x = savedState->readLESint32();
|
||||
strSize = savedState->readLESint32();
|
||||
savedState->read(str, strSize);
|
||||
str2 = str;
|
||||
savedState->endSection();
|
||||
delete savedState;
|
||||
|
||||
lua_pushobject(result);
|
||||
lua_pushnumber(i++);
|
||||
|
||||
str2 = g_localizer->localize(str2.c_str());
|
||||
|
||||
lua_Object keyVal = lua_createtable();
|
||||
// The key-value-mapping:
|
||||
{
|
||||
|
||||
lua_pushobject(keyVal);
|
||||
lua_pushstring("slot");
|
||||
lua_pushnumber(slot);
|
||||
lua_settable();
|
||||
|
||||
lua_pushobject(keyVal);
|
||||
lua_pushstring("title");
|
||||
lua_pushstring(str2.c_str());
|
||||
lua_settable();
|
||||
|
||||
lua_pushobject(keyVal);
|
||||
lua_pushstring("timeDateString");
|
||||
lua_pushstring("Unknown");
|
||||
lua_settable();
|
||||
|
||||
lua_pushobject(keyVal);
|
||||
lua_pushstring("mural_info");
|
||||
lua_pushstring(str1.c_str());
|
||||
lua_settable();
|
||||
|
||||
lua_pushobject(keyVal);
|
||||
lua_pushstring("setIndex");
|
||||
lua_pushnumber(x);
|
||||
lua_settable();
|
||||
}
|
||||
lua_pushobject(keyVal);
|
||||
|
||||
lua_settable();
|
||||
}
|
||||
|
||||
lua_pushobject(result);
|
||||
}
|
||||
|
||||
|
||||
void Lua_Remastered::Load() {
|
||||
lua_Object fileName = lua_getparam(1);
|
||||
// lua_Object param2 = lua_getparam(2);
|
||||
|
||||
if (lua_isnil(fileName)) {
|
||||
g_grim->loadGame("");
|
||||
} else if (lua_isnumber(fileName)) {
|
||||
int slot = lua_getnumber(fileName);
|
||||
Common::String saveGameFilename = Common::String::format("grim_r%03d.sav", slot);
|
||||
g_grim->loadGame(saveGameFilename.c_str());
|
||||
} else if (lua_isstring(fileName)) { // Check for number before this
|
||||
g_grim->loadGame(lua_getstring(fileName));
|
||||
} else {
|
||||
warning("Load() fileName is wrong");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
void Lua_Remastered::Save() {
|
||||
lua_Object param1 = lua_getparam(1);
|
||||
lua_Object param2 = lua_getparam(2);
|
||||
lua_Object param3 = lua_getparam(3);
|
||||
lua_Object param4 = lua_getparam(4);
|
||||
assert(lua_isnumber(param1));
|
||||
assert(lua_isstring(param2));
|
||||
assert(lua_isnumber(param3));
|
||||
assert(lua_isstring(param4));
|
||||
|
||||
int slot = lua_getnumber(param1);
|
||||
const char *p2Str = lua_getstring(param2);
|
||||
int p3Num = lua_getnumber(param3);
|
||||
const char *p4Str = lua_getstring(param4);
|
||||
|
||||
warning("REMASTERED save: %d, %s, %d, %s", slot, p2Str, p3Num, p4Str);
|
||||
Common::String saveGameFilename = Common::String::format("grim_r%03d.sav", slot);
|
||||
g_grim->setSaveMetaData(p2Str, p3Num, p4Str);
|
||||
g_grim->saveGame(saveGameFilename.c_str());
|
||||
}
|
||||
|
||||
void Lua_Remastered::ShowCursor() {
|
||||
lua_Object param1 = lua_getparam(1);
|
||||
assert(lua_isnumber(param1));
|
||||
@ -357,7 +487,6 @@ static void stubError(const char *funcName) {
|
||||
|
||||
STUB_FUNC(Lua_Remastered::PreloadCursors)
|
||||
STUB_FUNC(Lua_Remastered::GetFindSaveGameStatus)
|
||||
STUB_FUNC(Lua_Remastered::FindSaveGames)
|
||||
STUB_FUNC(Lua_Remastered::InitiateFindSaveGames)
|
||||
STUB_FUNC(Lua_Remastered::AreAchievementsInstalled)
|
||||
STUB_FUNC(Lua_Remastered::UnlockAchievement)
|
||||
|
@ -102,6 +102,10 @@ protected:
|
||||
DECLARE_LUA_OPCODE(GetSaveStatus);
|
||||
DECLARE_LUA_OPCODE(StartCheckOfCrossSaveStatus);
|
||||
DECLARE_LUA_OPCODE(GetCrossSaveStatus);
|
||||
|
||||
// Overridden:
|
||||
DECLARE_LUA_OPCODE(Load);
|
||||
DECLARE_LUA_OPCODE(Save);
|
||||
};
|
||||
|
||||
} // end of namespace Grim
|
||||
|
Loading…
x
Reference in New Issue
Block a user