void Settings::setDefaultValue(const UTF8 *settingName, const UTF8 *settingValue, const UTF8 *settingType)
{
   String baseName;
   buildGroupString(baseName, settingName);
   String name = baseName + "_default";
   StringTableEntry nameEntry = StringTable->insert(name.c_str());
   String type = baseName + "_type";
   StringTableEntry typeEntry = StringTable->insert(type.c_str());

   setModStaticFields(false);
   setDataField(nameEntry, NULL, settingValue);
   setDataField(typeEntry, NULL, settingType);
   setModStaticFields(true);
}
void Settings::readLayer(SimXMLDocument *document, String groupStack)
{
   for(S32 i=0; document->pushChildElement(i); i++)
   {
	  const UTF8 *type = document->elementValue();
	  const UTF8 *name = document->attribute("name");
	  const UTF8 *value = document->getText();
	  
	  if(dStrcmp(type, "Group") == 0)
	  {
		 String newStack = groupStack;

		 if(!groupStack.isEmpty())
			newStack += "/";

		 newStack += name;
         readLayer(document, newStack);
	  } else if(dStrcmp(type, "Setting") == 0)
	  {
		 String nameString = groupStack;
         
		 if(!groupStack.isEmpty())
		    nameString += "/";

         nameString += name;
         setDataField(StringTable->insert(nameString.c_str()), NULL, value);
	  }
	  
	  document->popElement();
   }
}
Beispiel #3
0
GuiGradientSwatchCtrl::GuiGradientSwatchCtrl()
{
	setPosition(0, 0);
	setExtent(14, 14);
	mMouseDownPosition = Point2I(0, 0);
	mSwatchColor = ColorI( 1, 1, 1, 1 );
	mColorFunction = StringTable->insert("getColorF");
	setDataField( StringTable->insert("Profile"), NULL, "GuiInspectorSwatchButtonProfile" );
}
void Settings::setValue(const UTF8 *settingName, const UTF8 *settingValue)
{
   String name;
   buildGroupString(name, settingName);
   StringTableEntry nameEntry = StringTable->insert(name.c_str());

   setModStaticFields(false);
   setDataField(nameEntry, NULL, settingValue);
   setModStaticFields(true);
}
GuiSwatchButtonCtrl::GuiSwatchButtonCtrl()
   : mSwatchColor(1, 1, 1, 1), mUseSRGB(false)
{
   mButtonText = StringTable->insert( "" );   
   setExtent(140, 30);
   
   static StringTableEntry sProfile = StringTable->insert( "profile" );
   setDataField( sProfile, NULL, "GuiInspectorSwatchButtonProfile" );

   mGridBitmap = "tools/gui/images/transp_grid";
}
Beispiel #6
0
bool GuiInspectorGroup::onAdd()
{
   setDataField( StringTable->insert("profile"), NULL, "GuiInspectorGroupProfile" );

   if( !Parent::onAdd() )
      return false;

   // Create our inner controls. Allow subclasses to provide other content.
   if(!createContent())
      return false;

   inspectGroup();

   return true;
}
bool SimObject::readObject(Stream *stream)
{
   const char *name = stream->readSTString(true);
   if(name && *name)
      assignName(name);

   U32 numFields;
   stream->read(&numFields);

   for(S32 i = 0;i < numFields;i++)
   {
      const char *fieldName = stream->readSTString();
      const char *data = stream->readSTString();

      setDataField(fieldName, NULL, data);
   }
   return true;
}
Beispiel #8
0
BehaviorInstance::BehaviorInstance( BehaviorTemplate* pTemplate ) :
    mTemplate( pTemplate ),
    mBehaviorOwner( NULL ),
    mBehaviorId( 0 )
{
    if ( pTemplate != NULL )
    {
        // Fetch field prototype count.
        const U32 fieldCount = pTemplate->getBehaviorFieldCount();

        // Set field prototypes.
        for( U32 index = 0; index < fieldCount; ++index )
        {        
            // Fetch fields.
            BehaviorTemplate::BehaviorField* pField = pTemplate->getBehaviorField( index );

            // Set cloned field.
            setDataField( pField->mName, NULL, pField->mDefaultValue );
        }
    }
}
Beispiel #9
0
bool SFXEmitter::onAdd()
{
   if( !Parent::onAdd() )
      return false;

   if( isServerObject() )
   {
      // Validate the data we'll be passing across
      // the network to the client.
      mDescription.validate();
      
      // Read an old 'profile' field for backwards-compatibility.
      
      if( !mTrack )
      {
         static const char* sProfile = StringTable->insert( "profile" );
         const char* profileName = getDataField( sProfile, NULL );
         if( profileName &&  profileName[ 0 ] )
         {
            if( !Sim::findObject( profileName, mTrack ) )
               Con::errorf( "SFXEmitter::onAdd - No SFXTrack '%s' in SFXEmitter '%i' (%s)", profileName, getId(), getName() );
            else
            {
               // Remove the old 'profile' field.
               setDataField( sProfile, NULL, "" );
            }
         }
      }

      // Convert a legacy 'channel' field, if we have one.
      
      static const char* sChannel = StringTable->insert( "channel" );
      const char* channelValue = getDataField( sChannel, NULL );
      if( channelValue && channelValue[ 0 ] )
      {
         const char* group = Con::evaluatef( "return sfxOldChannelToGroup( %s );", channelValue );
         SFXSource* sourceGroup;
         if( !Sim::findObject( group, sourceGroup ) )
            Con::errorf( "SFXEmitter::onAdd - could not resolve channel '%s' to SFXSource", channelValue );
         else
         {
            static const char* sSourceGroup = StringTable->insert( "sourceGroup" );
            setDataField( sSourceGroup, NULL, sourceGroup->getIdString() );
            
            // Remove the old 'channel' field.
            setDataField( sChannel, NULL, "" );
         }
      }
   }
   else
   {
      _update();

      // Do we need to start playback?
      if( mPlayOnAdd && mSource )
         mSource->play();
   }
   
   // Setup the bounds.

   mObjScale.set( mDescription.mMaxDistance, mDescription.mMaxDistance, mDescription.mMaxDistance );
   resetWorldBox();

   addToScene();
   return true;
}