From 78f813052db1607c45a203527f733bc00cd4caf5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= Date: Wed, 5 Feb 2014 16:14:48 +0200 Subject: [PATCH] UI|Client: Game selection menu behaves differently when game loaded Order groups differently and use different titles. --- .../src/ui/widgets/gameselectionwidget.cpp | 32 +++++++++++++++---- 1 file changed, 26 insertions(+), 6 deletions(-) diff --git a/doomsday/client/src/ui/widgets/gameselectionwidget.cpp b/doomsday/client/src/ui/widgets/gameselectionwidget.cpp index 209511f6b1..c1f2dac8b5 100644 --- a/doomsday/client/src/ui/widgets/gameselectionwidget.cpp +++ b/doomsday/client/src/ui/widgets/gameselectionwidget.cpp @@ -128,16 +128,27 @@ DENG_GUI_PIMPL(GameSelectionWidget) return menu->itemWidget(item); } + String textForTitle(bool whenOpen) const + { + if(whenOpen) return titleText; + return QString("%1 (%2)").arg(titleText).arg(menu->items().size()); + } + void preparePanelForOpening() { FoldPanelWidget::preparePanelForOpening(); - title().setText(titleText); + title().setText(textForTitle(true)); } void panelClosing() { FoldPanelWidget::panelClosing(); - title().setText(QString("%1 (%2)").arg(titleText).arg(menu->items().size())); + title().setText(textForTitle(false)); + } + + void updateTitleText() + { + title().setText(textForTitle(isOpen())); } }; @@ -154,7 +165,7 @@ DENG_GUI_PIMPL(GameSelectionWidget) { // Menu of available games. self.add(available = new Subset(Subset::NormalGames, - tr("Available Games"), this)); + App_GameLoaded()? tr("Switch Game") : tr("Available Games"), this)); // Menu of incomplete games. self.add(incomplete = new Subset(Subset::NormalGames, @@ -166,8 +177,6 @@ DENG_GUI_PIMPL(GameSelectionWidget) superLayout.setOverrideWidth(self.rule().width() - self.margins().width()); - available->title().margins().setTop(""); - updateSubsetLayout(); App_Games().audienceForAddition += this; @@ -189,12 +198,23 @@ DENG_GUI_PIMPL(GameSelectionWidget) superLayout.clear(); QList order; - order << available << multi << incomplete; + if(!App_GameLoaded()) + { + order << available << multi << incomplete; + } + else + { + order << multi << available << incomplete; + } foreach(Subset *s, order) { + // The first group should not have extra space above it. + s->title().margins().setTop(s == order.first()? "" : "gap"); + if(!s->items().isEmpty()) { + s->updateTitleText(); s->title().show(); superLayout << s->title() << *s; }