コード例 #1
0
int CEntitiesDialog::EditEntity( CEntityArray& Entities, int CurrentEntity, CFusionDoc* Doc)
{
	// If more than one entity selected, make sure they're all the same type.
	int nSel = 0;
	CString EntityClassname;
	int i;

	pDoc = Doc;
	mEntityArray = &Entities;

	for (i = 0; i < mEntityArray->GetSize(); ++i)
	{
		CEntity *pEnt;

		pEnt = &Entities[i];
		if (pEnt->IsSelected ())
		{
			if (nSel == 0)
			{
				EntityClassname = pEnt->GetClassname ();
				mCurrentEntity = i;
			}
			else
			{
				if (pEnt->GetClassname () != EntityClassname)
				{
					AfxMessageBox ("To edit multiple entities, they must all be of the same type.");
					return CurrentEntity;
				}
			}
			++nSel;
		}
	}

	MultiEntityFlag = (nSel > 1);
	if (MultiEntityFlag)
	{
	}
	else
	{
		if (CurrentEntity != -1)
		{
			mCurrentEntity = CurrentEntity;
		}
		else
		{
			//	Let's set entity 0 as selected if it exists...
			mCurrentEntity = 0;
			if (mEntityArray->GetSize()  > 0)
			{
				pDoc->ResetAllSelectedEntities();
				pDoc->SelectEntity (&(*mEntityArray)[mCurrentEntity]);
				pDoc->mCurrentEntity = mCurrentEntity;
			}
		}
	}

	DoModal();
	return mCurrentEntity;
}
コード例 #2
0
BOOL CEntitiesDialog::NeedTextNotify( UINT id, NMHDR * pNMHDR, LRESULT * pResult )
{
	TOOLTIPTEXT *pTTT = (TOOLTIPTEXT *)pNMHDR;
	const char *pDocField;
	CString EntityClassname;
	CString FieldName;
	int Index;
	CEntity *pEnt;

	// default return value is nothing...
	pTTT->szText[0] = '\0';

	// Fill the szText field with the documentation string for the current field.
	
	// Get current entity selection and retrieve its name
	Index = m_EntityCombo.GetCurSel ();
	if (Index == CB_ERR)
	{
		return FALSE;
	}
	Index = m_EntityCombo.GetItemData (Index);
	pEnt = &((*mEntityArray)[Index]);
	EntityClassname = pEnt->GetClassname ();

	m_PropertiesList.GetText (UglyGlobalItemId, FieldName);

	pDocField = EntityTable_GetEntityFieldDoc (Level_GetEntityDefs (pDoc->pLevel), EntityClassname, FieldName);
	if (pDocField != NULL)
	{
		strncpy (pTTT->szText, pDocField, sizeof (pTTT->szText));
		pTTT->szText[sizeof (pTTT->szText)-1] = '\0';
	}
	return FALSE;
}
コード例 #3
0
bool CServerOP4CTF::ClientIsImportant(CClient *pClient)
{
   // see if this player has the flag...
   CEntity *pEntity = NULL;
   while (pEntity = UTIL_FindEntityInSphere(pEntity, pClient->GetOrigin(), 10)) {
      if (!pEntity->GetOwner())
         continue; // reliability check
      if (*pEntity->GetOwner() == *pClient &&
         pEntity->GetOrigin() == pClient->GetOrigin() &&
         strcmp(pEntity->GetClassname(), "item_ctfflag") == 0)
         return true; // this player has the flag
   }
   return false; // this player doesn't have the flag
}
コード例 #4
0
void our_trie_iterator(KTrie<IEntityFactory_CE *> *pTrie, const char *name, IEntityFactory_CE *& obj, void *data)
{
	SourceHook::List<CEntity *> *cent_list = (SourceHook::List<CEntity *> *)data;
	int count = 0;
	SourceHook::List<CEntity *>::iterator _iter;
	CEntity *pInfo;
	for(_iter=cent_list->begin(); _iter!=cent_list->end(); _iter++)
	{
		pInfo = (*_iter);

		if(strcmp(name, pInfo->GetClassname()) == 0)
		{
			count++;
			continue;
		}
		IType *pType = GetType(pInfo->BaseEntity());
		IBaseType *pBase = pType->GetBaseType();

		do 
		{
			const char *classname = GetTypeName(pBase->GetTypeInfo());
			if(strcmp(classname, name) == 0)
			{
				count++;
			}
		} while (pBase->GetNumBaseClasses() && (pBase = pBase->GetBaseClass(0)));
		pType->Destroy();
	}

	if(strlen(name) < 7)
		META_CONPRINTF("%s:\t\t\t\t%d\n",name,count);
	else if(strlen(name) < 15)
		META_CONPRINTF("%s:\t\t\t%d\n",name,count);
	else if(strlen(name) < 23)
		META_CONPRINTF("%s:\t\t%d\n",name,count);
	else
		META_CONPRINTF("%s:\t%d\n",name,count);
}
コード例 #5
0
void CEntitiesDialog::OnDblclkPropertieslist() 
{
	// Double-click on the item...Edit it.
	mCurrentKey = m_PropertiesList.GetCurSel ();

	if (mCurrentKey != LB_ERR)
	{
		CEntity *Ent = &((*mEntityArray)[mCurrentEntity]);
		CString EntityTypeName = Ent->GetClassname ();
		CString KeyName;
		CString TheValue;

		m_PropertiesList.GetText (mCurrentKey, KeyName);
		Ent->GetKeyValue (KeyName, TheValue);

		
		TopType eType;
		
		if (EntityTable_GetEntityPropertyType (Level_GetEntityDefs (pDoc->pLevel), EntityTypeName, KeyName, &eType))
		{
			CDialog *pEditDialog = NULL;

			// Create the dialog that's appropriate for this type....
			switch (eType)
			{
				case T_INT :
					pEditDialog = new CIntKeyEditDlg (this, KeyName, &TheValue);
					break;
				case T_FLOAT :
					pEditDialog = new CFloatKeyEditDlg (this, KeyName, &TheValue);
					break;
				case T_COLOR :
					pEditDialog = new CColorKeyEditDlg (this, KeyName, &TheValue);
					break;
				case T_POINT :
					pEditDialog = new CPointKeyEditDlg (this, KeyName, &TheValue);
					break;
				case T_STRING :
					pEditDialog = new CKeyEditDlg (this, KeyName, &TheValue);
					break;
				case T_MODEL :
					pEditDialog = new CModelKeyEditDlg (this, Level_GetModelInfo (pDoc->pLevel)->Models, KeyName, &TheValue);
					break;
				case T_STRUCT :
					pEditDialog = new CStructKeyEditDlg (this, *Ent, KeyName, mEntityArray, &TheValue, Level_GetEntityDefs (pDoc->pLevel));
					break;
				case T_BOOLEAN :
					pEditDialog = new CBoolKeyEditDlg (this, KeyName, &TheValue);
					break;
				case T_PTR :
				default :
					// bad or unknown type
					assert (0);
					break;
			}

			if (pEditDialog != NULL)
			{
				int ModalResult = pEditDialog->DoModal ();

				delete pEditDialog;

				if (ModalResult == IDOK)
				{
					if (MultiEntityFlag)
					{
						// multiple entities--change this property on all of them
						int i;

						for (i = 0; i < mEntityArray->GetSize (); ++i)
						{
							CEntity *pEnt;

							pEnt = &(*mEntityArray)[i];
							if (pEnt->IsSelected ())
							{
								pEnt->SetKeyValue (KeyName, TheValue);
							}
						}
					}
					else
					{
						// update
						Ent->SetKeyValue (KeyName, TheValue);
					}
					FillInKeyValuePairs(mCurrentKey);
				}
			}
		}
	}
}
コード例 #6
0
//================================================================================
// This function fills in the key value pairs for the current dialog.
//================================================================================
void CEntitiesDialog::FillInKeyValuePairs(int Selection)
{
	// now get the actual entity number from that
	int Entity ;

//ASSERT( m_EntityCombo.GetItemData( m_EntityCombo.GetCurSel( ) ) == (DWORD)Entity ) ;
	Entity = m_EntityCombo.GetItemData( m_EntityCombo.GetCurSel( ) ) ;

	// now go through that entity and add key/value pairs
	// to the dialog
	m_PropertiesList.ResetContent();

	// what do we have here?
	if( Entity == LB_ERR ) 
	{
		mCurrentKey = LB_ERR;
		return;
	}

	CEntity *Ent = &((*mEntityArray)[Entity]);
	EntityPropertiesList const *pProps;

	// Get sorted list of published key/value pairs
	CString EntityClassname = Ent->GetClassname ();
	pProps = EntityTable_GetEntityPropertiesFromName (Level_GetEntityDefs (pDoc->pLevel), EntityClassname, ET_PUBLISHED);
	if (pProps != NULL)
	{
		// Add key/value pairs to the listbox
		for (int iProp = 0; iProp < pProps->NumProps; iProp++)
		{
			EntityProperty const *p;

			p = &(pProps->Props[iProp]);
			if (p->KeyNum == -1)
			{
				// a key number of -1 indicates the end of valid keys...
				break;
			}

			// if this key doesn't exist for this entity, then add it
			// and its default value...
			CString TheVal;
			if (!Ent->GetKeyValue (p->pKey, TheVal))
			{
				Ent->SetKeyValue (p->pKey, p->pValue);
			}

			if (p->published)
			{
				// add it to the listbox
				m_PropertiesList.AddString (p->pKey);
			}
		}
		EntityTable_ReleaseEntityProperties (pProps);
	}
	else
	{
		/*
		  We know nothing about this entity's type.
		  We have the key/value pairs, but we don't know what's supposed
		  to be published.  So we'll display "unknown type".
		*/
		m_PropertiesList.AddString ("Unknown Entity Type");
		Selection = LB_ERR;
	}

	// set the current
	m_PropertiesList.SetCurSel (Selection);
}