Skip to content

Commit

Permalink
UI|Home: Added a Home settings popup and config variables
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Feb 21, 2016
1 parent 5d336d3 commit 42b1a69
Show file tree
Hide file tree
Showing 5 changed files with 61 additions and 10 deletions.
4 changes: 3 additions & 1 deletion doomsday/apps/client/include/ui/home/homewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#ifndef DENG_CLIENT_UI_HOMEWIDGET_H
#define DENG_CLIENT_UI_HOMEWIDGET_H

#include <de/GuiWidget>
#include <de/PopupWidget>

/**
* Root widget for the Home UI.
Expand All @@ -39,6 +39,8 @@ class HomeWidget : public de::GuiWidget
bool dispatchEvent(de::Event const &event,
bool (de::Widget::*memberFunc)(de::Event const &)) override;

static de::PopupWidget *makeSettingsPopup();

public slots:
void tabChanged();
void mouseActivityInColumn(QObject const *);
Expand Down
10 changes: 10 additions & 0 deletions doomsday/apps/client/net.dengine.client.pack/modules/appconfig.de
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,16 @@ def setDefaults(d)
autoHide = 3 * 60
end

# Home.
record d.home
record d.home.columns
d.home.showUnplayableGames = True
d.home.columns.doom = True
d.home.columns.heretic = True
d.home.columns.hexen = True
d.home.columns.otherGames = True
d.home.columns.multiplayer = True

# Input defaults.
record d.input
record d.input.mouse
Expand Down
21 changes: 20 additions & 1 deletion doomsday/apps/client/src/ui/home/gamecolumnwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@

#include <de/ChildWidgetOrganizer>
#include <de/MenuWidget>
#include <de/App>

using namespace de;

DENG_GUI_PIMPL(GameColumnWidget)
, DENG2_OBSERVES(Games, Readiness)
, DENG2_OBSERVES(Variable, Change)
, public ChildWidgetOrganizer::IWidgetFactory
{
// Item for a particular loadable game.
Expand Down Expand Up @@ -69,11 +71,13 @@ DENG_GUI_PIMPL(GameColumnWidget)
style().rules().rule("gap")*2);

DoomsdayApp::games().audienceForReadiness() += this;
App::config("home.showUnplayableGames").audienceForChange() += this;
}

~Instance()
{
DoomsdayApp::games().audienceForReadiness() -= this;
App::config("home.showUnplayableGames").audienceForChange() -= this;
}

ui::Item const *findItem(String const &id) const
Expand Down Expand Up @@ -132,6 +136,12 @@ DENG_GUI_PIMPL(GameColumnWidget)
populateItems();
}

void variableValueChanged(Variable &var, Value const &)
{
qDebug() << var.name() << "changed";
populateItems();
}

//- ChildWidgetOrganizer::IWidgetFactory --------------------------------------

GuiWidget *makeItemWidget(ui::Item const &item, GuiWidget const *)
Expand All @@ -140,10 +150,19 @@ DENG_GUI_PIMPL(GameColumnWidget)
return button;
}

void updateItemWidget(GuiWidget &widget, ui::Item const &/*item*/)
void updateItemWidget(GuiWidget &widget, ui::Item const &item)
{
auto &drawer = widget.as<GamePanelButtonWidget>();
drawer.updateContent();

if(!App::config().getb("home.showUnplayableGames"))
{
drawer.show(item.as<MenuItem>().game.isPlayable());
}
else
{
drawer.show();
}
}
};

Expand Down
20 changes: 18 additions & 2 deletions doomsday/apps/client/src/ui/home/homewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,8 @@
#include <de/LabelWidget>
#include <de/SequentialLayout>
#include <de/TabWidget>
#include <de/PopupMenuWidget>
#include <de/App>

using namespace de;

Expand Down Expand Up @@ -236,9 +238,8 @@ HomeWidget::HomeWidget()
: GuiWidget("home")
, d(new Instance(this))
{
ColumnWidget *column;

// Create the columns.
ColumnWidget *column;

column = new NoGamesColumnWidget();
d->addColumn(column);
Expand Down Expand Up @@ -322,6 +323,21 @@ bool HomeWidget::handleEvent(Event const &event)
return false;
}

