Skip to content

Commit

Permalink
Client|GameSelectionWidget: Sort games by name
Browse files Browse the repository at this point in the history
The game selection widget now displays the games in the same order
as 'listgames'.
  • Loading branch information
skyjake committed Jul 16, 2013
1 parent f24abe9 commit e1f5bd9
Showing 1 changed file with 15 additions and 0 deletions.
15 changes: 15 additions & 0 deletions doomsday/client/src/ui/widgets/gameselectionwidget.cpp
Expand Up @@ -33,10 +33,25 @@ DENG2_OBSERVES(App, StartupComplete)
typedef QMap<Game *, ButtonWidget *> Buttons;
Buttons buttons;

/**
* Sorts the game buttons by label text.
*/
struct Sorting : public ISortOrder
{
int compareMenuItemsForSorting(Widget const &a, Widget const &b) const
{
ButtonWidget const &x = a.as<ButtonWidget>();
ButtonWidget const &y = b.as<ButtonWidget>();
return x.text().compareWithoutCase(y.text());
}
};

Instance(Public *i) : Base(i)
{
App_Games().audienceForAddition += this;
App::app().audienceForStartupComplete += this;

self.setLayoutSortOrder(new Sorting);
}

~Instance()
Expand Down

0 comments on commit e1f5bd9

Please sign in to comment.