aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2012-05-16 00:05:48 +1000
committerPaul Gilbert2012-05-17 19:38:57 +1000
commit59942d9a41cf7d43b95e9775aca66c241884b516 (patch)
tree7f8b0b671cff28dfb233c57ee6f3502f084db538 /engines
parent88762667b52e4b904c56ecc94bf304c1a91e9feb (diff)
downloadscummvm-rg350-59942d9a41cf7d43b95e9775aca66c241884b516.tar.gz
scummvm-rg350-59942d9a41cf7d43b95e9775aca66c241884b516.tar.bz2
scummvm-rg350-59942d9a41cf7d43b95e9775aca66c241884b516.zip
TONY: Work on enabling GMM saving and loading
Diffstat (limited to 'engines')
-rw-r--r--engines/tony/detection.cpp36
-rw-r--r--engines/tony/gfxengine.cpp12
-rw-r--r--engines/tony/gfxengine.h5
-rw-r--r--engines/tony/tony.cpp44
-rw-r--r--engines/tony/tony.h8
5 files changed, 93 insertions, 12 deletions
diff --git a/engines/tony/detection.cpp b/engines/tony/detection.cpp
index 944f717f26..5b1092d2c0 100644
--- a/engines/tony/detection.cpp
+++ b/engines/tony/detection.cpp
@@ -25,6 +25,7 @@
#include "engines/advancedDetector.h"
#include "common/system.h"
+#include "graphics/surface.h"
#include "tony/tony.h"
#include "tony/game.h"
@@ -75,18 +76,23 @@ public:
virtual SaveStateList listSaves(const char *target) const;
virtual int getMaximumSaveSlot() const;
virtual void removeSaveState(const char *target, int slot) const;
+ SaveStateDescriptor TonyMetaEngine::querySaveMetaInfos(const char *target, int slot) const;
};
bool TonyMetaEngine::hasFeature(MetaEngineFeature f) const {
return
(f == kSupportsListSaves) ||
-// (f == kSupportsLoadingDuringStartup) ||
- (f == kSupportsDeleteSave);
+ (f == kSupportsLoadingDuringStartup) ||
+ (f == kSupportsDeleteSave) ||
+ (f == kSavesSupportMetaInfo) ||
+ (f == kSavesSupportThumbnail);
}
bool Tony::TonyEngine::hasFeature(EngineFeature f) const {
return
- (f == kSupportsRTL);
+ (f == kSupportsRTL) ||
+ (f == kSupportsLoadingDuringRuntime) ||
+ (f == kSupportsSavingDuringRuntime);
}
bool TonyMetaEngine::createInstance(OSystem *syst, Engine **engine, const ADGameDescription *desc) const {
@@ -136,6 +142,30 @@ void TonyMetaEngine::removeSaveState(const char *target, int slot) const {
g_system->getSavefileManager()->removeSavefile(filename);
}
+SaveStateDescriptor TonyMetaEngine::querySaveMetaInfos(const char *target, int slot) const {
+ Tony::RMString saveName;
+ byte difficulty;
+
+ Graphics::PixelFormat pixelFormat(2, 5, 5, 5, 0, 10, 5, 0, 0);
+ Graphics::Surface *thumbnail = new Graphics::Surface();
+ thumbnail->create(160, 120, pixelFormat);
+
+ if (Tony::RMOptionScreen::LoadThumbnailFromSaveState(slot, (byte *)thumbnail->pixels, saveName, difficulty)) {
+ // Create the return descriptor
+ SaveStateDescriptor desc(slot, (const char *)saveName);
+ desc.setDeletableFlag(true);
+ desc.setWriteProtectedFlag(false);
+ desc.setThumbnail(thumbnail);
+
+ return desc;
+ }
+
+ thumbnail->free();
+ delete thumbnail;
+ return SaveStateDescriptor();
+}
+
+
#if PLUGIN_ENABLED_DYNAMIC(TONY)
REGISTER_PLUGIN_DYNAMIC(TONY, PLUGIN_TYPE_ENGINE, TonyMetaEngine);
#else
diff --git a/engines/tony/gfxengine.cpp b/engines/tony/gfxengine.cpp
index 384e80f209..7cfeaecb6f 100644
--- a/engines/tony/gfxengine.cpp
+++ b/engines/tony/gfxengine.cpp
@@ -698,7 +698,7 @@ void LoadMusic(Common::InSaveFile *f);
#define TONY_SAVEGAME_VERSION 8
-void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bool bFastCompress) {
+void RMGfxEngine::SaveState(const Common::String &fn, byte *curThumb, const Common::String &name) {
Common::OutSaveFile *f;
byte *state;
uint thumbsize;
@@ -733,9 +733,9 @@ void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bo
i = mpalQueryGlobalVar("VERSIONEFACILE");
f->writeByte(i);
- i = strlen(name);
+ i = strlen(name.c_str());
f->writeByte(i);
- f->write(name, i);
+ f->write(name.c_str(), i);
f->writeUint32LE(m_nCurLoc);
f->writeUint32LE(tp.x);
f->writeUint32LE(tp.y);
@@ -801,7 +801,7 @@ void RMGfxEngine::SaveState(const char *fn, byte *curThumb, const char *name, bo
delete f;
}
-void RMGfxEngine::LoadState(CORO_PARAM, const char *fn) {
+void RMGfxEngine::LoadState(CORO_PARAM, const Common::String &fn) {
// PROBLEMA: Bisognerebbe caricare la locazione in un thread a parte per fare la OnEnter ...
CORO_BEGIN_CONTEXT;
Common::InSaveFile *f;
@@ -986,4 +986,8 @@ void RMGfxEngine::WaitWipeEnd(CORO_PARAM) {
CoroScheduler.waitForSingleObject(coroParam, m_hWipeEvent, CORO_INFINITE);
}
+bool RMGfxEngine::CanLoadSave() {
+ return m_bInput && !m_tony.InAction();
+}
+
} // End of namespace Tony
diff --git a/engines/tony/gfxengine.h b/engines/tony/gfxengine.h
index 24deb47ec4..06eb3cc4ba 100644
--- a/engines/tony/gfxengine.h
+++ b/engines/tony/gfxengine.h
@@ -133,8 +133,8 @@ public:
void Unfreeze(void);
// State management
- void SaveState(const char *fn, byte *curThumb, const char *name, bool bFastCompress = false);
- void LoadState(CORO_PARAM, const char *fn);
+ void SaveState(const Common::String &fn, byte *curThumb, const Common::String &name);
+ void LoadState(CORO_PARAM, const Common::String &fn);
// Selects a location
void SelectLocation(const RMPoint &ptTonyStart = RMPoint(-1, -1), const RMPoint &start = RMPoint(-1, -1));
@@ -150,6 +150,7 @@ public:
void SetPalesati(bool bpal) {
m_inter.SetPalesati(bpal);
}
+ bool CanLoadSave();
};
} // End of namespace Tony
diff --git a/engines/tony/tony.cpp b/engines/tony/tony.cpp
index d476f60859..c7056cb88d 100644
--- a/engines/tony/tony.cpp
+++ b/engines/tony/tony.cpp
@@ -43,6 +43,14 @@ TonyEngine::TonyEngine(OSystem *syst, const TonyGameDescription *gameDesc) : Eng
DebugMan.addDebugChannel(kTonyDebugActions, "actions", "Actions debugging");
DebugMan.addDebugChannel(kTonyDebugSound, "sound", "Sound debugging");
DebugMan.addDebugChannel(kTonyDebugMusic, "music", "Music debugging");
+
+ // Set up load slot number
+ _loadSlotNumber = -1;
+ if (ConfMan.hasKey("save_slot")) {
+ int slotNumber = ConfMan.getInt("save_slot");
+ if (slotNumber >= 0 && slotNumber <= 99)
+ _loadSlotNumber = slotNumber;
+ }
}
TonyEngine::~TonyEngine() {
@@ -400,7 +408,7 @@ void TonyEngine::AutoSave(CORO_PARAM) {
CORO_INVOKE_0(MainWaitFrame);
MainFreeze();
_ctx->buf = GetSaveStateFileName(0);
- _theEngine.SaveState(_ctx->buf.c_str(), (byte *)m_curThumbnail, "Autosave", true);
+ _theEngine.SaveState(_ctx->buf, (byte *)m_curThumbnail, "Autosave");
MainUnfreeze();
CORO_END_CODE;
@@ -499,17 +507,26 @@ void TonyEngine::Abort(void) {
*/
void TonyEngine::PlayProcess(CORO_PARAM, const void *param) {
CORO_BEGIN_CONTEXT;
+ Common::String fn;
CORO_END_CONTEXT(_ctx);
+
CORO_BEGIN_CODE(_ctx);
- // CORO_INFINITE loop. We rely on the outer main process to detect if a shutdown is required,
+ // Game loop. We rely on the outer main process to detect if a shutdown is required,
// and kill the scheudler and all the processes, including this one
for (;;) {
// Se siamo in pausa, entra nel loop appropriato
if (_vm->m_bPaused)
_vm->PauseLoop();
+ // If a savegame needs to be loaded, then do so
+ if (_vm->_loadSlotNumber != -1 && GLOBALS.GfxEngine != NULL) {
+ _ctx->fn = GetSaveStateFileName(_vm->_loadSlotNumber);
+ CORO_INVOKE_1(GLOBALS.GfxEngine->LoadState, _ctx->fn);
+ _vm->_loadSlotNumber = -1;
+ }
+
// Wait for the next frame
CORO_INVOKE_1(CoroScheduler.sleep, 50);
@@ -627,4 +644,27 @@ uint32 TonyEngine::GetTime() {
return g_system->getMillis();
}
+bool TonyEngine::canLoadGameStateCurrently() {
+ return GLOBALS.GfxEngine != NULL && GLOBALS.GfxEngine->CanLoadSave();
+}
+bool TonyEngine::canSaveGameStateCurrently() {
+ return GLOBALS.GfxEngine != NULL && GLOBALS.GfxEngine->CanLoadSave();
+}
+
+Common::Error TonyEngine::loadGameState(int slot) {
+ _loadSlotNumber = slot;
+ return Common::kNoError;
+}
+
+Common::Error TonyEngine::saveGameState(int slot, const Common::String &desc) {
+ if (!GLOBALS.GfxEngine)
+ return Common::kUnknownError;
+
+ RMSnapshot s;
+ s.GrabScreenshot(*GLOBALS.GfxEngine, 4, m_curThumbnail);
+
+ GLOBALS.GfxEngine->SaveState(GetSaveStateFileName(slot), (byte *)m_curThumbnail, desc);
+ return Common::kNoError;
+}
+
} // End of namespace Tony
diff --git a/engines/tony/tony.h b/engines/tony/tony.h
index c106a0856b..574861487a 100644
--- a/engines/tony/tony.h
+++ b/engines/tony/tony.h
@@ -78,8 +78,9 @@ struct VoiceHeader {
class TonyEngine : public Engine {
private:
- Common::ErrorCode Init();
+ int _loadSlotNumber;
+ Common::ErrorCode Init();
void InitMusic();
void CloseMusic();
bool OpenVoiceDatabase();
@@ -142,6 +143,11 @@ public:
RMGfxEngine *GetEngine() { return &_theEngine; }
void GUIError(const Common::String &msg);
+ virtual bool canLoadGameStateCurrently();
+ virtual bool canSaveGameStateCurrently();
+ Common::Error TonyEngine::loadGameState(int slot);
+ Common::Error TonyEngine::saveGameState(int slot, const Common::String &desc);
+
// Avverte che siamo guidati dal GDI
void GDIControl(bool bCon);