aboutsummaryrefslogtreecommitdiff
path: root/engines
diff options
context:
space:
mode:
authorPaul Gilbert2017-08-18 21:53:57 -0400
committerPaul Gilbert2017-08-18 21:53:57 -0400
commit8e35f77e2ddec913e35134be12ef23c6d696c3db (patch)
treed72550df4ba63c29d99d9229d7b4adc1cef11a93 /engines
parent98e0e023874faa41bb8300a6832b3b1193ecf4ac (diff)
downloadscummvm-rg350-8e35f77e2ddec913e35134be12ef23c6d696c3db.tar.gz
scummvm-rg350-8e35f77e2ddec913e35134be12ef23c6d696c3db.tar.bz2
scummvm-rg350-8e35f77e2ddec913e35134be12ef23c6d696c3db.zip
TITANIC: Implement F5 & F7 Saving and Loading
Diffstat (limited to 'engines')
-rw-r--r--engines/titanic/main_game_window.cpp6
-rw-r--r--engines/titanic/titanic.cpp39
-rw-r--r--engines/titanic/titanic.h10
3 files changed, 55 insertions, 0 deletions
diff --git a/engines/titanic/main_game_window.cpp b/engines/titanic/main_game_window.cpp
index 053712d412..cfea98cdf1 100644
--- a/engines/titanic/main_game_window.cpp
+++ b/engines/titanic/main_game_window.cpp
@@ -341,6 +341,12 @@ void CMainGameWindow::keyDown(Common::KeyState keyState) {
_gameManager->_gameState.changeView(newView, nullptr);
}
+ } else if (keyState.keycode == Common::KEYCODE_F5) {
+ // Show the GMM save dialog
+ g_vm->showScummVMSaveDialog();
+ } else if (keyState.keycode == Common::KEYCODE_F7) {
+ // Show the GMM load dialog
+ g_vm->showScummVMRestoreDialog();
} else if (_inputAllowed) {
_gameManager->_inputTranslator.keyDown(keyState);
}
diff --git a/engines/titanic/titanic.cpp b/engines/titanic/titanic.cpp
index 8a1b00c0fc..5fd72371eb 100644
--- a/engines/titanic/titanic.cpp
+++ b/engines/titanic/titanic.cpp
@@ -25,9 +25,11 @@
#include "common/config-manager.h"
#include "common/debug-channels.h"
#include "common/events.h"
+#include "common/translation.h"
#include "engines/util.h"
#include "graphics/scaler.h"
#include "graphics/thumbnail.h"
+#include "gui/saveload.h"
#include "titanic/titanic.h"
#include "titanic/debugger.h"
#include "titanic/carry/hose.h"
@@ -251,4 +253,41 @@ void TitanicEngine::GUIError(const char *msg, ...) {
GUIErrorMessage(buffer);
}
+
+void TitanicEngine::showScummVMSaveDialog() {
+ if (!canSaveGameStateCurrently())
+ return;
+
+ GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true);
+
+ int slot = dialog->runModalWithCurrentTarget();
+ if (slot >= 0) {
+ Common::String desc = dialog->getResultString();
+
+ if (desc.empty()) {
+ // create our own description for the saved game, the user didn't enter it
+ desc = dialog->createDefaultSaveDescription(slot);
+ }
+
+ // Save the game
+ saveGameState(slot, desc);
+ }
+
+ delete dialog;
+}
+
+void TitanicEngine::showScummVMRestoreDialog() {
+ if (!canLoadGameStateCurrently())
+ return;
+
+ GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false);
+
+ int slot = dialog->runModalWithCurrentTarget();
+ if (slot >= 0) {
+ loadGameState(slot);
+ }
+
+ delete dialog;
+}
+
} // End of namespace Titanic
diff --git a/engines/titanic/titanic.h b/engines/titanic/titanic.h
index dc7fd156b8..0c15cf3e72 100644
--- a/engines/titanic/titanic.h
+++ b/engines/titanic/titanic.h
@@ -191,6 +191,16 @@ public:
* Displays an error message in a GUI dialog
*/
void GUIError(const char *msg, ...) GCC_PRINTF(2, 3);
+
+ /**
+ * Shows the ScummVM GMM save dialog
+ */
+ void showScummVMSaveDialog();
+
+ /**
+ * Shows the ScummVM GMM load dialog
+ */
+ void showScummVMRestoreDialog();
};
extern TitanicEngine *g_vm;