Exemplo n.º 1
0
// ***************************************************************************
void CClientChatManager::buildTellSentence(const ucstring &sender, const ucstring &msg, ucstring &result)
{
	// If no sender name was provided, show only the msg
	if ( sender.empty() )
		result = msg;
	else
	{
		ucstring name = CEntityCL::removeTitleAndShardFromName(sender);
		ucstring csr;

		// special case where there is only a title, very rare case for some NPC
		if (name.empty())
		{
			// we need the gender to display the correct title
			CCharacterCL *entity = dynamic_cast<CCharacterCL*>(EntitiesMngr.getEntityByName(sender, true, true));
			bool bWoman = entity && entity->getGender() == GSGENDER::female;

			name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender), bWoman);
			{
				// Sometimes translation contains another title
				ucstring::size_type pos = name.find('$');
				if (pos != ucstring::npos)
				{
					name = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(name), bWoman);
				}
			}


		}
		else
		{
			// Does the char have a CSR title?
			csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender)) ? ucstring("(CSR) ") : ucstring("");
		}

		result = csr + name + ucstring(" ") + CI18N::get("tellsYou") + ucstring(": ") + msg;
	}
}
Exemplo n.º 2
0
// ****************************************************************************
ucstring CViewTextFormated::formatString(const ucstring &inputString, const ucstring &paramString)
{
	ucstring formatedResult;
	// Apply the format
	for(ucstring::const_iterator it = inputString.begin(); it != inputString.end();)
	{
		if (*it == '$')
		{
			++it;
			if (it == inputString.end()) break;
			switch(*it)
			{
				case 't': // add text ID
					formatedResult += paramString;
				break;

				case 'P':
				case 'p':  // add player name
					if (ClientCfg.Local)
					{
						formatedResult += ucstring("player");
					}
					else
					{
						if(UserEntity)
						{
							ucstring name = UserEntity->getEntityName();
							if (*it == 'P') setCase(name, CaseUpper);
							formatedResult += name;
						}
					}
				break;
				//
				case 's':
				case 'b': // add bot name
				{
					ucstring botName;
					bool womanTitle = false;
					if (ClientCfg.Local)
					{
						botName = ucstring("NPC");
					}
					else
					{
						CLFECOMMON::TCLEntityId trader = CLFECOMMON::INVALID_SLOT;
						if(UserEntity)
							trader = UserEntity->trader();
						if (trader != CLFECOMMON::INVALID_SLOT)
						{
							CEntityCL *entity = EntitiesMngr.entity(trader);
							if (entity != NULL)
							{
								uint32 nDBid = entity->getNameId();

								if (nDBid != 0)
								{
									CStringManagerClient *pSMC = CStringManagerClient::instance();
									pSMC->getString(nDBid, botName);
								}
								else
								{
									botName = entity->getDisplayName();
								}

								CCharacterCL *pChar = dynamic_cast<CCharacterCL*>(entity);
								if (pChar != NULL)
									womanTitle = pChar->getGender() == GSGENDER::female;
							}
						}
					}

					// get the title translated
					ucstring sTitleTranslated = botName;
					CStringPostProcessRemoveName spprn;
					spprn.Woman = womanTitle;
					spprn.cbIDStringReceived(sTitleTranslated);

					botName = CEntityCL::removeTitleAndShardFromName(botName);

					// short name (with no title such as 'guard', 'merchant' ...)
					if (*it == 's')
					{
						// But if there is no name, display only the title
						if (botName.empty())
							botName = sTitleTranslated;
					}
					else
					{
						// Else we want the title !
						if (!botName.empty())
							botName += " ";
						botName += sTitleTranslated;
					}

					formatedResult += botName;
				}
				break;
				default:
					formatedResult += (ucchar) '$';
				break;
			}
			++it;
		}
		else
		{
			formatedResult += (ucchar) *it;
			++it;
		}
	}

	return formatedResult;
}
Exemplo n.º 3
0
// ***************************************************************************
void CClientChatManager::buildChatSentence(TDataSetIndex /* compressedSenderIndex */, const ucstring &sender, const ucstring &msg, CChatGroup::TGroupType type, ucstring &result)
{
	// if its a tell, then use buildTellSentence
	if(type==CChatGroup::tell)
	{
		buildTellSentence(sender, msg, result);
		return;
	}

	// If no sender name was provided, show only the msg
	if ( sender.empty() )
	{
		result = msg;
		return;
	}

	// get the category if any. Note, in some case (chat from other player), there is not categories
	// and we do not want getStringCategory to return 'SYS' category.
	ucstring finalMsg;
	string catStr = getStringCategory(msg, finalMsg, false);
	ucstring cat;
	if (!catStr.empty())
		cat = string("&")+catStr+"&";

	if ( ! cat.empty())
	{
		result = msg;
		return;
	}

	// Format the sentence with the provided sender name
	ucstring senderName = CEntityCL::removeTitleAndShardFromName(sender);

	ucstring csr;
	// Does the char have a CSR title?
	csr = CHARACTER_TITLE::isCsrTitle(CEntityCL::getTitleFromName(sender)) ? ucstring("(CSR) ") : ucstring("");

	if (UserEntity && senderName == UserEntity->getDisplayName())
	{
		// The player talks
		switch(type)
		{
			case CChatGroup::shout:
				result = cat + csr + CI18N::get("youShout") + ucstring(": ") + finalMsg;
			break;
			default:
				result = cat + csr + CI18N::get("youSay") + ucstring(": ") + finalMsg;
			break;
		}
	}
	else
	{
		// Special case where there is only a title, very rare case for some NPC
		if (senderName.empty())
		{
			CCharacterCL *entity = dynamic_cast<CCharacterCL*>(EntitiesMngr.getEntityByName(sender, true, true));
			// We need the gender to display the correct title
			bool bWoman = entity && entity->getGender() == GSGENDER::female;

			senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(sender), bWoman);
			{
				// Sometimes translation contains another title
				ucstring::size_type pos = senderName.find('$');
				if (pos != ucstring::npos)
				{
					senderName = STRING_MANAGER::CStringManagerClient::getTitleLocalizedName(CEntityCL::getTitleFromName(senderName), bWoman);
				}
			}


		}

		switch(type)
		{
			case CChatGroup::shout:
				result = cat + csr + senderName + ucstring(" ") + CI18N::get("heShout") + ucstring(": ") + finalMsg;
			break;
			default:
				result = cat + csr + senderName + ucstring(" ") + CI18N::get("heSays") + ucstring(": ") + finalMsg;
			break;
		}
	}
}