示例#1
0
void LLPanelNearByMedia::updateListItem(LLScrollListItem* item, LLViewerMediaImpl* impl)
{
	std::string item_name;
	std::string item_tooltip;		
	std::string debug_str;
	LLPanelNearByMedia::MediaClass media_class = MEDIA_CLASS_ALL;
	
	getNameAndUrlHelper(impl, item_name, item_tooltip, mEmptyNameString);
	// Focused
	if (impl->hasFocus())
	{
		media_class = MEDIA_CLASS_FOCUSED;
	}
	// Is attached to another avatar?
	else if (impl->isAttachedToAnotherAvatar())
	{
		media_class = MEDIA_CLASS_ON_OTHERS;
	}
	// Outside agent parcel
	else if (!impl->isInAgentParcel())
	{
		media_class = MEDIA_CLASS_OUTSIDE_PARCEL;
	}
	else {
		// inside parcel
		media_class = MEDIA_CLASS_WITHIN_PARCEL;
	}
	
	if(mDebugInfoVisible)
	{
		debug_str += llformat("%g/", (float)impl->getInterest());
		
		// proximity distance is actually distance squared -- display it as straight distance.
		debug_str += llformat("%g/", (F32) sqrt(impl->getProximityDistance()));
		
		//			s += llformat("%g/", (float)impl->getCPUUsage());
		//			s += llformat("%g/", (float)impl->getApproximateTextureInterest());
		debug_str += llformat("%g/", (float)(NULL == impl->getSomeObject()) ? 0.0 : impl->getSomeObject()->getPixelArea());
		
		debug_str += LLPluginClassMedia::priorityToString(impl->getPriority());
		
		if(impl->hasMedia())
		{
			debug_str += '@';
		}
		else if(impl->isPlayable())
		{
			debug_str += '+';
		}
		else if(impl->isForcedUnloaded())
		{
			debug_str += '!';
		}
	}
	
	updateListItem(item,
				   item_name,
				   item_tooltip,
				   impl->getProximity(),
				   impl->isMediaDisabled(),
				   impl->hasMedia(),
				   impl->isMediaTimeBased() &&	impl->isMediaPlaying(),
				   media_class,
				   debug_str);
}
void LLPanelNearByMedia::refreshParcelItems()
{
	//
	// First add/remove the "fake" items Parcel Media and Parcel Audio.
	// These items will have special UUIDs 
	//    PARCEL_MEDIA_LIST_ITEM_UUID
	//    PARCEL_AUDIO_LIST_ITEM_UUID
	//
	// Get the filter choice.
	const LLSD &choice_llsd = mShowCtrl->getSelectedValue();
	MediaClass choice = (MediaClass)choice_llsd.asInteger();
	// Only show "special parcel items" if "All" or "Within" filter
	// (and if media is "enabled")
	bool should_include = (choice == MEDIA_CLASS_ALL || choice == MEDIA_CLASS_WITHIN_PARCEL);
	
	// First Parcel Media: add or remove it as necessary
	if (gSavedSettings.getBOOL("AudioStreamingMedia") &&should_include && LLViewerMedia::hasParcelMedia())
	{
		// Yes, there is parcel media.
		if (NULL == mParcelMediaItem)
		{
			mParcelMediaItem = addListItem(PARCEL_MEDIA_LIST_ITEM_UUID);
			mMediaList->setNeedsSort(true);
		}
	}
	else {
		if (NULL != mParcelMediaItem) {
			removeListItem(PARCEL_MEDIA_LIST_ITEM_UUID);
			mParcelMediaItem = NULL;
			mMediaList->setNeedsSort(true);	
		}
	}
	
	// ... then update it
	if (NULL != mParcelMediaItem)
	{
		std::string name, url, tooltip;
		if (!LLViewerParcelMgr::getInstance()->getAgentParcel()->getObscureMedia())
		{
			getNameAndUrlHelper(LLViewerParcelMedia::getParcelMedia(), name, url, "");
			if (name.empty() || name == url)
			{
				tooltip = url;
			}
			else {
				tooltip = name + " : " + url;
			}
		}
		LLViewerMediaImpl *impl = LLViewerParcelMedia::getParcelMedia();
		updateListItem(mParcelMediaItem,
					   mParcelMediaName,
					   tooltip,
					   -2, // Proximity closer than anything else, before Parcel Audio
					   impl == NULL || impl->isMediaDisabled(),
					   impl != NULL && !LLViewerParcelMedia::getURL().empty(),
					   impl != NULL && impl->isMediaTimeBased() &&	impl->isMediaPlaying(),
					   MEDIA_CLASS_ALL,
					   "parcel media");
	}
	
	// Next Parcel Audio: add or remove it as necessary (don't show if disabled in prefs)
	if (should_include && LLViewerMedia::hasParcelAudio() && gSavedSettings.getBOOL("AudioStreamingMusic"))
	{
		// Yes, there is parcel audio.
		if (NULL == mParcelAudioItem)
		{
			mParcelAudioItem = addListItem(PARCEL_AUDIO_LIST_ITEM_UUID);
			mMediaList->setNeedsSort(true);
		}
	}
	else {
		if (NULL != mParcelAudioItem) {
			removeListItem(PARCEL_AUDIO_LIST_ITEM_UUID);
			mParcelAudioItem = NULL;
			mMediaList->setNeedsSort(true);
		}
	}
	
	// ... then update it
	if (NULL != mParcelAudioItem)
	{
		bool is_playing = LLViewerMedia::isParcelAudioPlaying();
	
		std::string url;
		if (!LLViewerParcelMgr::getInstance()->getAgentParcel()->getObscureMusic())
		{
			url = LLViewerMedia::getParcelAudioURL();
		}
		updateListItem(mParcelAudioItem,
					   mParcelAudioName,
					   url,
					   -1, // Proximity after Parcel Media, but closer than anything else
					   (!is_playing),
					   is_playing,
					   is_playing,
					   MEDIA_CLASS_ALL,
					   "parcel audio");
	}
}