[Scummvm-cvs-logs] SF.net SVN: scummvm:[46380] scummvm/trunk/gui

fingolfin at users.sourceforge.net fingolfin at users.sourceforge.net
Tue Dec 15 09:19:34 CET 2009


Revision: 46380
          http://scummvm.svn.sourceforge.net/scummvm/?rev=46380&view=rev
Author:   fingolfin
Date:     2009-12-15 08:19:34 +0000 (Tue, 15 Dec 2009)

Log Message:
-----------
GUI: Fix some GUI hacks, add some comments, etc.

* Rename LauncherDialog::selectGame() to selectTarget()
* Get rid of the 'temp_selection' ConfMan entry hack
* Add some Doxygen comments
* Turn a printf(...) into a debug(1,...)
* Don't scroll around if 'Mass Add' is cancelled

Modified Paths:
--------------
    scummvm/trunk/gui/launcher.cpp
    scummvm/trunk/gui/launcher.h
    scummvm/trunk/gui/massadd.cpp
    scummvm/trunk/gui/massadd.h

Modified: scummvm/trunk/gui/launcher.cpp
===================================================================
--- scummvm/trunk/gui/launcher.cpp	2009-12-15 08:18:57 UTC (rev 46379)
+++ scummvm/trunk/gui/launcher.cpp	2009-12-15 08:19:34 UTC (rev 46380)
@@ -538,7 +538,7 @@
 
 	// Restore last selection
 	String last(ConfMan.get("lastselectedgame", ConfigManager::kApplicationDomain));
-	selectGame(last);
+	selectTarget(last);
 
 	// En-/disable the buttons depending on the list selection
 	updateButtons();
@@ -550,12 +550,12 @@
 	_loadDialog = new SaveLoadChooser("Load game:", "Load");
 }
 
-void LauncherDialog::selectGame(const String &name) {
-	if (!name.empty()) {
+void LauncherDialog::selectTarget(const String &target) {
+	if (!target.empty()) {
 		int itemToSelect = 0;
 		StringList::const_iterator iter;
 		for (iter = _domains.begin(); iter != _domains.end(); ++iter, ++itemToSelect) {
-			if (name == *iter) {
+			if (target == *iter) {
 				_list->setSelected(itemToSelect);
 				break;
 			}
@@ -657,19 +657,17 @@
 		if (alert.runModal() == GUI::kMessageOK && _browser->runModal() > 0) {
 			MassAddDialog massAddDlg(_browser->getResult());
 
-			if (_list->getSelected() != -1) {
-				// Save current game position, so on cancel cursor will move back
-				ConfMan.set("temp_selection", _domains[_list->getSelected()], ConfigManager::kApplicationDomain);
-			}
-
 			massAddDlg.runModal();
 
 			// Update the ListWidget and force a redraw
-			updateListing();
 
-			// Set cursor to first detected game
-			selectGame(ConfMan.get("temp_selection", ConfigManager::kApplicationDomain));
-			ConfMan.removeKey("temp_selection", ConfigManager::kApplicationDomain);
+			// If new target(s) were added, update the ListWidget and move
+			// the selection to to first newly detected game.
+			Common::String newTarget = massAddDlg.getFirtAddedTarget();
+			if (!newTarget.empty()) {
+				updateListing();
+				selectTarget(newTarget);
+			}
 
 			draw();
 		}
@@ -750,7 +748,7 @@
 
 					// Update the ListWidget, select the new item, and force a redraw
 					updateListing();
-					selectGame(editDialog.getDomain());
+					selectTarget(editDialog.getDomain());
 					draw();
 				} else {
 					// User aborted, remove the the new domain again
@@ -840,7 +838,7 @@
 
 		// Update the ListWidget, reselect the edited game and force a redraw
 		updateListing();
-		selectGame(editDialog.getDomain());
+		selectTarget(editDialog.getDomain());
 		draw();
 	}
 }
@@ -923,7 +921,7 @@
 	case kStartCmd:
 	case kListItemActivatedCmd:
 	case kListItemDoubleClickedCmd:
-		// Print out what was selected
+		// Start the selected game.
 		assert(item >= 0);
 		ConfMan.setActiveDomain(_domains[item]);
 		close();
@@ -940,9 +938,11 @@
 		close();
 		break;
 	case kSearchCmd:
+		// Update the active search filter.
 		_list->setFilter(_searchWidget->getEditString());
 		break;
 	case kSearchClearCmd:
+		// Reset the active search filter, thus showing all games again
 		_searchWidget->setEditString("");
 		_list->setFilter("");
 		break;

Modified: scummvm/trunk/gui/launcher.h
===================================================================
--- scummvm/trunk/gui/launcher.h	2009-12-15 08:18:57 UTC (rev 46379)
+++ scummvm/trunk/gui/launcher.h	2009-12-15 08:19:34 UTC (rev 46380)
@@ -72,17 +72,44 @@
 
 	virtual void reflowLayout();
 
+	/**
+	 * Fill the list widget with all currently configured targets, and trigger
+	 * a redraw.
+	 */
 	void updateListing();
+
 	void updateButtons();
 
 	void open();
 	void close();
+
+	/**
+	 * Handle "Add game..." button.
+	 */
 	virtual void addGame();
+
+	/**
+	 * Handle "Remove game..." button.
+	 */
 	void removeGame(int item);
+
+	/**
+	 * Handle "Edit game..." button.
+	 */
 	void editGame(int item);
+
+	/**
+	 * Handle "Load..." button.
+	 */
 	void loadGame(int item);
 
-	void selectGame(const String &name);
+	/**
+	 * Select the target with the given name in the launcher game list.
+	 * Also scrolls the list so that the newly selected item is visible.
+	 *
+	 * @target	name of target to select
+	 */
+	void selectTarget(const String &target);
 };
 
 } // End of namespace GUI

Modified: scummvm/trunk/gui/massadd.cpp
===================================================================
--- scummvm/trunk/gui/massadd.cpp	2009-12-15 08:18:57 UTC (rev 46379)
+++ scummvm/trunk/gui/massadd.cpp	2009-12-15 08:19:34 UTC (rev 46380)
@@ -139,7 +139,7 @@
 		sort(_games.begin(), _games.end(), GameTargetLess());
 		// Add all the detected games to the config
 		for (GameList::iterator iter = _games.begin(); iter != _games.end(); ++iter) {
-			printf("  Added gameid '%s', desc '%s'\n",
+			debug(1, "  Added gameid '%s', desc '%s'\n",
 				(*iter)["gameid"].c_str(),
 				(*iter)["description"].c_str());
 			(*iter)["gameid"] = addGameToConf(*iter);
@@ -157,6 +157,7 @@
 		close();
 	} else if (cmd == kCancelCmd) {
 		// User cancelled, so we don't do anything and just leave.
+		_games.clear();
 		close();
 	} else {
 		Dialog::handleCommand(sender, cmd, data);

Modified: scummvm/trunk/gui/massadd.h
===================================================================
--- scummvm/trunk/gui/massadd.h	2009-12-15 08:18:57 UTC (rev 46379)
+++ scummvm/trunk/gui/massadd.h	2009-12-15 08:19:34 UTC (rev 46380)
@@ -44,6 +44,12 @@
 	void handleCommand(CommandSender *sender, uint32 cmd, uint32 data);
 	void handleTickle();
 
+	Common::String getFirtAddedTarget() const {
+		if (!_games.empty())
+			return _games.front().gameid();
+		return Common::String();
+	}
+
 private:
 	Common::Stack<Common::FSNode>  _scanStack;
 	GameList _games;


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