示例#1
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);
}
// *************************************************************************************************
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);
	}
}