void FSNearbyChat::sendChat(LLWString text, EChatType type)
{
	LLWStringUtil::trim(text);

	if (!text.empty())
	{
		if (type == CHAT_TYPE_OOC)
		{
			std::string tempText = wstring_to_utf8str( text );
			tempText = gSavedSettings.getString("FSOOCPrefix") + " " + tempText + " " + gSavedSettings.getString("FSOOCPostfix");
			text = utf8str_to_wstring(tempText);
		}

		// Check if this is destined for another channel
		S32 channel = 0;
		bool is_set = false;
		stripChannelNumber(text, &channel, &sLastSpecialChatChannel, &is_set);
		// If "/<number>" is not specified, see if a channel has been set in
		//  the spinner.
		if (!is_set &&
			gSavedSettings.getBOOL("FSNearbyChatbar") &&
			gSavedSettings.getBOOL("FSShowChatChannel"))
		{
			channel = (S32)(FSFloaterNearbyChat::getInstance()->getChild<LLSpinCtrl>("ChatChannel")->get());
		}
		
		std::string utf8text = wstring_to_utf8str(text);
		// Try to trigger a gesture, if not chat to a script.
		std::string utf8_revised_text;
		if (0 == channel)
		{
			// Convert OOC and MU* style poses
			utf8text = applyAutoCloseOoc(utf8text);
			utf8text = applyMuPose(utf8text);

			// discard returned "found" boolean
			if(!LLGestureMgr::instance().triggerAndReviseString(utf8text, &utf8_revised_text))
			{
				utf8_revised_text = utf8text;
			}
		}
		else
		{
			utf8_revised_text = utf8text;
		}

		utf8_revised_text = utf8str_trim(utf8_revised_text);

		EChatType nType;
		if (type == CHAT_TYPE_OOC)
		{
			nType = CHAT_TYPE_NORMAL;
		}
		else
		{
			nType = type;
		}

		type = processChatTypeTriggers(nType, utf8_revised_text);

		if (!utf8_revised_text.empty() && cmd_line_chat(utf8_revised_text, type))
		{
			// Chat with animation
			sendChatFromViewer(utf8_revised_text, type, gSavedSettings.getBOOL("PlayChatAnim"));
		}
	}

	gAgent.stopTyping();
}
Exemplo n.º 2
0
void FSFloaterNearbyChat::sendChat( EChatType type )
{
	if (mInputEditor)
	{
		LLWString text = mInputEditor->getWText();
		LLWStringUtil::trim(text);
		LLWStringUtil::replaceChar(text,182,'\n'); // Convert paragraph symbols back into newlines.
		if (!text.empty())
		{
			if(type == CHAT_TYPE_OOC)
			{
				std::string tempText = wstring_to_utf8str( text );
				tempText = gSavedSettings.getString("FSOOCPrefix") + " " + tempText + " " + gSavedSettings.getString("FSOOCPostfix");
				text = utf8str_to_wstring(tempText);
			}
			
			// Check if this is destined for another channel
			S32 channel = 0;
			stripChannelNumber(text, &channel);
			// If "/<number>" is not specified, see if a channel has been set in
			//  the spinner.
			if (gSavedSettings.getBOOL("FSNearbyChatbar") &&
				gSavedSettings.getBOOL("FSShowChatChannel") &&
				(channel == 0))
			{
				channel = (S32)(FSFloaterNearbyChat::getInstance()->getChild<LLSpinCtrl>("ChatChannel")->get());
			}
			
			std::string utf8text = wstring_to_utf8str(text);
			// Try to trigger a gesture, if not chat to a script.
			std::string utf8_revised_text;
			if (0 == channel)
			{
				// Convert OOC and MU* style poses
				utf8text = applyAutoCloseOoc(utf8text);
				utf8text = applyMuPose(utf8text);
				
				// discard returned "found" boolean
				LLGestureMgr::instance().triggerAndReviseString(utf8text, &utf8_revised_text);
			}
			else
			{
				utf8_revised_text = utf8text;
			}
			
			utf8_revised_text = utf8str_trim(utf8_revised_text);
			
			EChatType nType;
			if(type == CHAT_TYPE_OOC)
				nType = CHAT_TYPE_NORMAL;
			else
				nType = type;
			
			type = processChatTypeTriggers(nType, utf8_revised_text);
			
			if (!utf8_revised_text.empty() && cmd_line_chat(utf8_revised_text, type))
			{
				// Chat with animation
				sendChatFromViewer(utf8_revised_text, type, gSavedSettings.getBOOL("PlayChatAnim"));
			}
		}
		
		mInputEditor->setText(LLStringExplicit(""));
	}
	
	gAgent.stopTyping();
	
	// If the user wants to stop chatting on hitting return, lose focus
	// and go out of chat mode.
	if (gSavedSettings.getBOOL("CloseChatOnReturn") && gSavedSettings.getBOOL("FSUnfocusChatHistoryOnReturn"))
	{
		stopChat();
	}
}