Exemplo n.º 1
0
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();
   }
}
Exemplo n.º 2
0
inline bool isGoodDirectoryCache(dirent* entry)
{
   return (entry->d_type == DT_DIR                          // is a dir
           && dStrcmp(entry->d_name,".") != 0                 // not here
           && dStrcmp(entry->d_name,"..") != 0                // not parent
           && !Platform::isExcludedDirectory(entry->d_name)); // not excluded
}
Exemplo n.º 3
0
void Settings::remove(const UTF8 *settingName, bool includeDefaults)
{
    // Fetch Dynamic-Field Dictionary.
    SimFieldDictionary* pFieldDictionary = getFieldDictionary();

    // Any Field Dictionary?
    if ( pFieldDictionary == NULL )
    {
        // No, so we're done.
        return;
    }

	 String name;
    buildGroupString(name, settingName);
    StringTableEntry nameEntry = StringTable->insert(name.c_str());
	 StringTableEntry nameEntryDefault = StringTable->insert( String::ToString("%s%s",name.c_str(), "_default") );

    // Iterate fields.
    for ( SimFieldDictionaryIterator itr(pFieldDictionary); *itr; ++itr )
    {
        // Fetch Field Entry.
        SimFieldDictionary::Entry* fieldEntry = *itr;

        // is this a field of our current group
        if ( (dStrcmp(nameEntry, "") == 0) || 
					dStrcmp( nameEntry, fieldEntry->slotName ) == 0 ||
					(includeDefaults && dStrcmp( nameEntryDefault, fieldEntry->slotName ) == 0) )
        {
            // Yes, so remove it.
            pFieldDictionary->setFieldValue( fieldEntry->slotName, "" );
        }
    }
}
Exemplo n.º 4
0
//-----------------------------------------------------------------------------
// utility for platform::hasSubDirectory() and platform::dumpDirectories()
// ensures that the entry is a directory, and isnt on the ignore lists.
inline bool isGoodDirectory(const char* path)
{
   char name[80];
   getDirectoryName(path, name);
   return (Platform::isDirectory(path)                          // is a dir
           && dStrcmp(name,".") != 0                 // not here
           && dStrcmp(name,"..") != 0                // not parent
           && !Platform::isExcludedDirectory(name)); // not excluded
}
Exemplo n.º 5
0
void ParamsDefHLSL::assignConstantNumbers()
{

   // Here we assign constant number to uniform vars, sorted 
   // by their update frequency.

   U32 mCurrConst = 0;
   for (U32 bin = cspUninit+1; bin < csp_Count; bin++)
   {   
      // Find all the uniform variables that are part of this group and assign constant numbers
      for( U32 i=0; i<LangElement::elementList.size(); i++)
      {
         Var *var = dynamic_cast<Var*>(LangElement::elementList[i]);
         if( var )
         {            
            bool shaderConst = var->uniform && !var->sampler && !var->texture;
            AssertFatal((!shaderConst) || var->constSortPos != cspUninit, "Const sort position has not been set, variable will not receive a constant number!!");
            if( shaderConst && var->constSortPos == bin)
            {
               var->constNum = mCurrConst;
               // Increment our constant number based on the variable type
               if (dStrcmp((const char*)var->type, "float4x4") == 0)
               {
                  mCurrConst += (4 * var->arraySize);
               }
               else
               {
                  if (dStrcmp((const char*)var->type, "float3x3") == 0)
                  {
                     mCurrConst += (3 * var->arraySize);
                  }
                  else
                  {
                     if (dStrcmp((const char*)var->type, "float4x3") == 0)
                     {
                        mCurrConst += (3 * var->arraySize);
                     }
                     else
                     {
                        mCurrConst += var->arraySize;
                     }
                  }
               }
            }
         }
      }
   }
}
void GuiTextEditCtrl::updateHistory( StringBuffer *inTxt, bool moveIndex )
{
   if(!mHistorySize)
      return;

   const UTF16* txt = inTxt->getPtr();
   
   // Reject empty strings.

   if( !txt || !txt[ 0 ] )
      return;

   // see if it's already in
   if(mHistoryLast == -1 || dStrcmp(txt, mHistoryBuf[mHistoryLast]))
   {
      if(mHistoryLast == mHistorySize-1) // we're at the history limit... shuffle the pointers around:
      {
         UTF16 *first = mHistoryBuf[0];
         for(U32 i = 0; i < mHistorySize - 1; i++)
            mHistoryBuf[i] = mHistoryBuf[i+1];
         mHistoryBuf[mHistorySize-1] = first;
         if(mHistoryIndex > 0)
            mHistoryIndex--;
      }
      else
         mHistoryLast++;

      inTxt->getCopy(mHistoryBuf[mHistoryLast], GuiTextCtrl::MAX_STRING_LENGTH);
      mHistoryBuf[mHistoryLast][GuiTextCtrl::MAX_STRING_LENGTH] = '\0';
   }

   if(moveIndex)
      mHistoryIndex = mHistoryLast + 1;
}
Exemplo n.º 7
0
bool GuiInspectorField::hasSameValueInAllObjects()
{
   char value1[ 2048 ];
   
   // Get field value from first object.
   
   const char* data1 = getData( 0 );
   if( data1 )
   {
      dStrncpy( value1, data1, sizeof( value1 ) );
      value1[ sizeof( value1 ) - 1 ] = 0;
   }
   else
      value1[ 0 ] = 0;
   
   // Check if all other objects have the same value.

   const U32 numObjects = mInspector->getNumInspectObjects();
   for( U32 i = 1; i < numObjects; ++ i )
   {
      const char* value2 = getData( i );
      if( !value2 )
         value2 = "";

      if( dStrcmp( value1, value2 ) != 0 )
         return false;
   }
         
   return true;
}
Exemplo n.º 8
0
/// Safe form of dStrcmp: checks both strings for NULL before comparing
bool dStrEqual(const char* str1, const char* str2)
{
   if (!str1 || !str2)
      return false;
   else
      return (dStrcmp(str1, str2) == 0);
}
Exemplo n.º 9
0
//--------------------------------------
StringTableEntry _StringTable::insert(const char* _val, const bool caseSens)
{
   // Added 3/29/2007 -- If this is undesirable behavior, let me know -patw
   const char *val = _val;
   if( val == NULL )
      val = "";
   //-

   Node **walk, *temp;
   U32 key = hashString(val);
   walk = &buckets[key % numBuckets];
   while((temp = *walk) != NULL)   {
      if(caseSens && !dStrcmp(temp->val, val))
         return temp->val;
      else if(!caseSens && !dStricmp(temp->val, val))
         return temp->val;
      walk = &(temp->next);
   }
   char *ret = 0;
   if(!*walk) {
      *walk = (Node *) mempool.alloc(sizeof(Node));
      (*walk)->next = 0;
      (*walk)->val = (char *) mempool.alloc(dStrlen(val) + 1);
      dStrcpy((*walk)->val, val);
      ret = (*walk)->val;
      itemCount ++;
   }
   if(itemCount > 2 * numBuckets) {
      resize(4 * numBuckets - 1);
   }
   return ret;
}
Exemplo n.º 10
0
void SimDataBlockEvent::unpack(NetConnection *cptr, BitStream *bstream)
{
   if(bstream->readFlag())
   {
      mProcess = true;
      id = bstream->readInt(DataBlockObjectIdBitSize) + DataBlockObjectIdFirst;
      S32 classId = bstream->readClassId(NetClassTypeDataBlock, cptr->getNetClassGroup());
      mIndex = bstream->readInt(DataBlockObjectIdBitSize);
      mTotal = bstream->readInt(DataBlockObjectIdBitSize + 1);
      
      SimObject* ptr;
      if( Sim::findObject( id, ptr ) )
      {
         // An object with the given ID already exists.  Make sure it has the right class.
         
         AbstractClassRep* classRep = AbstractClassRep::findClassRep( cptr->getNetClassGroup(), NetClassTypeDataBlock, classId );
         if( classRep && dStrcmp( classRep->getClassName(), ptr->getClassName() ) != 0 )
         {
            Con::warnf( "A '%s' datablock with id: %d already existed. "
                        "Clobbering it with new '%s' datablock from server.",
                        ptr->getClassName(), id, classRep->getClassName() );
            ptr->deleteObject();
            ptr = NULL;
         }
      }
      
      if( !ptr )
         ptr = ( SimObject* ) ConsoleObject::create( cptr->getNetClassGroup(), NetClassTypeDataBlock, classId );
         
      mObj = dynamic_cast< SimDataBlock* >( ptr );
      if( mObj != NULL )
      {
         #ifdef DEBUG_SPEW
         Con::printf(" - SimDataBlockEvent: unpacking event of type: %s", mObj->getClassName());
         #endif
         
         mObj->unpackData( bstream );
      }
      else
      {
         #ifdef DEBUG_SPEW
         Con::printf(" - SimDataBlockEvent: INVALID PACKET!  Could not create class with classID: %d", classId);
         #endif
         
         delete ptr;
         cptr->setLastError("Invalid packet in SimDataBlockEvent::unpack()");
      }

#ifdef TORQUE_DEBUG_NET
      U32 checksum = bstream->readInt(32);
      AssertISV( (checksum ^ DebugChecksum) == (U32)classId,
         avar("unpack did not match pack for event of class %s.",
            mObj->getClassName()) );
#endif

   }
}
Exemplo n.º 11
0
void GuiPopupMenuTextListCtrl::onRenderCell(Point2I offset, Point2I cell, bool selected, bool mouseOver)
{
    if (dStrcmp(mList[cell.y].text + 3, "-\t")) //  Was: dStrcmp(mList[cell.y].text + 2, "-\t")) but has been changed to take into account the submenu flag
        Parent::onRenderCell(offset, cell, selected, mouseOver);
    else
    {
        S32 yp = offset.y + mCellSize.y / 2;
        GFX->getDrawUtil()->drawLine(offset.x, yp, offset.x + mCellSize.x, yp, ColorI(128, 128, 128));
        GFX->getDrawUtil()->drawLine(offset.x, yp + 1, offset.x + mCellSize.x, yp + 1, ColorI(255, 255, 255));
    }
    // now see if there's a bitmap...
    U8 idx = mList[cell.y].text[0];
    if (idx != 1)
    {
        // there's a bitmap...
        U32 index = U32(idx - 2) * 3;
        if (!mList[cell.y].active)
            index += 2;
        else if (selected || mouseOver)
            index++;

        if (mProfile->mBitmapArrayRects.size() > index)
        {
            RectI rect = mProfile->mBitmapArrayRects[index];
            Point2I off = maxBitmapSize - rect.extent;
            off /= 2;

            GFX->getDrawUtil()->clearBitmapModulation();
            GFX->getDrawUtil()->drawBitmapSR(mProfile->mTextureObject, offset + off, rect);
        }
    }

    //  Check if this is a submenu
    idx = mList[cell.y].text[1];
    if (idx != 1)
    {
        // This is a submenu, so draw an arrow
        S32 left = offset.x + mCellSize.x - 12;
        S32 right = left + 8;
        S32 top = mCellSize.y / 2 + offset.y - 4;
        S32 bottom = top + 8;
        S32 middle = top + 4;

        PrimBuild::begin(GFXTriangleList, 3);
        if (selected || mouseOver)
            PrimBuild::color(mProfile->mFontColorHL);
        else
            PrimBuild::color(mProfile->mFontColor);

        PrimBuild::vertex2i(left, top);
        PrimBuild::vertex2i(right, middle);
        PrimBuild::vertex2i(left, bottom);
        PrimBuild::end();
    }
}
Exemplo n.º 12
0
/**
 * What gets called when this gets created, different from constructor
 */
