[Scummvm-cvs-logs] SF.net SVN: scummvm:[48563] scummvm/trunk/engines
fingolfin at users.sourceforge.net
fingolfin at users.sourceforge.net
Tue Apr 6 11:26:20 CEST 2010
Revision: 48563
http://scummvm.svn.sourceforge.net/scummvm/?rev=48563&view=rev
Author: fingolfin
Date: 2010-04-06 09:26:20 +0000 (Tue, 06 Apr 2010)
Log Message:
-----------
Factor out save/load code from MainMenuDialog::handleCommand into new methods
Modified Paths:
--------------
scummvm/trunk/engines/dialogs.cpp
scummvm/trunk/engines/dialogs.h
Modified: scummvm/trunk/engines/dialogs.cpp
===================================================================
--- scummvm/trunk/engines/dialogs.cpp 2010-04-06 09:26:04 UTC (rev 48562)
+++ scummvm/trunk/engines/dialogs.cpp 2010-04-06 09:26:20 UTC (rev 48563)
@@ -125,49 +125,10 @@
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 @@
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 '
};
Modified: scummvm/trunk/engines/dialogs.h
===================================================================
--- scummvm/trunk/engines/dialogs.h 2010-04-06 09:26:04 UTC (rev 48562)
+++ scummvm/trunk/engines/dialogs.h 2010-04-06 09:26:20 UTC (rev 48563)
@@ -47,6 +47,10 @@
virtual void reflowLayout();
protected:
+ void save();
+ void load();
+
+protected:
Engine *_engine;
GUI::GraphicsWidget *_logo;
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list