コード例 #1
0
ファイル: CommunityBox.cpp プロジェクト: leloulight/lbanet
/***********************************************************
add people friend
***********************************************************/
void CommunityBox::UpdateFriend(const LbaNet::FriendInfo & frd)
{
	//RemoveFriend(frd.Name);

	CEGUI::Listbox * lb = static_cast<CEGUI::Listbox *> (
		CEGUI::WindowManager::getSingleton().getWindow("Community/friendlist"));


	bool connected = false;
	std::string color = "FF777777";
	std::map<std::string, CEGUI::ListboxItem *>::iterator iton = _onlines.find(frd.Name);
	if(iton != _onlines.end())
	{
		connected = true;
		color = "FF33FF33";
	}

	std::string dis = "[colour='" + color + "']";
	if(frd.ToAccept)
		dis += "(Request) ";

	dis += frd.Name;

	if(frd.Pending)
		dis += " (Pending)";


	//check if already exist just update the text
	T_friendmap::iterator it = _friends.find(frd.Id);
	if(it != _friends.end())
	{
		it->second.second->setText(dis);
		lb->invalidate();
	}
	else
	{
		CEGUI::ListboxItem *item = new MyComListItem(dis);
		item->setID((unsigned int)frd.Id);
		lb->addItem(item);
		_friends[frd.Id] = std::make_pair<LbaNet::FriendInfo, CEGUI::ListboxItem *>(frd, item);

	}
}
コード例 #2
0
ファイル: CommunityBox.cpp プロジェクト: leloulight/lbanet
/***********************************************************
add people online
***********************************************************/
void CommunityBox::AddOnline(const std::string & listname, const std::string &_online,
							 const std::string &_status, const std::string &color)
{
	if(listname == "online")
	{
		CEGUI::Listbox * lb = static_cast<CEGUI::Listbox *> (
			CEGUI::WindowManager::getSingleton().getWindow("Community/onlinelist"));

		std::string dis = "[colour='" + color + "']" + _online;
		if(_status != "")
			dis += " (" + _status + ")";

		std::map<std::string, CEGUI::ListboxItem *>::iterator itmap = _onlines.find(_online);
		if(itmap != _onlines.end())
		{
			itmap->second->setText(dis);
			lb->invalidate();
		}
		else
		{
			CEGUI::ListboxItem *it = new MyComListItem(dis);
			lb->addItem(it);
			_onlines[_online] = it;
		}


		if(IsFriend(_online))
			UpdateFriend(_online);
	}

	if(listname == "IRC")
	{
		CEGUI::Listbox * lb = static_cast<CEGUI::Listbox *> (
			CEGUI::WindowManager::getSingleton().getWindow("Community/IRClist"));

		CEGUI::ListboxItem *it = lb->findItemWithText(_online, NULL);
		if(it == NULL)
			lb->addItem(new MyComListItem(_online));
	}
}