当前位置: 首页>>代码示例>>C++>>正文


C++ CEntity::SetKeyValue方法代码示例

本文整理汇总了C++中CEntity::SetKeyValue方法的典型用法代码示例。如果您正苦于以下问题:C++ CEntity::SetKeyValue方法的具体用法?C++ CEntity::SetKeyValue怎么用?C++ CEntity::SetKeyValue使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在CEntity的用法示例。


在下文中一共展示了CEntity::SetKeyValue方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: OnDblclkPropertieslist

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);
				}
			}
		}
	}
}
开发者ID:RealityFactory,项目名称:Genesis3D-Tools,代码行数:91,代码来源:EntitiesDialog.cpp

示例2: FillInKeyValuePairs

//================================================================================
// 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);
}
开发者ID:RealityFactory,项目名称:Genesis3D-Tools,代码行数:72,代码来源:EntitiesDialog.cpp


注:本文中的CEntity::SetKeyValue方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。