Beispiel #1
0
void CEventWizardDlg::UpdateButtons()
{
	if(m_iStep == 1)
	{
		int sel = m_List.GetSelectedItem();
		m_Next.SetWindowText("Next");
		if(sel == -1)
			m_Next.EnableWindow(FALSE);
		
		else
			m_Next.EnableWindow();
		
		m_Back.EnableWindow(FALSE);
	}

	if(m_iStep == 2)
	{
		int sel = m_ACEList.GetSelectedItem();

		if(sel == -1) //nothing selected...
		{
			m_Next.SetWindowText("Next");
			m_Next.EnableWindow(false);
		}

		else
		{
			aceIndex = m_ACEList.GetItemData(sel);
			CObjType* pType = application->FindObjTypeFromNumber(m_pSelectedObject);

			ACESEntry2* pACE = NULL;

			if(pType)
			{
				int sel = m_Tabs.SelectionGet();
				if(sel == 0) // object
				{
					m_childid = -1;	
					pACE = pType->GetACESEntry(m_aceType, aceIndex);
				}

				else if(sel <= pType->behaviors.size())
				{
					list<CBehavior>::iterator i = pType->behaviors.begin();
					advance(i, sel-1);
					m_childid = i->id;
					CObjType tmp;
					tmp.CreateFromBehavior(&*i);

					pACE = tmp.GetACESEntry(m_aceType, aceIndex);			
				}
				else
				{
					sel -= pType->behaviors.size() + 1;
					list<CEffect>::iterator i = pType->effects.begin();
					advance(i, sel);
					m_childid = -i->m_effectID;
				
					CObjType tmp;
					tmp.CreateFromEffect(&*i);

					pACE = tmp.GetACESEntry(m_aceType, aceIndex);

				}
			}
		
			if (pACE != NULL)
			{
				if (pACE->params.size() == 0 || m_aceType == EXPRESSION)
					m_Next.SetWindowText("Finish");
			}

			else
				m_Next.SetWindowText("Next");

			m_Next.EnableWindow();
		}

		m_Back.EnableWindow();	
	}

	if(m_iStep == 3)
	{
		m_Next.SetWindowText("Finish");
		m_Next.EnableWindow();
		m_Back.EnableWindow();
	}
}
void CEventWizardDlg::UpdateDisplay(CString Previous, bool addTabs)
{
	if (m_iStep == 1)
	{
		// Add objects in
		LVITEM InsertPlugin;

		// Mask: TEXT, IMAGE, LPARAM, STATE
		InsertPlugin.mask = LVIF_TEXT | LVIF_IMAGE | LVIF_PARAM | LVIF_STATE | LVIF_GROUPID;
		InsertPlugin.state = 0;
		InsertPlugin.stateMask = 0;
		InsertPlugin.iItem = 0;
		InsertPlugin.iSubItem = 0;
		InsertPlugin.iGroupId = 0;

		// Normal objects
		int index = 0;

		for(map<CString, int>::iterator i = object_folders.begin(); i!= object_folders.end(); i++)
		{
			m_List.AddGroup(i->second, i->first);
			index++;
		}
		int Icon = 1;

		// System object
		if (ApproveItem(SYSTEM))
		{
			InsertPlugin.iImage = 0;
			InsertPlugin.iGroupId = object_folders["Object"];
			InsertPlugin.pszText = new char[SYSTEM.GetLength() + 1];
			strcpy(InsertPlugin.pszText, SYSTEM);
			ListView_InsertItem(m_List.m_hWnd, &InsertPlugin);

			if(SYSTEM == Previous)
				m_List.SetItemState(0,LVIS_SELECTED, LVIS_SELECTED);

			m_List.SetItemData(0, application->m_System.ObjectIdentifier);	
		}

		// Now loop the otList backwards to display each object icon
		for(vector<CObjType*>::iterator i = m_otList.begin(); i != m_otList.end(); i++)
		{	
			CString Name = (*i)->GetName();

			if (ApproveItem(Name))
			{
				InsertPlugin.iItem = ListView_GetItemCount(m_List.m_hWnd);
				InsertPlugin.iImage = Icon;
				InsertPlugin.pszText = Name.GetBuffer(Name.GetLength());
				InsertPlugin.iGroupId = object_folders[(*i)->GetFolder()];
				ListView_InsertItem(m_List.m_hWnd, &InsertPlugin);

				m_List.SetItemData(m_List.GetItemCount() - 1, (*i)->ObjectIdentifier);	

				if((*i)->GetName() == Previous)
					m_List.SetItemState(m_List.GetItemCount() - 1, LVIS_SELECTED, LVIS_SELECTED);
			}

			// Increment icon number
			Icon++;
		}	

		// Add families
		m_List.AddGroup(object_folders.size(), "Families");

		bool bFamilies = false;
		list<Family>::iterator f = application->families.begin();

		for ( ; f != application->families.end(); f++)
		{
			if(f->is_in_use)
			{
				bFamilies = true;

				if (ApproveItem(f->name))
				{
					InsertPlugin.iItem = ListView_GetItemCount(m_List.m_hWnd);
					InsertPlugin.iImage = Icon;
					InsertPlugin.iGroupId = object_folders.size();
					InsertPlugin.pszText = f->name.GetBuffer(f->name.GetLength());
					ListView_InsertItem(m_List.m_hWnd, &InsertPlugin);

					m_List.SetItemData(m_List.GetItemCount() - 1, f->identifier);

					if(f->name == Previous)
						m_List.SetItemState(m_List.GetItemCount() - 1,LVIS_SELECTED, LVIS_SELECTED);
				}
			}
			Icon++;
		}

		if (!bFamilies && object_folders.size() <= 1) m_List.RemoveAllGroups();
		else m_List.EnableGroups();
	}

	else if (m_iStep == 2)
	{
		if (addTabs) {
			m_CategoryTabs.ItemInsert("All");

			m_bOK = true;
			m_CategoryTabs.SelectionSet(0); //default
			m_bOK = false;
		}

		int index = 1;
		for(map<CString, int>::iterator i = categories.begin(); i != categories.end(); i++)
		{
			CString tabText = i->first;
			tabText.Replace("&", "&&");

			if (addTabs)
				m_CategoryTabs.ItemInsert(tabText,0,0,0,index++);

			m_bOK = true;
			if(i->first == SelectedCategory && addTabs)
				m_CategoryTabs.SelectionSet(m_CategoryTabs.ItemGetCount()-1);
			m_bOK = false;

			m_ACEList.AddGroup(i->second, i->first);
		}

		m_ACEList.bold_items.clear();

		// BOOM!  The vector element pMov points to is nuked
		//CObjType* pType = application->FindObjTypeFromNumber(m_pSelectedObject);
		//pType = application->FindObjTypeFromNumber(m_pSelectedObject);
		CObjType* pType = step2_type;

		if(pType)
		{	
			// Get all categories
			CObjType temp;
			if(pMov)
			{
				temp.CreateFromBehavior(pMov);
				pType = &temp;
			}

			if(pEff)
			{
				temp.CreateFromEffect(pEff);
				pType = &temp;
			}	

			vector<SortedACE> aces;

			for (int i = 0; i < pType->GetTableCount(m_aceType); i++)
			{
				ACESEntry2* pAce = pType->GetACESEntry(m_aceType, i);
				if(pAce == NULL || pAce->aceListName == "")
					continue; // ignore null entries

				// Verify it meets the filter
				if (!ApproveItem(pAce->aceListName))
					continue;

				CString category = pAce->aceCategory;
				
				if(SelectedCategory == "Common")
				{
					if(i >= 255) 
						i = pType->GetTableCount(m_aceType); //skip anything about the first aces
				}
				else
					if(SelectedCategory != "All" && SelectedCategory != category)
						continue; // if its not the current category

				aces.push_back(SortedACE(pAce->aceListName, i, categories[category]));
			}

			// now sort
			sort(aces.begin(), aces.end());

			for (int j = 0; j < aces.size(); j++)
			{
				// If *, bold it and remove star
				//MessageBox("fast bullets 3");
				CString name = aces[j].name;
				if (aces[j].name.Left(1) == "*")
				{
					name = aces[j].name.Right(aces[j].name.GetLength() - 1);
					m_ACEList.InsertItem(j, name, NULL, aces[j].category);
					m_ACEList.bold_items[j] = true;
				}

				else
				{
					m_ACEList.InsertItem(j, name, NULL, aces[j].category);
					m_ACEList.bold_items[j] = false;
				}
				//MessageBox("fast bullets 4");

				

				m_ACEList.SetItemData(j, aces[j].i);
				if(name == Previous)
				{
					m_ACEList.SetItemState(j, LVIS_SELECTED, LVIS_SELECTED);
				}

				


				//MessageBox("fast bullets 5");
				
				//m_ACEList.SetItemState(j, LVIS_SELECTED, LVIS_SELECTED);
			}
		}
	}
}
// OnRClick(NMHDR* pNMHDR, LRESULT* pResult) 
// Handle right clicking an object and inserting an expression.
void CParametersDlg::OnDblClick(NMHDR* pNMHDR, LRESULT* pResult) 
{
	POSITION listpos = m_Expand.GetFirstSelectedItemPosition();
	int item = m_Expand.GetNextSelectedItem(listpos);

	//if(item == -1) return;

	CObjType* pObjType = (CObjType*)m_Expand.GetItemData(item);

	CEventWizardDlg EventWizard;
	EventWizard.m_aceType = EXPRESSION;
	EventWizard.layout = layout;
	EventWizard.application = application;

	if(pObjType){
		EventWizard.m_pSelectedObject = pObjType->ObjectIdentifier;
		EventWizard.m_iStep = 2;
	}
	else
		EventWizard.m_iStep = 1;
	
	EventWizard.SetMap(&application->object_types);

	if(EventWizard.DoModal() != IDOK)
		return;

	// The user can click Back and get a different object's expression, so make sure we're using the current one.
	pObjType = application->FindObjTypeFromNumber(EventWizard.m_pSelectedObject);

	int aceIndex = EventWizard.m_aceIndex;
	int mID = EventWizard.m_childid;

	CObjType tmp;
	CObjType *pInfoType = NULL;
	if(mID == -1)
		pInfoType = pObjType;

	CBehavior* pMov = NULL;
	CEffect* pEffect = NULL; // there are no effect expressions but perhaps in the future...
	if(mID < -1)
	{
		pInfoType = &tmp;
		pEffect = pObjType->GetEffect(-mID);
		tmp.CreateFromEffect(pEffect);
	}
	if(mID > -1)
	{
		pInfoType = &tmp;
		pMov = pObjType->GetBehaviorByUniqueID(mID);
		tmp.CreateFromBehavior(pMov);
	}

	if(!pInfoType)
		return;
	ACESEntry2* pACE = pInfoType->GetACESEntry(EXPRESSION, aceIndex);

	if (pWndFocusParam == NULL) 
		return;

	CString Func;
	if(pObjType->ObjectIdentifier == -1)
	{
		Func.Format("%s",  pACE->aceDisplayText);

		if (pACE->auxStr != "") 
		{
			Func += "(";
			Func += pACE->auxStr;
			Func += ")";
		}
	}
	else 
	{
		if(pMov)
		{
			Func.Format("%s[%s].%s", pObjType->GetName(), pMov->Text, pACE->aceDisplayText);

			if (pACE->params.size() != 0)
			{
				Func += "(";

				for (int i = 0; i < pACE->params.size(); i++)
				{
					Func += pACE->params[i].name;

					if (i != (pACE->params.size() - 1))
						Func += ", ";
				}

				Func += ")";
			}
		}

		else
		{
			// Starts with <:  interpret as shortcut for other expression eg. <MouseX>
			if (pACE->aceDisplayText.Left(1) == "<") {
				Func = pACE->aceDisplayText.Mid(1, pACE->aceDisplayText.GetLength() - 2);
			}
			else {
				Func = pObjType->GetName();

				// Allow expressions to specify object name like 'Counter'
				if (pACE->aceDisplayText != "") {
					// Allow expressions to specify an ACE name like "(x,y,z)" eg. Array(x,y,z)
					if (pACE->aceDisplayText.Left(1) != "(")
						Func += ".";

					Func += pACE->aceDisplayText;
				}

				if (pACE->params.size() != 0)
				{
					Func += "(";
					// okay loop params, add name and ,
					for (int i = 0; i < pACE->params.size(); i++)
					{
						Func += pACE->params[i].name;
						//only add if liek not last 0ne
						if (i != (pACE->params.size() - 1))
							Func += ", ";
					}
					Func += ")";
				}
			}
		}
	}

	pWndFocusParam->SendMessage(SCI_REPLACESEL, 0, (LPARAM)(const char*)Func);

	*pResult = 0;
}