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

sev at users.sourceforge.net sev at users.sourceforge.net
Sat Jun 6 19:49:59 CEST 2009


Revision: 41263
          http://scummvm.svn.sourceforge.net/scummvm/?rev=41263&view=rev
Author:   sev
Date:     2009-06-06 17:49:59 +0000 (Sat, 06 Jun 2009)

Log Message:
-----------
Implement FR#2707442: "GUI: Improve Mass Add dialog"

Modified Paths:
--------------
    scummvm/trunk/gui/ListWidget.cpp
    scummvm/trunk/gui/ListWidget.h
    scummvm/trunk/gui/launcher.cpp
    scummvm/trunk/gui/massadd.cpp
    scummvm/trunk/gui/massadd.h
    scummvm/trunk/gui/themes/scummmodern/scummmodern_layout.stx
    scummvm/trunk/gui/themes/scummmodern.zip

Modified: scummvm/trunk/gui/ListWidget.cpp
===================================================================
--- scummvm/trunk/gui/ListWidget.cpp	2009-06-06 17:49:09 UTC (rev 41262)
+++ scummvm/trunk/gui/ListWidget.cpp	2009-06-06 17:49:59 UTC (rev 41263)
@@ -133,6 +133,11 @@
 	scrollBarRecalc();
 }
 
+void ListWidget::append(const String &s) {
+	_list.push_back(s);
+	scrollBarRecalc();
+}
+
 void ListWidget::scrollTo(int item) {
 	int size = _list.size();
 	if (item >= size)
@@ -445,6 +450,18 @@
 	_scrollBar->recalc();
 }
 
