Exemplo n.º 1
0
	void CInterfaceElement::setSizeParent( const std::string &id )
	{
		// Parent or empty id simply means the group parent
		if( ( id == "parent" ) || ( id.empty() ) )
		{
			setParentSize( getParent() );
			return;
		}

		CInterfaceElement *pp = NULL;

		// Check if it's a short Id
		std::string::size_type idx = id.find( "ui:" );
		if( idx == std::string::npos )
		{
			// If it is, find the widget in the parent group and set as posparent
			CInterfaceGroup *p = getParent();
			if( p != NULL )
			{
				pp = p->findFromShortId( id );
			}
		}
		else
		{
			// If it is not, find using the widgetmanager
			// TODO: refactor, shouldn't use a singleton
			pp = CWidgetManager::getInstance()->getElementFromId( id );
		}

		if( pp != NULL )
			setParentSize( pp );
	}
Exemplo n.º 2
0
// ----------------------------------------------------------------------------
void CViewBitmap::draw ()
{
	CInterfaceManager *pIM = CInterfaceManager::getInstance();
	CViewRenderer &rVR = pIM->getViewRenderer();

	CRGBA col;
	if(getModulateGlobalColor())
	{
		col.modulateFromColor (_Color, pIM->getGlobalColorForContent());
	}
	else
	{
		col= _Color;
		col.A = (uint8)(((sint32)col.A*((sint32)pIM->getGlobalColorForContent().A+1))>>8);
	}

	if (_InheritGCAlpha)
	{
		// search a parent container
		CInterfaceGroup *gr = getParent();
		while (gr)
		{
			if (gr->isGroupContainer())
			{
				CGroupContainer *gc = static_cast<CGroupContainer *>(gr);
				col.A = (uint8)(((sint32)col.A*((sint32)gc->getCurrentContainerAlpha()+1))>>8);
				break;
			}
			gr = gr->getParent();
		}
	}
Exemplo n.º 3
0
// ***************************************************************************
void addMacroLine (CGroupList *pParent, uint macNb, const CMacroCmd &macro)
{
	CInterfaceManager	*pIM = CInterfaceManager::getInstance();

	vector< pair<string, string> > vParams;
	vParams.push_back(pair<string,string>("id", "m"+toString(macNb)));
	CInterfaceGroup *pNewMacro = CWidgetManager::getInstance()->getParser()->createGroupInstance(TEMPLATE_MACRO_ELT, pParent->getId(), vParams);
	if (pNewMacro == NULL) return;

	CViewText *pVT = dynamic_cast<CViewText*>(pNewMacro->getView(TEMPLATE_MACRO_ELT_TEXT));
	if (pVT != NULL) pVT->setText(macro.Name);

	CDBCtrlSheet *pCS = dynamic_cast<CDBCtrlSheet*>(pNewMacro->getCtrl(TEMPLATE_MACRO_ELT_ICON));
	if (pCS != NULL) pCS->readFromMacro(macro);

	pVT = dynamic_cast<CViewText*>(pNewMacro->getView(TEMPLATE_MACRO_ELT_KEYTEXT));
	if (pVT != NULL)
	{
		if (macro.Combo.Key != KeyCount)
			pVT->setText(macro.Combo.toUCString());
		else
			pVT->setText(CI18N::get(VIEW_EDITCMD_TEXT_KEY_DEFAULT));
	}

	pNewMacro->setParent (pParent);
	pParent->addChild (pNewMacro);
}
Exemplo n.º 4
0
// ***************************************************************************
void	CGroupTab::setup()
{
	if(_Setuped)
		return;
	_Setuped= true;

	_Buttons.clear();
	_Groups.clear();

	/* Buttons must be named tab0,tab1,tab2...
		and tab_array0_0, tab_array0_1 .... (for vector of tab)
		Only 10 tab array are allowed
	*/
	for(sint tabArrayIndex= -1;tabArrayIndex<10;tabArrayIndex++)
	{
		// prefix according to array or not
		string	prefix;
		if(tabArrayIndex==-1)
			prefix= "tab";
		else
			prefix= toString("tab_array%d_", tabArrayIndex);

		// for all tab of this type (standard tab or array of tab), find the Buttons and groups.
		uint	tabIndex=0;
		for(;;)
		{
			// find the ctrl named "tab0"
			CCtrlTabButton	*but= dynamic_cast<CCtrlTabButton*>(getCtrl(toString("%s%d", prefix.c_str(), tabIndex)));
			if(!but)
				break;

			// find the associated group
			CInterfaceGroup	*pGroup = NULL;
			CInterfaceGroup	*pFather = this;

			while ((pGroup == NULL) && (pFather != NULL))
			{
				pGroup = pFather->getGroup(but->_AssociatedGroup);
				pFather = pFather->getParent();
			}

			// add to the button and group list
			_Buttons.push_back(but);
			_Groups.push_back(pGroup);

			// try next
			tabIndex++;
		}
	}

	// at the first setup, select by default the 1st
	if(_Selection<0)
		select(0);
}
Exemplo n.º 5
0
	bool CInterfaceElement::isInGroup( CInterfaceGroup *group )
	{
		CInterfaceGroup *parent = getParent();
		while( parent != NULL )
		{
			if( parent == group )
				return true;
			else
				parent = parent->getParent();
		}
		return false;
	}
Exemplo n.º 6
0
//*****************************************************************************************************************
void	CGroupHeaderEntry::updateCoords()
{
	CInterfaceGroup::updateCoords();
	CInterfaceGroup *targetColumn = getTargetColumn();
	if (targetColumn)
	{
		if (targetColumn->getW() != getW())
		{
			targetColumn->setW(getW());
			targetColumn->invalidateCoords();
		}
	}
}
Exemplo n.º 7
0
	// ------------------------------------------------------------------------------------------------
	CInterfaceGroup* CInterfaceElement::getParentContainer()
	{
		CInterfaceElement *parent = this;
		while (parent)
		{
			CInterfaceGroup *gc = dynamic_cast< CInterfaceGroup* >( parent );
			if( ( gc != NULL ) && gc->isGroupContainer() )
				return gc;

			parent = parent->getParent();
		}
		return NULL;
	}
Exemplo n.º 8
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;
}
Exemplo n.º 9
0
//*********************************************************************************************************
void CInstanceMapDeco::onAdd(CGroupMap &owner)
{
	//H_AUTO(R2_CInstanceMapDeco_onAdd)
	nlassert(_Instance);
	nlassert(!_Main);
	nlassert(!_Over);
	nlassert(!_OverInvalid);
	_Main = new CCtrlButtonEntity(*_Instance);
	_Main->setPosRef(Hotspot_MM);
	_Main->setParentPosRef(Hotspot_BL);
	_Main->setModulateGlobalColorAll(false);
	owner.addCtrl(_Main);
	_Main->setParent(&owner);
	_Main->setRenderLayer(2);
	_Main->setId(owner.getId() + ":" + _Instance->getId());
	_Main->setActive(_Active);
	//
	_Over   = newQuad(owner);
	_Over->setRenderLayer(3);
	_Over->setActive(_Active);
	//
	_OverInvalid = newQuad(owner);
	_OverInvalid->setRenderLayer(4);
	_OverInvalid->setActive(_Active && _InvalidPos);
	//
	if (_Orientable)
	{
		_Orient = newQuad(owner);
		_Orient->setTexture(CV_MapEntityOrientTexture.get());
		_Orient->setRenderLayer(3);
		_Orient->setActive(_Active);
	}
	//
	CInterfaceGroup *window = owner.getParentContainer();
	if (window)
	{
		for(uint k = 0; k < 2; ++k)
		{
			_GlowStar[k] = new CCtrlQuad;
			_GlowStar[k]->setActive(false);
			_GlowStar[k]->setModulateGlobalColor(false);
			window->addCtrl(_GlowStar[k]);
			_GlowStar[k]->setParent(window);
			_GlowStar[k]->setAdditif(true);
			_GlowStar[k]->setTexture(CV_MapGlowStarTexture.get());
		}
	}
	_AddedToMap = true;
}
Exemplo n.º 10
0
// ***************************************************************************
void addCommandLine (CGroupList *pParent, uint cmdNb, const ucstring &cmdName)
{
	CInterfaceManager	*pIM = CInterfaceManager::getInstance();

	vector< pair<string, string> > vParams;
	vParams.push_back(pair<string,string>("id", "c"+toString(cmdNb)));
	CInterfaceGroup *pNewCmd = CWidgetManager::getInstance()->getParser()->createGroupInstance(TEMPLATE_NEWMACRO_COMMAND, pParent->getId(), vParams);
	if (pNewCmd == NULL) return;

	CViewText *pVT = dynamic_cast<CViewText*>(pNewCmd->getView(TEMPLATE_NEWMACRO_COMMAND_TEXT));
	if (pVT != NULL) pVT->setText(cmdName);

	pNewCmd->setParent (pParent);
	pParent->addChild (pNewCmd);
}
// *************************************************************************************************
void CBotChatPageDynamicMission::begin()
{
	CBotChatPage::begin();
	// clear db entries for dynamic missions
	CInterfaceManager *im = CInterfaceManager::getInstance();
	invalidateMission();
	// clear all choices options
	for(uint k = 0; k < DYNAMIC_MISSION_NUM_CHOICES; ++k)
	{
		im->getDbProp(toString(DM_CHOICE "%d:TITLE", (int) k))->setValue32(0);
		for(uint l = 0; l < DYNAMIC_MISSION_MAX_NUM_OPTIONS; ++l)
		{
			im->getDbProp(toString(DM_CHOICE "%d:%d:TEXT", (int) k, (int) l))->setValue32(0);
		}
	}
	activateWindow(WIN_BOT_CHAT_PAGE_DYNAMIC_MISSION, true);
	CInterfaceGroup *ig = dynamic_cast<CInterfaceGroup *>(im->getElementFromId(WIN_BOT_CHAT_PAGE_DYNAMIC_MISSION));
	if (!ig)
	{
		std::fill(_ChoiceCB, _ChoiceCB + DYNAMIC_MISSION_NUM_CHOICES, (CDBGroupComboBox *) NULL);
	}
	else
	{
		for(uint k = 0; k < DYNAMIC_MISSION_NUM_CHOICES; ++k)
		{
			// get pointers on combo boxs
			_ChoiceCB[k] = dynamic_cast<CDBGroupComboBox *>(ig->getGroup(toString("choice%d", (int) k)));
			// empty the choice list (no datas received yet)
			if (_ChoiceCB[k])
			{
				_ChoiceCB[k]->setActive(false);
				_ChoiceCB[k]->resetTexts();
			}
			for(uint l = 0; l < DYNAMIC_MISSION_MAX_NUM_OPTIONS; ++l)
			{
				_TextReceived[k][l] = false;
			}
		}
	}
	std::fill(_Choice, _Choice + DYNAMIC_MISSION_NUM_CHOICES, -1);
	for(uint k = 0; k < DYNAMIC_MISSION_NUM_CHOICES; ++k)
	{
		im->getDbProp(toString("UI:TEMP:DYNAMIC_MISSION:CHOICE%d", (int) k))->setValue32(-1);
	}
}
Exemplo n.º 12
0
	CInterfaceElement* CRootGroup::getElement (const std::string &id)
	{
		if (_Id == id)
		return this;

		if (id.substr(0, _Id.size()) != _Id)
			return NULL;

		std::vector<CViewBase*>::const_iterator itv;
		for (itv = _Views.begin(); itv != _Views.end(); itv++)
		{
			CViewBase *pVB = *itv;
			if (pVB->getId() == id)
				return pVB;
		}

		std::vector<CCtrlBase*>::const_iterator itc;
		for (itc = _Controls.begin(); itc != _Controls.end(); itc++)
		{
			CCtrlBase* ctrl = *itc;
			if (ctrl->getId() == id)
				return ctrl;
		}

		// Accelerate
		std::string sTmp = id;
		sTmp = sTmp.substr(_Id.size()+1,sTmp.size());
		std::string::size_type pos = sTmp.find(':');
		if (pos != std::string::npos)
			sTmp = sTmp.substr(0,pos);

		std::map<std::string,CInterfaceGroup*>::iterator it = _Accel.find(sTmp);
		if (it != _Accel.end())
		{
			CInterfaceGroup *pIG = it->second;
			return pIG->getElement(id);
		}
		return NULL;
	}
