Ejemplo n.º 1
0
void Draw_DecalSetName( int decal, char *name )
{
	while ( decal >= g_DecalLookup.Count() )
	{
		MEM_ALLOC_CREDIT();
		int idx = g_DecalLookup.AddToTail();
		g_DecalLookup[idx] = g_DecalDictionary.InvalidIndex();
	}

	FileNameHandle_t fnHandle = g_pFileSystem->FindOrAddFileName( name );
	int lookup = g_DecalDictionary.Find( fnHandle );
	if ( lookup == g_DecalDictionary.InvalidIndex() )
	{
		DecalEntry entry;
#ifdef _DEBUG
		int len = strlen(name) + 1;
		entry.m_pDebugName = new char[len];
		memcpy( entry.m_pDebugName, name, len );
#endif
		entry.material = GL_LoadMaterial( name, TEXTURE_GROUP_DECAL );
		entry.index = decal;

		lookup = g_DecalDictionary.Insert( fnHandle, entry );
	}
	else
	{
		g_DecalDictionary[lookup].index = decal;
	}

	g_DecalLookup[decal] = lookup;
}
Ejemplo n.º 2
0
std::string get_attr_name(int type, const CAttr _attr_array[], CUtlMap<int, int>& _attr_type_table)
{
    int index = _attr_type_table.Find(type);
    if (!_attr_type_table.IsValidIndex(index)) {
        return "";
    }
    return _attr_array[_attr_type_table[index]].attr_name;
}
Ejemplo n.º 3
0
int get_attr_type(std::string name, CUtlMap<CUtlSymbol, int>& _attr_name_table)
{
    CUtlSymbol symbol(name.c_str());
    int index = _attr_name_table.Find(symbol);
    if (!_attr_name_table.IsValidIndex(index)) {
        return 0;
    }
    return _attr_name_table[index];
}
Ejemplo n.º 4
0
bool CNameTextMgr::_AddText(char* szString, CUtlMap<CUtlSymbol, CUtlSymbol>& vec)
{
	CUtlSymbol symbol(szString);
	int index = vec.Find(symbol);
	if(vec.IsValidIndex(index))
	{
		LOGGER_ERROR("[NameText] Error:%s", szString);
		return false;
	}
	vec.Insert(symbol, symbol);
	return true;
}
Ejemplo n.º 5
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void Decal_Shutdown( void )
{
	for ( int index = g_DecalDictionary.FirstInorder(); index != g_DecalDictionary.InvalidIndex(); index = g_DecalDictionary.NextInorder(index) )
	{
		IMaterial *mat = g_DecalDictionary[index].material;
		if ( mat )
		{
			GL_UnloadMaterial( mat );
		}
#ifdef _DEBUG
		delete[] g_DecalDictionary[index].m_pDebugName;
#endif
	}
	g_DecalLookup.Purge();
	g_DecalDictionary.RemoveAll();
}
Ejemplo n.º 6
0
// called from cl_parse.cpp
// find the server side decal id given it's name.
// used for save/restore
int Draw_DecalIndexFromName( char *name, bool *found )
{
	Assert( found );

	FileNameHandle_t fnHandle = g_pFileSystem->FindOrAddFileName( name );
	int lookup = g_DecalDictionary.Find( fnHandle );
	if ( lookup == g_DecalDictionary.InvalidIndex() )
	{
		if ( found )
		{
			*found = false;
		}
		return 0;
	}

	if ( found )
	{
		*found = true;
	}
	return g_DecalDictionary[lookup].index;
}
Ejemplo n.º 7
0
bool init_attrs(const CAttr _attr_array[], uint32 _array_len, CUtlMap<int, int>& _attr_type_table, CUtlMap<CUtlSymbol, int>& _attr_name_table)
{
    SetDefLessFunc(_attr_type_table);
    SetDefLessFunc(_attr_name_table);

    for (uint32 i = 0; i < _array_len; i++)
    {
        int keyIndex = _attr_type_table.Find(_attr_array[i].attr_type);
        if (_attr_type_table.IsValidIndex(keyIndex))
        {
            Log.Error("[init_attrs] Init Attr Key Error:%d", _attr_array[i].attr_type);
            return false;
        }
        _attr_type_table.Insert(_attr_array[i].attr_type, i);

        CUtlSymbol symbol(_attr_array[i].attr_name.c_str());
        int nameIndex = _attr_name_table.Find(symbol);
        if (_attr_name_table.IsValidIndex(nameIndex))
        {
            Log.Error("[init_attrs] Init Attr Name Error:%s", _attr_array[i].attr_name.c_str());
            return false;
        }
        _attr_name_table.Insert(symbol, _attr_array[i].attr_type);
    }
    return true;
}
Ejemplo n.º 8
0
//-----------------------------------------------------------------------------
// Purpose: request the cef thread to make a new browser
//-----------------------------------------------------------------------------
void CHTMLController::CreateBrowser( IHTMLResponses *pBrowser, bool bPopupWindow, const char *pchUserAgentIdentifier )
{
	m_BrowserSerial++;
	m_mapBrowserRequests.Insert( m_BrowserSerial, pBrowser );

	CHTMLProtoBufMsg<CMsgBrowserCreate> cmd( eHTMLCommands_BrowserCreate );
	cmd.Body().set_request_id( m_BrowserSerial );
	cmd.Body().set_popup( bPopupWindow );
	cmd.Body().set_useragent( pchUserAgentIdentifier );
	HTMLCommandBuffer_t *pBuf = AccessHTMLWrapper().GetFreeCommandBuffer( eHTMLCommands_BrowserCreate, -1 ); 
	cmd.SerializeCrossProc( &pBuf->m_Buffer ); 
	AccessHTMLWrapper().PushCommand( pBuf ); 
}
Ejemplo n.º 9
0
//-----------------------------------------------------------------------------
// Purpose: 
// Sets the name of the bitmap from decals.wad to be used in a specific slot #
// called from cl_parse.cpp twice
// This sets the name of a decal prototype texture
// Input  : decal - 
//			*name - 
//-----------------------------------------------------------------------------
// called from gl_rsurf.cpp
IMaterial *Draw_DecalMaterial( int index )
{
	if ( index < 0 || index >= g_DecalLookup.Count() )
		return NULL;

	int slot = g_DecalLookup[index];
	if ( slot < 0 || slot >= (int)g_DecalDictionary.MaxElement() )
		return NULL;

	DecalEntry * entry = &g_DecalDictionary[slot];
	
	if ( entry )
	{
		return entry->material;
	}
	else
	{
		return NULL;
	}
}
Ejemplo n.º 10
0
//-----------------------------------------------------------------------------
// Purpose: this function will attempt to remap a key's value
// Input  : pszKey - the name of the key
//			pszInvalue - the original value
//			AllowNameRemapping - only do name remapping if this parameter is true.  
//				this is generally only false on the instance level.
// Output : returns true if the value changed
//			pszOutValue - the new value if changed
//-----------------------------------------------------------------------------
bool GameData::RemapKeyValue( const char *pszKey, const char *pszInValue, char *pszOutValue, TNameFixup NameFixup )
{
	if ( RemapOperation.Count() == 0 )
	{
		RemapOperation.SetLessFunc( &CUtlType_LessThan );
		RemapOperation.Insert( ivAngle, REMAP_ANGLE );
		RemapOperation.Insert( ivTargetDest, REMAP_NAME );
		RemapOperation.Insert( ivTargetSrc, REMAP_NAME );
		RemapOperation.Insert( ivOrigin, REMAP_POSITION );
		RemapOperation.Insert( ivAxis, REMAP_ANGLE );
		RemapOperation.Insert( ivAngleNegativePitch, REMAP_ANGLE_NEGATIVE_PITCH );
	}

	if ( !m_InstanceClass )
	{
		return false;
	}

	GDinputvariable *KVVar = m_InstanceClass->VarForName( pszKey );
	if ( !KVVar )
	{
		return false;
	}

	GDIV_TYPE	KVType = KVVar->GetType();
	int			KVRemapIndex = RemapOperation.Find( KVType );
	if ( KVRemapIndex == RemapOperation.InvalidIndex() )
	{
		return false;
	}

	strcpy( pszOutValue, pszInValue );

	switch( RemapOperation[ KVRemapIndex ] )
	{
		case REMAP_NAME:
			if ( KVType != ivInstanceVariable )
			{
				RemapNameField( pszInValue, pszOutValue, NameFixup );
			}
			break;

		case REMAP_POSITION:
			{
				Vector	inPoint( 0.0f, 0.0f, 0.0f ), outPoint;

				sscanf ( pszInValue, "%f %f %f", &inPoint.x, &inPoint.y, &inPoint.z );
				VectorTransform( inPoint, m_InstanceMat, outPoint );
				sprintf( pszOutValue, "%g %g %g", outPoint.x, outPoint.y, outPoint.z );
			}
			break;
			
		case REMAP_ANGLE:
			if ( m_InstanceAngle.x != 0.0f || m_InstanceAngle.y != 0.0f || m_InstanceAngle.z != 0.0f )
			{
				QAngle		inAngles( 0.0f, 0.0f, 0.0f ), outAngles;
				matrix3x4_t angToWorld, localMatrix;

				sscanf ( pszInValue, "%f %f %f", &inAngles.x, &inAngles.y, &inAngles.z );

				AngleMatrix( inAngles, angToWorld );
				MatrixMultiply( m_InstanceMat, angToWorld, localMatrix );
				MatrixAngles( localMatrix, outAngles );

				sprintf( pszOutValue, "%g %g %g", outAngles.x, outAngles.y, outAngles.z );
			}
			break;

		case REMAP_ANGLE_NEGATIVE_PITCH:
			if ( m_InstanceAngle.x != 0.0f || m_InstanceAngle.y != 0.0f || m_InstanceAngle.z != 0.0f )
			{
				QAngle		inAngles( 0.0f, 0.0f, 0.0f ), outAngles;
				matrix3x4_t angToWorld, localMatrix;

				sscanf ( pszInValue, "%f", &inAngles.x );	// just the pitch
				inAngles.x = -inAngles.x;

				AngleMatrix( inAngles, angToWorld );
				MatrixMultiply( m_InstanceMat, angToWorld, localMatrix );
				MatrixAngles( localMatrix, outAngles );

				sprintf( pszOutValue, "%g", -outAngles.x );	// just the pitch
			}
			break;
	}

	return ( strcmpi( pszInValue, pszOutValue ) != 0 );
}
//
// IF YOU ADD COLORS HERE, REMEMBER TO UPDATE THE RANGES
// FOR GEUTIL_IsValidColorHint() OR ELSE THEY WON'T BE APPLIED!
//
void insertDefaultColors()
{
	if (g_mColorList.Count() != 0)
		return;

	g_mColorList.Insert(L'a', Color(0xFF00FFFF)); //aqua
	g_mColorList.Insert(L'b', Color(0xFF000000)); //black
	g_mColorList.Insert(L'c', Color(0xFF0000FF)); //blue
	g_mColorList.Insert(L'd', Color(0xFFFF4500)); //OrangeRed
	g_mColorList.Insert(L'e', Color(0xFF808080)); //gray
	g_mColorList.Insert(L'f', Color(0xFFFF00FF)); //fuchsia
	g_mColorList.Insert(L'g', Color(0xFF008000)); //green
	g_mColorList.Insert(L'h', Color(0xFF00FF7F)); //SpringGreen
	g_mColorList.Insert(L'i', Color(0xFF87CEEB)); //SkyBlue
	g_mColorList.Insert(L'j', Color(0xFF696969)); //DimGray
	g_mColorList.Insert(L'k', Color(0xFF808000)); //olive
	g_mColorList.Insert(L'l', Color(0xFF00FF00)); //lime
	g_mColorList.Insert(L'm', Color(0xFF800000)); //maroon
	g_mColorList.Insert(L'n', Color(0xFF000080)); //navy
	g_mColorList.Insert(L'o', Color(0xFFFFA500)); //Orange
	g_mColorList.Insert(L'p', Color(0xFF800080)); //purple
	g_mColorList.Insert(L'q', Color(0xFF8B4513)); //SaddleBrown
	g_mColorList.Insert(L'r', Color(0xFFFF0000)); //red
	g_mColorList.Insert(L's', Color(0xFFC0C0C0)); //silver
	g_mColorList.Insert(L't', Color(0xFF008080)); //teal
	g_mColorList.Insert(L'u', Color(0xFF00FA9A)); //MediumSpringGreen
	g_mColorList.Insert(L'v', Color(0xFFD3D3D3)); //LightGrey
	g_mColorList.Insert(L'w', Color(0xFFFFFFFF)); //white
	g_mColorList.Insert(L'x', Color(0xFFFFFFE0)); //LightYellow
	g_mColorList.Insert(L'y', Color(0xFFFFFF00)); //yellow
	g_mColorList.Insert(L'z', Color(0xFFFF1493)); //DeepPink
}