Example #1
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);
}
Example #2
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);
}
Example #3
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;
	}
}