[Scummvm-cvs-logs] SF.net SVN: scummvm:[41236] scummvm/trunk/gui/launcher.cpp
sev at users.sourceforge.net
sev at users.sourceforge.net
Sat Jun 6 19:37:16 CEST 2009
Revision: 41236
http://scummvm.svn.sourceforge.net/scummvm/?rev=41236&view=rev
Author: sev
Date: 2009-06-06 17:37:15 +0000 (Sat, 06 Jun 2009)
Log Message:
-----------
Implement FR#1522626: "GUI: Friendlier "Add Game" session"
Modified Paths:
--------------
scummvm/trunk/gui/launcher.cpp
Modified: scummvm/trunk/gui/launcher.cpp
===================================================================
--- scummvm/trunk/gui/launcher.cpp 2009-06-06 17:36:58 UTC (rev 41235)
+++ scummvm/trunk/gui/launcher.cpp 2009-06-06 17:37:15 UTC (rev 41236)
@@ -652,68 +652,77 @@
// 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.
+ // options for that game
+ // 4) If no game is found in the specified directory, return to the
+ // dialog.
- if (_browser->runModal() > 0) {
- // User made his choice...
- Common::FSNode dir(_browser->getResult());
- Common::FSList files;
- if (!dir.getChildren(files, Common::FSNode::kListAll)) {
- MessageDialog alert("ScummVM couldn't open the specified directory!");
- alert.runModal();
- return;
- }
+ bool looping;
+ do {
+ looping = false;
- // ...so let's determine a list of candidates, games that
- // could be contained in the specified directory.
- GameList candidates(EngineMan.detectGames(files));
+ if (_browser->runModal() > 0) {
+ // User made his choice...
+ Common::FSNode dir(_browser->getResult());
+ Common::FSList files;
+ if (!dir.getChildren(files, Common::FSNode::kListAll)) {
+ MessageDialog alert("ScummVM couldn't open the specified directory!");
+ alert.runModal();
+ return;
+ }
- 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();
- idx = -1;
- } else if (candidates.size() == 1) {
- // Exact match
- idx = 0;
- } else {
- // Display the candidates to the user and let her/him pick one
- StringList list;
- for (idx = 0; idx < (int)candidates.size(); idx++)
- list.push_back(candidates[idx].description());
+ // ...so let's determine a list of candidates, games that
+ // could be contained in the specified directory.
+ GameList candidates(EngineMan.detectGames(files));
- ChooserDialog dialog("Pick the game:");
- dialog.setList(list);
- idx = dialog.runModal();
- }
- if (0 <= idx && idx < (int)candidates.size()) {
- GameDescriptor result = candidates[idx];
+ 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();
+ idx = -1;
- // TODO: Change the detectors to set "path" !
- result["path"] = dir.getPath();
+ looping = true;
+ } else if (candidates.size() == 1) {
+ // Exact match
+ idx = 0;
+ } else {
+ // Display the candidates to the user and let her/him pick one
+ StringList list;
+ for (idx = 0; idx < (int)candidates.size(); idx++)
+ list.push_back(candidates[idx].description());
- Common::String domain = addGameToConf(result);
+ ChooserDialog dialog("Pick the game:");
+ dialog.setList(list);
+ idx = dialog.runModal();
+ }
+ if (0 <= idx && idx < (int)candidates.size()) {
+ GameDescriptor result = candidates[idx];
- // Display edit dialog for the new entry
- EditGameDialog editDialog(domain, result.description());
- if (editDialog.runModal() > 0) {
- // User pressed OK, so make changes permanent
+ // TODO: Change the detectors to set "path" !
+ result["path"] = dir.getPath();
- // Write config to disk
- ConfMan.flushToDisk();
+ Common::String domain = addGameToConf(result);
- // Update the ListWidget, select the new item, and force a redraw
- updateListing();
- selectGame(editDialog.getDomain());
- draw();
- } else {
- // User aborted, remove the the new domain again
- ConfMan.removeGameDomain(domain);
+ // 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();
+
+ // Update the ListWidget, select the new item, and force a redraw
+ updateListing();
+ selectGame(editDialog.getDomain());
+ draw();
+ } else {
+ // User aborted, remove the the new domain again
+ ConfMan.removeGameDomain(domain);
+ }
+
}
-
}
- }
+ } while (looping);
}
Common::String addGameToConf(const GameDescriptor &result) {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
More information about the Scummvm-git-logs
mailing list