aboutsummaryrefslogtreecommitdiff
path: root/engines/cruise/menu.cpp
diff options
context:
space:
mode:
authorPaul Gilbert2009-08-24 09:07:21 +0000
committerPaul Gilbert2009-08-24 09:07:21 +0000
commitde2e283492fc9378909ffa892f2ef5f1b0698e1e (patch)
tree535c8e04c1fb35d09dfdd4a6220076582dae3749 /engines/cruise/menu.cpp
parent45802e31244502d946461992357aef4373843e1c (diff)
downloadscummvm-rg350-de2e283492fc9378909ffa892f2ef5f1b0698e1e.tar.gz
scummvm-rg350-de2e283492fc9378909ffa892f2ef5f1b0698e1e.tar.bz2
scummvm-rg350-de2e283492fc9378909ffa892f2ef5f1b0698e1e.zip
Added code to launch the GMM save/load dialogues from the in-game Player menu, replacing the older code that just saved/loaded the game in a single slot without prompting
svn-id: r43685
Diffstat (limited to 'engines/cruise/menu.cpp')
-rw-r--r--engines/cruise/menu.cpp42
1 files changed, 39 insertions, 3 deletions
diff --git a/engines/cruise/menu.cpp b/engines/cruise/menu.cpp
index 7e454e78f8..c620a39b7d 100644
--- a/engines/cruise/menu.cpp
+++ b/engines/cruise/menu.cpp
@@ -27,8 +27,13 @@
#include "cruise/cruise_main.h"
#include "cruise/staticres.h"
+#include "engines/metaengine.h"
+#include "gui/saveload.h"
+
namespace Cruise {
+extern int currentMouseButton;
+
menuStruct *menuTable[8];
menuStruct *createMenu(int X, int Y, const char *menuName) {
@@ -202,6 +207,38 @@ int processMenu(menuStruct *pMenu) {
return -1;
}
+static void handleSaveLoad(bool saveFlag) {
+ const EnginePlugin *plugin = 0;
+ EngineMan.findGame(_vm->getGameId(), &plugin);
+ GUI::SaveLoadChooser *dialog;
+ if (saveFlag)
+ dialog = new GUI::SaveLoadChooser("Save game:", "Save");
+ else
+ dialog = new GUI::SaveLoadChooser("Load game:", "Load");
+
+ dialog->setSaveMode(saveFlag);
+ int slot = dialog->runModal(plugin, ConfMan.getActiveDomainName());
+
+ if (slot >= 0) {
+ if (!saveFlag)
+ _vm->loadGameState(slot);
+ else {
+ Common::String result(dialog->getResultString());
+ if (result.empty()) {
+ // If the user was lazy and entered no save name, come up with a default name.
+ char buf[20];
+ snprintf(buf, 20, "Save %d", slot + 1);
+
+ _vm->saveGameState(slot, buf);
+ } else {
+ _vm->saveGameState(slot, result.c_str());
+ }
+ }
+ }
+
+ delete dialog;
+}
+
int playerMenu(int menuX, int menuY) {
int retourMenu;
//int restartGame = 0;
@@ -251,15 +288,14 @@ int playerMenu(int menuX, int menuY) {
freeMenu(menuTable[0]);
menuTable[0] = NULL;
+ currentMouseButton = 0;
switch (retourMenu) {
case 3: // select save drive
break;
case 4: // save
- saveSavegameData(0, "Default Save");
- break;
case 5: // load
- loadSavegameData(0);
+ handleSaveLoad(retourMenu == 4);
break;
case 6: // restart
_vm->sound().fadeOutMusic();