本文整理汇总了C++中ogre::UTFString::size方法的典型用法代码示例。如果您正苦于以下问题:C++ UTFString::size方法的具体用法?C++ UTFString::size怎么用?C++ UTFString::size使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ogre::UTFString
的用法示例。
在下文中一共展示了UTFString::size方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: getOnlyText
// возвращает текст без тегов
Ogre::UTFString TextIterator::getOnlyText(const Ogre::UTFString& _text)
{
Ogre::UTFString ret;
ret.reserve(_text.size());
Ogre::UTFString::const_iterator end = _text.end();
for (Ogre::UTFString::const_iterator iter=_text.begin(); iter!=end; ++iter) {
if ((*iter) == L'#') {
// следующий символ
++ iter;
if (iter == end) break;
// тэг цвета
if ((*iter) != L'#') {
// остальные 5 символов цвета
for (size_t pos=0; pos<5; pos++) {
++ iter;
if (iter == end) {
--iter;
break;
}
}
continue;
}
}
// обыкновенный символ
ret.push_back(*iter);
}
return ret;
}
示例2: SendPrivateChat
void SendPrivateChat(int target_uid, Ogre::UTFString chatline, Ogre::UTFString target_username)
{
#ifdef USE_SOCKETW
char buffer[MAX_MESSAGE_LENGTH] = {0};
const char *chat_msg = (const char *)chatline.asUTF8_c_str();
// format: int of UID, then chat message
memcpy(buffer, &target_uid, sizeof(int));
strncpy(buffer + sizeof(int), chat_msg, MAX_MESSAGE_LENGTH - sizeof(int));
size_t len = sizeof(int) + chatline.size() * sizeof(wchar_t);
buffer[len] = 0;
RoR::Networking::AddPacket(m_stream_id, MSG2_UTF_PRIVCHAT, (unsigned int)len, buffer);
if (target_username.empty())
{
user_info_t user;
if (RoR::Networking::GetUserInfo(target_uid, user))
{
target_username = GetColouredName(user.username, user.colournum);
}
}
// add local visual
Ogre::UTFString local_username = GetColouredName(RoR::Networking::GetUsername(), RoR::Networking::GetUserColor());
Ogre::UTFString nmsg = local_username + RoR::Color::WhisperColour + _L(" [whispered to ") + RoR::Color::NormalColour + target_username + RoR::Color::WhisperColour + "]" + RoR::Color::NormalColour + ": " + chatline;
#ifdef USE_MYGUI
RoR::Application::GetGuiManager()->pushMessageChatBox(nmsg);
#endif // USE_MYGUI
#endif // USE_SOCKETW
}
示例3: sendPrivateChat
void ChatSystem::sendPrivateChat(int target_uid, Ogre::UTFString chatline, Ogre::UTFString username)
{
#ifdef USE_SOCKETW
char buffer[MAX_MESSAGE_LENGTH] = "";
const char *chat_msg = (const char *)chatline.asUTF8_c_str();
// format: int of UID, then chat message
memcpy(buffer, &target_uid, sizeof(int));
strncpy(buffer + sizeof(int), chat_msg, MAX_MESSAGE_LENGTH - sizeof(int));
size_t len = sizeof(int) + chatline.size() * sizeof(wchar_t);
buffer[len] = 0;
this->addPacket(MSG2_UTF_PRIVCHAT, (unsigned int)len, buffer);
if(username.empty())
{
client_t *c = net->getClientInfo(target_uid);
if(c) username = getColouredName(*c);
}
// add local visual
#ifdef USE_MYGUI
UTFString nmsg = net->getNickname(true) + normalColour + whisperColour + _L(" [whispered to ") + normalColour + username + whisperColour + "]" + normalColour + ": " + chatline;
Console::getInstance().putMessage(Console::CONSOLE_MSGTYPE_NETWORK, Console::CONSOLE_LOCAL_CHAT, nmsg, "script_key.png");
#endif // USE_MYGUI
#endif // USE_SOCKETW
}
示例4: GetColouredName
Ogre::UTFString GetColouredName(Ogre::UTFString nick, int colour_number)
{
Ogre::ColourValue col_val = PlayerColours::getSingleton().getColour(colour_number);
char tmp[255] = {0};
sprintf(tmp, "#%02X%02X%02X", (unsigned int)(col_val.r * 255.0f), (unsigned int)(col_val.g * 255.0f), (unsigned int)(col_val.b * 255.0f));
// replace # with X in nickname so the user cannot fake the colour
for (unsigned int i=0; i<nick.size(); i++)
if (nick[i] == '#') nick[i] = 'X';
return tryConvertUTF(tmp) + nick;
}
示例5: setTagColour
bool TextIterator::setTagColour(Ogre::UTFString _colour)
{
if (mCurrent == mEnd) return false;
// очищаем все цвета
clearTagColour();
// на всякий
if (mCurrent == mEnd) return false;
// проверяем на цвет хоть чуть чуть
if ( (_colour.size() != 7) || (_colour.find(L'#', 1) != _colour.npos) ) return false;
// непосредственная вставка
insert(mCurrent, _colour);
return true;
}
示例6: GetColouredName
Ogre::UTFString GetColouredName(Ogre::UTFString nick, int colour_number)
{
#ifdef USE_SOCKETW
Ogre::ColourValue col_val = Networking::GetPlayerColor(colour_number);
char tmp[255] = {0};
sprintf(tmp, "#%02X%02X%02X", (unsigned int)(col_val.r * 255.0f), (unsigned int)(col_val.g * 255.0f), (unsigned int)(col_val.b * 255.0f));
// replace # with X in nickname so the user cannot fake the colour
for (unsigned int i = 0; i < nick.size(); i++)
if (nick[i] == '#')
nick[i] = 'X';
return tryConvertUTF(tmp) + nick;
#else // USE_SOCKETW
return nick;
#endif // USE_SOCKETW
}
示例7: getColouredName
Ogre::UTFString ChatSystem::getColouredName(Ogre::UTFString nick, int auth, int colourNumber)
{
Ogre::ColourValue col_val = PlayerColours::getSingleton().getColour(colourNumber);
char tmp[255] = "";
sprintf(tmp, "#%02X%02X%02X", (unsigned int)(col_val.r * 255.0f), (unsigned int)(col_val.g * 255.0f), (unsigned int)(col_val.b * 255.0f));
// replace # with X in nickname so the user cannot fake the colour
for(unsigned int i=0; i<nick.size(); i++)
if(nick[i] == '#') nick[i] = 'X';
return tryConvertUTF(tmp) + nick;
#if 0
// old code: colour not depending on auth status anymore ...
if(auth == AUTH_NONE) col = "#c9c9c9"; // grey
if(auth & AUTH_BOT ) col = "#0000c9"; // blue
if(auth & AUTH_RANKED) col = "#00c900"; // green
if(auth & AUTH_MOD) col = "#c90000"; // red
if(auth & AUTH_ADMIN) col = "#c97100"; // orange
return col + nick;
#endif //0
}
示例8: ConvertToQString
//----------------------------------------------------------------------------------------
QString ConvertToQString(Ogre::UTFString& value)
{
QByteArray encodedString((const char*)value.data(), value.size() * 2);
QTextCodec *codec = QTextCodec::codecForName("UTF-16");
return codec->toUnicode(encodedString);
}