mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-15 08:39:45 +00:00
CRYOMNI3D: Implement load/save in-game with GMM
This commit is contained in:
parent
70c7133e4b
commit
3915be8ff1
@ -42,7 +42,8 @@ namespace CryOmni3D {
|
||||
|
||||
CryOmni3DEngine::CryOmni3DEngine(OSystem *syst,
|
||||
const CryOmni3DGameDescription *gamedesc) : Engine(syst), _gameDescription(gamedesc),
|
||||
_fontManager(), _sprites(), _dragStatus(kDragStatus_NoDrag), _autoRepeatNextEvent(-1u) {
|
||||
_canLoadSave(false), _fontManager(), _sprites(), _dragStatus(kDragStatus_NoDrag),
|
||||
_autoRepeatNextEvent(-1u) {
|
||||
if (!_mixer->isReady()) {
|
||||
error("Sound initialization failed");
|
||||
}
|
||||
|
@ -100,7 +100,10 @@ public:
|
||||
Common::Language getLanguage() const;
|
||||
|
||||
bool hasFeature(EngineFeature f) const override;
|
||||
bool canLoadGameStateCurrently() override { return _canLoadSave; }
|
||||
bool canSaveGameStateCurrently() override { return _canLoadSave; }
|
||||
|
||||
void setCanLoadSave(bool canLoadSave) { _canLoadSave = canLoadSave; }
|
||||
static const uint kSaveDescriptionLen = 20;
|
||||
private:
|
||||
void pauseEngineIntern(bool);
|
||||
@ -157,6 +160,8 @@ protected:
|
||||
void setBlackPalette();
|
||||
|
||||
protected:
|
||||
bool _canLoadSave;
|
||||
|
||||
FontManager _fontManager;
|
||||
Sprites _sprites;
|
||||
Objects _objects;
|
||||
|
@ -188,10 +188,15 @@ void ZonFixedImage::manage() {
|
||||
_usedObject = nullptr;
|
||||
_key.reset();
|
||||
|
||||
// As the game lets load/save from main menu displayed by cliking from the toolbar,
|
||||
// it's safe to enable GMM Load/Save there
|
||||
_engine.setCanLoadSave(true);
|
||||
|
||||
// Force poll events even when we must refresh the cursor
|
||||
if (!_engine.pollEvents() && !_refreshCursor) {
|
||||
g_system->updateScreen();
|
||||
g_system->delayMillis(10);
|
||||
_engine.setCanLoadSave(false);
|
||||
return;
|
||||
}
|
||||
_refreshCursor = false;
|
||||
@ -202,9 +207,11 @@ void ZonFixedImage::manage() {
|
||||
|
||||
if (_key == Common::KEYCODE_ESCAPE) {
|
||||
_exit = true;
|
||||
_engine.setCanLoadSave(false);
|
||||
return;
|
||||
} else if (_engine.shouldAbort()) {
|
||||
_exit = true;
|
||||
_engine.setCanLoadSave(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -221,6 +228,7 @@ void ZonFixedImage::manage() {
|
||||
}
|
||||
// Return without any event to redo the loop and force refresh
|
||||
_refreshCursor = true;
|
||||
_engine.setCanLoadSave(false);
|
||||
return;
|
||||
}
|
||||
|
||||
@ -268,6 +276,8 @@ void ZonFixedImage::manage() {
|
||||
|
||||
g_system->updateScreen();
|
||||
g_system->delayMillis(10);
|
||||
|
||||
_engine.setCanLoadSave(false);
|
||||
}
|
||||
|
||||
void ZonFixedImage::handleMouseZones(const Common::Array<Zone>::const_iterator ¤tZone) {
|
||||
|
@ -67,6 +67,12 @@ CryOmni3DEngine_Versailles::~CryOmni3DEngine_Versailles() {
|
||||
delete _fixedImage;
|
||||
}
|
||||
|
||||
bool CryOmni3DEngine_Versailles::hasFeature(EngineFeature f) const {
|
||||
return CryOmni3DEngine::hasFeature(f)
|
||||
|| (f == kSupportsSavingDuringRuntime)
|
||||
|| (f == kSupportsLoadingDuringRuntime);
|
||||
}
|
||||
|
||||
Common::Error CryOmni3DEngine_Versailles::run() {
|
||||
CryOmni3DEngine::run();
|
||||
|
||||
@ -1135,6 +1141,7 @@ int CryOmni3DEngine_Versailles::handleWarp() {
|
||||
bool moving = true;
|
||||
uint actionId;
|
||||
showMouse(true);
|
||||
_canLoadSave = true;
|
||||
while (!leftButtonPressed && !exit) {
|
||||
int xDelta = 0, yDelta = 0;
|
||||
uint movingCursor = -1;
|
||||
@ -1219,6 +1226,7 @@ int CryOmni3DEngine_Versailles::handleWarp() {
|
||||
// Slow down loop but after updating screen
|
||||
g_system->delayMillis(10);
|
||||
}
|
||||
_canLoadSave = false;
|
||||
showMouse(false);
|
||||
return actionId;
|
||||
}
|
||||
|
@ -217,6 +217,10 @@ public:
|
||||
CryOmni3DEngine_Versailles(OSystem *syst, const CryOmni3DGameDescription *gamedesc);
|
||||
virtual ~CryOmni3DEngine_Versailles();
|
||||
|
||||
bool hasFeature(EngineFeature f) const override;
|
||||
virtual Common::Error loadGameState(int slot) override;
|
||||
virtual Common::Error saveGameState(int slot, const Common::String &desc) override;
|
||||
|
||||
Common::String prepareFileName(const Common::String &baseName, const char *extension) const {
|
||||
const char *const extensions[] = { extension, nullptr };
|
||||
return prepareFileName(baseName, extensions);
|
||||
|
@ -30,6 +30,16 @@
|
||||
namespace CryOmni3D {
|
||||
namespace Versailles {
|
||||
|
||||
Common::Error CryOmni3DEngine_Versailles::loadGameState(int slot) {
|
||||
_loadedSave = slot + 1;
|
||||
_abortCommand = kAbortLoadGame;
|
||||
return Common::kNoError;
|
||||
}
|
||||
|
||||
Common::Error CryOmni3DEngine_Versailles::saveGameState(int slot, const Common::String &desc) {
|
||||
saveGame(_isVisiting, slot + 1, desc);
|
||||
return Common::kNoError;
|
||||
}
|
||||
|
||||
Common::String CryOmni3DEngine_Versailles::getSaveFileName(bool visit, uint saveNum) const {
|
||||
return Common::String::format("%s%s.%04u", _targetName.c_str(), visit ? "_visit" : "", saveNum);
|
||||
|
Loading…
x
Reference in New Issue
Block a user