Ejemplo n.º 1
0
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
}
Ejemplo n.º 2
0
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;
}
Ejemplo n.º 3
0
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
}
Ejemplo n.º 4
0
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");
}
Ejemplo n.º 5
0
void CLASS::eventCommandAccept(MyGUI::Edit* _sender)
{
	Ogre::UTFString msg = convertFromMyGUIString(_sender->getCaption());
	isTyping = false;
	_sender->setCaption("");

	if (autoHide)
		_sender->setEnabled(false);

	if (msg.empty())
	{
		// discard the empty message
		return;
	}

	if (msg[0] == '/' || msg[0] == '\\')
	{
		Ogre::StringVector args = Ogre::StringUtil::split(msg, " ");
		if (args[0] == "/whisper")
		{
			if (args.size() != 3)
			{
				pushMsg("usage: /whisper username message");
				return;
			}
			netChat->sendPrivateChat(args[1], args[2]);
			return;
		}
	}

	if (gEnv->network && netChat)
	{
		netChat->sendChat(msg.c_str());
		return;
	}

	//MyGUI::InputManager::getInstance().resetKeyFocusWidget();
	RoR::Application::GetGuiManager()->UnfocusGui();
}
Ejemplo n.º 6
0
	void TextIterator::cutMaxLengthFromBeginning(size_t _max)
	{
		// узнаем размер без тегов
		size_t size = getSize();
		if (size <= _max) return;

		// разница 
		size_t diff = size - _max;

		// последний цвет
		Ogre::UTFString::iterator iter_colour = mEnd;

		// теперь пройдем от начала и узнаем реальную позицию разницы
		Ogre::UTFString::iterator iter=mText.begin();
		for (; iter!=mEnd; ++iter)
		{
			if ((*iter) == L'#')
			{
				Ogre::UTFString::iterator save = iter;

				// следующий символ
				++ iter;
				if (iter == mEnd) break;

				// тэг цвета
				if ((*iter) != L'#')
				{
					// остальные 5 символов цвета
					for (size_t pos=0; pos<5; pos++)
					{
						++ iter;
						if (iter == mEnd)
						{
							-- iter;
							break;
						}
					}
					// сохраняем цвет
					iter_colour = save;
				}
				continue;
			}
			// обычный символ был
			if (diff == 0) break;
			-- diff;
		}

		Ogre::UTFString colour;
		// если бы цвет, то вставляем назад
		if (iter_colour != mEnd)
		{
			colour.append(iter_colour, iter_colour + size_t(7));
		}

		mCurrent = erase(mText.begin(), iter);
		mEnd = mText.end();
		mSave = mText.end(); //FIXME
		mPosition = 0;
		mSize = _max;

		if ( ! colour.empty() ) setTagColour(colour);

	}