void AIClient::onAdd( const char *nameSpace ) {

   // This doesn't work...
   //
   if( dStrcmp( nameSpace, mNameSpace->mName ) ) {
      Con::linkNamespaces( mNameSpace->mName, nameSpace );
      mNameSpace = Con::lookupNamespace( nameSpace );
   }

   throwCallback( "onAdd" );
}
 bool Platform::hasSubDirectory(const char *pPath)
 {
   if (!pPath)
     return false;

   struct dirent *d;
   DIR           *dip;
   dip = opendir(pPath);
   if (dip == NULL)
     return false;

   while (d = readdir(dip))
     {
	bool isDir = false;
	if (d->d_type == DT_UNKNOWN)
	{
		char child [1024];
		if ((pPath[dStrlen(pPath) - 1] == '/'))
			dSprintf(child, 1024, "%s%s", pPath, d->d_name);
		else
			dSprintf(child, 1024, "%s/%s", pPath, d->d_name);
		isDir = Platform::isDirectory (child);
	}
	else if (d->d_type & DT_DIR)
		isDir = true;
	  	if( isDir )
	  	{
 	  	// Skip the . and .. directories
 	  	if (dStrcmp(d->d_name, ".") == 0 ||dStrcmp(d->d_name, "..") == 0)
 		    continue;
 		if (Platform::isExcludedDirectory(d->d_name))
 		    continue;
 		  Platform::clearExcludedDirectories();
 		  closedir(dip);
 		  return true;
 	}
     }
   closedir(dip);
   Platform::clearExcludedDirectories();
   return false;
 }
