コード例 #1
0
//-----------------------------------------------------------------------------
// Call this to install a new panel type
//-----------------------------------------------------------------------------
void CPanelMetaClassMgrImp::InstallPanelType( const char* pPanelName, IPanelFactory* pFactory )
{
	Assert( pPanelName && pFactory );
	
	// convert to lowercase
	int len = Q_strlen(pPanelName) + 1;
	char* pTemp = (char*)stackalloc( len );
	Q_strncpy( pTemp, pPanelName, len );
	Q_strnlwr( pTemp, len );

	m_PanelTypeDict.Insert( pTemp, pFactory );

	stackfree( pTemp );
}
コード例 #2
0
//-----------------------------------------------------------------------------
// Finds all .VMT files in a particular directory
//-----------------------------------------------------------------------------
bool CMaterial::LoadMaterialsInDirectory( char const* pDirectoryName, int nDirectoryNameLen,
						IMaterialEnumerator *pEnum, int nContext, int nFlags )
{
	//Assert( Q_strnicmp( pDirectoryName, "materials", 9 ) == 0 );

	char *pWildCard;
	pWildCard = ( char * )stackalloc( nDirectoryNameLen + 7 );
	Q_snprintf( pWildCard, nDirectoryNameLen + 7, "%s/*.vmt", pDirectoryName );

	if ( !g_pFileSystem )
	{
		return false;
	}

	FileFindHandle_t findHandle;
	const char *pFileName = g_pFullFileSystem->FindFirstEx( pWildCard, "GAME", &findHandle );
	while( pFileName )
	{
		if( !g_pFullFileSystem->FindIsDirectory( findHandle ) )
		{
			// Strip off the 'materials/' part of the material name.
			char *pFileNameWithPath;
			int nAllocSize = nDirectoryNameLen + Q_strlen(pFileName) + 2;
			pFileNameWithPath = (char *)stackalloc( nAllocSize );
			Q_snprintf(	pFileNameWithPath, nAllocSize, "%s/%s", &pDirectoryName[MATERIAL_PREFIX_LEN], pFileName ); 
			Q_strnlwr( pFileNameWithPath, nAllocSize );

			// Strip off the extension...
			char *pExt = Q_strrchr( pFileNameWithPath, '.');
			if (pExt)
				*pExt = 0;

			if (!pEnum->EnumMaterial( pFileNameWithPath, nContext ))
			{
				return false;
			}
		}
		pFileName = g_pFullFileSystem->FindNext( findHandle );
	}
	g_pFullFileSystem->FindClose( findHandle );
	return true;
}