From 57c069ad47b3ca40f7ec280d3c30942cc4b41e86 Mon Sep 17 00:00:00 2001 From: Max Horn Date: Tue, 29 Jul 2008 16:29:28 +0000 Subject: Mass detector: sort all newly detected games by target name before adding them to the config manager svn-id: r33415 --- gui/massadd.cpp | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'gui') diff --git a/gui/massadd.cpp b/gui/massadd.cpp index 687d367516..6842466ad9 100644 --- a/gui/massadd.cpp +++ b/gui/massadd.cpp @@ -23,7 +23,9 @@ */ #include "engines/metaengine.h" +#include "common/algorithm.h" #include "common/events.h" +#include "common/func.h" #include "common/config-manager.h" #include "gui/launcher.h" // For addGameToConf() @@ -113,10 +115,19 @@ MassAddDialog::MassAddDialog(const FilesystemNode &startDir) } } +struct GameDescLess { + bool operator()(const GameDescriptor &x, const GameDescriptor &y) const { + return x.preferredtarget().compareToIgnoreCase(y.preferredtarget()) < 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()); // Add all the detected games to the config for (GameList::const_iterator iter = _games.begin(); iter != _games.end(); ++iter) { printf(" Added gameid '%s', desc '%s'\n", -- cgit v1.2.3