Exemplo n.º 14
0
Node* MaterialWindow::findNode(const char* name)
{
    for(S32 n = 0; n < nodeList.size(); ++n )
    {
        Node* node = &nodeList[n];
        if ( dStrcmp(node->name, name) == 0 )
        {
            return node;
        }
    }
    return NULL;
}
Exemplo n.º 15
0
//--------------------------------------------------------------------------
// Find element of specified name
//--------------------------------------------------------------------------
LangElement * LangElement::find( const char *name )
{
   for( U32 i=0; i<elementList.size(); i++ )
   {
      if( !dStrcmp( (char*)elementList[i]->name, name ) )
      {
         return elementList[i];
      }
   }
   
   return NULL;
}
Exemplo n.º 16
0
Connection* MaterialWindow::findConnectionFromInput(const char* name, U32 index)
{
    for(S32 n = 0; n < connectionList.size(); ++n )
    {
        Connection* connection = &connectionList[n];
        if ( dStrcmp(connection->inputNodeName, name) == 0 )
        {
            if ( index == -1 || connection->inputIndex == index )
                return connection;
        }
    }
    return NULL;
}
Exemplo n.º 17
0
//--------------------------------------
bool Platform::isSubDirectory(const char *pParent, const char *pDir)
{
   if (!pParent || !*pDir)
      return false;

   const char* fileName = avar("%s/*", pParent);

   TempAlloc< TCHAR > file( dStrlen( fileName ) + 1 );
   TempAlloc< TCHAR > dir( dStrlen( pDir ) + 1 );

#ifdef UNICODE
   convertUTF8toUTF16( fileName, file, file.size );
   convertUTF8toUTF16( pDir, dir, dir.size );
#else
   dStrcpy( file, fileName );
   dStrcpy( dir, pDir );
#endif

   backslash( file );
   backslash( dir );

   // this is somewhat of a brute force method but we need to be 100% sure
   // that the user cannot enter things like ../dir or /dir etc,...
   WIN32_FIND_DATA findData;
   HANDLE handle = FindFirstFile(file, &findData);
   if (handle == INVALID_HANDLE_VALUE)
      return false;
   do
   {
      // if it is a directory...
      if (findData.dwFileAttributes &
          (FILE_ATTRIBUTE_DIRECTORY|
           FILE_ATTRIBUTE_OFFLINE|
           FILE_ATTRIBUTE_SYSTEM|
           FILE_ATTRIBUTE_TEMPORARY) )
      {
         //FIXME: this has to be dStrcasecmp but there's no implementation for Unicode

         // and the names match
         if (dStrcmp(dir, findData.cFileName ) == 0)
         {
            // then we have a real sub directory
            FindClose(handle);
            return true;
         }
      }
   }while(FindNextFile(handle, &findData));

   FindClose(handle);
   return false;
}
Exemplo n.º 18
0
const UTF8 *Settings::value(const UTF8 *settingName, const UTF8 *defaultValue)
{
   String name;
   buildGroupString(name, settingName);

   StringTableEntry nameEntry = StringTable->insert(name.c_str());
   name += "_default";
   StringTableEntry defaultNameEntry = StringTable->insert(name.c_str());

   // we do this setModStaticFields call to make sure our get/set calls
   // don't grab a regular field, don't want to stomp anything
   setModStaticFields(false);  
   const UTF8 *value = getDataField(nameEntry, NULL);
   const UTF8 *storedDefaultValue = getDataField(defaultNameEntry, NULL);
   setModStaticFields(true);

   if(dStrcmp(value, "") != 0)
      return value;
   else if(dStrcmp(storedDefaultValue, "") != 0)
      return storedDefaultValue;
   else
	  return defaultValue;
}
Exemplo n.º 19
0
//--------------------------------------
StringTableEntry _StringTable::lookup(const char* val, const bool  caseSens)
{
   Node **walk, *temp;
   U32 key = hashString(val);
   walk = &buckets[key % numBuckets];
   while((temp = *walk) != NULL)   {
      if(caseSens && !dStrcmp(temp->val, val))
            return temp->val;
      else if(!caseSens && !dStricmp(temp->val, val))
         return temp->val;
      walk = &(temp->next);
   }
   return NULL;
}
Exemplo n.º 20
0
//--------------------------------------
void AbstractClassRep::registerClassRep(AbstractClassRep* in_pRep)
{
   AssertFatal(in_pRep != NULL, "AbstractClassRep::registerClassRep was passed a NULL pointer!");

#ifdef TORQUE_DEBUG  // assert if this class is already registered.
   for(AbstractClassRep *walk = classLinkList; walk; walk = walk->nextClass)
   {
      AssertFatal(dStrcmp(in_pRep->mClassName, walk->mClassName),
         "Duplicate class name registered in AbstractClassRep::registerClassRep()");
   }
#endif

   in_pRep->nextClass = classLinkList;
   classLinkList = in_pRep;
}
Exemplo n.º 21
0
void TSShapeInstance::setMeshForceHidden( const char *meshName, bool hidden )
{
   Vector<MeshObjectInstance>::iterator iter = mMeshObjects.begin();
   for ( ; iter != mMeshObjects.end(); iter++ )
   {
      S32 nameIndex = iter->object->nameIndex;
      const char *name = mShape->names[ nameIndex ];

      if ( dStrcmp( meshName, name ) == 0 )
      {
         iter->forceHidden = hidden;
         return;
      }
   }
}
Exemplo n.º 22
0
bool NavPath::setProtectedTo(void *obj, const char *index, const char *data)
{
   NavPath *object = static_cast<NavPath*>(obj);

   if(dStrcmp(data, ""))
   {
      object->mToSet = true;
      return true;
   }
   else
   {
      object->mToSet = false;
      return false;
   }
}
Exemplo n.º 23
0
void GuiInspectorDynamicField::setData( const char* data, bool callbacks )
{
   if ( mDynField == NULL )
      return;
   
   const U32 numTargets = mInspector->getNumInspectObjects();
   if( callbacks && numTargets > 1 )
   { mInspector->beginCompoundUndo_callback(); }
      
   // Setting an empty string will kill the field.
   const bool isRemoval = !data[ 0 ];
      
   for( U32 i = 0; i < numTargets; ++ i )
   {
      SimObject* target = mInspector->getInspectObject( i );

      // Callback on the inspector when the field is modified
      // to allow creation of undo/redo actions.
      const char *oldData = target->getDataField( mDynField->slotName, NULL );
      if ( !oldData )
         oldData = "";
      if ( dStrcmp( oldData, data ) != 0 )
      {
         target->inspectPreApply();
         
         if( callbacks )
         {
            if( isRemoval )
            { mInspector->onFieldRemoved_callback( target->getIdString(), mDynField->slotName ); }
            else
            { mInspector->onInspectorFieldModified_callback( target->getIdString(), mDynField->slotName,"(null)", oldData, data ); }
         }

         target->setDataField( mDynField->slotName, NULL, data );

         // give the target a chance to validate
         target->inspectPostApply();
      }
   }
   
   if( callbacks && numTargets > 1 )
   { mInspector->endCompoundUndo_callback(); }

   // Force our edit to update
   updateValue();
}
 //-----------------------------------------------------------------------------
 bool Platform::isSubDirectory(const char *pParent, const char *pDir)
 {
    if (!pParent || !*pDir)
       return false;

    // this is somewhat of a brute force method but we need to be 100% sure
    // that the user cannot enter things like ../dir or /dir etc,...
    DIR *directory;

    directory = opendir(pParent);
    if (directory == NULL)
       return false;

    struct dirent *fEntry;
    fEntry = readdir(directory);
    if ( fEntry == NULL )
    {
       closedir(directory);
       return false;
    }

    do
    {
       char dirBuf[MaxPath];
       struct stat fStat;

       dSprintf(dirBuf, sizeof(dirBuf), "%s/%s", pParent, fEntry->d_name);
       if (stat(dirBuf, &fStat) < 0)
          continue;
       // if it is a directory...
       if ( (fStat.st_mode & S_IFMT) == S_IFDIR)
       {
          // and the names match
          if (dStrcmp(pDir, fEntry->d_name ) == 0)
          {
             // then we have a real sub directory
             closedir(directory);
             return true;
          }
       }
    } while( (fEntry = readdir(directory)) != NULL );

    closedir(directory);
    return false;
 }
