예제 #1
0
	void execute (CCtrlBase * /* pCaller */, const std::string &sParams)
	{
		// Param
		ucstring text = CI18N::get ("uiTalkMemMsg"+sParams);

		// Find the base group
		if (!text.empty())
		{
			ChatMngr.setChatMode (CChatGroup::say);
			ChatMngr.chat(text);
		}
	}
예제 #2
0
	void execute (CCtrlBase * /* pCaller */, const std::string &sParams)
	{
		// Param
		uint mode;
		fromString(getParam (sParams, "mode"), mode);
		ucstring text;
		text.fromUtf8 (getParam (sParams, "text"));
//		text = getParam (sParams, "text");

		// Parse any tokens in the text
		if ( ! CInterfaceManager::parseTokens(text))
		{
			return;
		}

		// Find the base group
		if ((mode<CChatGroup::nbChatMode) && !text.empty())
		{
			if(text[0] == '/')
			{
				string str = text.toUtf8();
				string cmdWithArgs = str.substr(1);

				// Get the command name from the string, can contain spaces
				string cmd = cmdWithArgs.substr(0, cmdWithArgs.find(' '));
				if (cmdWithArgs.find('"') == 0)
				{
					string::size_type pos = cmdWithArgs.find('"', 1);
					if (string::npos != pos)
					{
						cmd = cmdWithArgs.substr(1, pos - 1);
					}
				}

				if ( NLMISC::ICommand::exists( cmd ) )
				{
					NLMISC::ICommand::execute( cmdWithArgs, g_log );
				} 
				else
				{
					CInterfaceManager *im = CInterfaceManager::getInstance();
					im->displaySystemInfo (ucstring(cmd+": ")+CI18N::get ("uiCommandNotExists"));
				}
			}
			else
			{
				ChatMngr.setChatMode((CChatGroup::TGroupType)mode);
				ChatMngr.chat(text, mode == CChatGroup::team);
			}
		}
	}
	void actionPart ()
	{
		// If the line starts with '/tell ', do not try to expand
		static const ucstring TELL_STR("/tell ");
		if (_GroupEdit->getInputString().substr(0, TELL_STR.length()) != TELL_STR)
		{
			if (_GroupEdit->expand()) return;
		}
		CInterfaceManager *im = CInterfaceManager::getInstance();
		if (!im->isInGame()) return;
		// there was no / at the start of the line so try to cycle through the last people on which a tell was done
		const ucstring *lastTellPeople = ChatMngr.cycleLastTell();
		if (!lastTellPeople) return;
		// Get chat box from ist edit box
		// If it isn't a user chat or the main chat, just display 'tell' with the name. Otherwise, change the target of the window
		CChatWindow *cw = getChatWndMgr().getChatWindowFromCaller(_GroupEdit);
		if (!cw) return;
		CFilteredChat *fc = PeopleInterraction.getFilteredChatFromChatWindow(cw);
		if (fc)
		{
			fc->Filter.setTargetPlayer(*lastTellPeople);
		}
		else
		{
			// it is not a filtered chat, display 'tell' (must be ingame)
			_GroupEdit->setCommand(ucstring("tell ") + *lastTellPeople + (ucchar) ' ', false);
		}
	}
예제 #4
0
	void execute (CCtrlBase * /* pCaller */, const std::string &sParams)
	{
		// Param
		uint mode;
		fromString(getParam (sParams, "mode"), mode);

		ChatMngr.updateChatModeAndButton(mode);
	}
