// **************************************************************************** ucstring CViewTextFormated::formatString(const ucstring &inputString, const ucstring ¶mString) { 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; }