Skip to content

Commit

Permalink
UI|Task Bar|Refactor: Use VariableToggleWidget for the FPS counter me…
Browse files Browse the repository at this point in the history
…nu item

There is now a proper widget that makes it easier to implement the
FPS toggling (via Config.window.main.showFps).
  • Loading branch information
skyjake committed Aug 10, 2013
1 parent 8b90c8f commit 5b19eed
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 19 deletions.
1 change: 0 additions & 1 deletion doomsday/client/include/ui/widgets/taskbarwidget.h
Expand Up @@ -57,7 +57,6 @@ public slots:
void open(bool doAction = true);
void close();
void openMainMenu();
void toggleFPS();
void confirmUnloadGame();
void unloadGame();

Expand Down
20 changes: 2 additions & 18 deletions doomsday/client/src/ui/widgets/taskbarwidget.cpp
Expand Up @@ -22,6 +22,7 @@
#include "ui/widgets/buttonwidget.h"
#include "ui/widgets/consolecommandwidget.h"
#include "ui/widgets/popupmenuwidget.h"
#include "ui/widgets/variabletogglewidget.h"
#include "ui/widgets/blurwidget.h"
#include "ui/clientwindow.h"
#include "ui/commandaction.h"
Expand All @@ -45,7 +46,6 @@ using namespace ui;
static TimeDelta OPEN_CLOSE_SPAN = 0.2;

DENG2_PIMPL(TaskBarWidget),
DENG2_OBSERVES(Variable, Change),
public IGameChangeObserver
{
typedef DefaultVertexBuf VertexBuf;
Expand All @@ -57,7 +57,6 @@ public IGameChangeObserver
PopupMenuWidget *mainMenu;
PopupMenuWidget *unloadMenu;
ButtonWidget *panelItem;
ButtonWidget *fpsItem;
ButtonWidget *unloadItem;
ScalarRule *vertShift;

Expand Down Expand Up @@ -158,15 +157,8 @@ public IGameChangeObserver
}
}

void variableValueChanged(Variable &, Value const &val)
{
// We are observing the value of the window's showFps variable.
updateMenuItems();
}

void updateMenuItems()
{
fpsItem->setText(ClientWindow::main().isFPSCounterVisible()? tr("Hide FPS") : tr("Show FPS"));
}
};

Expand Down Expand Up @@ -254,7 +246,7 @@ TaskBarWidget::TaskBarWidget() : GuiWidget("taskbar"), d(new Instance(this))
// depending on whether a game is loaded.
d->panelItem = d->mainMenu->addItem(_E(b) + tr("Open Control Panel"), new CommandAction("panel"));
d->mainMenu->addItem(tr("Toggle Fullscreen"), new CommandAction("togglefullscreen"));
d->fpsItem = d->mainMenu->addItem("", new SignalAction(this, SLOT(toggleFPS())));
d->mainMenu->addItem(new VariableToggleWidget(tr("Show FPS"), App::config()["window.main.showFps"]));
d->unloadItem = d->mainMenu->addItem(tr("Unload Game"), new SignalAction(this, SLOT(confirmUnloadGame())), false);
d->mainMenu->addSeparator();
d->mainMenu->addItem(tr("Check for Updates..."), new CommandAction("updateandnotify"));
Expand All @@ -277,9 +269,6 @@ TaskBarWidget::TaskBarWidget() : GuiWidget("taskbar"), d(new Instance(this))
d->unloadItem->hide();
d->updateMenuItems();

// Observe when the showFps variable changes.
App::config()["window.main.showFps"].audienceForChange += d;

d->logo->setAction(new SignalAction(this, SLOT(openMainMenu())));
}

Expand Down Expand Up @@ -504,11 +493,6 @@ void TaskBarWidget::openMainMenu()
d->mainMenu->open();
}

void TaskBarWidget::toggleFPS()
{
root().window().toggleFPSCounter();
}

void TaskBarWidget::confirmUnloadGame()
{
d->unloadMenu->open();
Expand Down

0 comments on commit 5b19eed

Please sign in to comment.