예제 #5
0
//=============================================================================================================
void CChatTargetFilter::msgEntered(const ucstring &msg, CChatWindow *chatWindow)
{
	// Special case for yubo chat
	if(_TargetGroup==CChatGroup::yubo_chat)
	{
		CInterfaceManager	*pIM= CInterfaceManager::getInstance();
		pIM->sendStringToYuboChat(msg);
		return;
	}

	// Common Target case
	if (ClientCfg.Local)
	{
		chatWindow->displayMessage(msg, CRGBA::White, _TargetGroup, _TargetDynamicChannelDbIndex);
		return;
	}

	// forward to the target
	if (_TargetPartyChat && _TargetPartyChat->getListener())
	{
		_TargetPartyChat->getListener()->msgEntered(msg, chatWindow);
	}
	else if (!_TargetPlayer.empty())
	{
		// the target must be a player, make a tell on him
		// TODO: adapt this to unicode when this is OK on server side
		ChatMngr.tell(_TargetPlayer.toString(), msg.toString());
		// direct output in the chat
		chatWindow->displayLocalPlayerTell(msg);
	}
	else
	{
		 // chat to a chat group (say, shout, universe) also for team (with special case in setChatMode)
		 // this mode is cached so this should be ok
		ChatMngr.setChatMode(_TargetGroup, ChatMngr.getDynamicChannelIdFromDbIndex(_TargetDynamicChannelDbIndex));
		// send the string
		ChatMngr.chat(msg, _TargetGroup == CChatGroup::team);
	}
}
예제 #6
0
	void execute (CCtrlBase *pCaller, const std::string &sParams)
	{
		string receiver = getParam (sParams, "player");
		ucstring message;
		message.fromUtf8(getParam (sParams, "text"));
//		message = getParam (sParams, "text");
		if (receiver.empty() || message.empty())
			return;

		// Get the chat window (if any)
		CChatWindow *cw = NULL;
		CGroupEditBox *eb = pCaller?dynamic_cast<CGroupEditBox *>(pCaller):NULL;
		if (eb)
			cw = getChatWndMgr().getChatWindowFromCaller(eb);

		// Send the message.
		ChatMngr.tell(receiver, message);

		// display in the good window
		CInterfaceProperty prop;
		prop.readRGBA("UI:SAVE:CHAT:COLORS:SPEAKER"," ");
		ucstring finalMsg;
		CChatWindow::encodeColorTag(prop.getRGBA(), finalMsg, false);

		ucstring csr(CHARACTER_TITLE::isCsrTitle(UserEntity->getTitleRaw()) ? "(CSR) " : "");
		finalMsg += csr + CI18N::get("youTell") + ": ";
		prop.readRGBA("UI:SAVE:CHAT:COLORS:TELL"," ");
		CChatWindow::encodeColorTag(prop.getRGBA(), finalMsg, true);
		finalMsg += message;
		// display msg with good color
//		TDataSetIndex dsi; // not used ....
		PeopleInterraction.ChatInput.Tell.displayTellMessage(/*dsi, */finalMsg, receiver, prop.getRGBA());

		ucstring s = CI18N::get("youTellPlayer");
		strFindReplace(s, "%name", receiver);
		strFindReplace(finalMsg, CI18N::get("youTell"), s);
		CInterfaceManager::getInstance()->log(finalMsg);
	}
