bool CEditorCondition::IsLoop(CApplication* app)
{
	if(m_Text != "")
	{
		return (m_Text.Find("<img>3</img>") != -1);
	}
	else
	{
		if(!app)
			return false;
		CObjType* objectType = app->FindObjTypeFromNumber(oid);
		if(!objectType)
			return false;
		ACESEntry2* acesEntry;

		if(mid == -1) // ace or custom ace
			acesEntry = objectType->GetACESEntry(CONDITION, cndID);
		else				 // movement			
		{
			//MovementIterator mi = objectType->m_Movements.begin();
			//advance(mi, mid);
			CBehavior* pMov = objectType->GetBehaviorByUniqueID(mid);
			if (pMov == NULL) throw;
			acesEntry = GetOINFO(pMov->BehaviorDLLIndex)->GetACEEntry(CONDITION, cndID);
		}

		// effects never have triggers

		if(!acesEntry)
			return false;
		if (acesEntry->aceDisplayText.Find("<img>3</img>") != -1)
			return true;
		return false;
	}



}
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);
			}
		}
	}
}
Esempio n. 3
0
void ObjectBarDialog::OnDblClickObject(NMHDR *pNMHDR, LRESULT *pResult)
{
	POSITION Pos = objects.GetFirstSelectedItemPosition();
	int Item = objects.GetNextSelectedItem(Pos);

	if (Item == -1) return;

	CObjType* pType;
	long ID = objects.GetItemData(Item);

	if (ID == -1)  // object folder
	{
		if (folderfilter == -1)  //Default folder
		{
			for(int i=0; i < application->object_folders.size(); i++)
			{
				if (objects.GetItemText(Item,0) == application->object_folders[i].name)
				{
					folderfilter=i;
					break;
				}
			}
		}
		else //return folder
		{
			folderfilter = -1;
		}
		Refresh();
		return;
	}

	application->object_types.Lookup(ID, pType);

	if (!pType) return;

	// If layout editor open..
	if (parent.m_tabs.SelectionGet() == 0 && parent.m_tabs.ItemGetCount() == 2)
	{
		POSITION ObjectPos = layout->objects.GetStartPosition();
		CObj* pObject;
		long ID = 0;

		for (int i = 0; i < layout->objects.GetCount(); i++) 
		{
			layout->objects.GetNextAssoc(ObjectPos, ID, pObject);

			CObjType* type = pObject->GetObjectType(application);

			if (type->ObjectIdentifier == pType->ObjectIdentifier)
			{
				OINFO* info = GetOINFO(pType->DLLIndex);
				if(info->ETOnNotify)
					info->ETOnNotify(pObject->editObject, 1);

				return;
			}
		}
	}

	// If event sheet editor, see if it has conditions. If so, open Event Wizard
	if ((parent.m_tabs.SelectionGet() == 1) && (parent.m_tabs.ItemGetCount() == 2) || parent.m_tabs.ItemGetCount() == 1)
	{
		bool bUse = false;

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

			bUse = true;
		}

		if (bUse)
		{
			parent.m_pEventView[0][0]->m_InitialStage = 2;
			parent.m_pEventView[0][0]->m_InitialSelect = ID;
			parent.m_pEventView[0][0]->m_OldName = pType->GetName();
			parent.m_pEventView[0][0]->AddCondition(true);
		}
	}
}
Esempio n. 4
0
// Initialise the dialog
//
BOOL CEventWizardDlg::OnInitDialog() 
{
	// Startup
	CDialog::OnInitDialog();

	int currentPosition = 1;

	// Create an m_ObjectImages
	m_ObjectImages.DeleteImageList();

	bool bSmallImages = false;

	// Check what size images we'll need
	// 32x32 without families or 16x16 with
	if (application->families.size() == 0)
	{
		m_ObjectImages.Create(32, 32, ILC_COLOR24, 3, 3);
		m_List.SetImageList(&m_ObjectImages, LVSIL_NORMAL);

		HBITMAP SystemBitmap = LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_SYSTEM));
		ImageList_Add(m_ObjectImages, SystemBitmap, SystemBitmap);
		DeleteObject(SystemBitmap);
	}

	else
	{
		// If it's small, also set the view to small images
		m_List.SetView(LV_VIEW_SMALLICON);

		m_ObjectImages.Create(16, 16, ILC_COLOR24, 3, 3);
		m_List.SetImageList(&m_ObjectImages, LVSIL_SMALL);

		HBITMAP SystemBitmap = LoadBitmap(AfxGetInstanceHandle(), MAKEINTRESOURCE(IDB_SYSTEMC));
		ImageList_Add(m_ObjectImages, SystemBitmap, SystemBitmap);	
		DeleteObject(SystemBitmap);

		bSmallImages = true;
	}

	// Prepare to iterate all objects to add icons
	POSITION pos = objMap->GetStartPosition();
	long mapKey;
	CObjType* ObjectType;

	// Add '(System)' because system uses it
	object_folders["(System)"] = 0;

	// Loop through and add all objects to the otList
	while (pos != NULL) 
	{
		objMap->GetNextAssoc(pos, mapKey, ObjectType);

		if(!ObjectType->m_bIsGroupType)
		{
			CObj *o;
			bool bAdd = false;

			// If global, its okay to add...if its not global..and we have a layout...we need to check
			if (ObjectType->m_bGlobal) 
			{
				bAdd = true;
			}
			else if(layout)
			{
				POSITION pos = layout->objects.GetStartPosition();

				for (int i = 0; i < layout->objects.GetCount(); i++) 
				{
					long ID;
					layout->objects.GetNextAssoc(pos, ID, o);
						
					if (o->GetGlobalID() == ObjectType->ObjectIdentifier)
					{
						bAdd = true;	
					}
				}
			}
			else // we have no layout to this event sheet
			{
				bAdd = true;
			}

			// Dont add if it doesn't have conditions/actions
			bool hasAces = false;
			for (int i = 0; i < ObjectType->GetTableCount(m_aceType); i++)
			{
				if (ObjectType->GetACESEntry(m_aceType, i)->aceListName == "")
				{
					hasAces = true;
					break;
				}
				if (hasAces)
					break;
			}
			if(!hasAces)
				bAdd = false;

			// Okay cool...look like its okay to add...just check if is showabout in the event sheet editor
			if(bAdd && ObjectType->m_bShowInEventSheetEditor)
			{
				// Possibly add a new category
				if(object_folders.find(ObjectType->GetFolder()) == object_folders.end())
				{
					object_folders[ObjectType->GetFolder()] = object_folders.size();
				}
				m_otList.push_back(ObjectType);
			}
		}
	}

	// Sort
	sort(m_otList.begin(), m_otList.end(), ObjTypeSortFunction);

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

		if (bSmallImages)
			Bitmap = (*i)->small_image.MakeBitmap();
		else
			Bitmap = (*i)->m_Image.MakeBitmap();

		ImageList_Add(m_ObjectImages, Bitmap, Bitmap);

		DeleteObject(Bitmap);
	}	

	pos = objMap->GetStartPosition();

	// Family icons
	list<Family>::iterator f = application->families.begin();

	for ( ; f != application->families.end(); f++)
	{
		if(f->is_in_use)
		{
			HBITMAP Bitmap = f->small_image.MakeBitmap();
			ImageList_Add(m_ObjectImages, Bitmap, Bitmap);
			
			DeleteObject(Bitmap);
		}
	}
	
	// Title
	CString Title;

	if (m_aceType == CONDITION)
		Title.Format("Construct : New condition");
	else if (m_aceType == ACTION)
		Title.Format("Construct : New action");
	else if (m_aceType == EXPRESSION)
		Title.Format("Construct : New expression");

	SetWindowText(Title);

	CRect Rect;
	m_ACEList.GetWindowRect(&Rect);
	ScreenToClient(&Rect);
	Rect.top = Rect.bottom - 1;
	Rect.bottom = Rect.top + 18;
	m_CategoryTabs.Create(this, Rect, 1001, WS_CHILD | WS_VISIBLE, __ETWS_ORIENT_BOTTOM);

	m_ACEList.GetWindowRect(&Rect);
	ScreenToClient(&Rect);
	Rect.top -= 17;
	Rect.bottom = Rect.top + 18;
	m_Tabs.Create(this, Rect, 1002, WS_CHILD | WS_VISIBLE, __ETWS_ORIENT_TOP);

	GetClientRect(&Rect);

	Rect.bottom = Rect.top + 22;
	Rect.right += 48;

	// Resizing anchors
	BOOL First = dlgMan.Load(this->m_hWnd, "Software\\Construct\\EventWizardDialogs");
	if (!First)
	{
		first_run.Attach(this);
		first_run.SetHighlightOnMouseOver();
		first_run.SetResize();
		first_run.SetWrapText();

		if (m_aceType == ACTION)
			first_run.SetText("Events are created via this wizard.  Choose an object from the list below.  A list of actions will then appear, some of which require parameters: for example 'Create object' under System.  Once all parameters are filled out, click Finish to insert your action.");
		if (m_aceType == CONDITION)
			first_run.SetText("Events are created via this wizard.  Choose an object from the list below.  A list of conditions will then appear, some of which require parameters: for example 'Compare' under System.  Once all parameters are filled out, click Finish to insert your condition.");

	}

    dlgAnchor.Init(this->m_hWnd);

	dlgAnchor.Add(IDC_OBJECTLIST, ANCHOR_TOPLEFT | ANCHOR_BOTTOMRIGHT);
	dlgAnchor.Add(IDC_ACELIST, ANCHOR_TOPLEFT | ANCHOR_BOTTOMRIGHT);
	dlgAnchor.Add(IDC_FIND, ANCHOR_TOP | ANCHOR_RIGHT);

	dlgAnchor.Add(1001, ANCHOR_LEFT | ANCHOR_BOTTOMRIGHT);
	dlgAnchor.Add(1002, ANCHOR_TOPLEFT | ANCHOR_RIGHT);
	dlgAnchor.Add(1003, ANCHOR_TOPLEFT | ANCHOR_RIGHT);
	
	dlgAnchor.Add(IDC_BACK, ANCHOR_BOTTOM | ANCHOR_RIGHT);
	dlgAnchor.Add(IDC_CANCEL, ANCHOR_BOTTOM | ANCHOR_LEFT);
	dlgAnchor.Add(IDC_NEXT, ANCHOR_BOTTOM | ANCHOR_RIGHT);
	
	m_Cancel.SetWindowText(CANCEL);

	// Set ACE margins
	CRect ListRect;
	m_ACEList.GetClientRect(&ListRect);
	ListRect.left += 5;
	ListRect.top += 5;
	m_ACEList.SetWorkAreas(1, &ListRect);
	m_ACEList.SetColumnWidth(0, 200);		// Spaces everything out nicely for step 2.

	int initStep = m_iStep;

	if (m_InitialStage == 0)
	{
		m_iStep = 1;
		ChangeStep();
	}

	else
	{
		// New to 0.96.3
		m_pSelectedObject = m_InitialSelect;
		initStep = 2;
	}

	// The below is used so we set the default selected items (eg. if we are editing)
	if(m_pSelectedObject != -2)
	{
		// Have an object already selected
		for(int i = 0; i < m_List.GetItemCount(); i++)
			if(m_List.GetItemData(i) == m_pSelectedObject)
				m_List.SetItemState(i,LVIS_SELECTED, LVIS_SELECTED);
	}

	if(m_aceIndex != -1)
	{
		PreChangeStep();
		m_iStep = 2;
		int aceIndex = m_aceIndex;

		ChangeStep();
		if(m_childid != 0)
		{
			CObjType* pType = application->FindObjTypeFromNumber(m_pSelectedObject);
			if(pType)
			{
				int index = 1;
				list<CBehavior>::iterator i = pType->behaviors.begin();
				list<CBehavior>::iterator end = pType->behaviors.end();

				for(; i!= end; i++)
				{
					if(i->id == m_childid)
					{
						m_Tabs.SelectionSet(index);
						break;
					}

					index ++;
				}

				list<CEffect>::iterator e = pType->effects.begin();
				for(;e!= pType->effects.end(); e++)
				{
					if(e->m_effectID == -m_childid)				
						m_Tabs.SelectionSet(index);

					index ++;
				}
			}

			ChangeStep();
		}

		m_aceIndex = aceIndex;

		for(int i = 0; i < m_ACEList.GetItemCount(); i++)
		{
			if(m_ACEList.GetItemData(i) == m_aceIndex)
				m_ACEList.SetItemState(i,LVIS_SELECTED, LVIS_SELECTED);
		}		
	}

	if(initStep != m_iStep)
	{
		PreChangeStep();
		m_iStep = initStep;
		ChangeStep();
	}

	UpdateButtons();

	// Expression dialogs will move slightly to make it clear it's on top of the existing parameters dialog.
	if (m_aceType == EXPRESSION) {
		RECT rc;
		this->GetWindowRect(&rc);
		rc.left += 50;
		rc.top += 50;
		this->SetWindowPos(NULL, rc.left, rc.top, 0, 0, SWP_NOSIZE);
	}

	// New drawing code
	LOGFONT* m_pLF;
	m_pLF=(LOGFONT*)calloc(1,sizeof(LOGFONT));
	strncpy(m_pLF->lfFaceName,"Segoe UI",9);
	m_pLF->lfHeight=14;
	m_pLF->lfWeight=600;
	m_pLF->lfItalic=0;
	m_pLF->lfUnderline=0;
	m_FontBold.CreateFontIndirect(m_pLF);

	m_pLF->lfWeight = 0;
	m_Font.CreateFontIndirect(m_pLF);

	m_Find.SetIcon(IDI_SEARCH);

	return FALSE;  // return TRUE unless you set the focus to a control
	              // EXCEPTION: OCX Property Pages should return FALSE
}
Esempio n. 5
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();
	}
}
Esempio n. 6
0
void CParamScintilla::OnChar(NMHDR* pNMHDR, LRESULT* pResult,CScintillaWnd& scintWin, CObjTypeMap* objectMap,
		CParamTooltipCtrl& m_Tooltip,
		bool& m_ParameterTooltipIsVisible,
		bool& m_QuotesOpen,
		CApplication* pApp,
		bool bInline)
{
	// This function is only for CScintilla...
	SCNotification *scn = (SCNotification*)pNMHDR;

	CString text;
	scintWin.GetWindowText(text);

	CString theChar = "a";
	theChar.SetAt(0, scn->ch);

	::SendMessage(scintWin.m_hWnd, SCI_AUTOCSETSEPARATOR, '|', '|');

	int carretPosition = scintWin.GetCurrentPosition();
	text = text.Left(carretPosition); // everything to the right is irrelavant

	// Get last char
	if (scn->ch=='.')
	{
		// Get name of object
		// First we need to get the current char.

		text = text.Left(scintWin.GetCurrentPosition());

		int pos = 0;
		char finds[] = " ()+-/*{},";
		for(int a = 0; a < strlen(finds); a++)
			pos = max(pos, text.ReverseFind(finds[a]));
		
		CString name = text.Right(text.GetLength() - pos);
		name = name.Left(name.GetLength() - 1);
		if(pos!=0)
			name = name.Right(name.GetLength()-1);
		
		bool exists = true;
		{		
			pApp->m_sort.RemoveAll();
			CString intel;

			if (name != "System")
			{
				// Display intellisense
				// Loop m_TypeCheckerressions
				CObjType* oT;

		
				//POSITION pos = objectMap->GetStartPosition();
				//long nKey;

				//while (pos != NULL) 
				vector<CObjType*> objects;
				pApp->GetObjectTypes(objects);
				pApp->GetFamilyObjectTypes(objects);
				vector<CObjType*>::iterator i = objects.begin();
				for(; i != objects.end(); i++)
				{
					oT = *i;
					//objectMap->GetNextAssoc(pos, nKey, oT);

					CString l = oT->GetName();
					CString r = name;
					l.MakeLower();
					r.MakeLower();
	
					if (l == r)
					{	
						// Enum m_TypeCheckerressions
						for (int i = 0; i < oT->GetTableCount(2); i++)
						{
							ACESEntry2* acesEntry = oT->GetACESEntry(2, i);
							if(acesEntry->aceDisplayText != "")
								pApp->m_sort.Add(acesEntry->aceDisplayText);
						}

						break;
					}
				}	
			}

			else // System
			{
				for (int i = 0; i < GetSystemTableCount(2); i++)
				{
					ACESEntry2* ACE;
					GetSystemExpression(i, ACE);
					pApp->m_sort.Add(ACE->aceDisplayText);
				}
			}
							
			pApp->m_sort.Sort();

			for (int i = 0; i < pApp->m_sort.GetSize(); i++)
			{
				intel += pApp->m_sort.GetAt(i);				
				intel += "|";
			}
			
			intel = intel.Left(intel.GetLength() - 1);
			
			if (intel != "")
				::SendMessage(scintWin.m_hWnd, SCI_AUTOCSHOW, 0, (long)(const char*)intel);
		}
	}

	// Add: Check for inline editing, don't handle this if we are. 0.96.2
	else if (scn->ch == '(' && !bInline)
	{
		if (m_ParameterTooltipIsVisible)
		{
			m_Tooltip.ShowWindow(SW_HIDE);
			m_ParameterTooltipIsVisible = false;
		}

		CString m_TypeCheckerressionName, ObjectName;

		// Get name of m_TypeCheckerression
		int pos = text.ReverseFind('.');

		CString name = text.Right(text.GetLength() - pos - 1);
		int start = (text.GetLength() - pos) - 1;
		m_TypeCheckerressionName = name.Left(name.GetLength() - 1);

		// Get name of object
		CString object = text.Left(text.GetLength() - start);
		pos = object.ReverseFind(' ');

		name = object.Right(object.GetLength() - pos);
		ObjectName = name.Left(name.GetLength() - 1);
		ObjectName.Trim();

		bool exists = true;
		bool alsoexists = false;

		if (ObjectName == "")
			ObjectName = "System";

		if (exists)
		{
			vector<CString> setParams;
			m_Tooltip.FlushMethods();

			if (ObjectName != "System")
			{
				CObjType* oT;
		
				POSITION pos = objectMap->GetStartPosition();
				long nKey;

				while (pos != NULL) 
				{
					objectMap->GetNextAssoc(pos, nKey, oT);

					CString l = oT->GetName();
					CString r = ObjectName;
					l.MakeLower();
					r.MakeLower();
	
					if (l == r)
					{	
						// Enum m_TypeCheckerressions
						for (int i = 0; i < oT->GetTableCount(2); i++)
						{
							ACESEntry2* acesEntry = oT->GetACESEntry(2, i);
							if (acesEntry->aceDisplayText == m_TypeCheckerressionName)
							{
								alsoexists = true;

								for (int x = 0; x < acesEntry->params.size();x++)
								{
									CString addParameter;

									// Check type
									if (acesEntry->params[x].type == 1)
										addParameter.Format("%s [number]", acesEntry->params[x].name);

									if (acesEntry->params[x].type == 2)
										addParameter.Format("%s [string]", acesEntry->params[x].name);

									setParams.push_back(addParameter);
								}
							}	
						}

						break;
					}
				}	
			}

			/*else
			{
				int numTableEntries = sizeof(SysExpIntellisenseTable) / sizeof(SysExpIntellisenseTable[0]);
				setParams.resize(0);

				for (int i = 0; i < numTableEntries; i++) {

					CString l = m_TypeCheckerressionName;
					CString r = SysExpIntellisenseTable[i].expname;

					l.MakeLower();
					r.MakeLower();

					if (l == r) {
						alsoexists = true;
						
						CString curParam;
						int paramNum = 0;

						do {
							AfxExtractSubString(curParam, SysExpIntellisenseTable[i].params, paramNum, ',');
							curParam.Trim();
							if (curParam != "")
								setParams.push_back(curParam);
							paramNum++;
						} while (curParam != "");

						m_Tooltip.AddMethod(m_TypeCheckerressionName, setParams);
						setParams.resize(0);
					}
				}
			}*/

			if (alsoexists && !m_ParameterTooltipIsVisible)
			{
				// Get position of caret
				int currentPosition = scintWin.SendMessage(SCI_GETCURRENTPOS, 0, 0);

				int caretX = scintWin.SendMessage(SCI_POINTXFROMPOSITION, 0, 0);
				int caretY = scintWin.SendMessage(SCI_POINTXFROMPOSITION, 0, 0);

				if (ObjectName != "System")
				{
					CString sMethod;
					m_Tooltip.AddMethod(m_TypeCheckerressionName, setParams);
				}

				m_Tooltip.SetCurMethod(0);
				m_Tooltip.SetCurParam(0);
				m_Tooltip.ShowTooltip(CPoint(caretX, caretY));

				m_ParameterTooltipIsVisible = true;
				m_QuotesOpen = false;
			}
		}
	}

	// Increment parameter count
	else if (scn->ch == ',' && !bInline)
	{
		//scintWin.SendMessage(SCI_AUTOCCOMPLETE, 0, 0);
		if (m_ParameterTooltipIsVisible && !m_QuotesOpen)
			m_Tooltip.ShowNextParam();
	}

	// Hide parameter tooltip
	else if (scn->ch == ')' && !bInline)
	{
		//scintWin.SendMessage(SCI_AUTOCCOMPLETE, 0, 0);
		if (m_ParameterTooltipIsVisible)
		{
			m_Tooltip.ShowWindow(SW_HIDE);
			m_ParameterTooltipIsVisible = false;
		}
	}
	// Hide parameter tooltip
	else if (scn->ch == '"')
	{
		if (m_QuotesOpen)
			m_QuotesOpen = false;
		else
			m_QuotesOpen = true;
	}

	// Prompt variable names
	else if (scn->ch == '\'')
	{
		// Trim the right two (' chars eg. Sprite('
		text = text.Left(text.GetLength() - 2);

		CString temp = text;
		temp.MakeReverse();
		int index = temp.FindOneOf(" {}()+-*/");

		if (index > -1)
			text = text.Right(index);

		// Now find if there's a dot to get the object name
		index = text.Find('.');

		if (index > -1)
			text = text.Left(index);

		CObjType* pType = GetTypeFromName(pApp, text);

		if (pType != NULL) {

			CString varnames;

			vector<PrivateValue>::iterator i = pType->m_PrivateValues.begin();
			vector<PrivateValue>::iterator end = pType->m_PrivateValues.end();

			for ( ; i != end; i++)
				varnames += i->name + "|";

			varnames = varnames.Left(varnames.GetLength() - 1);

			if (varnames != "")
				::SendMessage(scintWin.m_hWnd, SCI_AUTOCSHOW, 0, (long)(const char*)varnames);
		}
		else{
			if(text == "global")
			{

			CString varnames;

			list<CApplication::GlobalVariable>::iterator i = pApp->global_variables.begin();
			list<CApplication::GlobalVariable>::iterator end = pApp->global_variables.end();

			for ( ; i != end; i++)
				varnames += i->name + "|";

			varnames = varnames.Left(varnames.GetLength() - 1);

			if (varnames != "")
				::SendMessage(scintWin.m_hWnd, SCI_AUTOCSHOW, 0, (long)(const char*)varnames);

			}

		}
	}
	/*else
	{
		
		if(text.GetLength() == 2)
		{
		// Any other type of letter, display intellisense for system expressions and object names
		CString suggestions;

		int numTableEntries = sizeof(SysExpIntellisenseTable) / sizeof(SysExpIntellisenseTable[0]);
		for (int i = 0; i < numTableEntries; i++) {
			CString expression = SysExpIntellisenseTable[i].expname;
			suggestions += expression + "|";
		}
		suggestions = suggestions.Left(suggestions.GetLength() - 1);
		if (suggestions != "")
			::SendMessage(scintWin.m_hWnd, SCI_AUTOCSHOW, 0, (long)(const char*)suggestions);
		}


	}*/
}
Esempio n. 7
0
// 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;
}