Exemplo n.º 25
0
void SimDataBlockEvent::process(NetConnection *cptr)
{
   if(mProcess)
   {
      //call the console function to set the number of blocks to be sent
      Con::executef("onDataBlockObjectReceived", Con::getIntArg(mIndex), Con::getIntArg(mTotal));

      SimDataBlock* obj = NULL;
      String &errorBuffer = NetConnection::getErrorBuffer();

      if( Sim::findObject( id,obj ) && dStrcmp( obj->getClassName(),mObj->getClassName() ) == 0 )
      {
         U8 buf[1500];
         BitStream stream(buf, 1500);
         mObj->packData(&stream);
         stream.setPosition(0);
         obj->unpackData(&stream);
         obj->preload(false, errorBuffer);
      }
      else
      {
         if( obj != NULL )
         {
            Con::warnf( "A '%s' datablock with id: %d already existed. "
                        "Clobbering it with new '%s' datablock from server.",
                        obj->getClassName(), id, mObj->getClassName() );
            obj->deleteObject();
         }

         bool ret = mObj->registerObject(id);

         if(ret)
         {
            cptr->addObject(mObj);

            GameConnection *conn = dynamic_cast<GameConnection *>(cptr);
            if(conn)
            {
               conn->preloadDataBlock(mObj);
               mObj = NULL;
            }
         }
      }
   }
}
Exemplo n.º 26
0
void MenuBar::updateMenuBar(PopupMenu *popupMenu /* = NULL */)
{
   //if(! isAttachedToCanvas())
   //   return;   

   GuiPlatformGenericMenuBar* menuBarGui = _FindMenuBarCtrl();
   popupMenu->mData->mMenuBar = this;

   AssertFatal( dStrcmp( popupMenu->mData->mMenuGui->text, popupMenu->getBarTitle() ) == 0, "");
   GuiMenuBar::Menu* menuGui = menuBarGui->findMenu( popupMenu->getBarTitle() );
   if(!menuGui)
   {
      menuBarGui->addMenu( popupMenu->mData->mMenuGui );
      menuGui = menuBarGui->findMenu( popupMenu->getBarTitle() );
   }

   PlatformPopupMenuData::mMenuMap[ menuGui ] = popupMenu;
}
Exemplo n.º 27
0
void TerrCell::preloadMaterials()
{
   PROFILE_SCOPE( TerrCell_PreloadMaterials );

   // If we have a VB then we need a material.
   if ( mVertexBuffer.isValid() )
   {
      TerrainCellMaterial *material = getMaterial();
      material->getReflectMat();

      if (  GFX->getPixelShaderVersion() > 2.0f && 
            dStrcmp( LIGHTMGR->getId(), "BLM" ) != 0)
         material->getPrePassMat();
   }

   for ( U32 i = 0; i < 4; i++ )
      if ( mChildren[i] ) 
         mChildren[i]->preloadMaterials();
}
Exemplo n.º 28
0
void ProjectManager::refreshChoices()
{
   if (!isProjectLoaded())
      return;

   mTextureAssetChoices.Clear();
   mTextureAssetChoices.Add("", 0);

   Vector<const AssetDefinition*> assetDefinitions = Torque::AssetDatabaseLink.getDeclaredAssets();

   // Iterate sorted asset definitions.
   for (Vector<const AssetDefinition*>::iterator assetItr = assetDefinitions.begin(); assetItr != assetDefinitions.end(); ++assetItr)
   {
      // Fetch asset definition.
      const AssetDefinition* pAssetDefinition = *assetItr;

      // Populate TextureAsset choices menu.
      if (dStrcmp(pAssetDefinition->mAssetType, "TextureAsset") == 0)
         mTextureAssetChoices.Add(pAssetDefinition->mAssetId, mTextureAssetChoices.GetCount());
   }
}
Exemplo n.º 29
0
U32 NetStringTable::addString(const char *string)
{
   U32 hash = _StringTable::hashString(string);
   U32 bucket = hash % HashTableSize;
   for(U32 walk = hashTable[bucket];walk; walk = table[walk].next)
   {
      if(!dStrcmp(table[walk].string, string))
      {
         table[walk].refCount++;
         return walk;
      }
   }
   U32 e = firstFree;
   firstFree = table[e].next;
   if(firstFree == InvalidEntry)
   {
      // in this case, we should expand the table for next time...
      U32 newSize = size * 2;
      table = (Entry *) dRealloc(table, newSize * sizeof(Entry));
      for(U32 i = size; i < newSize; i++)
      {
         table[i].next = i + 1;
         table[i].refCount = 0;
         table[i].scriptRefCount = 0;
      }
      firstFree = size;
      table[newSize - 1].next = InvalidEntry;
      size = newSize;
   }
   table[e].refCount++;
   table[e].string = (char *) allocator->alloc(dStrlen(string) + 1);
   dStrcpy(table[e].string, string);
   table[e].next = hashTable[bucket];
   hashTable[bucket] = e;
   table[e].link = firstValid;
   table[firstValid].prevLink = e;
   firstValid = e;
   table[e].prevLink = 0;
   return e;
}
Exemplo n.º 30
0
static bool isFnOk( const char *name)
{
   bool ok = false;

   // JMQ: these are specific to torque's d3d->gl wrapper.  They are not used under linux.
   if (dStrcmp(name, "glAvailableVertexBufferEXT")==0)
      ok = true;
   else if (dStrcmp(name, "glAllocateVertexBufferEXT")==0)
      ok = true;
   else if (dStrcmp(name, "glLockVertexBufferEXT")==0)
      ok = true;
   else if (dStrcmp(name, "glUnlockVertexBufferEXT")==0)
      ok = true;
   else if (dStrcmp(name, "glSetVertexBufferEXT")==0)
      ok = true;
   else if (dStrcmp(name, "glOffsetVertexBufferEXT")==0)
      ok = true;
   else if (dStrcmp(name, "glFillVertexBufferEXT")==0)
      ok = true;
   else if (dStrcmp(name, "glFreeVertexBufferEXT")==0)
      ok = true;

   return ok;
}