diff options
author | Johannes Schickel | 2012-06-10 04:49:42 +0200 |
---|---|---|
committer | Johannes Schickel | 2012-06-10 04:53:17 +0200 |
commit | 7c5cf1b400808865a5f601f70d624ad6704a0c8c (patch) | |
tree | 488862f566ac55bbadf84440115a12b91a213b5d /engines | |
parent | 9b05f4e1039ade7f2d0b774c18a6767113f2c848 (diff) | |
download | scummvm-rg350-7c5cf1b400808865a5f601f70d624ad6704a0c8c.tar.gz scummvm-rg350-7c5cf1b400808865a5f601f70d624ad6704a0c8c.tar.bz2 scummvm-rg350-7c5cf1b400808865a5f601f70d624ad6704a0c8c.zip |
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.
Diffstat (limited to 'engines')
-rw-r--r-- | engines/agi/saveload.cpp | 6 | ||||
-rw-r--r-- | engines/cge/events.cpp | 10 | ||||
-rw-r--r-- | engines/cruise/menu.cpp | 4 | ||||
-rw-r--r-- | engines/dialogs.cpp | 14 | ||||
-rw-r--r-- | engines/dreamweb/saveload.cpp | 10 | ||||
-rw-r--r-- | engines/hugo/file.cpp | 8 | ||||
-rw-r--r-- | engines/mohawk/riven.cpp | 7 | ||||
-rw-r--r-- | engines/parallaction/saveload.cpp | 7 | ||||
-rw-r--r-- | engines/sci/engine/kfile.cpp | 8 | ||||
-rw-r--r-- | engines/toon/toon.cpp | 8 | ||||
-rw-r--r-- | engines/tsage/scenes.cpp | 4 |
11 files changed, 18 insertions, 68 deletions
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; diff --git a/engines/cge/events.cpp b/engines/cge/events.cpp index e903584100..095aac2412 100644 --- a/engines/cge/events.cpp +++ b/engines/cge/events.cpp @@ -70,11 +70,8 @@ bool Keyboard::getKey(Common::Event &event) { return false; case Common::KEYCODE_F5: if (_vm->canSaveGameStateCurrently()) { - const EnginePlugin *plugin = NULL; - EngineMan.findGame(_vm->_gameDescription->gameid, &plugin); - GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser("Save game:", "Save", true); - int16 savegameId = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); + int16 savegameId = dialog->runModalWithCurrentTarget(); Common::String savegameDescription = dialog->getResultString(); delete dialog; @@ -84,11 +81,8 @@ bool Keyboard::getKey(Common::Event &event) { return false; case Common::KEYCODE_F7: if (_vm->canLoadGameStateCurrently()) { - const EnginePlugin *plugin = NULL; - EngineMan.findGame(_vm->_gameDescription->gameid, &plugin); - GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser("Restore game:", "Restore", false); - int16 savegameId = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); + int16 savegameId = dialog->runModalWithCurrentTarget(); delete dialog; if (savegameId != -1) diff --git a/engines/cruise/menu.cpp b/engines/cruise/menu.cpp index 988355e777..512259f7d7 100644 --- a/engines/cruise/menu.cpp +++ b/engines/cruise/menu.cpp @@ -207,15 +207,13 @@ int processMenu(menuStruct *pMenu) { } static void handleSaveLoad(bool saveFlag) { - const EnginePlugin *plugin = 0; - EngineMan.findGame(_vm->getGameId(), &plugin); GUI::SaveLoadChooser *dialog; if (saveFlag) dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true); else dialog = new GUI::SaveLoadChooser(_("Load game:"), _("Load"), false); - int slot = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); + int slot = dialog->runModalWithCurrentTarget(); if (slot >= 0) { if (!saveFlag) 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); diff --git a/engines/dreamweb/saveload.cpp b/engines/dreamweb/saveload.cpp index e659c03e13..ea9cdc0249 100644 --- a/engines/dreamweb/saveload.cpp +++ b/engines/dreamweb/saveload.cpp @@ -158,11 +158,8 @@ void DreamWebEngine::doLoad(int savegameId) { if (savegameId == -1) { // Open dialog to get savegameId - const EnginePlugin *plugin = NULL; - Common::String gameId = ConfMan.get("gameid"); - EngineMan.findGame(gameId, &plugin); GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false); - savegameId = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); + savegameId = dialog->runModalWithCurrentTarget(); delete dialog; } @@ -244,11 +241,8 @@ void DreamWebEngine::saveGame() { } return; } else { - const EnginePlugin *plugin = NULL; - Common::String gameId = ConfMan.get("gameid"); - EngineMan.findGame(gameId, &plugin); GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true); - int savegameId = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); + int savegameId = dialog->runModalWithCurrentTarget(); Common::String game_description = dialog->getResultString(); if (game_description.empty()) game_description = "Untitled"; diff --git a/engines/hugo/file.cpp b/engines/hugo/file.cpp index 3c94b2ee3d..f94f3b0443 100644 --- a/engines/hugo/file.cpp +++ b/engines/hugo/file.cpp @@ -330,14 +330,12 @@ sound_pt FileManager::getSound(const int16 sound, uint16 *size) { bool FileManager::saveGame(const int16 slot, const Common::String &descrip) { debugC(1, kDebugFile, "saveGame(%d, %s)", slot, descrip.c_str()); - const EnginePlugin *plugin = NULL; int16 savegameId; Common::String savegameDescription; - EngineMan.findGame(_vm->getGameId(), &plugin); if (slot == -1) { GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser("Save game:", "Save", true); - savegameId = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); + savegameId = dialog->runModalWithCurrentTarget(); savegameDescription = dialog->getResultString(); delete dialog; } else { @@ -435,13 +433,11 @@ bool FileManager::saveGame(const int16 slot, const Common::String &descrip) { bool FileManager::restoreGame(const int16 slot) { debugC(1, kDebugFile, "restoreGame(%d)", slot); - const EnginePlugin *plugin = NULL; int16 savegameId; - EngineMan.findGame(_vm->getGameId(), &plugin); if (slot == -1) { GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser("Restore game:", "Restore", false); - savegameId = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); + savegameId = dialog->runModalWithCurrentTarget(); delete dialog; } else { savegameId = slot; diff --git a/engines/mohawk/riven.cpp b/engines/mohawk/riven.cpp index d66e46f4a8..e54d6fefa2 100644 --- a/engines/mohawk/riven.cpp +++ b/engines/mohawk/riven.cpp @@ -715,12 +715,7 @@ void MohawkEngine_Riven::delayAndUpdate(uint32 ms) { void MohawkEngine_Riven::runLoadDialog() { GUI::SaveLoadChooser slc(_("Load game:"), _("Load"), false); - Common::String gameId = ConfMan.get("gameid"); - - const EnginePlugin *plugin = 0; - EngineMan.findGame(gameId, &plugin); - - int slot = slc.runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); + int slot = slc.runModalWithCurrentTarget(); if (slot >= 0) loadGameState(slot); } diff --git a/engines/parallaction/saveload.cpp b/engines/parallaction/saveload.cpp index 85923363c7..8de2d89b18 100644 --- a/engines/parallaction/saveload.cpp +++ b/engines/parallaction/saveload.cpp @@ -184,12 +184,7 @@ int SaveLoad::selectSaveFile(Common::String &selectedName, bool saveMode, const selectedName.clear(); - Common::String gameId = ConfMan.get("gameid"); - - const EnginePlugin *plugin = 0; - EngineMan.findGame(gameId, &plugin); - - int idx = slc.runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); + int idx = slc.runModalWithCurrentTarget(); if (idx >= 0) { selectedName = slc.getResultString(); } diff --git a/engines/sci/engine/kfile.cpp b/engines/sci/engine/kfile.cpp index 6c40be87e2..4af71f41af 100644 --- a/engines/sci/engine/kfile.cpp +++ b/engines/sci/engine/kfile.cpp @@ -562,10 +562,8 @@ reg_t kSaveGame(EngineState *s, int argc, reg_t *argv) { // we are supposed to show a dialog for the user and let him choose where to save g_sci->_soundCmd->pauseAll(true); // pause music - const EnginePlugin *plugin = NULL; - EngineMan.findGame(g_sci->getGameIdStr(), &plugin); GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), true); - savegameId = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); + savegameId = dialog->runModalWithCurrentTarget(); game_description = dialog->getResultString(); if (game_description.empty()) { // create our own description for the saved game, the user didnt enter it @@ -668,10 +666,8 @@ reg_t kRestoreGame(EngineState *s, int argc, reg_t *argv) { if (savegameId == -1) { // we are supposed to show a dialog for the user and let him choose a saved game g_sci->_soundCmd->pauseAll(true); // pause music - const EnginePlugin *plugin = NULL; - EngineMan.findGame(g_sci->getGameIdStr(), &plugin); GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser(_("Restore game:"), _("Restore"), false); - savegameId = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); + savegameId = dialog->runModalWithCurrentTarget(); delete dialog; if (savegameId < 0) { g_sci->_soundCmd->pauseAll(false); // unpause music diff --git a/engines/toon/toon.cpp b/engines/toon/toon.cpp index 9da06ce5be..be298e1236 100644 --- a/engines/toon/toon.cpp +++ b/engines/toon/toon.cpp @@ -2955,14 +2955,12 @@ Common::String ToonEngine::getSavegameName(int nr) { } bool ToonEngine::saveGame(int32 slot, const Common::String &saveGameDesc) { - const EnginePlugin *plugin = NULL; int16 savegameId; Common::String savegameDescription; - EngineMan.findGame(_gameDescription->gameid, &plugin); if (slot == -1) { GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser("Save game:", "Save", true); - savegameId = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); + savegameId = dialog->runModalWithCurrentTarget(); savegameDescription = dialog->getResultString(); delete dialog; } else { @@ -3051,13 +3049,11 @@ bool ToonEngine::saveGame(int32 slot, const Common::String &saveGameDesc) { } bool ToonEngine::loadGame(int32 slot) { - const EnginePlugin *plugin = NULL; int16 savegameId; - EngineMan.findGame(_gameDescription->gameid, &plugin); if (slot == -1) { GUI::SaveLoadChooser *dialog = new GUI::SaveLoadChooser("Restore game:", "Restore", false); - savegameId = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); + savegameId = dialog->runModalWithCurrentTarget(); delete dialog; } else { savegameId = slot; diff --git a/engines/tsage/scenes.cpp b/engines/tsage/scenes.cpp index 8fe7b8c458..774a5277dc 100644 --- a/engines/tsage/scenes.cpp +++ b/engines/tsage/scenes.cpp @@ -569,15 +569,13 @@ void Game::quitGame() { } void Game::handleSaveLoad(bool saveFlag, int &saveSlot, Common::String &saveName) { - const EnginePlugin *plugin = 0; - EngineMan.findGame(g_vm->getGameId(), &plugin); GUI::SaveLoadChooser *dialog; if (saveFlag) dialog = new GUI::SaveLoadChooser(_("Save game:"), _("Save"), saveFlag); else dialog = new GUI::SaveLoadChooser(_("Load game:"), _("Load"), saveFlag); - saveSlot = dialog->runModalWithPluginAndTarget(plugin, ConfMan.getActiveDomainName()); + saveSlot = dialog->runModalWithCurrentTarget(); saveName = dialog->getResultString(); delete dialog; |