//-------------------------------------------------------------------------------------------------------- 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 ) ); } } } }
//----------------------------------------------------------------------------- // Purpose: Constructor //----------------------------------------------------------------------------- CButtonPanel::CButtonPanel() : EditablePanel(NULL, "button_panel") { SetParent(enginevgui->GetPanel( PANEL_GAMEUIDLL )); SetProportional(true); LoadControlSettings( "Resource/UI/buttonpanel.res" ); InvalidateLayout(); m_pNews = new ImageButton(this, "NewsButton", "news", NULL, NULL, "opennews"); m_pLeaderboard = new ImageButton(this, "LeaderboardButton", "leaderboard", NULL, NULL, "openleaderboard"); MakeReadyForUse(); Update(); KeyValues *manifest = new KeyValues( "latest_news" ); if ( manifest->LoadFromFile( filesystem, "latest_news.txt" ) ) m_iLatestNews = atol(manifest->GetFirstValue()->GetString()); else m_iLatestNews = 0; // Start us out with the leaderboard. CloseAll(); Leaderboard()->SetVisible(true); }
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; }
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; }