aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBorja Lorente2016-08-02 13:01:35 +0200
committerBorja Lorente2016-08-14 19:00:36 +0200
commit9ab6ce04a11de0bf5f56a7866a4837c7431cefbe (patch)
treeeb794e21227051c9546901afcf123297709a9666
parentb7b4862e4c93898e5a315c672e52df0ea1894cc6 (diff)
downloadscummvm-rg350-9ab6ce04a11de0bf5f56a7866a4837c7431cefbe.tar.gz
scummvm-rg350-9ab6ce04a11de0bf5f56a7866a4837c7431cefbe.tar.bz2
scummvm-rg350-9ab6ce04a11de0bf5f56a7866a4837c7431cefbe.zip
MACVENTURE: Change GUI to accept ScummVM dialogs
-rw-r--r--engines/macventure/detection.cpp17
-rw-r--r--engines/macventure/dialog.h2
-rw-r--r--engines/macventure/gui.cpp6
-rw-r--r--engines/macventure/gui.h2
-rw-r--r--engines/macventure/macventure.h4
-rw-r--r--engines/macventure/prebuilt_dialogs.h2
-rw-r--r--engines/macventure/saveload.cpp41
7 files changed, 60 insertions, 14 deletions
diff --git a/engines/macventure/detection.cpp b/engines/macventure/detection.cpp
index 64a7923f04..082a8acc65 100644
--- a/engines/macventure/detection.cpp
+++ b/engines/macventure/detection.cpp
@@ -32,9 +32,7 @@ namespace MacVenture {
const char *MacVentureEngine::getGameFileName() const {
return _gameDescription->filesDescriptions[0].fileName;
}
-}
-
-namespace MacVenture {
+} // End of namespace MacVenture
#include "macventure/detection_tables.h"
@@ -45,6 +43,8 @@ static const PlainGameDescriptor macventureGames[] = {
{ 0, 0 }
};
+namespace MacVenture {
+
SaveStateDescriptor loadMetaData(Common::SeekableReadStream *s, int slot);
class MacVentureMetaEngine : public AdvancedMetaEngine {
@@ -73,6 +73,12 @@ bool MacVentureMetaEngine::hasFeature(MetaEngineFeature f) const {
(f == kSupportsLoadingDuringStartup);
}
+bool MacVentureEngine::hasFeature(EngineFeature f) const {
+ return
+ (f == kSupportsLoadingDuringRuntime) ||
+ (f == kSupportsSavingDuringRuntime);
+}
+
SaveStateList MacVentureMetaEngine::listSaves(const char *target) const {
Common::SaveFileManager *saveFileMan = g_system->getSavefileManager();
Common::StringArray filenames;
@@ -116,14 +122,11 @@ int MacVentureMetaEngine::getMaximumSaveSlot() const { return 999; }
bool MacVentureMetaEngine::createInstance(OSystem * syst, Engine ** engine, const ADGameDescription *game) const {
if (game) {
- *engine = new MacVentureEngine(syst, game);
+ *engine = new MacVenture::MacVentureEngine(syst, game);
}
return game != 0;
}
-
-
-
} // End of namespace MacVenture
#if PLUGIN_ENABLED_DYNAMIC(MACVENTURE)
diff --git a/engines/macventure/dialog.h b/engines/macventure/dialog.h
index d40639a2d3..a01011f2b8 100644
--- a/engines/macventure/dialog.h
+++ b/engines/macventure/dialog.h
@@ -39,7 +39,7 @@ extern PrebuiltDialog prebuiltDialogs[];
class Dialog {
public:
Dialog(Gui *gui, Common::Point pos, uint width, uint height);
- Dialog(Gui *gui, PrebuiltDialogs prebuilt);
+ Dialog(Gui *gui, PrebuiltDialogs prebuilt);
~Dialog();
diff --git a/engines/macventure/gui.cpp b/engines/macventure/gui.cpp
index 7691b56697..d615493b60 100644
--- a/engines/macventure/gui.cpp
+++ b/engines/macventure/gui.cpp
@@ -1081,15 +1081,15 @@ void Gui::handleMenuAction(MenuAction action) {
break;
case MacVenture::kMenuActionOpen:
debug("MacVenture Menu Action: Open");
- loadGame(0);
+ _engine->scummVMSaveLoadDialog(false);
break;
case MacVenture::kMenuActionSave:
debug("MacVenture Menu Action: Save");
- saveInto(0);
+ _engine->scummVMSaveLoadDialog(true);
break;
case MacVenture::kMenuActionSaveAs:
debug("MacVenture Menu Action: Save As");
- showPrebuiltDialog(kSaveAsDialog);
+ _engine->scummVMSaveLoadDialog(true);
break;
case MacVenture::kMenuActionQuit:
debug("MacVenture Menu Action: Quit");
diff --git a/engines/macventure/gui.h b/engines/macventure/gui.h
index 8b0cbc6a6b..31cacd76ef 100644
--- a/engines/macventure/gui.h
+++ b/engines/macventure/gui.h
@@ -156,6 +156,8 @@ public:
void setTextInput(Common::String str);
void closeDialog();
+
+ // TODO: Currently unused, we are using ScummVM dialogs instead.
void loadGame(int slot);
void saveInto(int slot);
diff --git a/engines/macventure/macventure.h b/engines/macventure/macventure.h
index 28eb8e42ff..3e6f7c02ce 100644
--- a/engines/macventure/macventure.h
+++ b/engines/macventure/macventure.h
@@ -181,7 +181,11 @@ public:
MacVentureEngine(OSystem *syst, const ADGameDescription *gameDesc);
~MacVentureEngine();
+ virtual bool hasFeature(EngineFeature f) const;
+
virtual Common::Error run();
+
+ bool scummVMSaveLoadDialog(bool isSave);
virtual Common::Error loadGameState(int slot);
virtual Common::Error saveGameState(int slot, const Common::String &desc);
diff --git a/engines/macventure/prebuilt_dialogs.h b/engines/macventure/prebuilt_dialogs.h
index 1e708dbb67..58e8f0b823 100644
--- a/engines/macventure/prebuilt_dialogs.h
+++ b/engines/macventure/prebuilt_dialogs.h
@@ -35,7 +35,7 @@ enum DialogAction {
};
enum PrebuiltDialogs {
- kSaveAsDialog = 0,
+ kSaveAsDialog = 0, //TODO: Currently unused, we are using ScummVM dialogs instead.
kSpeakDialog = 1,
kPrebuiltDialogCount
};
diff --git a/engines/macventure/saveload.cpp b/engines/macventure/saveload.cpp
index a256713b24..e1b6227851 100644
--- a/engines/macventure/saveload.cpp
+++ b/engines/macventure/saveload.cpp
@@ -25,6 +25,7 @@
#include "common/error.h"
#include "common/savefile.h"
#include "engines/savestate.h"
+#include "gui/saveload.h"
namespace MacVenture {
@@ -71,19 +72,55 @@ void writeMetaData(Common::OutSaveFile *file, Common::String desc) {
}
Common::Error MacVentureEngine::loadGameState(int slot) {
- Common::InSaveFile *file = getSaveFileManager()->openForLoading("shadowgate.001");
+ Common::String saveFileName = Common::String::format("%s.%03d", _targetName.c_str(), slot);
+ Common::InSaveFile *file;
+ if(!(file = getSaveFileManager()->openForLoading(saveFileName))) {
+ error("missing savegame file %s", saveFileName.c_str());
+ }
_world->loadGameFrom(file);
reset();
return Common::kNoError;
}
Common::Error MacVentureEngine::saveGameState(int slot, const Common::String &desc) {
+ Common::String saveFileName = Common::String::format("%s.%03d", _targetName.c_str(), slot);
Common::SaveFileManager *manager = getSaveFileManager();
// HACK Get a real name!
- Common::OutSaveFile *file = manager->openForSaving(desc);
+ Common::OutSaveFile *file = manager->openForSaving(saveFileName);
_world->saveGameInto(file);
writeMetaData(file, desc);
delete file;
}
+bool MacVentureEngine::scummVMSaveLoadDialog(bool isSave) {
+ if (!isSave) {
+ // do loading
+ GUI::SaveLoadChooser dialog = GUI::SaveLoadChooser(Common::String("Load game:"), Common::String("Load"), false);
+ int slot = dialog.runModalWithCurrentTarget();
+
+ if (slot < 0)
+ return true;
+
+ return loadGameState(slot).getCode() == Common::kNoError;
+ }
+
+ // do saving
+ GUI::SaveLoadChooser dialog = GUI::SaveLoadChooser(Common::String("Save game:"), Common::String("Save"), true);
+ int slot = dialog.runModalWithCurrentTarget();
+ Common::String desc = dialog.getResultString();
+
+ if (desc.empty()) {
+ // create our own description for the saved game, the user didnt enter it
+ desc = dialog.createDefaultSaveDescription(slot);
+ }
+
+ if (desc.size() > (1 << MACVENTURE_DESC_LENGTH * 4) - 1)
+ desc = Common::String(desc.c_str(), (1 << MACVENTURE_DESC_LENGTH * 4) - 1);
+
+ if (slot < 0)
+ return true;
+
+ return saveGameState(slot, desc).getCode() == Common::kNoError;
+}
+
} // End of namespace MacVenture