示例#1
0
// --------------------------------------------------------------------------------------------------------------------
bool CViewPointer::drawCustom(CCtrlBase* pCB)
{
	string texName;
	uint8 rot;
	NLMISC::CRGBA col;
	if (pCB->getMouseOverShape(texName, rot, col))
	{
		if (texName[0] == '@')
		{
			const string &tooltipInfos = texName.substr(1);
			string tooltip;
			vector<string> tooltipInfosList;
			splitString(tooltipInfos, "@", tooltipInfosList);
			texName = tooltipInfosList[0];
			tooltip = tooltipInfosList[1];
			nlinfo(tooltip.c_str());
			setString(ucstring(tooltip));
			CInterfaceManager *pIM = CInterfaceManager::getInstance();
			CViewRenderer &rVR = pIM->getViewRenderer();
			sint32 texId = rVR.getTextureIdFromName (texName);

			CInterfaceGroup *stringCursor = IsMouseCursorHardware() ? _StringCursorHardware : _StringCursor;
			if (stringCursor)
			{
				stringCursor->setX(_PointerX);
				stringCursor->setY(_PointerY);
				stringCursor->updateCoords();
				stringCursor->draw();
				// if in hardware mode, force to draw the default cursor no matter what..
				if (IsMouseCursorHardware())
					drawCursor(texId, col, 0);
			}
			else
			{
				drawCursor(texId, col, 0);
			}
			return true;
		}
		else
		{
			CInterfaceManager *pIM = CInterfaceManager::getInstance();
			CViewRenderer &rVR = pIM->getViewRenderer();
			sint32 texId = rVR.getTextureIdFromName (texName);
			drawCursor(texId, col, 0);
			return true;
		}
	}
	return false;
}
示例#2
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);
		}
	}
}
示例#3
0
// --------------------------------------------------------------------------------------------------------------------
void CViewPointer::draw ()
{
	// Do not display the pointer if not visible.
	if(!_PointerVisible)
		return;

	CInterfaceManager *pIM = CInterfaceManager::getInstance();
	CViewRenderer &rVR = pIM->getViewRenderer();

	if (pIM->isInGame())
	if (!_StringCursor)
	{
		// Create the string cursor instance
		std::vector<std::pair<std::string,std::string> > templateParams;
		templateParams.push_back (std::pair<std::string,std::string>("id", "string_cursor"));

		_StringCursor = pIM->createGroupInstance("string_cursor", "", templateParams);
		if (_StringCursor)
			_StringCursor->setParentPos(pIM->getElementFromId("ui:interface"));

		templateParams.clear();
		templateParams.push_back (std::pair<std::string,std::string>("id", "string_cursor_hardware"));
		_StringCursorHardware = pIM->createGroupInstance("string_cursor_hardware", "", templateParams);
		if (_StringCursorHardware)
			_StringCursorHardware->setParentPos(pIM->getElementFromId("ui:interface"));
	}

	CRGBA col;
	if(getModulateGlobalColor())
		col.modulateFromColor (_Color, pIM->getGlobalColor());
	else
		col= _Color;

	//col.A = (uint8)(((sint32)col.A*((sint32)pIM->getGlobalColor().A+1))>>8);
	col.A = _Color.A;

	if (_LastHightLight != NULL)
	{
		_LastHightLight->setHighLighted(false,0);
		_LastHightLight = NULL;
	}

	if (pIM->getCapturePointerLeft() != NULL && pIM->isMouseHandlingEnabled())
	{
		CCtrlMover *pCM = dynamic_cast<CCtrlMover*>(pIM->getCapturePointerLeft());
		if ((pCM != NULL) && (pCM->canMove() == true))
		{
			CGroupContainer *pGC = dynamic_cast<CGroupContainer *>(pCM->getParent());
			if (pGC != NULL && !pGC->isLocked())
			{
				pGC->setHighLighted(true, 255);
				_LastHightLight = pGC;
			}
		}
	}

	if (_TxIdDefault == -2)
	{
		_TxIdDefault	= rVR.getTextureIdFromName (_TxDefault);
		_TxIdMoveWindow = rVR.getTextureIdFromName (_TxMoveWindow);
		_TxIdResizeBRTL = rVR.getTextureIdFromName (_TxResizeBRTL);
		_TxIdResizeBLTR = rVR.getTextureIdFromName (_TxResizeBLTR);
		_TxIdResizeTB	= rVR.getTextureIdFromName (_TxResizeTB);
		_TxIdResizeLR	= rVR.getTextureIdFromName (_TxResizeLR);
		_TxIdRotate		= rVR.getTextureIdFromName (_TxRotate);
		_TxIdScale		= rVR.getTextureIdFromName (_TxScale);
		_TxIdColPick	= rVR.getTextureIdFromName (_TxColPick);
		_TxIdPan		= rVR.getTextureIdFromName (_TxPan);
		_TxIdCanPan		= rVR.getTextureIdFromName (_TxCanPan);
		if (ClientCfg.R2EDEnabled)
		{
			_TxIdPanR2		= rVR.getTextureIdFromName (_TxPanR2);
			_TxIdCanPanR2	= rVR.getTextureIdFromName (_TxCanPanR2);
		}
	}

	const vector<CCtrlBase *> &rICL = pIM->getCtrlsUnderPointer ();


	// Draw the captured cursor
	CCtrlBase *pCB = pIM->getCapturePointerLeft();
	if (pCB != NULL)
	{
		if (drawResizer(pCB,col)) return;
		//if (drawMover(pCB,col)) return;
		if (drawColorPicker(pCB,col)) return;
		if (drawRotate(pCB,col)) return;
		if (drawPan(pCB,col)) return;
		if (drawCustom(pCB)) return;
		drawCursor(_TxIdDefault, col, 0);
		return;
	}

	const vector<CViewBase *> &vUP = pIM->getViewsUnderPointer ();

	for(uint i=0;i<vUP.size();i++)
	{
		CViewLink *vLink = dynamic_cast<CViewLink*>(vUP[i]);
		if (vLink != NULL)
		{
			string tooltip;
			uint8 rot;

			if (vLink->getMouseOverShape(tooltip, rot, col))
			{
				setString(ucstring(tooltip));
				sint32 texId = rVR.getTextureIdFromName ("curs_pick.tga");

				CInterfaceGroup *stringCursor = IsMouseCursorHardware() ? _StringCursorHardware : _StringCursor;
				if (stringCursor)
				{
					stringCursor->setX(_PointerX);
					stringCursor->setY(_PointerY);
					stringCursor->updateCoords();
					stringCursor->draw();
					// if in hardware mode, force to draw the default cursor no matter what..
					if (IsMouseCursorHardware())
						drawCursor(texId, col, 0);
				}
				else
				{
					drawCursor(texId, col, 0);
				}
				return;
			}
		}
	}

	// Draw if capture right
	pCB = pIM->getCapturePointerRight();
	if (pCB != NULL)
	{
		// Is it a 3d scene ?
		if (drawScale(pCB,col)) return;
		drawCursor(_TxIdDefault, col, 0);
		return;
	}

	bool overModalWindow = false;


	// is the cursor currently over a modal window ?
	CInterfaceGroup *currModal = pIM->getModalWindow();
	if (currModal)
	{
		sint32 xPos = _XReal + _OffsetX;
		sint32 yPos = _YReal + _OffsetY;
		overModalWindow = currModal->isIn(xPos, yPos, _WReal, _HReal);
	}

	// Draw the cursor type that are under the pointer
	if (pIM->isMouseHandlingEnabled())
	{
		// Sorts the controls according to their depth, to approximate as best the CapturePointerLeft algo.
		// Especially important so that Resizers controls get the precedence over the move control (else could randomly bug like in chat group)
		static vector<CCtrlDepthEntry>		sortedControls;
		sortedControls.clear();
		for(uint i=0;i<rICL.size();i++)
		{
			CCtrlDepthEntry		cde;
			cde.Ctrl= rICL[i];
			// NB: not the exact CInterfaceManager getDepth test here, but should work fine
			cde.Depth= cde.Ctrl->getParentDepth() + cde.Ctrl->getDeltaDepth();
			sortedControls.push_back(cde);
		}
		std::sort(sortedControls.begin(), sortedControls.end());

		// Then draw the correct cursor
		for (uint32 i = 0; i < sortedControls.size(); ++i)
		{
			CCtrlBase *pCB = sortedControls[i].Ctrl;

			if (overModalWindow)
			{
				if (!pCB->isSonOf(currModal)) continue;
			}

			if (drawBrowse(pCB, col)) return;
			if (drawResizer(pCB,col)) return;
			if (drawColorPicker(pCB,col)) return;
			if (drawLink (pCB, col)) return;
			if (drawCustom(pCB)) return;

			// test for move highlight
			if (_LastHightLight == NULL)
			{
				CCtrlMover *pCM = dynamic_cast<CCtrlMover*>(pCB);
				if ( (pCM != NULL) && (pCM->canMove() == true) )
				{
					CGroupContainer *pGC = dynamic_cast<CGroupContainer *>(pCM->getParent());
					if (pGC != NULL && !pGC->isLocked())
					{
						if (pIM->getCapturePointerLeft() != pCM)
							pGC->setHighLighted(true, 128);
						else
							pGC->setHighLighted(true, 255);
						_LastHightLight = pGC;
						break;
					}
				}
			}

			//if (drawMover(pCB,col)) return;
		}
	}

	if (pIM->isMouseHandlingEnabled())
	{
		if (rICL.empty())
		{
			const vector<CInterfaceGroup *> &rIGL = pIM->getGroupsUnderPointer ();
			for (uint32 i = 0; i < rIGL.size(); ++i)
			{
				CInterfaceGroup *pG = rIGL[i];
				if (overModalWindow)
				{
					if (!pG->isSonOf(currModal)) continue;
				}
				if (drawPan (pG, col)) return;
				if (drawBrowse(pG, col)) return;
			}
		}
	}

	if (_StringMode && pIM->isMouseHandlingEnabled())
	{
		CInterfaceGroup *stringCursor = IsMouseCursorHardware() ? _StringCursorHardware : _StringCursor;
		if (stringCursor)
		{
			stringCursor->setX(_PointerX);
			stringCursor->setY(_PointerY);
			stringCursor->updateCoords();
			stringCursor->draw();
			// if in hardware mode, force to draw the default cursor no matter what..
			if (IsMouseCursorHardware())
			{
				drawCursor(_TxIdDefault, col, 0);
			}
		}
	}
	else
	{
		// Draw the default cursor
		drawCursor(_TxIdDefault, col, 0);
	}
}