本文整理汇总了C++中ogre::UTFString类的典型用法代码示例。如果您正苦于以下问题:C++ UTFString类的具体用法?C++ UTFString怎么用?C++ UTFString使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了UTFString类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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
}
示例2: 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
}
示例3: trimUTFString
void trimUTFString( Ogre::UTFString &str, bool left, bool right)
{
static const String delims = " \t\r";
if(right)
str.erase(str.find_last_not_of(delims)+1); // trim right
if(left)
str.erase(0, str.find_first_not_of(delims)); // trim left
}
示例4: isLocked
bool GameRootLinux::isLocked()
{
Ogre::UTFString homeDir = this->getHomeDirectory();
// check if the folder exists otherwise create it
if (opendir(homeDir.asUTF8_c_str()) == nullptr)
{
if (mkdir(homeDir.asUTF8_c_str(), S_IRWXU|S_IRGRP|S_IXGRP) != 0)
{
OGRE_EXCEPT(Ogre::Exception::ERR_INVALID_STATE, "Can not create folder in home directory", "GameRootLinux::isLocked");
}
}
homeDir = homeDir+Ogre::UTFString("/pid");
std::fstream runfile;
char* buf;
int len, pid;
runfile.open(homeDir.asUTF8_c_str(), std::fstream::in | std::fstream::out | std::fstream::app);
// No file, game not running
if (!runfile.is_open())
return false;
runfile.seekg (0, std::ios::end);
len = runfile.tellg();
runfile.seekg (0, std::ios::beg);
if (len > 20)
{
// should only store a number
runfile.close();
return true;
}
buf = OGRE_NEW char[len];
runfile.read(buf,len);
runfile.close();
pid = atoi(buf);
OGRE_DELETE buf;
buf = 0;
if (pid < 1)
return false;
Ogre::String proc = "/proc/"+Ogre::StringConverter::toString(pid)+"/status";
runfile.open(proc.c_str(), std::fstream::in);
// No file, game not running
if (!runfile.is_open())
return false;
runfile.close();
return true;
}
示例5: getHomeDirectory
Ogre::UTFString GameRootLinux::getHomeDirectory()
{
Ogre::UTFString homeDir;
homeDir = Ogre::UTFString(getenv("HOME"));
if (homeDir.empty())
{
struct passwd *pw = getpwuid(getuid());
homeDir = Ogre::UTFString(pw->pw_dir);
}
return homeDir + Ogre::UTFString("/.hardwar");
}
示例6: clearNewLine
void TextIterator::clearNewLine(Ogre::UTFString & _text)
{
for (Ogre::UTFString::iterator iter=_text.begin(); iter!=_text.end(); ++iter) {
if ( ((*iter) == Font::FONT_CODE_NEL) ||
((*iter) == Font::FONT_CODE_CR) ||
((*iter) == Font::FONT_CODE_LF) )
{
(*iter) = Font::FONT_CODE_SPACE;
}
}
}
示例7: toUTF
/*
* @brief Converts a string into a Ogre UTF string. This is necessary if you need to handle non ascii characters (like accents: ó á and such).
* @note Source: http://www.ogre3d.org/forums/viewtopic.php?t=32814&highlight=utfstring
* @param str String to convert
* @return the converted to UTF string
*/
Ogre::UTFString toUTF( const std::string& str)
{
Ogre::UTFString UTFString;
int i;
Ogre::UTFString::code_point cp;
for (i=0; i<(int)str.size(); ++i)
{
cp = str[i];
cp &= 0xFF;
UTFString.append(1, cp);
}
return UTFString;
}
示例8: setLocked
void GameRootLinux::setLocked(const bool& locked)
{
Ogre::UTFString homeDir = this->getHomeDirectory() + Ogre::UTFString("/pid");
std::fstream runfile;
std::string buf;
remove(homeDir.asUTF8_c_str());
if (locked)
{
buf = Ogre::String(Ogre::StringConverter::toString(getpid()));
runfile.open(homeDir.asUTF8_c_str(), std::fstream::in | std::fstream::out | std::fstream::app);
runfile.write(buf.c_str(),buf.size());
runfile.close();
}
}
示例9: 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;
}
示例10: SelectObject
bool EditorFrameHandler::SelectObject(Ogre::UTFString name)
{
MyGUI::Gui *gui = GUISystem::GetInstance()->GetGui();
if (ObjectDescription)
{
//ObjectDescription->Hide();
//gui->destroyWidget(ObjectDescription.get());
ObjectDescription->Destroy();
}
if (SelectedObjectName == name || name.empty())
{
delete ObjectDescription;
ObjectDescription = NULL;
return false;
}
std::map<Ogre::UTFString, SEditableDescription>::iterator iRes = EditorNodes.find(name);
assert(EditorNodes.end()!=iRes);
if (EditorNodes.end()!=iRes)
{
SelectedObjectName = name;
SelectedObject = &iRes->second;
ObjectDescription = new ObjectDescriptionLayout("EditorObjectOptions.layout");
ObjectDescription->Load();
ObjectDescription->Parse(SelectedObject->EditElement);
ObjectDescription->Show();
}
return true;
}
示例11: SendChat
void SendChat(Ogre::UTFString chatline)
{
#ifdef USE_SOCKETW
const char *utf8_line = chatline.asUTF8_c_str();
RoR::Networking::AddPacket(m_stream_id, MSG2_UTF_CHAT, (unsigned int)strlen(utf8_line), (char *)utf8_line);
#endif // USE_SOCKETW
}
示例12: insert
void TextIterator::insert(Ogre::UTFString::iterator & _start, Ogre::UTFString & _insert)
{
// сбрасываем размер
mSize = ITEM_NONE;
// записываем в историю
if (mHistory) mHistory->push_back(TextCommandInfo(_insert, _start-mText.begin(), TextCommandInfo::COMMAND_INSERT));
// запоминаем позицию итератора
size_t pos = _start - mText.begin();
size_t pos_save = (mSave==mEnd) ? ITEM_NONE : _start - mText.begin();
// непосредственно вставляем
mText.insert(_start, _insert.begin(), _insert.end());
// возвращаем итераторы
_start = mText.begin() + pos;
mEnd = mText.end();
(pos_save==ITEM_NONE) ? mSave = mEnd : mSave = mText.begin() + pos_save;
}
示例13: ReportError
// Helper function
void Character::ReportError(const char* detail)
{
#ifdef USE_SOCKETW
Ogre::UTFString username;
RoRnet::UserInfo info;
if (!RoR::Networking::GetUserInfo(m_source_id, info))
username = "~~ERROR getting username~~";
else
username = info.username;
char msg_buf[300];
snprintf(msg_buf, 300,
"[RoR|Networking] ERROR on m_is_remote character (User: '%s', SourceID: %d, StreamID: %d): ",
username.asUTF8_c_str(), m_source_id, m_stream_id);
LOGSTREAM << msg_buf << detail;
#endif
}
示例14: 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;
}
示例15: flipList
void MultiList::flipList()
{
if (ITEM_NONE == mSortColumnIndex) return;
size_t end = mVectorColumnInfo.front().list->getItemCount();
if (0 == end) return;
end --;
size_t start = 0;
Ogre::UTFString tmp;
tmp.reserve(64);
size_t index1, index2;
VectorSizeT vec;
size_t size2 = mToSortIndex.size();
vec.resize(size2);
for (size_t pos=0; pos<size2; ++pos) vec[mToSortIndex[pos]] = pos;
while (start < end) {
for (VectorColumnInfo::iterator iter=mVectorColumnInfo.begin(); iter!=mVectorColumnInfo.end(); ++iter) {
tmp = (*iter).list->getItem(start);
(*iter).list->setItem(start, (*iter).list->getItem(end));
(*iter).list->setItem(end, tmp);
}
index1 = vec[start];
index2 = vec[end];
mToSortIndex[index1] = mToSortIndex[index2];
mToSortIndex[index2] = start;
vec[start] = vec[end];
vec[end] = index1;
start++;
end--;
}
}