示例#1
0
//*****************************************************************************************************************
void	CGroupHeaderEntry::updateCoords()
{
	CInterfaceGroup::updateCoords();
	CInterfaceGroup *targetColumn = getTargetColumn();
	if (targetColumn)
	{
		if (targetColumn->getW() != getW())
		{
			targetColumn->setW(getW());
			targetColumn->invalidateCoords();
		}
	}
}
示例#2
0
static CInterfaceGroup *buildLineWithCommand(CInterfaceGroup *commandGroup, CViewText *text)
{
	nlassert(commandGroup);
	nlassert(text);
	CInterfaceGroup *group = new CInterfaceGroup(CViewBase::TCtorParam());
	static int groupId = 0;
	group->setId(NLMISC::toString("%d", groupId++));
	static volatile bool sizeref = 1;
	static volatile sint32 w = 0;
	group->setSizeRef(sizeref);
	group->setW(w);
	group->setResizeFromChildH(true);
	//
	group->addGroup(commandGroup);
	commandGroup->setParent(group);
	text->setParent(group);
	text->setParentPos(commandGroup);
	text->setPosRef(Hotspot_TL);
	text->setParentPosRef(Hotspot_TR);
	group->addView(text);
	return group;
}
示例#3
0
//-----------------------------------------------
//	updateChatModeAndButton
//
//-----------------------------------------------
void CClientChatManager::updateChatModeAndButton(uint mode, uint32 dynamicChannelDbIndex)
{
	// Check if USER chat is active
	bool userActive = false;
	CChatGroupWindow *pCGW = PeopleInterraction.getChatGroupWindow();
	if (pCGW)
	{
		CInterfaceGroup* pIG = pCGW->getContainer()->getGroup("content:cb:user");
		if (pIG)
		userActive = pIG->getActive();
	}

	CChatGroup::TGroupType m = (CChatGroup::TGroupType)mode;

	if (userActive)
	{
		// Change the button of the user chat to the corresponding chat target
		if (pCGW)
		{
			CCtrlTextButton *pUserBut = dynamic_cast<CCtrlTextButton*>(pCGW->getContainer()->getCtrl("content:but_user"));
			CCtrlTextButton *pEmoteBut = dynamic_cast<CCtrlTextButton*>(pCGW->getContainer()->getCtrl("content:but_emote"));
			CInterfaceGroup *pEditBox = dynamic_cast<CInterfaceGroup*>(pCGW->getContainer()->getGroup("content:ebw"));

			CInterfaceManager *pIM = CInterfaceManager::getInstance();
			const bool teamActive = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GROUP:0:PRESENT")->getValueBool();
			const bool guildActive = NLGUI::CDBManager::getInstance()->getDbProp("SERVER:GUILD:NAME")->getValueBool();

			if (m == CChatGroup::team && ! teamActive)
				m = PeopleInterraction.TheUserChat.Filter.getTargetGroup();

			if (m == CChatGroup::guild && ! guildActive)
				m = PeopleInterraction.TheUserChat.Filter.getTargetGroup();

			if (pUserBut)
			{
				switch(m)
				{
					default:
					case CChatGroup::arround:
					case CChatGroup::say:		pUserBut->setHardText("uiFilterAround");	break;
					case CChatGroup::region:	pUserBut->setHardText("uiFilterRegion");	break;
					case CChatGroup::universe:	pUserBut->setHardText("uiFilterUniverse");	break;
					case CChatGroup::team:		if (teamActive) pUserBut->setHardText("uiFilterTeam");		break;
					case CChatGroup::guild:		if (guildActive) pUserBut->setHardText("uiFilterGuild");	break;
					case CChatGroup::dyn_chat:
						uint32 textId = ChatMngr.getDynamicChannelNameFromDbIndex(dynamicChannelDbIndex);
						ucstring title;
						STRING_MANAGER::CStringManagerClient::instance()->getDynString(textId, title);
						if (title.empty())
						{
							// Dyn channel does not exist, don't change
							m = PeopleInterraction.TheUserChat.Filter.getTargetGroup();
							dynamicChannelDbIndex = PeopleInterraction.TheUserChat.Filter.getTargetDynamicChannelDbIndex();
						}
						else
						{
							pUserBut->setHardText(title.toUtf8());
						}
						break;
					// NB: user chat cannot have yubo_chat target
				}

				pUserBut->setActive(true);
				pUserBut->getParent()->updateCoords();
				pUserBut->updateCoords();
			}

			if (pEmoteBut)
			{
				pEmoteBut->setActive(true);
				pEmoteBut->updateCoords();
			}

			if (pEditBox && pUserBut && pEmoteBut)
			{
				pEditBox->setW(-pUserBut->getWReal()-pEmoteBut->getWReal()-8);
				pEditBox->setX(pUserBut->getWReal()+4);
			}

			PeopleInterraction.TheUserChat.Filter.setTargetGroup(m, dynamicChannelDbIndex);
			PeopleInterraction.ChatGroup.Filter.setTargetGroup(m, dynamicChannelDbIndex);
		}
	}
}
示例#4
0
//*****************************************************************************************************************
void CGroupHeader::enlargeColumns(sint32 margin)
{
	std::vector<CGroupHeaderEntry *> entries;
	getEntries(entries);
	sint32 totalWidth = 0;
	for (uint k = 0; k < entries.size(); ++k)
	{
		CInterfaceGroup *colEnclosing = entries[k]->getTargetColumn();
		if (colEnclosing && !colEnclosing->getGroups().empty())
		{
			CInterfaceGroup *col = colEnclosing->getGroups()[0];
			if (col)
			{
				// enlarge to the max to be able to measure the sub text (they may clamp themselves based
				// on their first non-"child resizing" parent (see CViewText::updateCoords)
				colEnclosing->setW(16384);
				colEnclosing->invalidateCoords();
				colEnclosing->updateCoords();

				// assume that first child is resizing from its children width (either 'child_resize_w=true' or a CGroupList)
				entries[k]->setW(std::max(entries[k]->getMinSize(), col->getW() + margin));
				entries[k]->invalidateCoords();
				totalWidth += entries[k]->getW();
			}
		}
	}
	// if total width bigger than allowed, reduce proportionnally
	if (totalWidth > _HeaderMaxSize)
	{
		while (totalWidth > _HeaderMaxSize)
		{
			bool adjusted = false;
			// stupid algo here, but ponctual ...
			for (uint k = 0; k < entries.size() && totalWidth > _HeaderMaxSize; ++k)
			{
				if (entries[k]->getW() > entries[k]->getMinSize())
				{
					entries[k]->setW(entries[k]->getW() - 1);
					entries[k]->invalidateCoords();
					--totalWidth;
					adjusted = true;
				}
			}
			// if all at min size, just exit ...
			if (!adjusted) break;
		}
	}
	else
	{
		// search first parent that limit size, if it is larger then enlarge to fit size
		CInterfaceGroup *limitingParent = getParent();
		while (limitingParent && (limitingParent->getResizeFromChildW() || dynamic_cast<CGroupList *>(limitingParent)))
		{
			// NB nico : the dynamic_cast for CGroupList is bad!!
			// can't avoid it for now, because, CGroupList implicitly does a "resize from child" in its update coords
			// ...
			limitingParent = limitingParent->getParent();
		}
		if (limitingParent && limitingParent->getWReal() > totalWidth)
		{
			while (limitingParent->getWReal() > totalWidth && totalWidth < _HeaderMaxSize)
			{
				// enlarge to matche parent size
				// stupid algo here, but ponctual ...
				for (uint k = 0; k < entries.size(); ++k)
				{
					entries[k]->setW(entries[k]->getW() + 1);
					entries[k]->invalidateCoords();
					++totalWidth;
					if (limitingParent->getWReal() <= totalWidth || totalWidth >= _HeaderMaxSize) break;
				}
			}
		}
	}
	invalidateCoords();
}
示例#5
0
//*****************************************************************************************************************
void CGroupHeader::resizeColumnsAndContainer(sint32 margin)
{
	std::vector<CGroupHeaderEntry *> entries;
	getEntries(entries);
	sint32 totalWidth = 0;
	for (uint k = 0; k < entries.size(); ++k)
	{
		CInterfaceGroup *colEnclosing = entries[k]->getTargetColumn();
		if (colEnclosing && !colEnclosing->getGroups().empty())
		{
			CInterfaceGroup *col = colEnclosing->getGroups()[0];
			if (col)
			{
				// enlarge to the max to be able to measure the sub text (they may clamp themselves based
				// on their first non-"child resizing" parent (see CViewText::updateCoords)
				colEnclosing->setW(16384);
				colEnclosing->invalidateCoords();
				colEnclosing->updateCoords();

				// assume that first child is resizing from its children width (either 'child_resize_w=true' or a CGroupList)
				entries[k]->setW(std::max(entries[k]->getMinSize(), col->getW() + margin));
				entries[k]->invalidateCoords();
				totalWidth += entries[k]->getW();
			}
		}
	}

	// resize W
	if (totalWidth <= _HeaderMaxSize)
	{
		// search first parent that limit size, if it is larger then enlarge to fit size
		CInterfaceGroup *limitingParent = getParent();
		while (limitingParent && (limitingParent->getResizeFromChildW() || dynamic_cast<CGroupList *>(limitingParent)))
		{
			// NB nico : the dynamic_cast for CGroupList is bad!!
			// can't avoid it for now, because, CGroupList implicitly does a "resize from child" in its update coords
			// ...
			limitingParent = limitingParent->getParent();
		}

		getParentContainer()->setW(totalWidth + getParentContainer()->getWReal() - limitingParent->getWReal());
	}

	// resize H
	if(entries.size()>0)
	{
		CInterfaceGroup *colEnclosing = entries[0]->getTargetColumn();
		if (colEnclosing && !colEnclosing->getGroups().empty())
		{
			CInterfaceGroup *col = colEnclosing->getGroups()[0];
			if (col)
			{
				// search first parent that limit size, if it is larger then enlarge to fit size
				CInterfaceGroup *limitingParent = colEnclosing->getParent();
				while (limitingParent && (limitingParent->getResizeFromChildH() || dynamic_cast<CGroupList *>(limitingParent)))
					limitingParent = limitingParent->getParent();

				getParentContainer()->setH(col->getH() + getParentContainer()->getHReal() - limitingParent->getHReal());
			}
		}
	}


	invalidateCoords();
}