aboutsummaryrefslogtreecommitdiff
path: root/engines/glk
diff options
context:
space:
mode:
authorPaul Gilbert2019-11-16 18:47:16 -0800
committerPaul Gilbert2019-11-16 18:47:16 -0800
commit023a587b5b2c8aad5c8770b3619e15bc35f0271f (patch)
tree81525b1efdfbf76fa08ebb6ac994adae5a8ad86b /engines/glk
parent7161995bb4225eb0461aa7d6636f3371b65c040d (diff)
downloadscummvm-rg350-023a587b5b2c8aad5c8770b3619e15bc35f0271f.tar.gz
scummvm-rg350-023a587b5b2c8aad5c8770b3619e15bc35f0271f.tar.bz2
scummvm-rg350-023a587b5b2c8aad5c8770b3619e15bc35f0271f.zip
GLK: ARCHETYPE: Allowing savegames from launcher
Diffstat (limited to 'engines/glk')
-rw-r--r--engines/glk/archetype/archetype.cpp25
-rw-r--r--engines/glk/archetype/archetype.h7
-rw-r--r--engines/glk/archetype/sys_object.cpp6
3 files changed, 34 insertions, 4 deletions
diff --git a/engines/glk/archetype/archetype.cpp b/engines/glk/archetype/archetype.cpp
index 204bd9fb2f..fb1d277bb1 100644
--- a/engines/glk/archetype/archetype.cpp
+++ b/engines/glk/archetype/archetype.cpp
@@ -87,6 +87,9 @@ bool Archetype::initialize() {
_mainWindow = glk_window_open(0, 0, 0, wintype_TextBuffer);
glk_set_window(_mainWindow);
+ // Check for savegame to load
+ _saveSlot = ConfMan.hasKey("save_slot") ? ConfMan.getInt("save_slot") : -1;
+
return true;
}
@@ -104,6 +107,12 @@ Common::Error Archetype::writeGameData(Common::WriteStream *ws) {
return Common::kNoError;
}
+Common::Error Archetype::loadLauncherSavegame() {
+ Common::Error result = loadGameState(_saveSlot);
+ _saveSlot = -2;
+ return result;
+}
+
void Archetype::interpret() {
Translating = false;
bool success = load_game(&_gameFile);
@@ -130,7 +139,9 @@ void Archetype::write(const String fmt, ...) {
va_end(ap);
_lastOutputText = s;
- glk_put_buffer(s.c_str(), s.size());
+
+ if (!loadingSavegame())
+ glk_put_buffer(s.c_str(), s.size());
}
void Archetype::writeln(const String fmt, ...) {
@@ -141,7 +152,9 @@ void Archetype::writeln(const String fmt, ...) {
s += '\n';
_lastOutputText = s;
- glk_put_buffer(s.c_str(), s.size());
+
+ if (!loadingSavegame())
+ glk_put_buffer(s.c_str(), s.size());
}
String Archetype::readLine() {
@@ -153,6 +166,14 @@ String Archetype::readLine() {
if (text.contains("save") || text.contains("load")) {
writeln();
return "";
+
+ } else if (loadingSavegame()) {
+ // Automatically trigger a load action if a savegame needs loading from the launcher
+ return String("load");
+
+ } else if (_saveSlot == -2) {
+ _saveSlot = -1;
+ return String("look");
}
event_t ev;
diff --git a/engines/glk/archetype/archetype.h b/engines/glk/archetype/archetype.h
index beb67b6680..643f5e0007 100644
--- a/engines/glk/archetype/archetype.h
+++ b/engines/glk/archetype/archetype.h
@@ -159,10 +159,15 @@ public:
* Returns true if a savegame is being loaded directly from the ScummVM launcher
*/
bool loadingSavegame() const {
- return _saveSlot != -1;
+ return _saveSlot >= 0;
}
/**
+ * Handles loading the savegame specified in the ScummVM launcher
+ */
+ Common::Error loadLauncherSavegame();
+
+ /**
* Write some text to the screen
*/
void write(const String fmt, ...);
diff --git a/engines/glk/archetype/sys_object.cpp b/engines/glk/archetype/sys_object.cpp
index 784d9a4cd7..ec98038be3 100644
--- a/engines/glk/archetype/sys_object.cpp
+++ b/engines/glk/archetype/sys_object.cpp
@@ -282,7 +282,11 @@ void send_to_system(int transport, String &strmsg, ResultType &result, ContextTy
break;
case LOAD_STATE: {
- Common::ErrorCode errCode = g_vm->loadGame().getCode();
+ Common::ErrorCode errCode;
+ if (g_vm->loadingSavegame())
+ errCode = g_vm->loadLauncherSavegame().getCode();
+ else
+ errCode = g_vm->loadGame().getCode();
if (errCode == Common::kNoError) {
result._kind = RESERVED;