Ejemplo n.º 1
0
void LobbyGUI::addTextToChatWindow(String txt, String channel)
{
	//catch special case that channel is empty -> Status Channel
	if (channel.empty())
		channel = "Status";
	String realchannel = channel;

	// escape #
	channel =StringUtil::replaceAll(channel, "#", "##");
	txt = StringUtil::replaceAll(txt, "#", "##");


	if (tabs.find(channel) == tabs.end())
	{
		// add a new tab
		addTab(realchannel);
	}

	MyGUI::Edit* ec = tabs[channel].txt;
	if (!ec->getCaption().empty())
		ec->addText("\n" + txt);
	else
		ec->addText(txt);

	ec->setTextSelection(ec->getTextLength(), ec->getTextLength());	
}
Ejemplo n.º 2
0
	void Console::notifyButtonPressed(MyGUI::Widget* _sender, MyGUI::KeyCode _key, MyGUI::Char _char)
	{
		size_t len = _sender->getCaption().length();
		MyGUI::Edit* edit = _sender->castType<MyGUI::Edit>();
		if ((_key == MyGUI::KeyCode::Backspace) && (len > 0) && (mAutocomleted))
		{
			edit->deleteTextSelection();
			len = _sender->getCaption().length();
			edit->eraseText(len-1);
		}

		MyGUI::UString command = _sender->getCaption();
		if (command.length() == 0) return;

		for (MapDelegate::iterator iter = mDelegates.begin(); iter != mDelegates.end(); ++iter)
		{
			if (iter->first.find(command) == 0)
			{
				if (command == iter->first) break;
				edit->setCaption(iter->first);
				edit->setTextSelection(command.length(), iter->first.length());
				mAutocomleted = true;
				return;
			}
		}
		mAutocomleted = false;
	}