[Scummvm-git-logs] scummvm master -> e9f2468df9c442b569081feb384a8fa2ed3fcc91

sev- noreply at scummvm.org
Sun Apr 7 12:06:38 UTC 2024


This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .

Summary:
e9f2468df9 GUI: Skip games during Mass Add


Commit: e9f2468df9c442b569081feb384a8fa2ed3fcc91
    https://github.com/scummvm/scummvm/commit/e9f2468df9c442b569081feb384a8fa2ed3fcc91
Author: HectorRecloud (hector at recloud.es)
Date: 2024-04-07T14:06:33+02:00

Commit Message:
GUI: Skip games during Mass Add

Use [x] for selected games, as well as enabled list items.

Co-Authored-By: Filippos Karapetis <bluegr at gmail.com>

Changed paths:
    engines/game.h
    gui/massadd.cpp
    gui/massadd.h
    gui/widgets/list.cpp
    gui/widgets/list.h


diff --git a/engines/game.h b/engines/game.h
index 326d1a16299..a5150caaa87 100644
--- a/engines/game.h
+++ b/engines/game.h
@@ -170,6 +170,11 @@ struct DetectedGame {
 	 */
 	bool hasUnknownFiles;
 
+	/**
+	 * A game was detected and is selected in the Mass Add list.
+	 */
+	bool isSelected;
+
 	/**
 	 * An optional list of the files that were used to match the game with the engine's detection tables
 	 */
diff --git a/gui/massadd.cpp b/gui/massadd.cpp
index f279d8a04a4..63102523147 100644
--- a/gui/massadd.cpp
+++ b/gui/massadd.cpp
@@ -136,10 +136,13 @@ void MassAddDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
 		Common::sort(_games.begin(), _games.end(), GameTargetLess());
 		// Add all the detected games to the config
 		for (DetectedGames::iterator iter = _games.begin(); iter != _games.end(); ++iter) {
-			debug(1, "  Added gameid '%s', desc '%s'\n",
-				iter->gameId.c_str(),
-				iter->description.c_str());
-			iter->gameId = EngineMan.createTargetForGame(*iter);
+			// Make sure the game is selected
+			if (iter->isSelected) {
+				debug(1, "  Added gameid '%s', desc '%s'",
+					iter->gameId.c_str(),
+					iter->description.c_str());
+				iter->gameId = EngineMan.createTargetForGame(*iter);
+			}
 		}
 
 		// Write everything to disk
@@ -156,11 +159,30 @@ void MassAddDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data
 		// User cancelled, so we don't do anything and just leave.
 		_games.clear();
 		close();
+	} else if (cmd == kListSelectionChangedCmd) {
+		// Select / unselect game from list
+		int curretScrollPos = _list->getCurrentScrollPos();
+		_games[_list->getSelected()].isSelected = !_games[_list->getSelected()].isSelected;
+		updateGameList();
+		_list->scrollTo(curretScrollPos);
 	} else {
 		Dialog::handleCommand(sender, cmd, data);
 	}
 }
 
+void MassAddDialog::updateGameList() {
+	// Update list to correctly display selected / unselected games
+	Common::U32StringArray l;
+	_list->setList(l);
+	_list->clearSelectedList();
+
+	for (const auto &game : _games) {
+		Common::U32String displayString = game.isSelected ? Common::String("[x] ") + game.description : Common::String("[\u2000] ") + game.description;
+		_list->append(displayString);
+		_list->appendToSelectedList(game.isSelected);
+	}
+}
+
 void MassAddDialog::handleTickle() {
 	if (_scanStack.empty())
 		return;	// We have finished scanning
@@ -227,6 +249,11 @@ void MassAddDialog::handleTickle() {
 			_list->append(result.description);
 		}
 
+		for (DetectedGame &game : _games) {
+			game.isSelected = true;
+		}
+
+		updateGameList();
 
 		// Recurse into all subdirs
 		for (Common::FSList::const_iterator file = files.begin(); file != files.end(); ++file) {
diff --git a/gui/massadd.h b/gui/massadd.h
index c2206497d83..b693a39324e 100644
--- a/gui/massadd.h
+++ b/gui/massadd.h
@@ -51,6 +51,8 @@ private:
 	Common::Stack<Common::FSNode>  _scanStack;
 	DetectedGames _games;
 
+	void updateGameList();
+
 	/**
 	 * Map each path occuring in the config file to the target(s) using that path.
 	 * Used to detect whether a potential new target is already present in the
diff --git a/gui/widgets/list.cpp b/gui/widgets/list.cpp
index be184a2364b..a30f37e5987 100644
--- a/gui/widgets/list.cpp
+++ b/gui/widgets/list.cpp
@@ -559,6 +559,12 @@ void ListWidget::drawWidget() {
 		if (_selectedItem == pos)
 			inverted = _inversion;
 
+		// Display selected/unselected games in mass detection as enabled/disabled items.
+		if (pos < (signed int)_listSelected.size() && _listSelected[pos])
+			_state = ThemeEngine::kStateEnabled;
+		else
+			_state = ThemeEngine::kStateDisabled;
+
 		Common::Rect r(getEditRect());
 		int pad = _leftPadding;
 		int rtlPad = (_x + r.left + _leftPadding) - (_x + _hlLeftPadding);
diff --git a/gui/widgets/list.h b/gui/widgets/list.h
index d1b515acdaf..b0e17ea541e 100644
--- a/gui/widgets/list.h
+++ b/gui/widgets/list.h
@@ -97,6 +97,8 @@ protected:
 	FilterMatcher	_filterMatcher;
 	void			*_filterMatcherArg;
 
+	Common::Array<bool>	_listSelected;
+
 public:
 	ListWidget(Dialog *boss, const Common::String &name, const Common::U32String &tooltip = Common::U32String(), uint32 cmd = 0);
 	ListWidget(Dialog *boss, int x, int y, int w, int h, bool scale, const Common::U32String &tooltip = Common::U32String(), uint32 cmd = 0);
@@ -131,6 +133,9 @@ public:
 	void setEditColor(ThemeEngine::FontColor color) { _editColor = color; }
 	void setFilterMatcher(FilterMatcher matcher, void *arg) { _filterMatcher = matcher; _filterMatcherArg = arg; }
 
+	void appendToSelectedList(bool selected) { _listSelected.push_back(selected); }
+	void clearSelectedList() { _listSelected.clear(); }
+
 	// Made startEditMode/endEditMode for SaveLoadChooser
 	void startEditMode() override;
 	void endEditMode() override;




More information about the Scummvm-git-logs mailing list