Skip to content

Commit

Permalink
UI|Task Bar: Updated DE menu with game selection items
Browse files Browse the repository at this point in the history
  • Loading branch information
skyjake committed Mar 6, 2014
1 parent c6ff5eb commit 8f46362
Show file tree
Hide file tree
Showing 2 changed files with 39 additions and 31 deletions.
3 changes: 2 additions & 1 deletion doomsday/client/include/ui/widgets/taskbarwidget.h
Expand Up @@ -63,7 +63,8 @@ public slots:
void unloadGame();
void showAbout();
void showUpdaterSettings();
void showGames();
void switchGame();
void showMultiplayer();
void connectToServerManually();

protected slots:
Expand Down
67 changes: 37 additions & 30 deletions doomsday/client/src/ui/widgets/taskbarwidget.cpp
Expand Up @@ -63,8 +63,8 @@ enum MenuItemPositions
POS_GAMES = 0,
POS_UNLOAD = 1,
POS_GAMES_SEPARATOR = 2,
POS_CONNECT = 3,
POS_CONNECT_SEPARATOR = 4,
POS_MULTIPLAYER = 3,
POS_CONNECT = 4,

// Config menu:
POS_RENDERER_SETTINGS = 0,
Expand Down Expand Up @@ -258,24 +258,33 @@ DENG_GUI_PIMPL(TaskBarWidget)
return *menu->menu().organizer().itemWidget(pos);
}

void currentGameChanged(game::Game const &newGame)
void showOrHideMenuItems()
{
updateStatus();
de::Game &game = App_CurrentGame();

itemWidget(mainMenu, POS_GAMES) .show(!newGame.isNull());
itemWidget(mainMenu, POS_UNLOAD) .show(!newGame.isNull());
itemWidget(mainMenu, POS_GAMES_SEPARATOR) .show(!newGame.isNull());
//itemWidget(mainMenu, POS_CONNECT) .show(!newGame.isNull());
//itemWidget(mainMenu, POS_CONNECT_SEPARATOR).show(!newGame.isNull());
itemWidget(mainMenu, POS_GAMES) .show(!game.isNull());
itemWidget(mainMenu, POS_UNLOAD) .show(!game.isNull());
itemWidget(mainMenu, POS_GAMES_SEPARATOR) .show(!game.isNull());
itemWidget(mainMenu, POS_MULTIPLAYER) .show(!game.isNull());
itemWidget(mainMenu, POS_CONNECT) .show(game.isNull());

itemWidget(configMenu, POS_RENDERER_SETTINGS).show(!newGame.isNull());
itemWidget(configMenu, POS_VR_SETTINGS) .show(!newGame.isNull());
itemWidget(configMenu, POS_CONFIG_SEPARATOR) .show(!newGame.isNull());
itemWidget(configMenu, POS_AUDIO_SETTINGS) .show(!newGame.isNull());
itemWidget(configMenu, POS_INPUT_SETTINGS) .show(!newGame.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_AUDIO_SETTINGS) .show(!game.isNull());
itemWidget(configMenu, POS_INPUT_SETTINGS) .show(!game.isNull());

configMenu->menu().updateLayout();
mainMenu->menu().updateLayout(); // Include/exclude shown/hidden menu items.
if(self.hasRoot())
{
configMenu->menu().updateLayout();
mainMenu->menu().updateLayout(); // Include/exclude shown/hidden menu items.
}
}

void currentGameChanged(game::Game const &newGame)
{
updateStatus();
showOrHideMenuItems();
}

void networkGameJoined()
Expand Down Expand Up @@ -412,27 +421,18 @@ TaskBarWidget::TaskBarWidget() : GuiWidget("taskbar"), d(new Instance(this))
<< new ui::SubwidgetItem(style().images().image("updater"), tr("Updater"), ui::Left, makeUpdaterSettings);

d->mainMenu->items()
<< new ui::ActionItem(tr("Games..."), new SignalAction(this, SLOT(showGames())))
<< new ui::ActionItem(tr("Switch Game..."), new SignalAction(this, SLOT(switchGame())))
<< unloadMenu // hidden with null-game
<< new ui::Item(ui::Item::Separator)
<< new ui::ActionItem(tr("Multiplayer Games..."), new SignalAction(this, SLOT(showMultiplayer())))
<< new ui::ActionItem(tr("Connect to Server..."), new SignalAction(this, SLOT(connectToServerManually())))
<< new ui::Item(ui::Item::Separator)
<< new ui::ActionItem(tr("Check for Updates..."), new CommandAction("updateandnotify"))
<< new ui::ActionItem(tr("About Doomsday"), new SignalAction(this, SLOT(showAbout())))
<< new ui::Item(ui::Item::Separator)
<< new ui::ActionItem(tr("Quit Doomsday"), new CommandAction("quit"));

d->itemWidget(d->mainMenu, POS_GAMES).hide();
d->itemWidget(d->mainMenu, POS_UNLOAD).hide();
d->itemWidget(d->mainMenu, POS_GAMES_SEPARATOR).hide();
//d->itemWidget(d->mainMenu, POS_CONNECT).hide();
//d->itemWidget(d->mainMenu, POS_CONNECT_SEPARATOR).hide();

d->itemWidget(d->configMenu, POS_RENDERER_SETTINGS).hide();
d->itemWidget(d->configMenu, POS_VR_SETTINGS).hide();
d->itemWidget(d->configMenu, POS_CONFIG_SEPARATOR).hide();
d->itemWidget(d->configMenu, POS_AUDIO_SETTINGS).hide();
d->itemWidget(d->configMenu, POS_INPUT_SETTINGS).hide();
d->showOrHideMenuItems();

conf->setAction(new SignalAction(this, SLOT(openConfigMenu())));
d->logo->setAction(new SignalAction(this, SLOT(openMainMenu())));
Expand Down Expand Up @@ -709,9 +709,16 @@ void TaskBarWidget::showUpdaterSettings()
dlg->open();
}

void TaskBarWidget::showGames()
void TaskBarWidget::switchGame()
{
GamesDialog *games = new GamesDialog(GamesDialog::ShowSingleplayerOnly);
games->setDeleteAfterDismissed(true);
games->exec(root());
}

void TaskBarWidget::showMultiplayer()
{
GamesDialog *games = new GamesDialog;
GamesDialog *games = new GamesDialog(GamesDialog::ShowMultiplayerOnly);
games->setDeleteAfterDismissed(true);
games->exec(root());
}
Expand Down

0 comments on commit 8f46362

Please sign in to comment.