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


C++ SimObject::isField方法代码示例

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


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

示例1: renameField

void GuiInspectorDynamicField::renameField( const char* newFieldName )
{
   newFieldName = StringTable->insert( newFieldName );
   
   if ( mDynField == NULL || mParent == NULL || mEdit == NULL )
   {
      Con::warnf("GuiInspectorDynamicField::renameField - No target object or dynamic field data found!" );
      return;
   }

   if ( !newFieldName )
   {
      Con::warnf("GuiInspectorDynamicField::renameField - Invalid field name specified!" );
      return;
   }

   // Only proceed if the name has changed
   if ( dStricmp( newFieldName, getFieldName() ) == 0 )
      return;
      
   // Grab a pointer to our parent and cast it to GuiInspectorDynamicGroup
   GuiInspectorDynamicGroup *group = dynamic_cast<GuiInspectorDynamicGroup*>(mParent);
   if ( group == NULL )
   {
      Con::warnf("GuiInspectorDynamicField::renameField - Unable to locate GuiInspectorDynamicGroup parent!" );
      return;
   }
   
   const U32 numTargets = mInspector->getNumInspectObjects();
   if( numTargets > 1 )
   { mInspector->onBeginCompoundEdit_callback(); }
      
   const char* oldFieldName = getFieldName();
   SimFieldDictionary::Entry* newEntry = NULL;
   
   for( U32 i = 0; i < numTargets; ++ i )
   {
      SimObject* target = mInspector->getInspectObject( i );
      
      // Make sure the new field is not already defined as a static field
      // on the object.
      
      if( target->isField( newFieldName ) )
      {
         // New field is already defined.  If we can, let the scripts handle
         // the error.  Otherwise, just emit an error on the console and proceed.
         
         if( numTargets == 1 )
         { mInspector->onFieldRenameAlreadyDefined_callback( target->getIdString(), oldFieldName, newFieldName ); }
         else
         { 
             Con::errorf( "GuiInspectorDynamicField::renameField - field '%s' is already defined on %i:%s (%s)", 
               newFieldName, target->getId(), target->getClassName(), target->getName() );
         }
               
         // Reset the text entry.
               
         if( mRenameCtrl )
            mRenameCtrl->setText( oldFieldName );
            
         continue;
      }
      
      char currentValue[1024] = {0};
      // Grab our current dynamic field value (we use a temporary buffer as this gets corrupted upon Con::eval)
      dSprintf( currentValue, sizeof( currentValue ), "%s", target->getDataField( oldFieldName, NULL ) );

      // Unset the old field and set the new field.
      
      target->setDataField( oldFieldName, NULL, "" );
      target->setDataField( newFieldName, NULL, currentValue );

      // Notify script.
      
      mInspector->onFieldRenamed_callback( target->getIdString(), oldFieldName, newFieldName );
      
      // Look up the new SimFieldDictionary entry.
      
      if( !newEntry )
      {
         newEntry = target->getFieldDictionary()->findDynamicField( newFieldName );
         if( !newEntry )
         {
            Con::warnf( "GuiInspectorDynamicField::renameField - could not find new field '%s' on object %i:%s (%s)",
               newFieldName, target->getId(), target->getClassName(), target->getName() );
         }
         
         mDynField = newEntry;
      }
   }

   if( numTargets > 1 )
   { mInspector->onEndCompoundEdit_callback(); }
      
   // Lastly we need to reassign our validate field for our value edit control
   char szBuffer[1024];
   dSprintf( szBuffer, sizeof( szBuffer ), "%d.apply(%d.getText());", getId(), mEdit->getId() );
   mEdit->setField("validate", szBuffer );

   if( mDeleteButton )
//.........这里部分代码省略.........
开发者ID:souxiaosou,项目名称:OmniEngine.Net,代码行数:101,代码来源:dynamicField.cpp


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