+void ListWidget::scrollToEnd() {
+	if (_currentPos + _entriesPerPage < (int)_list.size()) {
+		_currentPos = _list.size() - _entriesPerPage;
+	} else {
+		return;
+	}
+
+	_scrollBar->_currentPos = _currentPos;
+	_scrollBar->recalc();
+	_scrollBar->draw();
+}
+
 void ListWidget::startEditMode() {
 	if (_editable && !_editMode && _selectedItem >= 0) {
 		_editMode = true;

Modified: scummvm/trunk/gui/ListWidget.h
===================================================================
--- scummvm/trunk/gui/ListWidget.h	2009-06-06 17:49:09 UTC (rev 41262)
+++ scummvm/trunk/gui/ListWidget.h	2009-06-06 17:49:59 UTC (rev 41263)
@@ -81,6 +81,7 @@
 	virtual Widget *findWidget(int x, int y);
 
 	void setList(const StringList &list);
+	void append(const String &s);
 	const StringList &getList()	const			{ return _list; }
 	int getSelected() const						{ return _selectedItem; }
 	void setSelected(int item);
@@ -89,6 +90,7 @@
 	bool isEditable() const						{ return _editable; }
 	void setEditable(bool editable)				{ _editable = editable; }
 	void scrollTo(int item);
+	void scrollToEnd();
 
 	virtual void handleTickle();
 	virtual void handleMouseDown(int x, int y, int button, int clickCount);

Modified: scummvm/trunk/gui/launcher.cpp
===================================================================
--- scummvm/trunk/gui/launcher.cpp	2009-06-06 17:49:09 UTC (rev 41262)
+++ scummvm/trunk/gui/launcher.cpp	2009-06-06 17:49:59 UTC (rev 41263)
@@ -630,8 +630,14 @@
 							"This could potentially add a huge number of games.", "Yes", "No");
 		if (alert.runModal() == GUI::kMessageOK && _browser->runModal() > 0) {
 			MassAddDialog massAddDlg(_browser->getResult());
+
+			ConfMan.set("temp_selection", _domains[_list->getSelected()], ConfigManager::kApplicationDomain);
+
 			massAddDlg.runModal();
 
+			selectGame(ConfMan.get("temp_selection", ConfigManager::kApplicationDomain));
+			ConfMan.removeKey("temp_selection", ConfigManager::kApplicationDomain);
+
 			// Update the ListWidget and force a redraw
 			updateListing();
 			draw();

Modified: scummvm/trunk/gui/massadd.cpp
===================================================================
--- scummvm/trunk/gui/massadd.cpp	2009-06-06 17:49:09 UTC (rev 41262)
+++ scummvm/trunk/gui/massadd.cpp	2009-06-06 17:49:59 UTC (rev 41263)
@@ -32,6 +32,7 @@
 #include "gui/massadd.h"
 #include "gui/GuiManager.h"
 #include "gui/widget.h"
+#include "gui/ListWidget.h"
 
 
 namespace GUI {
@@ -65,6 +66,8 @@
 	_dirProgressText(0),
 	_gameProgressText(0) {
 
+	Common::StringList l;
+
 	// The dir we start our scan at
 	_scanStack.push(startDir);
 
@@ -80,6 +83,11 @@
 	_dirProgressText->setAlign(Graphics::kTextAlignCenter);
 	_gameProgressText->setAlign(Graphics::kTextAlignCenter);
 
+	_list = new ListWidget(this, "MassAdd.GameList");
+	_list->setEditable(false);
+	_list->setNumberingMode(kListNumberingOff);
+	_list->setList(l);
+
 	_okButton = new ButtonWidget(this, "MassAdd.Ok", "OK", kOkCmd, Common::ASCII_RETURN);
 	_okButton->setEnabled(false);
 
@@ -110,30 +118,40 @@
 	}
 }
 
-struct GameDescLess {
+struct GameTargetLess {
 	bool operator()(const GameDescriptor &x, const GameDescriptor &y) const {
 		return x.preferredtarget().compareToIgnoreCase(y.preferredtarget()) < 0;
 	}
 };
 
+struct GameDescLess {
+	bool operator()(const GameDescriptor &x, const GameDescriptor &y) const {
+		return x.description().compareToIgnoreCase(y.description()) < 0;
+	}
+};
 
+
 void MassAddDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
 	// FIXME: It's a really bad thing that we use two arbitrary constants
 	if (cmd == kOkCmd) {
 		// Sort the detected games. This is not strictly necessary, but nice for
 		// people who want to edit their config file by hand after a mass add.
-		sort(_games.begin(), _games.end(), GameDescLess());
+		sort(_games.begin(), _games.end(), GameTargetLess());
 		// Add all the detected games to the config
-		for (GameList::const_iterator iter = _games.begin(); iter != _games.end(); ++iter) {
+		for (GameList::iterator iter = _games.begin(); iter != _games.end(); ++iter) {
 			printf("  Added gameid '%s', desc '%s'\n",
 				(*iter)["gameid"].c_str(),
 				(*iter)["description"].c_str());
-			addGameToConf(*iter);
+			(*iter)["gameid"] = addGameToConf(*iter);
 		}
 
 		// Write everything to disk
 		ConfMan.flushToDisk();
 
+		// And scroll to first detected game
+		sort(_games.begin(), _games.end(), GameDescLess());
+		ConfMan.set("temp_selection", _games.front().gameid());
+
 		close();
 	} else if (cmd == kCancelCmd) {
 		// User cancelled, so we don't do anything and just leave.
@@ -196,6 +214,8 @@
 			}
 			result["path"] = path;
 			_games.push_back(result);
+
+			_list->append(result.description());
 		}
 
 
@@ -231,6 +251,10 @@
 		_gameProgressText->setLabel(buf);
 	}
 
+	if (_games.size() > 0) {
+		_list->scrollToEnd();
+	}
+
 	drawDialog();
 }
 

Modified: scummvm/trunk/gui/massadd.h
===================================================================
--- scummvm/trunk/gui/massadd.h	2009-06-06 17:49:09 UTC (rev 41262)
+++ scummvm/trunk/gui/massadd.h	2009-06-06 17:49:59 UTC (rev 41263)
@@ -60,6 +60,8 @@
 	Widget *_okButton;
 	StaticTextWidget *_dirProgressText;
 	StaticTextWidget *_gameProgressText;
+
+	ListWidget *_list;
 };
 
 

Modified: scummvm/trunk/gui/themes/scummmodern/scummmodern_layout.stx
===================================================================
--- scummvm/trunk/gui/themes/scummmodern/scummmodern_layout.stx	2009-06-06 17:49:09 UTC (rev 41262)
+++ scummvm/trunk/gui/themes/scummmodern/scummmodern_layout.stx	2009-06-06 17:49:59 UTC (rev 41263)
@@ -721,7 +721,14 @@
 					width = '250'
 					height = 'Globals.Line.Height'
 			/>
-			<space size = '32' />
+			<widget name = 'GameProgressText' 
+					width = '250'
+					height = 'Globals.Line.Height'
+			/>
+			<widget name = 'GameList'
+					width = '480'
+					height = '250'
+			/>
 			<layout type = 'horizontal' padding = '8, 8, 8, 8'>
 				<widget name = 'Ok'
 						type = 'Button'

Modified: scummvm/trunk/gui/themes/scummmodern.zip
===================================================================
(Binary files differ)


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