예제 #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;
	}
}
예제 #2
0
void CIGSeasonCallback::instanceGroupAdded(NL3D::UInstanceGroup *ig)
{
	H_AUTO(RZ_IGSeasonCallback)
	// Set the season texture for all the buildings

	uint8 selectedTextureSet = (uint8) computeCurrSeason();

	const uint numInstances = ig->getNumInstance();
	for(uint k = 0; k < numInstances; k++)
	{
		NL3D::UInstance instance = ig->getInstance (k);
		if (!instance.empty())
			instance.selectTextureSet(selectedTextureSet);  // TODO Nico : instant loading here (async not useful)
	}
	// for all the bot objects, force to rebuild them to update their textures
	for (uint k = 0; k < CLFECOMMON::INVALID_SLOT; ++k)
	{
		CCharacterCL *charCL = dynamic_cast<CCharacterCL *>(EntitiesMngr.entity(k));
		if (charCL && charCL->getSheet())
		{
			std::string sheetName = charCL->getSheet()->Id.toString();
			static const  char *botObjectPrefix = "object_";
			if (NLMISC::nlstricmp(sheetName.substr(0, strlen(botObjectPrefix)), botObjectPrefix) == 0)
			{
				for(uint k = 0; k < charCL->instances().size(); ++k)
				{
					charCL->instances()[k].selectTextureSet(selectedTextureSet, false); // want immediate change here (frozen any way ...)
				}
				if (!charCL->instance().empty())
				{
					charCL->instance().selectTextureSet(selectedTextureSet);
				}
			}
		}
	}
}
예제 #3
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;
}
예제 #4
0
// ------------------------------------------------------------------------------------------------
void CCharacter3D::setAnim (uint animID)
{
	CCharacterCL * character = NULL;

	if(!_CopyAnim)
	{
		_CurrentSetup.AnimPlayed = animID;
		if (_CurrentSetup.Male)
		{
			if (animID >= _AnimMale.size()) return;
			animID = _AnimMale[animID].AnimId;
		}
		else
		{
			if (animID >= _AnimFemale.size()) return;
			animID = _AnimFemale[animID].AnimId;
		}
	}
	else
	{
		CInstance * selectedInst = getEditor().getSelectedInstance();
		if(!selectedInst) return;
		CEntityCL * entity = selectedInst->getEntity();
		if(!(entity && ((character=dynamic_cast<CCharacterCL*>(entity))!=NULL)))
			return;

		animID = character->playList()->getAnimation(MOVE);
		_CurrentSetup.AnimPlayed = animID;
	}


	float animSpeedFactor = 0.9f + 0.2f * NLMISC::frand(1);
	if (_PlayList)
	{
		if(_CopyAnim)
		{
			_PlayList->setTimeOrigin(MOVE, character->playList()->getTimeOrigin(MOVE));
			if(character->playList()->getAnimation(MOVE)!=_PlayList->getAnimation(MOVE))
			{
				_PlayList->setAnimation(MOVE, animID);
				_PlayList->setSpeedFactor(MOVE, character->playList()->getSpeedFactor(MOVE));
				_PlayList->setWrapMode(MOVE, character->playList()->getWrapMode(MOVE));
			}
		}
		else
		{
			_PlayList->setAnimation(MOVE, animID);
			_PlayList->setSpeedFactor(MOVE, animSpeedFactor);
			_PlayList->setTimeOrigin(MOVE, TimeInSec);
			_PlayList->setWrapMode(MOVE, UPlayList::Repeat);
		}
	}

	if (_FacePlayList)
	{
		uint	faceAnimId=UPlayList::empty;
		if(_AnimationSet && animID<_AnimationSet->getNumAnimation())
		{
			// build the anim name of the face
			string	faceAnimName= COptionsAnimationSet::getFaceAnimName(_AnimationSet->getAnimationName(animID));
			// find the face anim for this name
			faceAnimId= _AnimationSet->getAnimationIdByName(faceAnimName);
			if(faceAnimId==UAnimationSet::NotFound)
				faceAnimId= UPlayList::empty;
		}

		_FacePlayList->setAnimation(MOVE, faceAnimId);
		if(faceAnimId!=UPlayList::empty)
		{
			if(_CopyAnim)
			{
				_FacePlayList->setTimeOrigin(MOVE, character->facePlayList()->getTimeOrigin(MOVE));
				_FacePlayList->setSpeedFactor(MOVE, character->facePlayList()->getSpeedFactor(MOVE));
				_FacePlayList->setWrapMode(MOVE, character->facePlayList()->getWrapMode(MOVE));
			}
			else
			{
				_FacePlayList->setSpeedFactor(MOVE, animSpeedFactor);
				_FacePlayList->setTimeOrigin(MOVE, TimeInSec);
				_FacePlayList->setWrapMode(MOVE, UPlayList::Repeat);
			}
		}
	}
}
예제 #5
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;
		}
	}
}