mirror of
https://github.com/libretro/scummvm.git
synced 2025-01-17 23:44:22 +00:00
Factor out save/load code from MainMenuDialog::handleCommand into new methods
svn-id: r48563
This commit is contained in:
parent
7dafef752f
commit
745edbadc7
@ -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 '
|
||||
};
|
||||
|
@ -46,6 +46,10 @@ public:
|
||||
|
||||
virtual void reflowLayout();
|
||||
|
||||
protected:
|
||||
void save();
|
||||
void load();
|
||||
|
||||
protected:
|
||||
Engine *_engine;
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user