void LLScriptFloaterManager::onAddNotification(const LLUUID& notification_id)
{
	if(notification_id.isNull())
	{
		llwarns << "Invalid notification ID" << llendl;
		return;
	}

	// get scripted Object's ID
	LLUUID object_id = notification_id_to_object_id(notification_id);
	
	// Need to indicate of "new message" for object chiclets according to requirements
	// specified in the Message Bar design specification. See EXT-3142.
	bool set_new_message = false;
	EObjectType obj_type = getObjectType(notification_id);

	// LLDialog can spawn only one instance, LLLoadURL and LLGiveInventory can spawn unlimited number of instances
	if(OBJ_SCRIPT == obj_type)
	{
//		// If an Object spawns more-than-one floater, only the newest one is shown. 
//		// The previous is automatically closed.
//		script_notification_map_t::const_iterator it = findUsingObjectId(object_id);
// [SL:KB] - Patch: UI-ScriptDialog | Checked: 2011-01-17 (Catznip-2.4.0h) | Added: Catznip-2.4.0h
		script_notification_map_t::const_iterator it = mNotifications.end();
		switch (gSavedSettings.getS32("ScriptDialogPerObject"))
		{
			case 0:			// One script dialog per object (viewer 2 default)
				{
					// If an Object spawns more-than-one floater, only the newest one is shown.
					// The previous is automatically closed.
					it = findUsingObjectId(object_id);
				}
				break;
			case 1:			// One script dialog per reply channel per object
				{
					// We'll allow an object to have more than one script dialog floater open, but we'll limit it to one per chat channel
					// (in practice a lot of objects open a new listen channel for each new dialog but it still reduces chiclets somewhat)
					LLNotificationPtr newNotif = LLNotifications::instance().find(notification_id);
					if (newNotif)
					{
						S32 nNewChannel = newNotif->getPayload()["chat_channel"].asInteger();
						for (it = mNotifications.begin(); it != mNotifications.end(); ++it)
						{
							if (it->second == object_id)
							{
								LLNotificationPtr curNotif = LLNotifications::instance().find(it->first);
								if (curNotif)
								{
									S32 nCurChannel = curNotif->getPayload()["chat_channel"].asInteger();
									if (nNewChannel == nCurChannel)
										break;
								}
							}
						}
					}
				}
				break;
			case 2:			// Unconstrained
			default:
				break;
		}
// [/SL:KB]

		if(it != mNotifications.end())
		{
			LLIMChiclet* chiclet = LLChicletBar::getInstance()->getChicletPanel()->findChiclet<LLIMChiclet>(it->first);
			if(chiclet)
			{
				// Pass the new_message icon state further.
				set_new_message = chiclet->getShowNewMessagesIcon();
			}

			LLScriptFloater* floater = LLFloaterReg::findTypedInstance<LLScriptFloater>("script_floater", it->first);
			if(floater)
			{
				// Generate chiclet with a "new message" indicator if a docked window was opened but not in focus. See EXT-3142.
				set_new_message |= !floater->hasFocus();
			}

			removeNotification(it->first);
		}
	}

	mNotifications.insert(std::make_pair(notification_id, object_id));

	// Create inventory offer chiclet for offer type notifications
	if( OBJ_GIVE_INVENTORY == obj_type )
	{
		LLChicletBar::instance().getChicletPanel()->createChiclet<LLInvOfferChiclet>(notification_id);
	}
	else
	{
		LLChicletBar::getInstance()->getChicletPanel()->createChiclet<LLScriptChiclet>(notification_id);
	}

	LLIMWellWindow::getInstance()->addObjectRow(notification_id, set_new_message);

	LLSD data;
	data["notification_id"] = notification_id;
	data["new_message"] = set_new_message;
	data["unread"] = 1; // each object has got only one floater
	mNewObjectSignal(data);

	toggleScriptFloater(notification_id, set_new_message);
}
Beispiel #2
0
void LLScriptFloaterManager::onAddNotification(const LLUUID& notification_id)
{
    if(notification_id.isNull())
    {
        llwarns << "Invalid notification ID" << llendl;
        return;
    }

    // get scripted Object's ID
    LLUUID object_id = notification_id_to_object_id(notification_id);

    // Need to indicate of "new message" for object chiclets according to requirements
    // specified in the Message Bar design specification. See EXT-3142.
    bool set_new_message = false;
    EObjectType obj_type = getObjectType(notification_id);

    // LLDialog can spawn only one instance, LLLoadURL and LLGiveInventory can spawn unlimited number of instances
    if(OBJ_SCRIPT == obj_type)
    {
        // If an Object spawns more-than-one floater, only the newest one is shown.
        // The previous is automatically closed.
        script_notification_map_t::const_iterator it = findUsingObjectId(object_id);
        if(it != mNotifications.end())
        {
            LLIMChiclet* chiclet = LLBottomTray::getInstance()->getChicletPanel()->findChiclet<LLIMChiclet>(it->first);
            if(chiclet)
            {
                // Pass the new_message icon state further.
                set_new_message = chiclet->getShowNewMessagesIcon();
            }

            LLScriptFloater* floater = LLFloaterReg::findTypedInstance<LLScriptFloater>("script_floater", it->first);
            if(floater)
            {
                // Generate chiclet with a "new message" indicator if a docked window was opened but not in focus. See EXT-3142.
                set_new_message |= !floater->hasFocus();
            }

            removeNotification(it->first);
        }
    }

    mNotifications.insert(std::make_pair(notification_id, object_id));

    // Create inventory offer chiclet for offer type notifications
    if( OBJ_GIVE_INVENTORY == obj_type )
    {
        LLBottomTray::instance().getChicletPanel()->createChiclet<LLInvOfferChiclet>(notification_id);
    }
    else
    {
        LLBottomTray::getInstance()->getChicletPanel()->createChiclet<LLScriptChiclet>(notification_id);
    }

    LLIMWellWindow::getInstance()->addObjectRow(notification_id, set_new_message);

    LLSD data;
    data["notification_id"] = notification_id;
    data["new_message"] = set_new_message;
    data["unread"] = 1; // each object has got only one floater
    mNewObjectSignal(data);

    toggleScriptFloater(notification_id, set_new_message);
}