Skip to content

Commit

Permalink
UI|Home: Sort options for game library
Browse files Browse the repository at this point in the history
Games can be sorted based on different criteria. The selected item is retained if the item order changes.

IssueID #2226
  • Loading branch information
skyjake committed Nov 3, 2018
1 parent de93b41 commit dc4482e
Show file tree
Hide file tree
Showing 5 changed files with 184 additions and 54 deletions.
2 changes: 2 additions & 0 deletions doomsday/apps/client/include/ui/widgets/homemenuwidget.h
Expand Up @@ -44,6 +44,8 @@ class HomeMenuWidget : public de::MenuWidget
*/
de::ui::DataPos selectedIndex() const;

const de::ui::Item *selectedItem() const;

/**
* @brief setSelectedIndex
* @param index
Expand Down
Expand Up @@ -54,6 +54,9 @@ def setDefaults(d)
record d.home()
showUnplayableGames = True
showColumnDescription = True
sortBy = 'release'
sortAscending = True
sortCustomSeparately = True
record columns()
doom = True
heretic = True
Expand Down
38 changes: 19 additions & 19 deletions doomsday/apps/client/src/ui/dialogs/uisettingsdialog.cpp
Expand Up @@ -20,11 +20,11 @@
#include "clientapp.h"
#include "ConfigProfiles"

#include <de/GridLayout>
#include <de/CallbackAction>
#include <de/Config>
#include <de/GridLayout>
#include <de/VariableChoiceWidget>
#include <de/VariableToggleWidget>
#include <de/App>

using namespace de;

Expand All @@ -33,8 +33,8 @@ DENG2_PIMPL(UISettingsDialog)
VariableChoiceWidget *uiScale;
VariableToggleWidget *uiTranslucency;
VariableToggleWidget *showAnnotations;
VariableToggleWidget *showColumnDescription;
VariableToggleWidget *showUnplayable;
// VariableToggleWidget *showColumnDescription;
// VariableToggleWidget *showUnplayable;
VariableToggleWidget *showDoom;
VariableToggleWidget *showHeretic;
VariableToggleWidget *showHexen;
Expand All @@ -45,16 +45,16 @@ DENG2_PIMPL(UISettingsDialog)
{
auto &area = self().area();

area.add(uiScale = new VariableChoiceWidget(App::config("ui.scaleFactor"), VariableChoiceWidget::Number));
area.add(uiTranslucency = new VariableToggleWidget(tr("Background Translucency"), App::config("ui.translucency")));
area.add(showAnnotations = new VariableToggleWidget(tr("Menu Annotations"), App::config("ui.showAnnotations")));
area.add(showColumnDescription = new VariableToggleWidget(tr("Game Descriptions"), App::config("home.showColumnDescription")));
area.add(showUnplayable = new VariableToggleWidget(tr("Unplayable Games"), App::config("home.showUnplayableGames")));
area.add(showDoom = new VariableToggleWidget(tr("Doom"), App::config("home.columns.doom")));
area.add(showHeretic = new VariableToggleWidget(tr("Heretic"), App::config("home.columns.heretic")));
area.add(showHexen = new VariableToggleWidget(tr("Hexen"), App::config("home.columns.hexen")));
area.add(showOther = new VariableToggleWidget(tr("Other Games"), App::config("home.columns.otherGames")));
area.add(showMultiplayer = new VariableToggleWidget(tr("Multiplayer"), App::config("home.columns.multiplayer")));
area.add(uiScale = new VariableChoiceWidget(Config::get("ui.scaleFactor"), VariableChoiceWidget::Number));
area.add(uiTranslucency = new VariableToggleWidget(tr("Background Translucency"), Config::get("ui.translucency")));
area.add(showAnnotations = new VariableToggleWidget(tr("Menu Annotations"), Config::get("ui.showAnnotations")));
// area.add(showColumnDescription = new VariableToggleWidget(tr("Game Descriptions"), Config::get("home.showColumnDescription")));
// area.add(showUnplayable = new VariableToggleWidget(tr("Unplayable Games"), Config::get("home.showUnplayableGames")));
area.add(showDoom = new VariableToggleWidget(tr("Doom"), Config::get("home.columns.doom")));
area.add(showHeretic = new VariableToggleWidget(tr("Heretic"), Config::get("home.columns.heretic")));
area.add(showHexen = new VariableToggleWidget(tr("Hexen"), Config::get("home.columns.hexen")));
area.add(showOther = new VariableToggleWidget(tr("Other Games"), Config::get("home.columns.otherGames")));
area.add(showMultiplayer = new VariableToggleWidget(tr("Multiplayer"), Config::get("home.columns.multiplayer")));

uiScale->items()
<< new ChoiceItem(tr("Huge (200%)"), 2.0)
Expand Down Expand Up @@ -105,19 +105,19 @@ UISettingsDialog::UISettingsDialog(String const &name)
layout.setCellAlignment(Vector2i(0, layout.gridSize().y), ui::AlignLeft);
layout.append(*library, 2);

auto *showLabel = LabelWidget::newWithText(tr("Show:"), &area());
auto *showLabel = LabelWidget::newWithText(tr("Enabled Tabs:"), &area());
showLabel->rule().setLeftTop(library->rule().left(), library->rule().bottom());

GridLayout showLayout(showLabel->rule().right(), showLabel->rule().top(),
GridLayout::RowFirst);
showLayout.setGridSize(2, 4);
showLayout.setGridSize(2, 3);
showLayout << *d->showDoom
<< *d->showHeretic
<< *d->showHexen
<< *d->showOther
<< *d->showMultiplayer
<< *d->showColumnDescription
<< *d->showUnplayable;
<< *d->showMultiplayer;
// << *d->showColumnDescription
// << *d->showUnplayable;

area().setContentSize(OperatorRule::maximum(layout.width(),
showLabel->rule().width() + showLayout.width()),
Expand Down

0 comments on commit dc4482e

Please sign in to comment.