Exemplo n.º 13
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;
}
Exemplo n.º 14
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);
		}
	}
}
Exemplo n.º 15
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);
	}
}
Exemplo n.º 16
0
	// ----------------------------------------------------------------------------
	void CGroupList::draw ()
	{
		// TEMP TEMP
		//CViewRenderer &rVR = *CViewRenderer::getInstance();
		//rVR.drawRotFlipBitmap _RenderLayer,   (_XReal,   _YReal,   _WReal,   _HReal,   0,   false,   rVR.getBlankTextureId(),   CRGBA(0,  255,  0,  255) );
		if (_Over)
		{
			CViewRenderer &rVR = *CViewRenderer::getInstance();

			if (CWidgetManager::getInstance()->getModalWindow() == NULL)
			{
				sint32 x = CWidgetManager::getInstance()->getPointer()->getX();
				sint32 y = CWidgetManager::getInstance()->getPointer()->getY();

				CInterfaceGroup	*pIG = CWidgetManager::getInstance()->getWindowUnder(x,  y);
				CInterfaceGroup	*pParent = this;
				bool bFound = false;
				while (pParent != NULL)
				{
					if (pParent == pIG)
					{
						bFound = true;
						break;
					}
					pParent = pParent->getParent();
				}

				sint32 clipx,  clipy,  clipw,  cliph;
				getClip(clipx,  clipy,  clipw,  cliph);
				if ((x < clipx) ||
					(x > (clipx + clipw)) ||
					(y < clipy) ||
					(y > (clipy + cliph)) || !bFound)
				{
					_OverElt = -1;
				}
				else
				{
					for (uint32 i = 0; i < _Elements.size(); ++i)
					if (_Elements[i].Element->getActive())
					{
						CViewBase *pVB = _Elements[i].Element;
						if ((x >= pVB->getXReal()) &&
							(x < (pVB->getXReal() + pVB->getWReal()))&&
							(y >= pVB->getYReal()) &&
							(y < (pVB->getYReal() + pVB->getHReal())))
						{
							_OverElt = i;
						}
					}
				}
			}

			if (_OverElt != -1)
			{
				// Find the first container
				CInterfaceGroup *pIG = _Parent;
				CGroupContainerBase *pGC = dynamic_cast<CGroupContainerBase*>(pIG);
				while (pIG != NULL)
				{
					pIG = pIG->_Parent;
					if (pIG == NULL) break;
					if (dynamic_cast<CGroupContainerBase*>(pIG) != NULL)
						pGC = dynamic_cast<CGroupContainerBase*>(pIG);
				}

				bool bDisplayOverSelection = true;
				if (pGC != NULL)
				{
					if (pGC->isGrayed())
						bDisplayOverSelection = false;
				}

				if (bDisplayOverSelection)
				{
					CViewBase *pVB = _Elements[_OverElt].Element;
					CRGBA col = _OverColor;
					if(getModulateGlobalColor())
					{
						col.modulateFromColor (_OverColor,   CWidgetManager::getInstance()->getGlobalColorForContent());
					}
					else
					{
						col= _OverColor;
						col.A = (uint8)(((sint32)col.A*((sint32)CWidgetManager::getInstance()->getGlobalColorForContent().A+1))>>8);
					}
					rVR.drawRotFlipBitmap (_RenderLayer,   pVB->getXReal(),   pVB->getYReal(),
											pVB->getWReal(),   pVB->getHReal(),   0,   false,   rVR.getBlankTextureId(),
											col );
				}

			}
		}
Exemplo n.º 17
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();
}
Exemplo n.º 18
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();
}
Exemplo n.º 19
0
// *********************************************************************************************************
void CDisplayerVisual::onPostRender()
{
	//H_AUTO(R2_CDisplayerVisual_onPostRender)
	if (!getActive()) return;

	// if this entity is currently moving then don't display the 'stop' icon
	// (it is already drawn by the mouse cursor)
	if (getDisplayedInstance() == getEditor().getSelectedInstance()
		&& dynamic_cast<CToolSelectMove *>(getEditor().getCurrentTool()))
	{
		if (_IconInScene)
		{
			_IconInScene->setActive(false);
		}
	}
	else
	{
		if (getDisplayFlag(FlagBadPos))
		{
			if (!_IconInScene && !_IconInSceneCreationFailed)
			{
				CInterfaceManager *pIM = CInterfaceManager::getInstance();
				const char *iconTemplateName = "r2ed_bad_pos_icon";
				// if the in scene 'stop' window wasn't created, then create it now
				CInterfaceGroup *group = CWidgetManager::getInstance()->getParser()->createGroupInstance (iconTemplateName , "ui:interface", NULL, 0);
				if (group)
				{
					_IconInScene = dynamic_cast<CGroupInScene *>(group);
					if (!_IconInScene)
					{
						nlwarning("Template %s has bad type : should be a derived group from CGroupInScene", iconTemplateName);
						delete group;
						_IconInSceneCreationFailed = true;
					}
					else
					{
						// Link to the interface
						CWidgetManager::getInstance()->addWindowToMasterGroup("ui:interface", group);
						CInterfaceGroup *pRoot = dynamic_cast<CInterfaceGroup*>(CWidgetManager::getInstance()->getElementFromId("ui:interface"));
						group->setParent(pRoot);
						if (pRoot)
							pRoot->addGroup (group);
					}
				}
				else
				{
					_IconInSceneCreationFailed = true;
				}
			}
			if (_IconInScene)
			{
				_IconInScene->setActive(true);
				// tmp set a position above head
				evalIconInScenePos(_IconInScene->Position);
			}
		}
		else
		{
			if (_IconInScene)
			{
				_IconInScene->setActive(false);
			}
		}
	}
}
Exemplo n.º 20
0
void CGroupSkills::createAllTreeNodes()
{
	CInterfaceManager *pIM = CInterfaceManager::getInstance();
	CSkillManager *pSM = CSkillManager::getInstance();

	// Construct the snode hierarchy structure
	_TreeRoot = new CGroupTree::SNode;
	_AllNodes.resize(SKILLS::NUM_SKILLS, NULL);
	bool bQuit = false;
	uint nCounter = 0;

	// local variable (avoid realloc in loop)
	vector< pair<string, string> > tempVec(2);
	ucstring	sSkillName;

	while ((!bQuit) && (nCounter < 32)) // Counter is used to not infinitly loop
	{
		nCounter++;
		bQuit = true;
		// Try to create a skill
		for (uint32 i = 0; i < SKILLS::NUM_SKILLS; ++i)
		if (_AllNodes[i] == NULL) // not already created
		{
			if (pSM->isUnknown((SKILLS::ESkills)i)) continue;

			// Create all skills
			SKILLS::ESkills		parentSkill= pSM->getParent((SKILLS::ESkills)i);

			// if parent, the parent node must be created
			if (parentSkill != SKILLS::unknown)
			{
				if (_AllNodes[parentSkill] == NULL)
				{
					bQuit = false;
					continue;
				}
			}

			// Ok lets create it
			CGroupTree::SNode *pNode = new CGroupTree::SNode;
			pNode->Id = NLMISC::toString(i);

			// get Skill Name
			sSkillName = STRING_MANAGER::CStringManagerClient::getSkillLocalizedName((SKILLS::ESkills)i);

			// just text or template?
			if(_TemplateSkill.empty())
			{
				pNode->DisplayText = true;
				pNode->Template = NULL;
				pNode->Text= sSkillName;
			}
			else
			{
				pNode->DisplayText = false;

				// create the template
				tempVec[0].first="id"; tempVec[0].second= pNode->Id;
				tempVec[1].first="skillid"; tempVec[1].second= NLMISC::toString(i);
				CInterfaceGroup	*pIG = CWidgetManager::getInstance()->getParser()->createGroupInstance(_TemplateSkill, getId() + ":" + WIN_TREE_LIST, tempVec);
				if (pIG == NULL)
					nlwarning("error");
				// Set Skill Name
				CViewText *pViewSkillName = dynamic_cast<CViewText*>(pIG->getView("name"));
				if (pViewSkillName != NULL)
					pViewSkillName->setText (sSkillName);
				// Set Skill Max Value
				CViewText *pViewSkillMax = dynamic_cast<CViewText*>(pIG->getView("max"));
				if (pViewSkillMax != NULL)
					pViewSkillMax->setText (toString(pSM->getMaxSkillValue((SKILLS::ESkills)i)));
				pNode->Template = pIG;
			}


			// Action handler?
			if(!_AHCtrlNode.empty())
			{
				pNode->AHName= _AHCtrlNode;
				pNode->AHParams= NLMISC::toString(i);
			}

			// bkup
			_AllNodes[i] = pNode;

			// not opened by default
			pNode->Opened= false;

			// Attach to the good parent
			if (parentSkill == SKILLS::unknown)
				_TreeRoot->addChild(pNode);
			else
				_AllNodes[parentSkill]->addChild(pNode);
		}
	}

	// Sort the First level in this order: Combat/Magic/Craft/Forage/Others.
	vector<CSortNode>	sortNodes;
	sortNodes.resize(_TreeRoot->Children.size());
	uint	i;
	for(i=0;i<_TreeRoot->Children.size();i++)
	{
		sortNodes[i].Node= _TreeRoot->Children[i];
		// get the skill value of this node
		sint	skillValue;
		fromString(_TreeRoot->Children[i]->Id, skillValue);
		// Special sort:
		if(skillValue==SKILLS::SF)
			skillValue= -4;
		if(skillValue==SKILLS::SM)
			skillValue= -3;
		if(skillValue==SKILLS::SC)
			skillValue= -2;
		if(skillValue==SKILLS::SH)
			skillValue= -1;
		// prepare tri
		sortNodes[i].Value= skillValue;
	}
	sort(sortNodes.begin(), sortNodes.end());
	// store sorted values
	for(i=0;i<_TreeRoot->Children.size();i++)
	{
		_TreeRoot->Children[i]= sortNodes[i].Node;
	}
}