aboutsummaryrefslogtreecommitdiff
path: root/gui/downloaddialog.cpp
diff options
context:
space:
mode:
authorAlexander Tkachev2016-07-12 14:00:11 +0600
committerAlexander Tkachev2016-08-24 16:07:55 +0600
commitd795c77ef53720fa423d9b827a66d1bea8b8e761 (patch)
tree2fac5ef89c3a83298dc151c247198df3f73617b9 /gui/downloaddialog.cpp
parent5c60cd14c2cf27e4b0c03183cef1b1b2e596782a (diff)
downloadscummvm-rg350-d795c77ef53720fa423d9b827a66d1bea8b8e761.tar.gz
scummvm-rg350-d795c77ef53720fa423d9b827a66d1bea8b8e761.tar.bz2
scummvm-rg350-d795c77ef53720fa423d9b827a66d1bea8b8e761.zip
GUI: Fix DownloadDialog detection
Now it calls Launcher directly, so it updates games list on success.
Diffstat (limited to 'gui/downloaddialog.cpp')
-rw-r--r--gui/downloaddialog.cpp77
1 files changed, 5 insertions, 72 deletions
diff --git a/gui/downloaddialog.cpp b/gui/downloaddialog.cpp
index 1d838f142c..5ed287160f 100644
--- a/gui/downloaddialog.cpp
+++ b/gui/downloaddialog.cpp
@@ -28,6 +28,7 @@
#include "gui/browser.h"
#include "gui/chooser.h"
#include "gui/editgamedialog.h"
+#include "gui/launcher.h"
#include "gui/message.h"
#include "gui/remotebrowser.h"
#include "gui/widgets/edittext.h"
@@ -39,8 +40,8 @@ enum {
kDownloadDialogButtonCmd = 'Dldb'
};
-DownloadDialog::DownloadDialog(uint32 storageId):
- Dialog("GlobalOptions_Cloud_DownloadDialog"), _close(false) {
+DownloadDialog::DownloadDialog(uint32 storageId, LauncherDialog *launcher):
+ Dialog("GlobalOptions_Cloud_DownloadDialog"), _launcher(launcher), _close(false) {
_backgroundType = GUI::ThemeEngine::kDialogBackgroundPlain;
_browser = new BrowserDialog(_("Select directory where to download game data"), true);
@@ -165,7 +166,8 @@ bool DownloadDialog::selectDirectories() {
void DownloadDialog::handleTickle() {
if (_close) {
- addGame();
+ if (_launcher)
+ _launcher->doGameDetection(_localDirectory);
close();
_close = false;
return;
@@ -174,75 +176,6 @@ void DownloadDialog::handleTickle() {
Dialog::handleTickle();
}
-void DownloadDialog::addGame() {
- // Allow user to add a new game to the list.
- // 2) try to auto detect which game is in the directory, if we cannot
- // determine it uniquely present a list of candidates to the user
- // to pick from
- // 3) Display the 'Edit' dialog for that item, letting the user specify
- // an alternate description (to distinguish multiple versions of the
- // game, e.g. 'Monkey German' and 'Monkey English') and set default
- // options for that game
- // 4) If no game is found in the specified directory, return to the
- // dialog.
-
- // User made his choice...
- Common::FSNode dir(_localDirectory);
- Common::FSList files;
- if (!dir.getChildren(files, Common::FSNode::kListAll)) {
- MessageDialog alert(_("ScummVM couldn't open the specified directory!"));
- alert.runModal();
- return;
- }
-
- // ...so let's determine a list of candidates, games that
- // could be contained in the specified directory.
- GameList candidates(EngineMan.detectGames(files));
-
- int idx;
- if (candidates.empty()) {
- // No game was found in the specified directory
- MessageDialog alert(_("ScummVM could not find any game in the specified directory!"));
- alert.runModal();
- return;
- }
-
- if (candidates.size() == 1) {
- // Exact match
- idx = 0;
- } else {
- // Display the candidates to the user and let her/him pick one
- Common::StringArray list;
- for (idx = 0; idx < (int)candidates.size(); idx++)
- list.push_back(candidates[idx].description());
-
- ChooserDialog dialog(_("Pick the game:"));
- dialog.setList(list);
- idx = dialog.runModal();
- }
- if (0 <= idx && idx < (int)candidates.size()) {
- GameDescriptor result = candidates[idx];
-
- // TODO: Change the detectors to set "path" !
- result["path"] = dir.getPath();
-
- Common::String domain = addGameToConf(result);
-
- // Display edit dialog for the new entry
- EditGameDialog editDialog(domain, result.description());
- if (editDialog.runModal() > 0) {
- // User pressed OK, so make changes permanent
-
- // Write config to disk
- ConfMan.flushToDisk();
- } else {
- // User aborted, remove the the new domain again
- ConfMan.removeGameDomain(domain);
- }
-
- }
-}
-
void DownloadDialog::reflowLayout() {
Dialog::reflowLayout();
refreshWidgets();