mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-09 19:32:11 +00:00
PETKA: fixed saving system
This commit is contained in:
parent
59669a5d5f
commit
b3e71ad429
@ -78,7 +78,8 @@ void InterfaceMain::start(int id) {
|
||||
bgsIni.loadFromStream(*bgsStream);
|
||||
Common::String startRoom;
|
||||
bgsIni.getKey("StartRoom", "Settings", startRoom);
|
||||
loadRoom(g_vm->getQSystem()->findObject(startRoom)->_id, false);
|
||||
if (g_vm->getSaveSlot() == -1)
|
||||
loadRoom(g_vm->getQSystem()->findObject(startRoom)->_id, false);
|
||||
}
|
||||
|
||||
void InterfaceMain::loadRoom(int id, bool fromSave) {
|
||||
|
@ -52,7 +52,6 @@ void InterfaceSaveLoad::start(int id) {
|
||||
|
||||
_loadMode = (id == kLoadMode);
|
||||
|
||||
_objs.clear();
|
||||
QObjectBG *bg = (QObjectBG *)sys->findObject("SAVELOAD");
|
||||
_objs.push_back(bg);
|
||||
bg->_resourceId = kFirstSaveLoadPageId + _page + (_loadMode ? 0 : 5);
|
||||
@ -85,6 +84,8 @@ void InterfaceSaveLoad::stop() {
|
||||
sys->_currInterface = sys->_prevInterface;
|
||||
sys->_currInterface->onMouseMove(Common::Point(cursor->_x, cursor->_y));
|
||||
|
||||
_objs.clear();
|
||||
|
||||
Interface::stop();
|
||||
}
|
||||
|
||||
|
@ -39,6 +39,8 @@ public:
|
||||
void start(int id) override;
|
||||
void stop() override;
|
||||
|
||||
bool loadMode() { return _loadMode; }
|
||||
|
||||
void onLeftButtonDown(const Common::Point p) override;
|
||||
void onRightButtonDown(const Common::Point p) override;
|
||||
void onMouseMove(const Common::Point p) override;
|
||||
|
@ -59,6 +59,9 @@ PetkaEngine::PetkaEngine(OSystem *system, const ADGameDescription *desc)
|
||||
|
||||
_part = 0;
|
||||
_chapter = 0;
|
||||
_shouldChangePart = false;
|
||||
_nextPart = 0;
|
||||
_saveSlot = -1;
|
||||
g_vm = this;
|
||||
|
||||
debug("PetkaEngine::ctor");
|
||||
@ -120,6 +123,9 @@ Common::Error PetkaEngine::run() {
|
||||
|
||||
if (_shouldChangePart) {
|
||||
loadPart(_nextPart);
|
||||
if (_saveSlot != -1)
|
||||
loadGameState(_saveSlot);
|
||||
_saveSlot = -1;
|
||||
_shouldChangePart = false;
|
||||
_vsys->makeAllDirty();
|
||||
}
|
||||
@ -132,7 +138,6 @@ Common::Error PetkaEngine::run() {
|
||||
|
||||
Common::SeekableReadStream *PetkaEngine::openFile(const Common::String &name, bool addCurrentPath) {
|
||||
if (name.empty()) {
|
||||
debug("PetkaEngine::openFile: attempt to open file with empty name");
|
||||
return nullptr;
|
||||
}
|
||||
return _fileMgr->getFileStream(addCurrentPath ? _currentPath + name : name);
|
||||
@ -252,6 +257,7 @@ void PetkaEngine::loadPart(byte part) {
|
||||
void PetkaEngine::loadPartAtNextFrame(byte part) {
|
||||
_shouldChangePart = true;
|
||||
_nextPart = part;
|
||||
_saveSlot = -1;
|
||||
}
|
||||
|
||||
void PetkaEngine::loadChapter(byte chapter) {
|
||||
@ -306,4 +312,18 @@ const Common::String &PetkaEngine::getSpeechPath() {
|
||||
return _speechPath;
|
||||
}
|
||||
|
||||
bool PetkaEngine::hasFeature(EngineFeature f) const {
|
||||
return
|
||||
f == kSupportsReturnToLauncher ||
|
||||
f == kSupportsLoadingDuringRuntime ||
|
||||
f == kSupportsSavingDuringRuntime ||
|
||||
f == kSupportsChangingOptionsDuringRuntime;
|
||||
}
|
||||
|
||||
void PetkaEngine::pauseEngineIntern(bool pause) {
|
||||
if (!pause)
|
||||
_vsys->updateTime();
|
||||
Engine::pauseEngineIntern(pause);
|
||||
}
|
||||
|
||||
} // End of namespace Petka
|
||||
|
@ -80,11 +80,14 @@ public:
|
||||
void loadPartAtNextFrame(byte part);
|
||||
|
||||
byte getPart();
|
||||
int getSaveSlot();
|
||||
|
||||
void loadChapter(byte chapter);
|
||||
|
||||
virtual Common::Error run() override;
|
||||
|
||||
bool hasFeature(EngineFeature f) const override;
|
||||
|
||||
Common::SeekableReadStream *openFile(const Common::String &name, bool addCurrentPath);
|
||||
|
||||
void playVideo(Common::SeekableReadStream *stream);
|
||||
@ -104,6 +107,9 @@ public:
|
||||
Common::Error saveGameState(int slot, const Common::String &desc, bool isAutosave) override;
|
||||
bool canSaveGameStateCurrently() override;
|
||||
|
||||
protected:
|
||||
void pauseEngineIntern(bool pause) override;
|
||||
|
||||
private:
|
||||
void loadStores();
|
||||
|
||||
@ -128,7 +134,7 @@ private:
|
||||
uint8 _nextPart;
|
||||
uint8 _chapter;
|
||||
bool _shouldChangePart;
|
||||
Common::String _saveName;
|
||||
int _saveSlot;
|
||||
};
|
||||
|
||||
class Console : public GUI::Debugger {
|
||||
|
@ -312,8 +312,8 @@ void QSystem::load(Common::ReadStream *s) {
|
||||
}
|
||||
|
||||
void QSystem::save(Common::WriteStream *s) {
|
||||
s->writeUint32LE(_allObjects.size());
|
||||
for (uint i = 0; i < _allObjects.size(); ++i) {
|
||||
s->writeUint32LE(_allObjects.size() - 3);
|
||||
for (uint i = 0; i < _allObjects.size() - 3; ++i) {
|
||||
writeString(s, _allObjects[i]->_name);
|
||||
s->writeUint32LE(_allObjects[i]->_holdMessages);
|
||||
s->writeUint32LE(_allObjects[i]->_status);
|
||||
|
@ -29,6 +29,7 @@
|
||||
|
||||
#include "petka/petka.h"
|
||||
#include "petka/q_system.h"
|
||||
#include "petka/interfaces/save_load.h"
|
||||
|
||||
namespace Petka {
|
||||
|
||||
@ -49,7 +50,7 @@ Common::Error PetkaEngine::loadGameState(int slot) {
|
||||
_qsystem->load(in);
|
||||
} else {
|
||||
_shouldChangePart = true;
|
||||
_saveName = generateSaveName(slot, _targetName.c_str());
|
||||
_saveSlot = slot;
|
||||
}
|
||||
|
||||
delete in;
|
||||
@ -62,6 +63,8 @@ Common::Error PetkaEngine::saveGameState(int slot, const Common::String &desci,
|
||||
return Common::kUnknownError;
|
||||
|
||||
out->writeUint32BE(MKTAG('p', 'e', 't', 'k'));
|
||||
out->writeByte(desci.size());
|
||||
out->writeString(desci);
|
||||
|
||||
TimeDate curTime;
|
||||
_system->getTimeAndDate(curTime);
|
||||
@ -84,10 +87,18 @@ Common::Error PetkaEngine::saveGameState(int slot, const Common::String &desci,
|
||||
|
||||
bool PetkaEngine::canSaveGameStateCurrently() {
|
||||
return true;
|
||||
InterfaceSaveLoad *interface =_qsystem->_saveLoadInterface.get();
|
||||
return (interface == _qsystem->_currInterface && !interface->loadMode());
|
||||
}
|
||||
|
||||
bool PetkaEngine::canLoadGameStateCurrently() {
|
||||
return true;
|
||||
InterfaceSaveLoad *interface =_qsystem->_saveLoadInterface.get();
|
||||
return (interface == _qsystem->_currInterface && interface->loadMode());
|
||||
}
|
||||
|
||||
int PetkaEngine::getSaveSlot() {
|
||||
return _saveSlot;
|
||||
}
|
||||
|
||||
bool readSaveHeader(Common::InSaveFile &in, SaveStateDescriptor &desc, bool skipThumbnail) {
|
||||
|
Loading…
Reference in New Issue
Block a user