From f11e80cd60f0bed976a27ae667b72df4a90748f2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jaakko=20Ker=C3=A4nen?= Date: Sun, 13 Apr 2014 18:13:16 +0300 Subject: [PATCH] Fixed|UI|Ring Zero: Keep MP sessions menu up to date --- .../src/ui/widgets/mpsessionmenuwidget.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/doomsday/client/src/ui/widgets/mpsessionmenuwidget.cpp b/doomsday/client/src/ui/widgets/mpsessionmenuwidget.cpp index eaa9d598e7..567fd658ac 100644 --- a/doomsday/client/src/ui/widgets/mpsessionmenuwidget.cpp +++ b/doomsday/client/src/ui/widgets/mpsessionmenuwidget.cpp @@ -33,6 +33,7 @@ using namespace de; DENG_GUI_PIMPL(MPSessionMenuWidget) +, DENG2_OBSERVES(App, GameChange) , DENG2_OBSERVES(ServerLink, DiscoveryUpdate) { static ServerLink &link() { return ClientApp::serverLink(); } @@ -154,6 +155,7 @@ DENG_GUI_PIMPL(MPSessionMenuWidget) } }; + DiscoveryMode mode; ServerLink::FoundMask mask; Instance(Public *i) @@ -161,11 +163,13 @@ DENG_GUI_PIMPL(MPSessionMenuWidget) , mask(ServerLink::Any) { link().audienceForDiscoveryUpdate += this; + App::app().audienceForGameChange() += this; } ~Instance() { link().audienceForDiscoveryUpdate -= this; + App::app().audienceForGameChange() -= this; } void linkDiscoveryUpdate(ServerLink const &link) @@ -210,11 +214,23 @@ DENG_GUI_PIMPL(MPSessionMenuWidget) emit self.availabilityChanged(); } } + + void currentGameChanged(game::Game const &newGame) + { + if(newGame.isNull() && mode == DiscoverUsingMaster) + { + // If the session menu exists across game changes, it's good to + // keep it up to date. + link().discoverUsingMaster(); + } + } }; MPSessionMenuWidget::MPSessionMenuWidget(DiscoveryMode discovery) : SessionMenuWidget("mp-session-menu"), d(new Instance(this)) { + d->mode = discovery; + switch(discovery) { case DiscoverUsingMaster: