Skip to content

Commit

Permalink
Client|Task Bar: Improved DE menu
Browse files Browse the repository at this point in the history
Rearranged the items of the DE menu and added a separator.

Now unloading the game plugin is confirmed with a separate popup menu.
  • Loading branch information
skyjake committed Jul 16, 2013
1 parent dedd901 commit 391d02b
Show file tree
Hide file tree
Showing 2 changed files with 32 additions and 3 deletions.
2 changes: 2 additions & 0 deletions doomsday/client/include/ui/widgets/taskbarwidget.h
Expand Up @@ -58,6 +58,8 @@ public slots:
void close();
void openMainMenu();
void toggleFPS();
void confirmUnloadGame();
void unloadGame();

signals:
void opened();
Expand Down
33 changes: 30 additions & 3 deletions doomsday/client/src/ui/widgets/taskbarwidget.cpp
Expand Up @@ -28,6 +28,7 @@
#include "ui/signalaction.h"

#include "ui/ui_main.h"
#include "con_main.h"

#include <de/App>
#include <de/KeyEvent>
Expand All @@ -52,6 +53,7 @@ public IGameChangeObserver
ButtonWidget *logo;
LabelWidget *status;
PopupMenuWidget *mainMenu;
PopupMenuWidget *unloadMenu;
ButtonWidget *panelItem;
ButtonWidget *fpsItem;
ButtonWidget *unloadItem;
Expand Down Expand Up @@ -241,17 +243,31 @@ TaskBarWidget::TaskBarWidget() : GuiWidget("taskbar"), d(new Instance(this))
// Taskbar height depends on the font size.
rule().setInput(Rule::Height, style().fonts().font("default").height() + gap * 2);

// The main DE menu.
// The DE menu.
d->mainMenu = new PopupMenuWidget("de-menu");
d->mainMenu->setAnchor(d->logo->rule().left() + d->logo->rule().width() / 2,
d->logo->rule().top());
d->fpsItem = d->mainMenu->addItem("", new SignalAction(this, SLOT(toggleFPS())));

// Set up items for the DE menu. Some of these are shown/hidden
// depending on whether a game is loaded.
d->panelItem = d->mainMenu->addItem(_E(b) "Open Control Panel", new CommandAction("panel"));
d->fpsItem = d->mainMenu->addItem("", new SignalAction(this, SLOT(toggleFPS())));
d->unloadItem = d->mainMenu->addItem("Unload game", new SignalAction(this, SLOT(confirmUnloadGame())), false);
d->mainMenu->addSeparator();
d->mainMenu->addItem("Check for updates...", new CommandAction("updateandnotify"));
d->unloadItem = d->mainMenu->addItem("Unload game", new CommandAction("unload"));
d->mainMenu->addItem("Quit Doomsday", new CommandAction("quit"));
add(d->mainMenu);

// Confirmation for unloading game.
d->unloadMenu = new PopupMenuWidget("unload-menu");
d->unloadMenu->setOpeningDirection(ui::Left);
d->unloadMenu->setAnchor(d->mainMenu->rule().left(),
d->unloadItem->rule().top() + d->unloadItem->rule().height() / 2);
d->unloadMenu->addSeparator("Really unload the game?");
d->unloadMenu->addItem("Unload "_E(b)"(discard progress)", new SignalAction(this, SLOT(unloadGame())));
d->unloadMenu->addItem("Cancel", new Action);
add(d->unloadMenu);

d->panelItem->hide();
d->unloadItem->hide();
d->updateFpsMenuItem();
Expand Down Expand Up @@ -486,3 +502,14 @@ void TaskBarWidget::toggleFPS()
{
root().window().toggleFPSCounter();
}

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

void TaskBarWidget::unloadGame()
{
Con_Execute(CMDS_DDAY, "unload", false, false);
d->mainMenu->close();
}

0 comments on commit 391d02b

Please sign in to comment.