aboutsummaryrefslogtreecommitdiff
path: root/engines/glk/frotz
diff options
context:
space:
mode:
authorPaul Gilbert2019-06-16 13:29:15 -0700
committerPaul Gilbert2019-06-16 14:59:26 -0700
commit553bb74f8c380ee31fb771c6619dad8e83fed8ce (patch)
treebf99be6554e96d66d2700837d7c08dc0d48ad127 /engines/glk/frotz
parent3876fb67108284063b4d133cf087a04dae6993e4 (diff)
downloadscummvm-rg350-553bb74f8c380ee31fb771c6619dad8e83fed8ce.tar.gz
scummvm-rg350-553bb74f8c380ee31fb771c6619dad8e83fed8ce.tar.bz2
scummvm-rg350-553bb74f8c380ee31fb771c6619dad8e83fed8ce.zip
GLK: Further changeover of sub-engines to use new savegame code
Diffstat (limited to 'engines/glk/frotz')
-rw-r--r--engines/glk/frotz/frotz.cpp37
-rw-r--r--engines/glk/frotz/frotz.h19
2 files changed, 41 insertions, 15 deletions
diff --git a/engines/glk/frotz/frotz.cpp b/engines/glk/frotz/frotz.cpp
index 0c33f417ec..02ee0900c9 100644
--- a/engines/glk/frotz/frotz.cpp
+++ b/engines/glk/frotz/frotz.cpp
@@ -26,6 +26,7 @@
#include "glk/frotz/quetzal.h"
#include "engines/util.h"
#include "common/config-manager.h"
+#include "common/translation.h"
namespace Glk {
namespace Frotz {
@@ -90,17 +91,13 @@ void Frotz::initialize() {
z_restart();
}
-Common::Error Frotz::saveGameData(strid_t file, const Common::String &desc) {
- Quetzal q(story_fp);
- bool success = q.save(*file, this, desc);
+Common::Error Frotz::loadGameState(int slot) {
+ FileReference ref(slot, "", fileusage_SavedGame | fileusage_TextMode);
- if (!success)
- print_string("Error writing save file\n");
+ strid_t file = _streams->openFileStream(&ref, filemode_Read);
+ if (file == nullptr)
+ return Common::kReadingFailed;
- return Common::kNoError;
-}
-
-Common::Error Frotz::loadGameData(strid_t file) {
Quetzal q(story_fp);
bool success = q.restore(*file, this) == 2;
@@ -123,14 +120,32 @@ Common::Error Frotz::loadGameData(strid_t file) {
* seems to cover up most of the resulting badness.
*/
if (h_version > V3 && h_version != V6 && (h_screen_rows != old_screen_rows
- || h_screen_cols != old_screen_cols))
+ || h_screen_cols != old_screen_cols))
erase_window(1);
} else {
- error("Error reading save file");
+ error(_("Error reading save file"));
}
return Common::kNoError;
}
+Common::Error Frotz::saveGameState(int slot, const Common::String &desc) {
+ Common::String msg;
+ FileReference ref(slot, desc, fileusage_BinaryMode | fileusage_SavedGame);
+
+ strid_t file = _streams->openFileStream(&ref, filemode_Write);
+ if (file == nullptr)
+ return Common::kWritingFailed;
+
+ Quetzal q(story_fp);
+ bool success = q.save(*file, this, desc);
+
+ if (!success)
+ print_string(_("Error writing save file\n"));
+
+ return Common::kNoError;
+
+}
+
} // End of namespace Frotz
} // End of namespace Glk
diff --git a/engines/glk/frotz/frotz.h b/engines/glk/frotz/frotz.h
index 8312e16b49..a8083a3093 100644
--- a/engines/glk/frotz/frotz.h
+++ b/engines/glk/frotz/frotz.h
@@ -72,14 +72,25 @@ public:
virtual void runGame() override;
/**
- * Load a savegame from the passed stream
+ * Load a savegame from a given slot
*/
- virtual Common::Error loadGameData(strid_t file) override;
+ virtual Common::Error loadGameState(int slot) override;
/**
- * Save the game to the passed stream
+ * Save the game to a given slot
*/
- virtual Common::Error saveGameData(strid_t file, const Common::String &desc) override;
+ virtual Common::Error saveGameState(int slot, const Common::String &desc) override;
+
+ /**
+ * Loading method not used for Frotz sub-engine
+ */
+ virtual Common::Error readSaveData(Common::SeekableReadStream *rs) override { return Common::kReadingFailed; }
+
+ /**
+ * Saving method not used for Frotz sub-engine
+ */
+ virtual Common::Error writeGameData(Common::WriteStream *ws) override { return Common::kWritingFailed; }
+
};
extern Frotz *g_vm;