PopupWidget *HomeWidget::makeSettingsPopup()
{
PopupMenuWidget *menu = new PopupMenuWidget;
menu->items()
<< new ui::VariableToggleItem(tr("Show Unplayable"), App::config("home.showUnplayableGames"))
<< new ui::Item(ui::Item::Separator)
<< new ui::Item(ui::Item::Separator, tr("Columns"))
<< new ui::VariableToggleItem(tr("Doom"), App::config("home.columns.doom"))
<< new ui::VariableToggleItem(tr("Heretic"), App::config("home.columns.heretic"))
<< new ui::VariableToggleItem(tr("Hexen"), App::config("home.columns.hexen"))
<< new ui::VariableToggleItem(tr("Other Games"), App::config("home.columns.otherGames"))
<< new ui::VariableToggleItem(tr("Multiplayer"), App::config("home.columns.multiplayer"));
return menu;
}

bool HomeWidget::dispatchEvent(Event const &event, bool (Widget::*memberFunc)(const Event &))
{
if(event.type() == Event::MouseWheel)
Expand Down
16 changes: 10 additions & 6 deletions doomsday/apps/client/src/ui/widgets/taskbarwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
#include "ui/widgets/consolecommandwidget.h"
#include "ui/widgets/multiplayermenuwidget.h"
#include "ui/widgets/tutorialwidget.h"
#include "ui/home/homewidget.h"
#include "ui/dialogs/aboutdialog.h"
#include "ui/dialogs/videosettingsdialog.h"
#include "ui/dialogs/audiosettingsdialog.h"
Expand Down Expand Up @@ -73,12 +74,13 @@ enum MenuItemPositions
POS_IWAD_FOLDER = 8,

// Config menu:
POS_RENDERER_SETTINGS = 0,
POS_VR_SETTINGS = 1,
POS_CONFIG_SEPARATOR = 3,
POS_HOME_SETTINGS = 0,
POS_RENDERER_SETTINGS = 1,
POS_VR_SETTINGS = 2,
POS_CONFIG_SEPARATOR = 4,

POS_AUDIO_SETTINGS = 5,
POS_INPUT_SETTINGS = 6
POS_AUDIO_SETTINGS = 6,
POS_INPUT_SETTINGS = 7,
};

DENG_GUI_PIMPL(TaskBarWidget)
Expand Down Expand Up @@ -276,9 +278,10 @@ DENG_GUI_PIMPL(TaskBarWidget)
itemWidget(mainMenu, POS_MULTIPLAYER) .show(!game.isNull());
itemWidget(mainMenu, POS_CONNECT) .show(game.isNull());

itemWidget(configMenu, POS_HOME_SETTINGS) .show(game.isNull());
itemWidget(configMenu, POS_RENDERER_SETTINGS).show(!game.isNull());
itemWidget(configMenu, POS_VR_SETTINGS) .show(!game.isNull());
itemWidget(configMenu, POS_CONFIG_SEPARATOR) .show(!game.isNull());
//itemWidget(configMenu, POS_CONFIG_SEPARATOR) .show(!game.isNull());
itemWidget(configMenu, POS_AUDIO_SETTINGS) .show(!game.isNull());
itemWidget(configMenu, POS_INPUT_SETTINGS) .show(!game.isNull());

Expand Down Expand Up @@ -427,6 +430,7 @@ TaskBarWidget::TaskBarWidget() : GuiWidget("taskbar"), d(new Instance(this))
* depending on whether a game is loaded.
*/
d->configMenu->items()
<< new ui::SubwidgetItem(style().images().image("package"), tr("Home"), ui::Left, HomeWidget::makeSettingsPopup)
<< new ui::SubwidgetItem(style().images().image("renderer"), tr("Renderer"), ui::Left, makePopup<RendererSettingsDialog>)
<< new ui::SubwidgetItem(style().images().image("vr"), tr("3D & VR"), ui::Left, makePopup<VRSettingsDialog>)
<< new ui::SubwidgetItem(style().images().image("package"), tr("Packages"), ui::Left, makePopup<PackagesDialog>)
Expand Down

0 comments on commit 42b1a69

Please sign in to comment.