aboutsummaryrefslogtreecommitdiff
path: root/engines/dialogs.cpp
diff options
context:
space:
mode:
authorMax Horn2010-04-06 09:26:20 +0000
committerMax Horn2010-04-06 09:26:20 +0000
commit745edbadc7b3841556c2e8962725bfd3de8a4dd3 (patch)
treea66b1f6eeaad3cbdb728c3cace44eb33c79b9591 /engines/dialogs.cpp
parent7dafef752fea7d968bd4a4bc1292fcfa65341529 (diff)
downloadscummvm-rg350-745edbadc7b3841556c2e8962725bfd3de8a4dd3.tar.gz
scummvm-rg350-745edbadc7b3841556c2e8962725bfd3de8a4dd3.tar.bz2
scummvm-rg350-745edbadc7b3841556c2e8962725bfd3de8a4dd3.zip
Factor out save/load code from MainMenuDialog::handleCommand into new methods
svn-id: r48563
Diffstat (limited to 'engines/dialogs.cpp')
-rw-r--r--engines/dialogs.cpp84
1 files changed, 43 insertions, 41 deletions
diff --git a/engines/dialogs.cpp b/engines/dialogs.cpp
index 4a2f0f9f5b..cd42c2a23d 100644
--- a/engines/dialogs.cpp
+++ b/engines/dialogs.cpp
@@ -125,49 +125,10 @@ void MainMenuDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 dat
close();
break;
case kLoadCmd:
- {
- Common::String gameId = ConfMan.get("gameid");
-
- const EnginePlugin *plugin = 0;
- EngineMan.findGame(gameId, &plugin);
-
- int slot = _loadDialog->runModal(plugin, ConfMan.getActiveDomainName());
-
- if (slot >= 0) {
- // FIXME: For now we just ignore the return
- // value, which is quite bad since it could
- // be a fatal loading error, which renders
- // the engine unusable.
- _engine->loadGameState(slot);
- close();
- }
-
- }
+ load();
break;
case kSaveCmd:
- {
- Common::String gameId = ConfMan.get("gameid");
-
- const EnginePlugin *plugin = 0;
- EngineMan.findGame(gameId, &plugin);
-
- int slot = _saveDialog->runModal(plugin, ConfMan.getActiveDomainName());
-
- if (slot >= 0) {
- Common::String result(_saveDialog->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);
- _engine->saveGameState(slot, buf);
- } else {
- _engine->saveGameState(slot, result.c_str());
- }
-
- close();
- }
-
- }
+ save();
break;
case kOptionsCmd:
_optionsDialog->runModal();
@@ -232,6 +193,47 @@ void MainMenuDialog::reflowLayout() {
Dialog::reflowLayout();
}
+void MainMenuDialog::save() {
+ Common::String gameId = ConfMan.get("gameid");
+
+ const EnginePlugin *plugin = 0;
+ EngineMan.findGame(gameId, &plugin);
+
+ int slot = _saveDialog->runModal(plugin, ConfMan.getActiveDomainName());
+
+ if (slot >= 0) {
+ Common::String result(_saveDialog->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);
+ _engine->saveGameState(slot, buf);
+ } else {
+ _engine->saveGameState(slot, result.c_str());
+ }
+
+ close();
+ }
+}
+
+void MainMenuDialog::load() {
+ Common::String gameId = ConfMan.get("gameid");
+
+ const EnginePlugin *plugin = 0;
+ EngineMan.findGame(gameId, &plugin);
+
+ int slot = _loadDialog->runModal(plugin, ConfMan.getActiveDomainName());
+
+ if (slot >= 0) {
+ // FIXME: For now we just ignore the return
+ // value, which is quite bad since it could
+ // be a fatal loading error, which renders
+ // the engine unusable.
+ _engine->loadGameState(slot);
+ close();
+ }
+}
+
enum {
kOKCmd = 'ok '
};