diff options
| author | andreykproductengine <akleshchev@productengine.com> | 2015-08-19 15:43:06 -0400 | 
|---|---|---|
| committer | andreykproductengine <akleshchev@productengine.com> | 2015-08-19 15:43:06 -0400 | 
| commit | 75304b4ca81e3fdb9164ec607997a6c30616d8ca (patch) | |
| tree | 4bee13989d3578a52e25eb867f94af08f2769ae3 | |
| parent | 6a5844d936c3317626cfcbe9d9cb66086d570fca (diff) | |
MAINT-5378 Add notices for avatar complexity changes
| -rwxr-xr-x | indra/newview/CMakeLists.txt | 2 | ||||
| -rw-r--r-- | indra/newview/llavatarrenderinfoaccountant.cpp | 7 | ||||
| -rw-r--r-- | indra/newview/llavatarrendernotifier.cpp | 182 | ||||
| -rw-r--r-- | indra/newview/llavatarrendernotifier.h | 73 | ||||
| -rwxr-xr-x | indra/newview/llnotificationtiphandler.cpp | 16 | ||||
| -rwxr-xr-x | indra/newview/llvoavatar.cpp | 25 | ||||
| -rwxr-xr-x | indra/newview/skins/default/xui/en/notifications.xml | 24 | 
7 files changed, 310 insertions, 19 deletions
| diff --git a/indra/newview/CMakeLists.txt b/indra/newview/CMakeLists.txt index b5a6912da0..73b60a8ffe 100755 --- a/indra/newview/CMakeLists.txt +++ b/indra/newview/CMakeLists.txt @@ -133,6 +133,7 @@ set(viewer_SOURCE_FILES      llavatarlist.cpp      llavatarlistitem.cpp      llavatarrenderinfoaccountant.cpp +    llavatarrendernotifier.cpp      llavatarpropertiesprocessor.cpp      llblockedlistitem.cpp      llblocklist.cpp @@ -755,6 +756,7 @@ set(viewer_HEADER_FILES      llavatarlistitem.h      llavatarpropertiesprocessor.h      llavatarrenderinfoaccountant.h +    llavatarrendernotifier.h      llblockedlistitem.h      llblocklist.h      llbox.h diff --git a/indra/newview/llavatarrenderinfoaccountant.cpp b/indra/newview/llavatarrenderinfoaccountant.cpp index b8ec1e150b..595a5f0224 100644 --- a/indra/newview/llavatarrenderinfoaccountant.cpp +++ b/indra/newview/llavatarrenderinfoaccountant.cpp @@ -38,6 +38,7 @@  #include "httpresponse.h"  #include "llcorehttputil.h"  #include "llappcorehttp.h" +#include "llavatarrendernotifier.h"  #include "lltimer.h"  #include "llviewercontrol.h"  #include "llviewermenu.h" @@ -102,7 +103,7 @@ public:  	void onCompleted(LLCore::HttpHandle handle,  					 LLCore::HttpResponse* response) -		{ +	{              LLCore::HttpStatus status = response->getStatus();              if (status)              { @@ -120,8 +121,8 @@ public:                              U32 overlimit = avatar_render_info[KEY_OVER_COMPLEXITY_LIMIT].asInteger();                              LL_DEBUGS("AvatarRenderInfo") << "complexity limit: "<<reporting<<" reporting, "<<overlimit<<" over limit"<<LL_ENDL; -                            //@TODO - at this point, pass reporting and overlimit to something -                            //        that remembers them and when they change displays a message + +							LLAvatarRenderNotifier::getInstance()->updateNotificationRegion(reporting, overlimit);                          }  						if (avatar_render_info.has(KEY_AGENTS)) diff --git a/indra/newview/llavatarrendernotifier.cpp b/indra/newview/llavatarrendernotifier.cpp new file mode 100644 index 0000000000..c7fdf4cce4 --- /dev/null +++ b/indra/newview/llavatarrendernotifier.cpp @@ -0,0 +1,182 @@ +/** + * @file   llavatarrendernotifier.cpp + * @author andreykproductengine + * @date   2015-08-05 + * @brief   + *  + * $LicenseInfo:firstyear=2013&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2013, Linden Research, Inc. + *  + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + *  + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU + * Lesser General Public License for more details. + *  + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA + *  + * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA + * $/LicenseInfo$ + */ + +// Pre-compiled headers +#include "llviewerprecompiledheaders.h" +// STL headers +// std headers +// external library headers +// other Linden headers +#include "llagentwearables.h" +#include "llnotifications.h" +#include "llnotificationsutil.h" +#include "llnotificationtemplate.h" +#include "lltimer.h" +#include "llviewercontrol.h" +// associated header +#include "llavatarrendernotifier.h" + +// when change exceeds this ration, notification is shown +static const F32 RENDER_ALLOWED_CHANGE_PCT = 0.1; + + +LLAvatarRenderNotifier::LLAvatarRenderNotifier() : +mAgentsCount(0), +mOverLimitAgents(0), +mAgentComplexity(0), +mOverLimitPct(0.0f), +mLatestAgentsCount(0), +mLatestOverLimitAgents(0), +mLatestAgentComplexity(0), +mLatestOverLimitPct(0.0f), +mShowOverLimitAgents(false) +{ +} + +void LLAvatarRenderNotifier::displayNotification() +{ +	static LLCachedControl<U32> expire_delay(gSavedSettings, "ShowMyComplexityChanges", 20); + +	LLDate expire_date(LLDate::now().secondsSinceEpoch() + expire_delay); +	LLSD args; +	args["AGENT_COMPLEXITY"] = LLSD::Integer(mLatestAgentComplexity); +	std::string notification_name; +	if (mShowOverLimitAgents) +	{ +		notification_name = "RegionAndAgentComplexity"; +		args["OVERLIMIT_PCT"] = LLSD::Integer(mLatestOverLimitPct); +	} +	else +	{ +		notification_name = "AgentComplexity"; +	} + +	if (mNotificationPtr != NULL && mNotificationPtr->getName() != notification_name) +	{ +		// since unique tag works only for same notification, +		// old notification needs to be canceled manually +		LLNotifications::instance().cancel(mNotificationPtr); +	} + +	mNotificationPtr = LLNotifications::instance().add(LLNotification::Params() +		.name(notification_name) +		.expiry(expire_date) +		.substitutions(args)); +} + +bool LLAvatarRenderNotifier::isNotificationVisible() +{ +	return mNotificationPtr != NULL && mNotificationPtr->isActive(); +} + +void LLAvatarRenderNotifier::updateNotification() +{ +	if (mAgentsCount == mLatestAgentsCount +		&& mOverLimitAgents == mLatestOverLimitAgents +		&& mAgentComplexity == mLatestAgentComplexity) +	{ +		//no changes since last notification +		return; +	} + +	if (mLatestAgentComplexity == 0 +		|| !gAgentWearables.areWearablesLoaded()) +	{ +		// data not ready, nothing to show. +		return; +	} + +	bool display_notification = false; +	bool is_visible = isNotificationVisible(); + +	if (mLatestOverLimitPct > 0 || mOverLimitPct > 0) +	{ +		//include 'over limit' information into notification +		mShowOverLimitAgents = true; +	} +	else +	{ +		// make sure that 'over limit' won't be displayed only to be hidden in a second +		mShowOverLimitAgents &= is_visible; +	} + +	if (mAgentComplexity != mLatestAgentComplexity) +	{ +		// if we have an agent complexity update, we always display it  +		display_notification = true; + +		// next 'over limit' update should be displayed as soon as possible if there is anything noteworthy +		mPopUpDelayTimer.resetWithExpiry(0); +	} +	else if ((mPopUpDelayTimer.hasExpired() || is_visible) +		&& (mOverLimitPct > 0 || mLatestOverLimitPct > 0) +		&& abs(mOverLimitPct - mLatestOverLimitPct) > mLatestOverLimitPct * RENDER_ALLOWED_CHANGE_PCT) +	{ +		// display in case of drop to/from zero and in case of significant (RENDER_ALLOWED_CHANGE_PCT) changes +		display_notification = true; + +		// default timeout before next notification +		static LLCachedControl<U32> pop_up_delay(gSavedSettings, "ComplexityChangesPopUpDelay", 300); +		mPopUpDelayTimer.resetWithExpiry(pop_up_delay); +	} + +	if (display_notification) +	{ +		mAgentComplexity = mLatestAgentComplexity; +		mAgentsCount = mLatestAgentsCount; +		mOverLimitAgents = mLatestOverLimitAgents; +		mOverLimitPct = mLatestOverLimitPct; + +		displayNotification(); +	} +} + +void LLAvatarRenderNotifier::updateNotificationRegion(U32 agentcount, U32 overLimit) +{ +	if (agentcount == 0) +	{ +		// Data not ready +		return; +	} + +	// save current values for later use +	mLatestAgentsCount = agentcount > overLimit ? agentcount - 1 : agentcount; // subtract self +	mLatestOverLimitAgents = overLimit; +	mLatestOverLimitPct = mLatestAgentsCount != 0 ? ((F32)overLimit / (F32)mLatestAgentsCount) * 100.0 : 0; + +	updateNotification(); +} + +void LLAvatarRenderNotifier::updateNotificationAgent(U32 agentComplexity) +{ +	// save the value for use in following messages +	mLatestAgentComplexity = agentComplexity; + +	updateNotification(); +} + diff --git a/indra/newview/llavatarrendernotifier.h b/indra/newview/llavatarrendernotifier.h new file mode 100644 index 0000000000..264c616543 --- /dev/null +++ b/indra/newview/llavatarrendernotifier.h @@ -0,0 +1,73 @@ +/** + * @file   llavatarrendernotifier.h + * @author andreykproductengine + * @date   2015-08-05 + * @brief   + *  + * $LicenseInfo:firstyear=2013&license=viewerlgpl$ + * Second Life Viewer Source Code + * Copyright (C) 2013, Linden Research, Inc. + *  + * This library is free software; you can redistribute it and/or + * modify it under the terms of the GNU Lesser General Public + * License as published by the Free Software Foundation; + * version 2.1 of the License only. + *  + * This library is distributed in the hope that it will be useful, + * but WITHOUT ANY WARRANTY; without even the implied warranty of + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU + * Lesser General Public License for more details. + *  + * You should have received a copy of the GNU Lesser General Public + * License along with this library; if not, write to the Free Software + * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA + *  + * Linden Research, Inc., 945 Battery Street, San Francisco, CA  94111  USA + * $/LicenseInfo$ + */ + +#if ! defined(LL_llavatarrendernotifier_H) +#define LL_llavatarrendernotifier_H + +#include "llnotificationptr.h" + +class LLViewerRegion; + +// Class to notify user about drastic changes in agent's render weights or if other agents +// reported that user's agent is too 'heavy' for their settings +class LLAvatarRenderNotifier : public LLSingleton<LLAvatarRenderNotifier> +{ +public: +	LLAvatarRenderNotifier(); + +	void displayNotification(); +	bool isNotificationVisible(); + +	void updateNotification(); +	void updateNotificationRegion(U32 agentcount, U32 overLimit); +	void updateNotificationAgent(U32 agentComplexity); + +private: + +	LLNotificationPtr mNotificationPtr; + +	// to prevent notification from popping up too often, show it only +	// if certain amount of time passed since previous notification +	LLFrameTimer mPopUpDelayTimer; + +	// values since last notification for comparison purposes +	U32 mAgentsCount; +	U32 mOverLimitAgents; +	U32 mAgentComplexity; +	F32 mOverLimitPct; + +	// last reported values +	U32 mLatestAgentsCount; +	U32 mLatestOverLimitAgents; +	U32 mLatestAgentComplexity; +	F32 mLatestOverLimitPct; + +	bool mShowOverLimitAgents; +}; + +#endif /* ! defined(LL_llavatarrendernotifier_H) */ diff --git a/indra/newview/llnotificationtiphandler.cpp b/indra/newview/llnotificationtiphandler.cpp index 4ca961c1f9..596327e8f1 100755 --- a/indra/newview/llnotificationtiphandler.cpp +++ b/indra/newview/llnotificationtiphandler.cpp @@ -113,11 +113,23 @@ bool LLTipHandler::processNotification(const LLNotificationPtr& notification)  	LLToast::Params p;  	p.notif_id = notification->getID();  	p.notification = notification; -	p.lifetime_secs = gSavedSettings.getS32("NotificationTipToastLifeTime");  	p.panel = notify_box;  	p.is_tip = true;  	p.can_be_stored = false; -		 + +	LLDate cur_time = LLDate::now(); +	LLDate exp_time = notification->getExpiration(); +	if (exp_time > cur_time) +	{ +		// we have non-default expiration time - keep visible until expires +		p.lifetime_secs = exp_time.secondsSinceEpoch() - cur_time.secondsSinceEpoch(); +	} +	else +	{ +		// use default time +		p.lifetime_secs = gSavedSettings.getS32("NotificationTipToastLifeTime"); +	} +  	LLScreenChannel* channel = dynamic_cast<LLScreenChannel*>(mChannel.get());  	if(channel)  		channel->addToast(p); diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index a073ac10b8..86db3689c7 100755 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -43,6 +43,7 @@  #include "llanimationstates.h"  #include "llavatarnamecache.h"  #include "llavatarpropertiesprocessor.h" +#include "llavatarrendernotifier.h"  #include "llexperiencecache.h"  #include "llphysicsmotion.h"  #include "llviewercontrol.h" @@ -8285,20 +8286,9 @@ void LLVOAvatar::idleUpdateRenderComplexity()  void LLVOAvatar::updateVisualComplexity()  { -    LL_DEBUGS("AvatarRender") << "avatar " << getID() << " appearance changed" << LL_ENDL; -    // Set the cache time to in the past so it's updated ASAP -    mVisualComplexityStale = true; -    LLCachedControl<U32> show_my_complexity_changes(gSavedSettings, "ShowMyComplexityChanges", 5); - -    if ( isSelf() && show_my_complexity_changes ) -    { -        // @TODO  -        LL_INFOS("AvatarRender") << "popup that displays my complexity (" << mVisualComplexity << ")" -                                 << " for " << show_my_complexity_changes << " seconds" -                                 << LL_ENDL; -    } - -         +	LL_DEBUGS("AvatarRender") << "avatar " << getID() << " appearance changed" << LL_ENDL; +	// Set the cache time to in the past so it's updated ASAP +	mVisualComplexityStale = true;  }  // Calculations for mVisualComplexity value @@ -8430,6 +8420,13 @@ void LLVOAvatar::calculateUpdateRenderComplexity()          }  		mVisualComplexity = cost;  		mVisualComplexityStale = false; + +		LLCachedControl<U32> show_my_complexity_changes(gSavedSettings, "ShowMyComplexityChanges", 20); + +		if (isSelf() && show_my_complexity_changes) +		{ +			LLAvatarRenderNotifier::getInstance()->updateNotificationAgent(mVisualComplexity); +		}  	}  } diff --git a/indra/newview/skins/default/xui/en/notifications.xml b/indra/newview/skins/default/xui/en/notifications.xml index d0ccf2e2d8..97c4c924e7 100755 --- a/indra/newview/skins/default/xui/en/notifications.xml +++ b/indra/newview/skins/default/xui/en/notifications.xml @@ -3294,6 +3294,30 @@ You can use [SECOND_LIFE] normally and other people will see you correctly.    </notification>    <notification +   icon = "notifytip.tga" +   name = "RegionAndAgentComplexity" +   type = "notifytip" +   log_to_chat = "false"> +   <unique combine = "cancel_old"> +     <context>AgentComplexityNotice</context> +   </unique> +   Your visual complexity is [AGENT_COMPLEXITY]. +[OVERLIMIT_PCT]% of nearby users may not fully show you +with complexity this high. +  </notification> + +  <notification +   icon = "notifytip.tga" +   name = "AgentComplexity" +   type = "notifytip" +   log_to_chat = "false"> +   <unique combine = "cancel_old"> +     <context>AgentComplexityNotice</context> +   </unique> +Your visual complexity is [AGENT_COMPLEXITY]. +  </notification> + +  <notification     icon="alertmodal.tga"     name="FirstRun"     type="alertmodal"> | 