예제 #7
0
// ***************************************************************************
void	CClientChatManager::processChatString( NLMISC::CBitMemStream& bms, IChatDisplayer &chatDisplayer)
{
	// before displaying anything, must ensure dynamic channels are up to date
	// NB: only processChatString() have to do this. Other methods cannot be in dyn_chat mode
	updateDynamicChatChannels(chatDisplayer);

	// serial
	CChatMsg chatMsg;
	bms.serial( chatMsg );
	CChatGroup::TGroupType	type = static_cast<CChatGroup::TGroupType>(chatMsg.ChatMode);
	ucstring	senderStr;

	bool complete = true;
	complete &= STRING_MANAGER::CStringManagerClient::instance()->getString(chatMsg.SenderNameId, senderStr);

	if (type == CChatGroup::dyn_chat)
	{
		// retrieve the DBIndex from the dynamic chat id
		sint32 dbIndex = ChatMngr.getDynamicChannelDbIndexFromId(chatMsg.DynChatChanID);
		// if the client database is not yet up to date, put the chat message in buffer
		if (dbIndex < 0)
			complete = false;
	}

	// if !complete, wait
	if (!complete)
	{
		_ChatBuffer.push_back(CChatMsgNode(chatMsg, false));
		//nldebug("<impulseChat> Received CHAT, put in buffer : waiting association");
		return;
	}

	// display
	ucstring	ucstr;
	buildChatSentence(chatMsg.CompressedIndex, senderStr, chatMsg.Content, type, ucstr);
	chatDisplayer.displayChat(chatMsg.CompressedIndex, ucstr, chatMsg.Content, type, chatMsg.DynChatChanID, senderStr);
}
예제 #8
0
// ***************************************************************************
void CClientChatManager::flushBuffer(IChatDisplayer &chatDisplayer)
{
	// before displaying anything, must ensure dynamic channels are up to date
	updateDynamicChatChannels(chatDisplayer);

	// **** Process waiting messages
	{
		list<CChatMsgNode>::iterator itMsg;
		for( itMsg = _ChatBuffer.begin(); itMsg != _ChatBuffer.end(); )
		{
			CChatGroup::TGroupType	type = static_cast<CChatGroup::TGroupType>(itMsg->ChatMode);
			ucstring sender, content;

			// all strings received?
			bool complete = true;
			if (itMsg->SenderNameId != 0)
				complete &= STRING_MANAGER::CStringManagerClient::instance()->getString(itMsg->SenderNameId, sender);
			if(itMsg->UsePhraseId)
				complete &= STRING_MANAGER::CStringManagerClient::instance()->getDynString(itMsg->PhraseId, content);
			else
				content= itMsg->Content;

			if (type == CChatGroup::dyn_chat)
			{
				// retrieve the DBIndex from the dynamic chat id
				sint32 dbIndex = ChatMngr.getDynamicChannelDbIndexFromId(itMsg->DynChatChanID);
				// if the client database is not yet up to date, leave the chat message in buffer
				if (dbIndex < 0)
					complete = false;
			}

			// if complete, process
			if (complete)
			{
				ucstring ucstr;
				if (itMsg->SenderNameId == 0)
				{
					ucstr = content;
				}
				else
				{
					if(itMsg->DisplayAsTell)
						buildTellSentence(sender, content, ucstr);
					else
						buildChatSentence(itMsg->CompressedIndex, sender, content, type, ucstr);
				}

				// display
				if(itMsg->DisplayAsTell)
					chatDisplayer.displayTell(/*itMsg->CompressedIndex, */ucstr, sender);
				else
					chatDisplayer.displayChat(itMsg->CompressedIndex, ucstr, content, type, itMsg->DynChatChanID, sender);

				list<CChatMsgNode>::iterator itTmp = itMsg++;
				_ChatBuffer.erase( itTmp );
			}
			else
			{
				++itMsg;
			}
		}
	}
} // flushBuffer //
예제 #9
0
//-----------------------------------------------
//	updateChatModeAndButton
//
//-----------------------------------------------
void CClientChatManager::updateChatModeAndButton(uint mode, uint32 dynamicChannelDbIndex)
{
	// Check if USER chat is active
	bool userActive = false;
	CChatGroupWindow *pCGW = PeopleInterraction.getChatGroupWindow();
	if (pCGW)
	{
		CInterfaceGroup* pIG = pCGW->getContainer()->getGroup("content:cb:user");
		if (pIG)
		userActive = pIG->getActive();
	}

	CChatGroup::TGroupType m = (CChatGroup::TGroupType)mode;

	if (userActive)
	{
		// Change the button of the user chat to the corresponding chat target
		if (pCGW)
		{
			CCtrlTextButton *pUserBut = dynamic_cast<CCtrlTextButton*>(pCGW->getContainer()->getCtrl("content:but_user"));
			CCtrlTextButton *pEmoteBut = dynamic_cast<CCtrlTextButton*>(pCGW->getContainer()->getCtrl("content:but_emote"));
			CInterfaceGroup *pEditBox = dynamic_cast<CInterfaceGroup*>(pCGW->getContainer()->getGroup("content:ebw"));

			CInterfaceManager *pIM = CInterfaceManager::getInstance();
			const bool teamActive = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GROUP:0:PRESENT")->getValueBool();
			const bool guildActive = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:NAME")->getValueBool();

			if (m == CChatGroup::team && ! teamActive)
				m = PeopleInterraction.TheUserChat.Filter.getTargetGroup();

			if (m == CChatGroup::guild && ! guildActive)
				m = PeopleInterraction.TheUserChat.Filter.getTargetGroup();

			if (pUserBut)
			{
				switch(m)
				{
					default:
					case CChatGroup::arround:
					case CChatGroup::say:		pUserBut->setHardText("uiFilterAround");	break;
					case CChatGroup::region:	pUserBut->setHardText("uiFilterRegion");	break;
					case CChatGroup::universe:	pUserBut->setHardText("uiFilterUniverse");	break;
					case CChatGroup::team:		if (teamActive) pUserBut->setHardText("uiFilterTeam");		break;
					case CChatGroup::guild:		if (guildActive) pUserBut->setHardText("uiFilterGuild");	break;
					case CChatGroup::dyn_chat:
						uint32 textId = ChatMngr.getDynamicChannelNameFromDbIndex(dynamicChannelDbIndex);
						ucstring title;
						STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title);
						if (title.empty())
						{
							// Dyn channel does not exist, don't change
							m = PeopleInterraction.TheUserChat.Filter.getTargetGroup();
							dynamicChannelDbIndex = PeopleInterraction.TheUserChat.Filter.getTargetDynamicChannelDbIndex();
						}
						else
						{
							pUserBut->setHardText(title.toUtf8());
						}
						break;
					// NB: user chat cannot have yubo_chat target
				}

				pUserBut->setActive(true);
				pUserBut->getParent()->updateCoords();
				pUserBut->updateCoords();
			}

			if (pEmoteBut)
			{
				pEmoteBut->setActive(true);
				pEmoteBut->updateCoords();
			}

			if (pEditBox && pUserBut && pEmoteBut)
			{
				pEditBox->setW(-pUserBut->getWReal()-pEmoteBut->getWReal()-8);
				pEditBox->setX(pUserBut->getWReal()+4);
			}

			PeopleInterraction.TheUserChat.Filter.setTargetGroup(m, dynamicChannelDbIndex);
			PeopleInterraction.ChatGroup.Filter.setTargetGroup(m, dynamicChannelDbIndex);
		}
	}
}