From 8314920310fa11d5974d733da6817176f7cc9b93 Mon Sep 17 00:00:00 2001 From: Jacek Antonelli Date: Thu, 29 Jul 2010 04:13:45 -0500 Subject: Don't spam user with ConfirmLightShare notifications. Now only one notification is created, but the class remembers the most recent settings and discards the old ones. --- linden/indra/newview/lightshare.cpp | 33 +++++++++++++++++++++++++-------- linden/indra/newview/lightshare.h | 5 +++-- 2 files changed, 28 insertions(+), 10 deletions(-) (limited to 'linden') diff --git a/linden/indra/newview/lightshare.cpp b/linden/indra/newview/lightshare.cpp index aa5443b..c9f34ee 100644 --- a/linden/indra/newview/lightshare.cpp +++ b/linden/indra/newview/lightshare.cpp @@ -45,6 +45,8 @@ const std::string WindlightMessage::sWaterPresetName = "(Region settings)"; const std::string WindlightMessage::sSkyPresetName = "(Region settings)"; +WindlightMessage* WindlightMessage::sMostRecent = NULL; + WindlightMessage::WindlightMessage( LLMessageSystem* msg ) : mPacket(NULL), @@ -116,10 +118,23 @@ void WindlightMessage::processWindlight(LLMessageSystem* msg, void**) } else { - LLNotifications::instance() - .add("ConfirmLightShare", - LLSD(), LLSD(), - boost::bind(&applyCallback, _1, _2, wl)); + if( sMostRecent == NULL ) + { + // No most recent, so store this and create notification + // asking the user whether to apply or not. + sMostRecent = wl; + LLNotifications::instance() + .add("ConfirmLightShare", + LLSD(), LLSD(), + boost::bind(&applyCallback, _1, _2)); + } + else + { + // No new notification (to avoid spamming the user), just + // store this as most recent. + delete sMostRecent; + sMostRecent = wl; + } } } } @@ -127,15 +142,17 @@ void WindlightMessage::processWindlight(LLMessageSystem* msg, void**) // static bool WindlightMessage::applyCallback(const LLSD& notification, - const LLSD& response, - WindlightMessage* wl) + const LLSD& response) { S32 option = LLNotification::getSelectedOption(notification, response); if( option == 0 ) { - wl->apply(); + sMostRecent->apply(); } - delete wl; + + delete sMostRecent; + sMostRecent = NULL; + return false; } diff --git a/linden/indra/newview/lightshare.h b/linden/indra/newview/lightshare.h index 2bf95c6..cbc03ad 100644 --- a/linden/indra/newview/lightshare.h +++ b/linden/indra/newview/lightshare.h @@ -49,14 +49,15 @@ class WindlightMessage ~WindlightMessage(); static void processWindlight(LLMessageSystem* msg, void**); static bool applyCallback(const LLSD& notification, - const LLSD& response, - WindlightMessage* wl); + const LLSD& response); bool apply(); bool isValid(); private: + static WindlightMessage* sMostRecent; + Meta7WindlightPacket* mPacket; LLWaterParamSet* mWater; LLWLParamSet* mSky; -- cgit v1.1