From 15046a7529e3c755de1f00b4a2666786eb2bd4f8 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 10 Jun 2012 04:14:17 +0200 Subject: GUI: Get rid of SaveLoadChooser::setSaveMode. We already pass the title and process button name to the constructor of SaveLoadChooser and then do not offer any way of changing it, thus changing the edit mode of the chooser is kind of pointless and was never actually used. Instead we pass the mode on SaveLoadChooser construction now. --- engines/agi/saveload.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'engines/agi/saveload.cpp') diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp index d58e55a6b9..cb7792af8e 100644 --- a/engines/agi/saveload.cpp +++ b/engines/agi/saveload.cpp @@ -802,8 +802,7 @@ int AgiEngine::scummVMSaveLoadDialog(bool isSave) { int slot; if (isSave) { - dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save")); - dialog->setSaveMode(true); + dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true); slot = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); desc = dialog->getResultString(); @@ -824,8 +823,7 @@ int AgiEngine::scummVMSaveLoadDialog(bool isSave) { if (desc.size() > 28) desc = Common::String(desc.c_str(), 28); } else { - dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore")); - dialog->setSaveMode(false); + dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false); slot = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); } -- cgit v1.2.3 From 7c5cf1b400808865a5f601f70d624ad6704a0c8c Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 10 Jun 2012 04:49:42 +0200 Subject: GUI: Add helper to SaveLoadChooser, which uses the currently active target. This reduces the code duplication in all client code, which formerly duplicated the querying of the plugin, game id etc. and now simply calls the newly added method runModalWithCurrentTarget() on a SaveLoadChooser object. --- engines/agi/saveload.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'engines/agi/saveload.cpp') diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp index cb7792af8e..25fa7829ef 100644 --- a/engines/agi/saveload.cpp +++ b/engines/agi/saveload.cpp @@ -795,8 +795,6 @@ int AgiEngine::selectSlot() { } int AgiEngine::scummVMSaveLoadDialog(bool isSave) { - const EnginePlugin *plugin = NULL; - EngineMan.findGame(ConfMan.get("gameid"), &plugin); GUI::SaveLoadChooser *dialog; Common::String desc; int slot; @@ -804,7 +802,7 @@ int AgiEngine::scummVMSaveLoadDialog(bool isSave) { if (isSave) { dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true); - slot = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); + slot = dialog->runModalWithCurrentTarget(); desc = dialog->getResultString(); if (desc.empty()) { @@ -824,7 +822,7 @@ int AgiEngine::scummVMSaveLoadDialog(bool isSave) { desc = Common::String(desc.c_str(), 28); } else { dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false); - slot = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); + slot = dialog->runModalWithCurrentTarget(); } delete dialog; -- cgit v1.2.3 From 49fafb48a7f089c97ed3baa9aefe65ec56dce682 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Sun, 10 Jun 2012 05:04:59 +0200 Subject: GUI: Refactor default savegame description creation. Formerly the GMM, AGI and SCI duplicated the logic for USE_SAVEGAME_TIMESTAMP. Now I added a method to SaveLoadChooser instead, which takes care of this. This might not be the best placement of such a functionality, thus I added a TODO which talks about moving it to a better place. --- engines/agi/saveload.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'engines/agi/saveload.cpp') diff --git a/engines/agi/saveload.cpp b/engines/agi/saveload.cpp index 25fa7829ef..3e63da756d 100644 --- a/engines/agi/saveload.cpp +++ b/engines/agi/saveload.cpp @@ -807,15 +807,7 @@ int AgiEngine::scummVMSaveLoadDialog(bool isSave) { if (desc.empty()) { // create our own description for the saved game, the user didnt enter it -#if defined(USE_SAVEGAME_TIMESTAMP) - TimeDate curTime; - g_system->getTimeAndDate(curTime); - curTime.tm_year += 1900; // fixup year - curTime.tm_mon++; // fixup month - desc = Common::String::format("%04d.%02d.%02d / %02d:%02d:%02d", curTime.tm_year, curTime.tm_mon, curTime.tm_mday, curTime.tm_hour, curTime.tm_min, curTime.tm_sec); -#else - desc = Common::String::format("Save %d", slot + 1); -#endif + desc = dialog->createDefaultSaveDescription(slot); } if (desc.size() > 28) -- cgit v1.2.3