//-------------------------------------------------------------------------------------------------------- void CPolygonButton::UpdateHotspots( KeyValues *data ) { // clear out our old hotspot if ( m_hotspotPoints ) { delete[] m_hotspotPoints; m_hotspotPoints = NULL; m_numHotspotPoints = 0; } if ( m_visibleHotspotPoints ) { delete[] m_visibleHotspotPoints; m_visibleHotspotPoints = NULL; m_numVisibleHotspotPoints = 0; } m_unscaledHotspotPoints.RemoveAll(); m_unscaledVisibleHotspotPoints.RemoveAll(); // read in a new one KeyValues *points = data->FindKey( "Hotspot", false ); if ( points ) { for ( KeyValues *value = points->GetFirstValue(); value; value = value->GetNextValue() ) { const char *str = value->GetString(); float x, y; if ( 2 == sscanf( str, "%f %f", &x, &y ) ) { m_unscaledHotspotPoints.AddToTail( Vector2D( x, y ) ); } } } points = data->FindKey( "VisibleHotspot", false ); if ( !points ) { points = data->FindKey( "Hotspot", false ); } if ( points ) { for ( KeyValues *value = points->GetFirstValue(); value; value = value->GetNextValue() ) { const char *str = value->GetString(); float x, y; if ( 2 == sscanf( str, "%f %f", &x, &y ) ) { m_unscaledVisibleHotspotPoints.AddToTail( Vector2D( x, y ) ); } } } }
void CheckKeyValues( KeyValues *pKeyValues, CUtlVector<VTFInfo_t> &vtf ) { for ( KeyValues *pSubKey = pKeyValues->GetFirstValue(); pSubKey; pSubKey = pSubKey->GetNextValue() ) { if ( pSubKey->GetDataType() != KeyValues::TYPE_STRING ) continue; if ( IsTexture( pSubKey->GetString() ) ) { int nLen = Q_strlen( pSubKey->GetString() ) + 1; char *pTemp = (char*)_alloca( nLen ); memcpy( pTemp, pSubKey->GetString(), nLen ); Q_FixSlashes( pTemp ); int nCount = vtf.Count(); for ( int i = 0; i < nCount; ++i ) { if ( Q_stricmp( vtf[i].m_VTFName, pTemp ) ) continue; vtf[i].m_bFoundInVMT = true; break; } } } for ( KeyValues *pSubKey = pKeyValues->GetFirstTrueSubKey(); pSubKey; pSubKey = pSubKey->GetNextTrueSubKey() ) { CheckKeyValues( pSubKey, vtf ); } }
void CShaderPrecache::LoadList() { KeyValues *pKV = df_LoadDump_List(); KeyValues *pKey = pKV->GetFirstValue(); while ( pKey ) { AddEntry( pKey->GetString() ); pKey = pKey->GetNextValue(); } pKV->deleteThis(); }
bool CMapAdd::HandleRemoveEnitity( KeyValues *mapaddValue) { if(AllocPooledString(mapaddValue->GetName()) == AllocPooledString("remove:sphere")) { Vector RemoveVector = Vector(0,0,0); CBaseEntity *ppEnts[256]; // CBaseEntity *ppCandidates[256]; RemoveVector.x = mapaddValue->GetFloat("x", RemoveVector.x); RemoveVector.y = mapaddValue->GetFloat("y", RemoveVector.y); RemoveVector.z = mapaddValue->GetFloat("z", RemoveVector.z); int nEntCount = UTIL_EntitiesInSphere( ppEnts, 256, RemoveVector, mapaddValue->GetFloat("radius", 0), 0 ); //Look through the entities it found KeyValues *pEntKeyValues = mapaddValue->FindKey("entities"); if(pEntKeyValues) { KeyValues *pEntKeyValuesRemove = pEntKeyValues->GetFirstValue(); while(pEntKeyValuesRemove) { int i; for ( i = 0; i < nEntCount; i++ ) { if ( ppEnts[i] == NULL ) continue; if(AllocPooledString(pEntKeyValuesRemove->GetName()) == AllocPooledString("classname")) // || ( AllocPooledString(pEntKeyValuesRemove->GetName()) == ppEnts[i]->GetEntityName()) { if(AllocPooledString(pEntKeyValuesRemove->GetString()) == AllocPooledString(ppEnts[i]->GetClassname())) { UTIL_Remove(ppEnts[i]); continue; } } if(AllocPooledString(pEntKeyValuesRemove->GetName()) == AllocPooledString("targetname")) // || ( AllocPooledString(pEntKeyValuesRemove->GetName()) == ppEnts[i]->GetEntityName()) { if(AllocPooledString(pEntKeyValuesRemove->GetString()) == ppEnts[i]->GetEntityName()) { UTIL_Remove(ppEnts[i]); continue; } } } pEntKeyValuesRemove = pEntKeyValuesRemove->GetNextValue(); } } return true; } return false; }
void ReadGameShaders( CUtlVector<BasicShaderCfg_t*> &hList ) { KeyValues *pKV = df_LoadDump_List(); KeyValues *pN = pKV->GetFirstValue(); while ( pN ) { BasicShaderCfg_t *shader = BuildShaderData( pN->GetString() ); hList.AddToTail( shader ); pN = pN->GetNextValue(); } pKV->deleteThis(); }
void CQCGenerator::OnNewLODText() { KeyValues *pEditItem = m_pLODPanel->GetItem( m_nSelectedSequence ); KeyValues *pListItem = pEditItem; wchar_t szEditText[MAX_PATH]; pEditItem = pEditItem->GetFirstValue(); const char *name = pEditItem->GetName(); for( int i = 0; i < m_nSelectedColumn; i++ ) { pEditItem = pEditItem->GetNextValue(); name = pEditItem->GetName(); } m_pLODEdit->GetText( szEditText, MAX_PATH ); pListItem->SetWString( name, szEditText ); m_pLODPanel->LeaveEditMode(); m_pLODPanel->InvalidateLayout(); return; }
virtual void OnValuesChanged( KeyValues **pValues, int iCount ) { bool bFoundAnything = false; bool bWasMultiSelected = m_bMultiSelection; m_bMultiSelection = false; for ( int i = 0; i < iCount; i++ ) { bool bFoundValue = false; for ( KeyValues *pValue = pValues[i]->GetFirstValue(); pValue; pValue = pValue->GetNextValue() ) { if ( !Q_stricmp( m_pValue->GetName(), pValue->GetName() ) ) { if ( i > 0 ) { if ( Q_stricmp( m_pValue->GetString(), pValue->GetString() ) ) m_bMultiSelection = true; } m_pValue->deleteThis(); m_pValue = pValue->MakeCopy(); bFoundAnything = true; bFoundValue = true; break; } } if ( !bFoundValue && bFoundAnything ) m_bMultiSelection = true; } if ( !bFoundAnything ) m_bMultiSelection = bWasMultiSelected; ReadValue(); };
//============================================================================= void Addons::Activate() { BaseClass::Activate(); m_GplAddons->RemoveAllPanelItems(); m_addonInfoList.RemoveAll(); m_pAddonList ? m_pAddonList->deleteThis() : NULL; // // Get the list of addons // // Load particular info for each addon if ( LoadAddonListFile( m_pAddonList ) ) { for ( KeyValues *pCur = m_pAddonList->GetFirstValue(); pCur; pCur = pCur->GetNextValue() ) { char szAddonDirName[60]; bool bIsVPK = true; // If the entry in the list is a .vpk then if ( V_stristr( pCur->GetName(), ".vpk" ) ) { V_StripExtension( pCur->GetName(), szAddonDirName, sizeof( szAddonDirName ) ); ExtractAddonMetadata( szAddonDirName ); } else { bIsVPK = false; V_strncpy( szAddonDirName, pCur->GetName(), sizeof( szAddonDirName ) ); } Addons::AddonInfo addonInfo; // Copy info to the AddonInfo struct KeyValues *pAddonInfo; if ( LoadAddonInfoFile( pAddonInfo, szAddonDirName, bIsVPK ) ) { // Convert JPEG image to VTF, if necessary GetAddonImage( pCur->GetName(), addonInfo.szImageName, sizeof( addonInfo.szImageName ), bIsVPK ); // Copy values from particular keys V_strncpy( addonInfo.szDirectory, pCur->GetName(), sizeof( addonInfo.szDirectory ) ); V_wcsncpy( addonInfo.szName, pAddonInfo->GetWString( "addontitle", g_pVGuiLocalize->Find( "#L4D360UI_Addon_None_Specified" ) ), sizeof( addonInfo.szName ) ); V_wcsncpy( addonInfo.szAuthor, pAddonInfo->GetWString( "addonauthor", g_pVGuiLocalize->Find( "#L4D360UI_Addon_None_Specified" ) ), sizeof( addonInfo.szAuthor ) ); V_wcsncpy( addonInfo.szDescription, pAddonInfo->GetWString( "addonDescription", g_pVGuiLocalize->Find( "#L4D360UI_Addon_None_Specified" ) ), sizeof( addonInfo.szDescription ) ); addonInfo.bEnabled = pCur->GetInt() != 0; // Generate the types string based on the value of keys bool bCampaign = false, bMaps = false, bSkin = false, bWeapon = false, bBoss = false, bCommon = false, bSurvivor = false, bSound = false, bMusic = false, bScript = false, bProp = false; bCampaign = pAddonInfo->GetInt( "addonContent_Campaign" ) != 0; bMaps = ( pAddonInfo->GetInt( "addonContent_Map" ) != 0 ) && !bCampaign; bSkin = pAddonInfo->GetInt( "addonContent_Skin" ) != 0; bWeapon = pAddonInfo->GetInt( "addonContent_weapon" ) != 0; bBoss = pAddonInfo->GetInt( "addonContent_BossInfected" ) != 0; bCommon = pAddonInfo->GetInt( "addonContent_CommonInfected" ) != 0; bSurvivor = pAddonInfo->GetInt( "addonContent_Survivor" ) != 0; bSound = pAddonInfo->GetInt( "addonContent_Sound" ) != 0; bScript = pAddonInfo->GetInt( "addonContent_Script" ) != 0; bMusic = pAddonInfo->GetInt( "addonContent_Music" ) != 0; bProp = pAddonInfo->GetInt( "addonContent_prop" ) != 0; // Make the addon types string based on the flags addonInfo.szTypes[0] = NULL; bCampaign ? wcsncat( addonInfo.szTypes, g_pVGuiLocalize->Find( "#L4D360UI_Addon_Type_Campaign" ), sizeof( addonInfo.szTypes ) ) : NULL; bMaps ? wcsncat( addonInfo.szTypes, g_pVGuiLocalize->Find( "#L4D360UI_Addon_Type_Map" ), sizeof( addonInfo.szTypes ) ) : NULL; bSkin ? wcsncat( addonInfo.szTypes, g_pVGuiLocalize->Find( "#L4D360UI_Addon_Type_Skin" ), sizeof( addonInfo.szTypes ) ) : NULL; bWeapon ? wcsncat( addonInfo.szTypes, g_pVGuiLocalize->Find( "#L4D360UI_Addon_Type_Weapon" ), sizeof( addonInfo.szTypes ) ) : NULL; bBoss ? wcsncat( addonInfo.szTypes, g_pVGuiLocalize->Find( "#L4D360UI_Addon_Type_Boss" ), sizeof( addonInfo.szTypes ) ) : NULL; bCommon ? wcsncat( addonInfo.szTypes, g_pVGuiLocalize->Find( "#L4D360UI_Addon_Type_Common" ), sizeof( addonInfo.szTypes ) ) : NULL; bSurvivor ? wcsncat( addonInfo.szTypes, g_pVGuiLocalize->Find( "#L4D360UI_Addon_Type_Survivor" ), sizeof( addonInfo.szTypes ) ) : NULL; bSound ? wcsncat( addonInfo.szTypes, g_pVGuiLocalize->Find( "#L4D360UI_Addon_Type_Sound" ), sizeof( addonInfo.szTypes ) ) : NULL; bScript ? wcsncat( addonInfo.szTypes, g_pVGuiLocalize->Find( "#L4D360UI_Addon_Type_Script" ), sizeof( addonInfo.szTypes ) ) : NULL; bMusic ? wcsncat( addonInfo.szTypes, g_pVGuiLocalize->Find( "#L4D360UI_Addon_Type_Music" ), sizeof( addonInfo.szTypes ) ) : NULL; bProp ? wcsncat( addonInfo.szTypes, g_pVGuiLocalize->Find( "#L4D360UI_Addon_Type_Props" ), sizeof( addonInfo.szTypes ) ) : NULL; // Remove trailing ',' if ( wcslen( addonInfo.szTypes ) ) { wchar_t *pwcComma = wcsrchr( addonInfo.szTypes, ',' ); if ( pwcComma ) { *pwcComma = NULL; } } } m_addonInfoList.AddToTail( addonInfo ); // Get rid of the temp files if ( bIsVPK ) { char tempFilename[MAX_PATH]; char modPath[MAX_PATH]; GetPrimaryModDirectory( modPath, MAX_PATH ); V_snprintf( tempFilename, sizeof( tempFilename ), "%s%s%c%s", modPath, ADDONS_DIRNAME, CORRECT_PATH_SEPARATOR, ADDONINFO_FILENAME ); g_pFullFileSystem->RemoveFile( tempFilename ); V_snprintf( tempFilename, sizeof( tempFilename ), "%s%s%c%s", modPath, ADDONS_DIRNAME, CORRECT_PATH_SEPARATOR, ADDONJPEG_FILENAME ); g_pFullFileSystem->RemoveFile( tempFilename ); } } } // // Add the addons to the list panel // FOR_EACH_VEC( m_addonInfoList, i ) { AddonListItem* panelItem = m_GplAddons->AddPanelItem<AddonListItem>( "AddonListItem" ); panelItem->SetParent( m_GplAddons ); panelItem->SetAddonName( m_addonInfoList[i].szName ); panelItem->SetAddonType( m_addonInfoList[i].szTypes ); panelItem->SetAddonEnabled( m_addonInfoList[i].bEnabled ); }
void CheckMaterial( KeyValues *pKeyValues, const char *pRoot, const char *pFileName, CUtlVector<VTFInfo_t> &vtf ) { const char *pShaderName = pKeyValues->GetName(); /* if ( Q_stristr( pShaderName, "Water" ) || Q_stristr( pShaderName, "Eyeball" ) || Q_stristr( pShaderName, "Shadow" ) || Q_stristr( pShaderName, "Refract" ) || Q_stristr( pShaderName, "Predator" ) || Q_stristr( pShaderName, "ParticleSphere" ) || Q_stristr( pShaderName, "DebugLuxels" ) || Q_stristr( pShaderName, "GooInGlass" ) || Q_stristr( pShaderName, "Modulate" ) || Q_stristr( pShaderName, "UnlitTwoTexture" ) || Q_stristr( pShaderName, "Cloud" ) || Q_stristr( pShaderName, "WorldVertexTransition" ) || Q_stristr( pShaderName, "DecalModulate" ) || Q_stristr( pShaderName, "DecalBaseTimesLightmapAlphaBlendSelfIllum" ) || Q_stristr( pShaderName, "Sprite" ) ) { return; } // Check for alpha channels const char *pBaseTextureName = pKeyValues->GetString( "$basetexture", NULL ); if ( pBaseTextureName != NULL ) { if ( DoesTextureUseAlpha( pBaseTextureName, pFileName ) ) { float flAlpha = MaterialFloatKeyValue( pKeyValues, "$alpha", 1.0f ); bool bHasVertexAlpha = DoesMaterialHaveKey( pKeyValues, "$vertexalpha" ); // Modulation always happens here whether we want it to or not bool bHasAlphaTest = DoesMaterialHaveKey( pKeyValues, "$alphatest" ); bool bHasTranslucent = DoesMaterialHaveKey( pKeyValues, "$translucent" ); bool bHasSelfIllum = DoesMaterialHaveKey( pKeyValues, "$selfillum" ); bool bHasBaseAlphaEnvMapMask = DoesMaterialHaveKey( pKeyValues, "$basealphaenvmapmask" ); if ( (flAlpha == 1.0f) && !bHasVertexAlpha && !bHasAlphaTest && !bHasTranslucent && !bHasSelfIllum && !bHasBaseAlphaEnvMapMask ) { Warning("Material \"%s\": BASETEXTURE \"%s\"\n", pFileName, pBaseTextureName ); } } } */ /* // Check for bump, spec, and no normalmapalphaenvmapmask const char *pBumpmapName = pKeyValues->GetString( "$bumpmap", NULL ); if ( pBumpmapName != NULL ) { if ( DoesTextureUseAlpha( pBumpmapName, pFileName ) ) { bool bHasEnvmap = DoesMaterialHaveKey( pKeyValues, "$envmap" ); bool bHasNormalMapAlphaEnvMapMask = DoesMaterialHaveKey( pKeyValues, "$normalmapalphaenvmapmask" ); if ( !bHasEnvmap || !bHasNormalMapAlphaEnvMapMask ) { Warning("Material \"%s\": BUMPMAP \"%s\"\n", pFileName, pBumpmapName ); } } } */ /* if ( !Q_stristr( pShaderName, "LightmappedGeneric" ) && !Q_stristr( pShaderName, "VertexLitGeneric" ) ) { return; } if ( DoesMaterialHaveKey( pKeyValues, "$envmap" ) && DoesMaterialHaveKey( pKeyValues, "$bumpmap" ) ) { int nDim; float retVal[4]; float defaultVal[4] = { 1, 1, 1, 1 }; if ( MaterialVectorKeyValue( pKeyValues, "$envmaptint", 3, defaultVal, &nDim, retVal ) ) { Warning("ENVMAP + ENVMAPTINT : Material \"%s\"\n", pFileName ); } // else // { // Warning("ENVMAP only: Material \"%s\"\n", pFileName ); // } } */ /* if ( !Q_stristr( pShaderName, "Refract" ) ) { return; } if ( !DoesMaterialHaveKey( pKeyValues, "$envmap" ) ) { bool bUsesAlpha, bIsCompressed, bIsPalettized; int nSizeInBytes; if ( DoesTextureUseNormal( pKeyValues->GetString( "$normalmap" ), pFileName, bUsesAlpha, bIsCompressed, bIsPalettized, nSizeInBytes ) ) { if ( bIsCompressed ) { Warning("Bad : Material compressed \"%s\"\n", pFileName ); } else { Warning("Bad : Material \"%s\"\n", pFileName ); } } } */ /* if ( !Q_stristr( pShaderName, "WorldTwoTextureBlend" ) ) { return; } if ( DoesMaterialHaveKey( pKeyValues, "$envmap" ) || DoesMaterialHaveKey( pKeyValues, "$parallaxmap" ) || DoesMaterialHaveKey( pKeyValues, "$bumpmap" ) || DoesMaterialHaveKey( pKeyValues, "$vertexcolor" ) || DoesMaterialHaveKey( pKeyValues, "$basetexture2" ) ) { Warning("Bad : Material \"%s\"\n", pFileName ); } */ for ( KeyValues *pSubKey = pKeyValues->GetFirstValue(); pSubKey; pSubKey = pSubKey->GetNextValue() ) { // Msg( " Checking %s\n", pSubKey->GetString() ); if ( pSubKey->GetDataType() != KeyValues::TYPE_STRING ) continue; bool bUsesAlpha, bIsCompressed; int nSizeInBytes; if ( DoesTextureUseNormal( pSubKey->GetString(), pFileName, bUsesAlpha, bIsCompressed, nSizeInBytes ) ) { if ( bUsesAlpha ) { if ( bIsCompressed ) { s_nNormalWithAlphaCompressedBytes += nSizeInBytes; } else { s_nNormalWithAlphaBytes += nSizeInBytes; Msg( "Normal texture w alpha uncompressed %s\n", pSubKey->GetString() ); } } else { if ( bIsCompressed ) { s_nNormalCompressedBytes += nSizeInBytes; } else { s_nNormalBytes += nSizeInBytes; } } } } /* if ( !Q_stristr( pShaderName, "VertexLitGeneric" ) ) return; if ( !DoesMaterialHaveKey( pKeyValues, "$envmap" ) && DoesMaterialHaveKey( pKeyValues, "$bumpmap" ) ) { Warning("BUMPMAP + no ENVMAP : Material \"%s\"\n", pFileName ); } */ // CheckKeyValues( pKeyValues, vtf ); }
bool CMapAdd::RunLabel( const char *mapaddMap, const char *szLabel) { if(AllocPooledString(mapaddMap) == AllocPooledString("") || !mapaddMap || !szLabel || AllocPooledString(szLabel) == AllocPooledString("")) return false; //Failed to load! //FileHandle_t fh = filesystem->Open(szMapadd,"r","MOD"); // Open the mapadd data file, and abort if we can't KeyValues *pMapAdd = new KeyValues( "MapAdd" ); if(pMapAdd->LoadFromFile( filesystem, mapaddMap, "MOD" )) { KeyValues *pMapAdd2 = pMapAdd->FindKey(szLabel); if(pMapAdd2) { KeyValues *pMapAddEnt = pMapAdd2->GetFirstTrueSubKey(); while (pMapAddEnt) { if(!HandlePlayerEntity(pMapAddEnt, false) && !HandleRemoveEnitity( pMapAddEnt ) && !HandleSMODEntity(pMapAddEnt) && !HandleSpecialEnitity(pMapAddEnt)) { Vector SpawnVector = Vector(0,0,0); QAngle SpawnAngle = QAngle(0,0,0); SpawnVector.x = pMapAddEnt->GetFloat("x", SpawnVector.x); SpawnVector.y = pMapAddEnt->GetFloat("y", SpawnVector.y); SpawnVector.z = pMapAddEnt->GetFloat("z", SpawnVector.z); SpawnAngle[PITCH] = pMapAddEnt->GetFloat("pitch", SpawnAngle[PITCH]); SpawnAngle[YAW] = pMapAddEnt->GetFloat("yaw", SpawnAngle[YAW]); SpawnAngle[ROLL] = pMapAddEnt->GetFloat("roll", SpawnAngle[ROLL]); CBaseEntity *createEnt = CBaseEntity::CreateNoSpawn(pMapAddEnt->GetName(),SpawnVector,SpawnAngle); KeyValues *pEntKeyValues = pMapAddEnt->FindKey("KeyValues"); if(pEntKeyValues && createEnt) { Msg("keyvalue for %s Found!\n",pMapAddEnt->GetName()); KeyValues *pEntKeyValuesAdd = pEntKeyValues->GetFirstValue(); while(pEntKeyValuesAdd && createEnt) { if(AllocPooledString(pEntKeyValuesAdd->GetName()) == AllocPooledString("model")) { PrecacheModel(pEntKeyValuesAdd->GetString("")); createEnt->SetModel(pEntKeyValuesAdd->GetString("")); } /* else if(AllocPooledString(pEntKeyValuesAdd->GetName()) == AllocPooledString("name")) { createEnt->SetName(AllocPooledString(pEntKeyValuesAdd->GetString(""))); } else if(AllocPooledString(pEntKeyValuesAdd->GetName()) == AllocPooledString("spawnflags")) { createEnt->AddSpawnFlags(pEntKeyValuesAdd->GetInt()); }*/ else { createEnt->KeyValue(pEntKeyValuesAdd->GetName(),pEntKeyValuesAdd->GetString("")); } pEntKeyValuesAdd = pEntKeyValuesAdd->GetNextValue(); } } //createEnt->Activate();//Is this a good idea? Not sure! //createEnt->Spawn(); DispatchSpawn( createEnt ); //I derped } pMapAddEnt = pMapAddEnt->GetNextTrueSubKey(); //Got to keep this! } } } pMapAdd->deleteThis(); return true; }