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/dialogs.cpp | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) (limited to 'engines/dialogs.cpp') diff --git a/engines/dialogs.cpp b/engines/dialogs.cpp index 1b54c7e26a..3fa01ddcbf 100644 --- a/engines/dialogs.cpp +++ b/engines/dialogs.cpp @@ -111,10 +111,8 @@ MainMenuDialog::MainMenuDialog(Engine *engine) _aboutDialog = new GUI::AboutDialog(); _optionsDialog = new ConfigDialog(_engine->hasFeature(Engine::kSupportsSubtitleOptions)); - _loadDialog = new GUI::SaveLoadChooser(_("Load game:"), _("Load")); - _loadDialog->setSaveMode(false); - _saveDialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save")); - _saveDialog->setSaveMode(true); + _loadDialog = new GUI::SaveLoadChooser(_("Load game:"), _("Load"), false); + _saveDialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true); } MainMenuDialog::~MainMenuDialog() { -- 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/dialogs.cpp | 14 ++------------ 1 file changed, 2 insertions(+), 12 deletions(-) (limited to 'engines/dialogs.cpp') diff --git a/engines/dialogs.cpp b/engines/dialogs.cpp index 3fa01ddcbf..9245d9fe62 100644 --- a/engines/dialogs.cpp +++ b/engines/dialogs.cpp @@ -214,12 +214,7 @@ void MainMenuDialog::reflowLayout() { } void MainMenuDialog::save() { - const Common::String gameId = ConfMan.get("gameid"); - - const EnginePlugin *plugin = 0; - EngineMan.findGame(gameId, &plugin); - - int slot = _saveDialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); + int slot = _saveDialog->runModalWithCurrentTarget(); if (slot >= 0) { Common::String result(_saveDialog->getResultString()); @@ -250,12 +245,7 @@ void MainMenuDialog::save() { } void MainMenuDialog::load() { - const Common::String gameId = ConfMan.get("gameid"); - - const EnginePlugin *plugin = 0; - EngineMan.findGame(gameId, &plugin); - - int slot = _loadDialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); + int slot = _loadDialog->runModalWithCurrentTarget(); _engine->setGameToLoadSlot(slot); -- 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/dialogs.cpp | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) (limited to 'engines/dialogs.cpp') diff --git a/engines/dialogs.cpp b/engines/dialogs.cpp index 9245d9fe62..cf3dfaa44b 100644 --- a/engines/dialogs.cpp +++ b/engines/dialogs.cpp @@ -220,15 +220,7 @@ void MainMenuDialog::save() { Common::String result(_saveDialog->getResultString()); if (result.empty()) { // If the user was lazy and entered no save name, come up with a default name. - #if defined(USE_SAVEGAME_TIMESTAMP) - TimeDate curTime; - g_system->getTimeAndDate(curTime); - curTime.tm_year += 1900; // fixup year - curTime.tm_mon++; // fixup month - result = 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 - result = Common::String::format("Save %d", slot + 1); - #endif + result = _saveDialog->createDefaultSaveDescription(slot); } Common::Error status = _engine->saveGameState(slot, result); -- cgit v1.2.3 From 89abab97e3124fa25eb4c7d3e8b38501747a8d17 Mon Sep 17 00:00:00 2001 From: Johannes Schickel Date: Wed, 26 Sep 2012 04:17:31 +0200 Subject: JANITORIAL: Remove trailing whitespaces. Powered by: git ls-files "*.cpp" "*.h" "*.m" "*.mm" | xargs sed -i -e 's/[ \t]*$//' --- engines/dialogs.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'engines/dialogs.cpp') diff --git a/engines/dialogs.cpp b/engines/dialogs.cpp index cf3dfaa44b..c884075093 100644 --- a/engines/dialogs.cpp +++ b/engines/dialogs.cpp @@ -229,7 +229,7 @@ void MainMenuDialog::save() { "Please consult the README for basic information, and for " "instructions on how to obtain further assistance."), status.getDesc().c_str()); GUI::MessageDialog dialog(failMessage); - dialog.runModal(); + dialog.runModal(); } close(); -- cgit v1.2.3