Ejemplo n.º 1
0
void PrecacheFileWeaponInfoDatabase( IFileSystem *filesystem, const unsigned char *pICEKey )
{
	if ( m_WeaponInfoDatabase.Count() )
		return;

	KeyValues *manifest = new KeyValues( "weaponscripts" );
	if ( manifest->LoadFromFile( filesystem, "scripts/weapon_manifest.txt", "GAME" ) )
	{
		for ( KeyValues *sub = manifest->GetFirstSubKey(); sub != NULL ; sub = sub->GetNextKey() )
		{
			if ( !Q_stricmp( sub->GetName(), "file" ) )
			{
				char fileBase[512];
				Q_FileBase( sub->GetString(), fileBase, sizeof(fileBase) );
				WEAPON_FILE_INFO_HANDLE tmp;
#ifdef CLIENT_DLL
				if ( ReadWeaponDataFromFileForSlot( filesystem, fileBase, &tmp, pICEKey ) )
				{
					gWR.LoadWeaponSprites( tmp );
				}
#else
				ReadWeaponDataFromFileForSlot( filesystem, fileBase, &tmp, pICEKey );
#endif
			}
			else
			{
				Error( "Expecting 'file', got %s\n", sub->GetName() );
			}
		}
	}
	manifest->deleteThis();
}
Ejemplo n.º 2
0
//------------------------------------------------------------------------------
// Purpose:
//------------------------------------------------------------------------------
bool CNPC_Furniture::CreateVPhysics( void )
{
#ifndef HL2_DLL
	return false;
#endif

	if ( !m_BoneFollowerManager.GetNumBoneFollowers() )
	{
		KeyValues *modelKeyValues = new KeyValues("");
		if ( modelKeyValues->LoadFromBuffer( modelinfo->GetModelName( GetModel() ), modelinfo->GetModelKeyValueText( GetModel() ) ) )
		{
			// Do we have a bone follower section?
			KeyValues *pkvBoneFollowers = modelKeyValues->FindKey("bone_followers");
			if ( pkvBoneFollowers )
			{
				// Loop through the list and create the bone followers
				KeyValues *pBone = pkvBoneFollowers->GetFirstSubKey();
				while ( pBone )
				{
					// Add it to the list
					const char *pBoneName = pBone->GetString();
					m_BoneFollowerManager.AddBoneFollower( this, pBoneName );

					pBone = pBone->GetNextKey();
				}
			}
		}
		modelKeyValues->deleteThis();
	}

	return true;
}
Ejemplo n.º 3
0
void VMFExporter::LoadUniqueKeyList()
{
    m_UniqueKeys.RemoveAll();
    m_NodeIDKeys.RemoveAll();

    // Open the manifest file, and read the particles specified inside it
    KeyValues *manifest = new KeyValues( UNIQUE_KEYS_FILE );
    if ( manifest->LoadFromFile( g_pFullFileSystem, UNIQUE_KEYS_FILE, "GAME" ) )
    {
        for ( KeyValues *sub = manifest->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
        {
            if ( !Q_stricmp( sub->GetName(), "key" ) )
            {
                m_UniqueKeys.AddToTail( sub->GetString() );
                continue;
            }
            if ( !Q_stricmp( sub->GetName(), "NodeID" ) )
            {
                m_NodeIDKeys.AddToTail( sub->GetString() );
                continue;
            }

            Warning( "VMFExporter::LoadUniqueKeyList:  Manifest '%s' with bogus file type '%s', expecting 'key' or 'NodeID'\n", UNIQUE_KEYS_FILE, sub->GetName() );
        }
    }
    else
    {
        Warning( "VMFExporter: Unable to load manifest file '%s'\n", UNIQUE_KEYS_FILE );
    }

    manifest->deleteThis();
}
int CASW_Mission_Chooser_Source_Local::GetNumMissionsInCampaign( int iCampaignIndex )
{
	if (!m_bBuiltMapList)
		BuildMapList();

	ASW_Mission_Chooser_Mission* pCampaign = GetCampaign( iCampaignIndex );
	if ( !pCampaign )
		return 0;

	KeyValues *pCampaignDetails = GetCampaignDetails( pCampaign->m_szMissionName );
	if ( !pCampaignDetails )
		return 0;

	CUtlVector<KeyValues*> aMissionKeys;
	bool bSkippedFirst = false;
	for ( KeyValues *pMission = pCampaignDetails->GetFirstSubKey(); pMission; pMission = pMission->GetNextKey() )
	{
		if ( !Q_stricmp( pMission->GetName(), "MISSION" ) )
		{
			if ( !bSkippedFirst )
			{
				bSkippedFirst = true;
			}
			else
			{
				aMissionKeys.AddToTail( pMission );
			}
		}
	}

	return aMissionKeys.Count();
}
Ejemplo n.º 5
0
//-----------------------------------------------------------------------------
// Purpose: Loads the surface properties database into the physics DLL
//-----------------------------------------------------------------------------
void LoadSurfaceProperties( void )
{
	CreateInterfaceFn physicsFactory = GetPhysicsFactory();
	if ( !physicsFactory )
		return;

	physprops = (IPhysicsSurfaceProps *)physicsFactory( VPHYSICS_SURFACEPROPS_INTERFACE_VERSION, NULL );

	const char *SURFACEPROP_MANIFEST_FILE = "scripts/surfaceproperties_manifest.txt";
	KeyValues *manifest = new KeyValues( SURFACEPROP_MANIFEST_FILE );
	if ( manifest->LoadFromFile( g_pFileSystem, SURFACEPROP_MANIFEST_FILE, "GAME" ) )
	{
		for ( KeyValues *sub = manifest->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
		{
			if ( !Q_stricmp( sub->GetName(), "file" ) )
			{
				// Add
				LoadSurfacePropFile( sub->GetString() );
				continue;
			}
		}
	}

	manifest->deleteThis();
}
Ejemplo n.º 6
0
void CClientTimesDisplay::LoadLocalTimes(KeyValues *kv)
{
    if (!m_bLocalTimesLoaded || m_bLocalTimesNeedUpdate)
    {
        //Clear the local times for a refresh
        m_vLocalTimes.RemoveAll();

        //Load from .tim file
        KeyValues *pLoaded = new KeyValues("local");
        char fileName[MAX_PATH];

        Q_snprintf(fileName, MAX_PATH, "maps/%s.tim", g_pGameRules->MapName() ? g_pGameRules->MapName() : "FIXME");

        if (pLoaded->LoadFromFile(filesystem, fileName, "MOD"))
        {
            DevLog("Loading from file %s...\n", fileName);
            for (KeyValues* kvLocalTime = pLoaded->GetFirstSubKey(); kvLocalTime; kvLocalTime = kvLocalTime->GetNextKey())
            {
                Time t = Time(kvLocalTime);
                m_vLocalTimes.AddToTail(t);
            }
            m_bLocalTimesLoaded = true;
            m_bLocalTimesNeedUpdate = false;
        }
        pLoaded->deleteThis();
    }

    //Convert
    if (!m_vLocalTimes.IsEmpty())
        ConvertLocalTimes(kv);
}
Ejemplo n.º 7
0
static cell_t smn_KvGotoFirstSubKey(IPluginContext *pCtx, const cell_t *params)
{
	Handle_t hndl = static_cast<Handle_t>(params[1]);
	HandleError herr;
	HandleSecurity sec;
	KeyValueStack *pStk;

	sec.pOwner = NULL;
	sec.pIdentity = g_pCoreIdent;

	if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
		!= HandleError_None)
	{
		return pCtx->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
	}

	KeyValues *pSubKey = pStk->pCurRoot.front();
	KeyValues *pFirstSubKey;
	if (params[2])
	{
		pFirstSubKey = pSubKey->GetFirstTrueSubKey();
	} else {
		pFirstSubKey = pSubKey->GetFirstSubKey();
	}

	if (!pFirstSubKey)
	{
		return 0;
	}
	pStk->pCurRoot.push(pFirstSubKey);

	return 1;
}
Ejemplo n.º 8
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void CBaseObject::AddAndParseBuildPoint( int iAttachmentNumber, KeyValues *pkvBuildPoint )
{
	int iPoint = AddBuildPoint( iAttachmentNumber );

	
	m_BuildPoints[iPoint].m_bPutInAttachmentSpace = (pkvBuildPoint->GetInt( "PutInAttachmentSpace", 0 ) != 0);

	// Now see if we've got a set of valid objects specified
	KeyValues *pkvValidObjects = pkvBuildPoint->FindKey( "valid_objects" );
	if ( pkvValidObjects )
	{
		KeyValues *pkvObject = pkvValidObjects->GetFirstSubKey();
		while ( pkvObject )
		{
			const char *pSpecifiedObject = pkvObject->GetName();
			int iLenObjName = Q_strlen( pSpecifiedObject );

			// Find the object index for the name
			for ( int i = 0; i < OBJ_LAST; i++ )
			{
				if ( !Q_strncasecmp( GetObjectInfo( i )->m_pClassName, pSpecifiedObject, iLenObjName) )
				{
					AddValidObjectToBuildPoint( iPoint, i );
					break;
				}
			}

			pkvObject = pkvObject->GetNextKey();
		}
	}
}
Ejemplo n.º 9
0
void C_SoundscapeSystem::AddSoundScapeFile( const char *filename )
{
	KeyValues *script = new KeyValues( filename );
#ifndef _XBOX
	if ( script->LoadFromFile( filesystem, filename ) )
#else
	if ( filesystem->LoadKeyValues( *script, IFileSystem::TYPE_SOUNDSCAPE, filename, "GAME" ) )
#endif
	{
		// parse out all of the top level sections and save their names
		KeyValues *pKeys = script;
		while ( pKeys )
		{
			// save pointers to all sections in the root
			// each one is a soundscape
			if ( pKeys->GetFirstSubKey() )
			{
				m_soundscapes.AddToTail( pKeys );
			}
			pKeys = pKeys->GetNextKey();
		}

		// Keep pointer around so we can delete it at exit
		m_SoundscapeScripts.AddToTail( script );
	}
	else
	{
		script->deleteThis();
	}
}
Ejemplo n.º 10
0
void PhysParseSurfaceData( IPhysicsSurfaceProps *pProps, IFileSystem *pFileSystem )
{
	KeyValues *manifest = new KeyValues( SURFACEPROP_MANIFEST_FILE );
	if ( manifest->LoadFromFile( pFileSystem, SURFACEPROP_MANIFEST_FILE, "GAME" ) )
	{
		for ( KeyValues *sub = manifest->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
		{
			if ( !Q_stricmp( sub->GetName(), "file" ) )
			{
				// Add
				AddSurfacepropFile( sub->GetString(), pProps, pFileSystem );
				continue;
			}

			Warning( "surfaceprops::Init:  Manifest '%s' with bogus file type '%s', expecting 'file'\n", 
				SURFACEPROP_MANIFEST_FILE, sub->GetName() );
		}
	}
	else
	{
		Error( "Unable to load manifest file '%s'\n", SURFACEPROP_MANIFEST_FILE );
	}

	manifest->deleteThis();
}
Ejemplo n.º 11
0
void CRoomTemplate::LoadFromKeyValues( const char *pRoomName, KeyValues *pKeyValues )
{
    m_nTilesX = pKeyValues->GetInt( "TilesX", 1 );
    m_nTilesY = pKeyValues->GetInt( "TilesY", 1 );
    SetSpawnWeight( pKeyValues->GetInt( "SpawnWeight", MIN_SPAWN_WEIGHT ) );

    SetFullName( pRoomName );

    Q_strncpy( m_Description, pKeyValues->GetString( "RoomTemplateDescription", "" ), m_nMaxDescriptionLength );
    Q_strncpy( m_Soundscape, pKeyValues->GetString( "Soundscape", "" ), m_nMaxSoundscapeLength );

    SetTileType( pKeyValues->GetInt( "TileType", ASW_TILETYPE_UNKNOWN ) );

    m_Tags.RemoveAll();

    // search through all the exit subsections
    KeyValues *pkvSubSection = pKeyValues->GetFirstSubKey();
    bool bClearedExits = false;
    while ( pkvSubSection )
    {
        // mission details
        if ( Q_stricmp(pkvSubSection->GetName(), "EXIT")==0 )
        {
            if ( !bClearedExits )
            {
                // if we haven't cleared previous exits yet then do so now
                m_Exits.PurgeAndDeleteElements();
                bClearedExits = true;
            }
            CRoomTemplateExit *pExit = new CRoomTemplateExit();
            pExit->m_iXPos = pkvSubSection->GetInt("XPos");
            pExit->m_iYPos = pkvSubSection->GetInt("YPos");
            pExit->m_ExitDirection = (ExitDirection_t) pkvSubSection->GetInt("ExitDirection");
            pExit->m_iZChange = pkvSubSection->GetInt("ZChange");
            Q_strncpy( pExit->m_szExitTag, pkvSubSection->GetString( "ExitTag" ), sizeof( pExit->m_szExitTag ) );
            pExit->m_bChokepointGrowSource = !!pkvSubSection->GetInt("ChokeGrow", 0);

            // discard exits outside the room bounds
            if ( pExit->m_iXPos < 0 || pExit->m_iYPos < 0 || pExit->m_iXPos >= m_nTilesX || pExit->m_iYPos >= m_nTilesY )
            {
                delete pExit;
            }
            else
            {
                m_Exits.AddToTail(pExit);
            }
        }
        else if ( Q_stricmp(pkvSubSection->GetName(), "Tags")==0 && TagList() )
        {
            for ( KeyValues *sub = pkvSubSection->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
            {
                if ( !Q_stricmp( sub->GetName(), "tag" ) )
                {
                    AddTag( sub->GetString() );
                }
            }
        }
        pkvSubSection = pkvSubSection->GetNextKey();
    }
}
Ejemplo n.º 12
0
bool VMFExporter::ProcessEntity( KeyValues *pEntityKeys )
{
    for ( KeyValues *pKeys = pEntityKeys->GetFirstSubKey(); pKeys; )
    {
        if ( pKeys->GetFirstSubKey() )
        {
            if ( !Q_stricmp( pKeys->GetName(), "solid" ) )
            {
                if ( !ProcessSolid( pKeys ) )
                    return false;
            }
            else if ( !Q_stricmp( pKeys->GetName(), "connections" ) )
            {
                if ( !ProcessConnections( pKeys ) )
                    return false;
            }
            else if ( !Q_stricmp( pKeys->GetName(), "editor" ) )	// remove editor keys
            {
                KeyValues *pRemoveKey = pKeys;
                pKeys = pKeys->GetNextKey();
                pEntityKeys->RemoveSubKey( pRemoveKey );
                pRemoveKey->deleteThis();
                continue;
            }
        }
        else
        {
            if ( !ProcessEntityKey( pKeys ) )
                return false;
        }
        pKeys = pKeys->GetNextKey();
    }

    return true;
}
Ejemplo n.º 13
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void C_TFHintManager::ResetDisplayStats( void )
{
	if ( !m_pkvHintDisplayStats )
	{
		Assert( 0 );
		return;
	}

	KeyValues *kv = m_pkvHintDisplayStats->GetFirstSubKey();
	while ( kv )
	{
		KeyValues *subKey = kv->GetFirstSubKey();
		if ( subKey && stricmp( subKey->GetName(), "times_shown") )
		{
			while ( subKey )
			{
				subKey->SetString( "times_shown", "0" );
				subKey = subKey->GetNextKey();
			}
		}
		else
		{
			kv->SetString( "times_shown", "0" );
		}

		kv = kv->GetNextKey();
	}
}
Ejemplo n.º 14
0
bool VMFExporter::AddLevelContainer()
{
    KeyValues *pLevelContainerKeys = new KeyValues( "LevelContainer" );
    if ( !pLevelContainerKeys->LoadFromFile( g_pFullFileSystem, "tilegen/roomtemplates/levelcontainer.vmf.no_func_detail", "GAME" ) )
        return false;

    m_bWritingLevelContainer = true;

    // set the extents of the map
    m_pMapLayout->GetExtents(m_iMapExtents_XMin, m_iMapExtents_XMax, m_iMapExtents_YMin, m_iMapExtents_YMax);
    Msg( "Layout extents: Topleft: %f %f - Lower right: %f %f\n", m_iMapExtents_XMin, m_iMapExtents_YMin, m_iMapExtents_XMax, m_iMapExtents_YMax );
    // adjust to be relative to the centre of the map
    int half_map_size = MAP_LAYOUT_TILES_WIDE * 0.5f;
    m_iMapExtents_XMin -= half_map_size;
    m_iMapExtents_XMax -= half_map_size;
    m_iMapExtents_YMin -= half_map_size;
    m_iMapExtents_YMax -= half_map_size;
    // pad them by 2 blocks, so the player doesn't move his camera into the wall when at an edge block
    m_iMapExtents_XMin -= 2;
    m_iMapExtents_XMax += 2;
    m_iMapExtents_YMin -= 2;
    m_iMapExtents_YMax += 2;

    Msg( "   Adjusted to: Topleft: %d %d - Lower right: %d %d\n", m_iMapExtents_XMin, m_iMapExtents_YMin, m_iMapExtents_XMax, m_iMapExtents_YMax );

    // find world keys
    KeyValues *pWorldKeys = NULL;
    for ( KeyValues *pKeys = pLevelContainerKeys; pKeys; pKeys = pKeys->GetNextKey() )
    {
        const char *szName = pKeys->GetName();
        if ( !Q_stricmp( szName, "world" ) )
        {
            pWorldKeys = pKeys;
            break;
        }
    }
    if ( !pWorldKeys || !ProcessWorld( pWorldKeys ) )
    {
        Q_snprintf( m_szLastExporterError, sizeof(m_szLastExporterError), "Failed to copy level container\n" );
        return false;
    }

    m_bWritingLevelContainer = false;

    for ( KeyValues *pKeys = pWorldKeys->GetFirstSubKey(); pKeys; pKeys = pKeys->GetNextKey() )
    {
        const char *szName = pKeys->GetName();
        if ( !Q_stricmp( szName, "solid" ) )
        {
            m_pExportWorldKeys->AddSubKey( pKeys->MakeCopy() );
        }
    }
    pLevelContainerKeys->deleteThis();

    m_pTemplateKeys->deleteThis();
    m_pTemplateKeys = NULL;

    return true;
}
Ejemplo n.º 15
0
	virtual void FrameUpdatePostEntityThink( void )
	{
		// Wait until we're all spawned in
		if ( gpGlobals->curtime < 5 )
			return;

		if ( m_bIssuedNextMapCommand )
			return;

		if ( !m_bParsedMapFile )
		{
			m_bParsedMapFile = true;

			// See if we've got a camera file to import cameras from
			char szFullName[512];
			Q_snprintf(szFullName,sizeof(szFullName), "maps/%s.txt", STRING( gpGlobals->mapname ));
			KeyValues *pkvMapCameras = new KeyValues( "MapCameras" );
			if ( pkvMapCameras->LoadFromFile( filesystem, szFullName, "MOD" ) )
			{
				Warning( "Devshots: Loading point_devshot_camera positions from %s. \n", szFullName );

				// Get each camera, and add it to our list
				KeyValues *pkvCamera = pkvMapCameras->GetFirstSubKey();
				while ( pkvCamera )
				{
					// Get camera name
					const char *pCameraName = pkvCamera->GetName();

					// Make a camera, and move it to the position specified
					CPointDevShotCamera	*pCamera = (CPointDevShotCamera*)CreateEntityByName( "point_devshot_camera" );
					Assert( pCamera );
					pCamera->KeyValue( "cameraname", pCameraName );
					pCamera->KeyValue( "origin", pkvCamera->GetString( "origin", "0 0 0" ) );
					pCamera->KeyValue( "angles", pkvCamera->GetString( "angles", "0 0 0" ) );
					pCamera->KeyValue( "FOV", pkvCamera->GetString( "FOV", "75" ) );
					DispatchSpawn( pCamera );
					pCamera->Activate();

					// Move to next camera
					pkvCamera = pkvCamera->GetNextKey();
				}
			}

			if ( !g_iDevShotCameraCount )
			{
				Warning( "Devshots: No point_devshot_camera in %s. Moving to next map.\n", STRING( gpGlobals->mapname ) );

				CBasePlayer *pPlayer = UTIL_GetLocalPlayerOrListenServerHost();
				if ( pPlayer )
				{
					engine->ClientCommand( pPlayer->edict(), "devshots_nextmap" );
					m_bIssuedNextMapCommand = true;
					return;
				}
			}
		}
	}
Ejemplo n.º 16
0
void PrecacheFileWeaponInfoDatabase( IFileSystem *filesystem, const unsigned char *pICEKey )
{
	if ( m_WeaponInfoDatabase.Count() )
		return;

#if !defined( _XBOX )
	FileFindHandle_t findHandle;
	const char *pFilename = filesystem->FindFirstEx( "scripts/weapon_*.txt", IsXbox() ? "XGAME" : "GAME", &findHandle );
	while ( pFilename != NULL )
	{
		char fileBase[512];
		Q_FileBase( pFilename, fileBase, sizeof(fileBase) );
		WEAPON_FILE_INFO_HANDLE tmp;
#ifdef CLIENT_DLL
		if ( ReadWeaponDataFromFileForSlot( filesystem, fileBase, &tmp, pICEKey ) )
		{
			gWR.LoadWeaponSprites( tmp );
		}
#else
		ReadWeaponDataFromFileForSlot( filesystem, fileBase, &tmp, pICEKey );
#endif
		pFilename = filesystem->FindNext( findHandle );
	}
	filesystem->FindClose( findHandle );
#else
#define WEAPON_SCRIPT_MANIFEST_FILE		"scripts/_weapon_manifest.txt"

	// Use a manifest file on the xbox
	KeyValues *manifest = new KeyValues( "weaponscripts" );
	if ( manifest->LoadFromFile( filesystem, WEAPON_SCRIPT_MANIFEST_FILE, "XGAME" ) )
	{
		for ( KeyValues *sub = manifest->GetFirstSubKey(); sub != NULL ; sub = sub->GetNextKey() )
		{
			if ( !Q_stricmp( sub->GetName(), "file" ) )
			{
				char fileBase[512];
				Q_FileBase( sub->GetString(), fileBase, sizeof(fileBase) );
				WEAPON_FILE_INFO_HANDLE tmp;
#ifdef CLIENT_DLL
				if ( ReadWeaponDataFromFileForSlot( filesystem, fileBase, &tmp, pICEKey ) )
				{
					gWR.LoadWeaponSprites( tmp );
				}
#else
				ReadWeaponDataFromFileForSlot( filesystem, fileBase, &tmp, pICEKey );
#endif
			}
			else
			{
				Error( "Expecting 'file', got %s\n", sub->GetName() );
			}
		}
	}
	manifest->deleteThis();
#endif
}
Ejemplo n.º 17
0
//-----------------------------------------------------------------------------
// Purpose: create the Border objects from the scheme data
//-----------------------------------------------------------------------------
void CScheme::LoadBorders()
{
	m_pkvBorders = m_pData->FindKey("Borders", true);
	{for ( KeyValues *kv = m_pkvBorders->GetFirstSubKey(); kv != NULL; kv = kv->GetNextKey())
	{
		if (kv->GetDataType() == KeyValues::TYPE_STRING)
		{
			// it's referencing another border, ignore for now
		}
		else
		{
			int i = m_BorderList.AddToTail();

			Border *border = new Border();
			border->SetName(kv->GetName());
			border->ApplySchemeSettings(this, kv);

			m_BorderList[i].border = border;
			m_BorderList[i].bSharedBorder = false;
			m_BorderList[i].borderSymbol = kv->GetNameSymbol();
		}
	}}

	// iterate again to get the border references
	for ( KeyValues *kv = m_pkvBorders->GetFirstSubKey(); kv != NULL; kv = kv->GetNextKey())
	{
		if (kv->GetDataType() == KeyValues::TYPE_STRING)
		{
			// it's referencing another border, find it
			Border *border = (Border *)GetBorder(kv->GetString());
//			const char *str = kv->GetName();
			Assert(border);

			// add an entry that just references the existing border
			int i = m_BorderList.AddToTail();
			m_BorderList[i].border = border;
			m_BorderList[i].bSharedBorder = true;
			m_BorderList[i].borderSymbol = kv->GetNameSymbol();
		}
	}
	
	m_pBaseBorder = GetBorder("BaseBorder");
}
Ejemplo n.º 18
0
//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
bool CTFIntroMenu::LoadCaptions( void )
{
	bool bSuccess = false;

	// clear any current captions
	m_Captions.PurgeAndDeleteElements();
	m_iCurrentCaption = 0;

	if ( m_pCaptionLabel )
	{
		KeyValues *kvCaptions = NULL;
		char strFullpath[MAX_PATH];

		Q_strncpy( strFullpath, TFGameRules()->GetVideoFileForMap( false ), MAX_PATH );	// Assume we must play out of the media directory
		Q_strncat( strFullpath, ".res", MAX_PATH );					// Assume we're a .res extension type

		if ( g_pFullFileSystem->FileExists( strFullpath ) )
		{
			kvCaptions = new KeyValues( strFullpath );

			if ( kvCaptions )
			{
				if ( kvCaptions->LoadFromFile( g_pFullFileSystem, strFullpath ) )
				{
					for ( KeyValues *pData = kvCaptions->GetFirstSubKey(); pData != NULL; pData = pData->GetNextKey() )
					{
						CVideoCaption *pCaption = new CVideoCaption;
						if ( pCaption )
						{
							pCaption->m_pszString = ReadAndAllocStringValue( pData, "string" );
							pCaption->m_flStartTime = pData->GetFloat( "start", 0.0 );
							pCaption->m_flDisplayTime = pData->GetFloat( "length", 3.0 );

							m_Captions.AddToTail( pCaption );

							// we have at least one caption to show
							bSuccess = true;
						}
					}
				}

				kvCaptions->deleteThis();
			}
		}
	}

	if ( bSuccess )
	{
		// sort the captions so we show them in the correct order (they're not necessarily in order in the .res file)
		m_Captions.Sort( CaptionsSort );
	}

	return bSuccess;
}
void CRuleInstanceNodePanel::CreatePanelContents()
{
	KeyValues *pNodeKV = GetData();

	// If this rule instance is wrapped in a dummy key values node, move down a level.
	if ( HasDummyContainerNode() )
	{
		pNodeKV = pNodeKV->GetFirstSubKey();
	}

	m_bDisabled = pNodeKV->GetBool( "disabled", false );
	m_pChangeRuleButton = new Button( this, "ChangeRule", "Change", this, "ChangeRule" );
	AddHeadingElement( m_pChangeRuleButton, 0.0f );
	m_pDisableRuleButton = new Button( this, "DisableRule", m_bDisabled ? "Enable" : "Disable", this, "DisableRule" );
	AddHeadingElement( m_pDisableRuleButton, 0.0f );
	
	Assert( pNodeKV != NULL );

	const char *pRuleName = pNodeKV->GetString( "name", NULL );
	
	if ( pRuleName == NULL )
	{
		Q_snprintf( m_NodeLabel, m_nNameLength, "No Rule specified" );
	}
	else
	{
		const CTilegenMissionPreprocessor *pPreprocessor = GetEditor()->GetPreprocessor();
		const CTilegenRule *pRule = pPreprocessor->FindRule( pRuleName );
		if ( pRule != NULL )
		{
			GetTooltip()->SetText( pRule->GetDescription() );

			if ( !m_bDisabled )
			{
				for ( int i = 0; i < pRule->GetParameterCount(); ++ i )
				{
					// @TODO: need to error if a non-optional parameter is missing
					const char *pParameterName = pRule->GetParameterName( i );
					KeyValues *pInstanceParameterKV = pNodeKV->FindKey( pParameterName );
					CRuleInstanceParameterPanel *pPanel = new CRuleInstanceParameterPanel( this, "text_entry", pRule, i );
					pPanel->SetEditor( GetEditor() );
					pPanel->SetData( pInstanceParameterKV );
					AddChild( pPanel, 0 );
				}
			}

			Q_snprintf( m_NodeLabel, m_nNameLength, "%s", pRule->GetFriendlyName() );
		}
		else
		{
			Q_snprintf( m_NodeLabel, m_nNameLength, "Rule '%s' not found!", pRuleName );
		}
	}
}
const char* CASW_Mission_Chooser_Source_Local::GetPrettySavedCampaignName(const char *szSaveName)
{
	static char szPrettyName[256];
	szPrettyName[0] = '\0';

	char stripped[MAX_PATH];
	V_StripExtension( szSaveName, stripped, MAX_PATH );
	char tempfile[MAX_PATH];
	Q_snprintf( tempfile, sizeof( tempfile ), "save/%s.campaignsave", stripped );

	KeyValues *pSaveKeyValues = new KeyValues( szSaveName );
	if (pSaveKeyValues->LoadFromFile(g_pFullFileSystem, tempfile))
	{
		const char *szCampaignName = pSaveKeyValues->GetString("CampaignName");
		const char *szPrettyCampaignName = szCampaignName;
		if (szCampaignName && Q_strlen(szCampaignName) > 0)
		{
			szPrettyCampaignName = GetPrettyCampaignName(szCampaignName);
		}
		const char *szDate = pSaveKeyValues->GetString("DateTime");
		char namebuffer[256];
		namebuffer[0] = '\0';
		int namepos = 0;
		KeyValues *pkvSubSection = pSaveKeyValues->GetFirstSubKey();
		while ( pkvSubSection && namepos < 253)
		{
			if (Q_stricmp(pkvSubSection->GetName(), "PLAYER")==0)
			{
				const char *pName = pkvSubSection->GetString("PlayerName");
				if (pName && pName[0] != '\0')
				{
					if (namepos != 0)
					{
						namebuffer[namepos] = ' '; namepos++;
					}
					int namelength = Q_strlen(pName);
					for (int charcopy=0; charcopy<namelength && namepos<253; charcopy++)
					{
						namebuffer[namepos] = pName[charcopy];
						namepos++;
					}
					namebuffer[namepos] = '\0';
				}
			}
			pkvSubSection = pkvSubSection->GetNextKey();
		}
		Q_snprintf(szPrettyName, sizeof(szPrettyName),
			"%s (%s) (%s)",
			szPrettyCampaignName, szDate, namebuffer);
	}
	pSaveKeyValues->deleteThis();

	return szPrettyName;
}
void CGECharacterDataParser::Parse( KeyValues *pKeyValuesData, const char *szFileWithoutEXT )
{
	CGECharData *pChar = g_GECharacters.Add( szFileWithoutEXT );

	Q_strncpy( pChar->szPrintName,	pKeyValuesData->GetString("printname",		"#GE_UNNAMED"),	MAX_CHAR_IDENT );
	Q_strncpy( pChar->szShortName,	pKeyValuesData->GetString("shortname",		"#GE_UNNAMED"),	MAX_CHAR_NAME  );
	Q_strncpy( pChar->szBio,		pKeyValuesData->GetString("bio",			""			 ),	MAX_CHAR_BIO   );

	// Load our weight
	pChar->iWeight = pKeyValuesData->GetInt( "weight" );

	// Affiliate them with a team
	const char *team = pKeyValuesData->GetString( "team", "unassigned" );
	if ( !Q_stricmp(team, "mi6") )
		pChar->iTeam = TEAM_MI6;
	else if ( !Q_stricmp(team, "janus") )
		pChar->iTeam = TEAM_JANUS;
	else
		pChar->iTeam = TEAM_UNASSIGNED;

	const char *gender = pKeyValuesData->GetString( "gender", "m" );
	if ( gender[0] == 'f' )
		pChar->iGender = CHAR_GENDER_FEMALE;
	else
		pChar->iGender = CHAR_GENDER_MALE;

	// Load our skins in
	KeyValues *pSkinValues = pKeyValuesData->FindKey( "skins" );
	if ( pSkinValues )
	{
		KeyValues *pSkinData = pSkinValues->GetFirstSubKey();
		for( int i=0; i < MAX_CHAR_SKINS; i++ )
		{
			if( pSkinData == NULL )
				break;

			GECharSkin *skin = new GECharSkin;

			Q_strncpy( skin->szIdent,		pSkinData->GetName(),								MAX_CHAR_IDENT );
			Q_strncpy( skin->szPreviewImg,	pSkinData->GetString("previewimg", "unknown"	 ),	MAX_CHAR_NAME  );
			Q_strncpy( skin->szModel,		pSkinData->GetString("model",	   ""			 ),	MAX_MODEL_PATH );
			Q_strncpy( skin->szHatModel,	pSkinData->GetString("hatmodel",   ""			 ),	MAX_MODEL_PATH );
			
			skin->iViewSkin	 = pSkinData->GetInt( "viewmodelskin",  0 );
			skin->iWorldSkin = pSkinData->GetInt( "worldmodelskin", 0 );

			// TODO: We need to error check this input....
			pChar->m_pSkins.AddToTail( skin );

			pSkinData = pSkinData->GetNextKey();
		}
	}
}
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *filename - 
//-----------------------------------------------------------------------------
void CSoundEmitterSystemBase::AddSoundsFromFile( const char *filename, bool precachealways )
{
	CSoundScriptFile sf;
	Assert( Q_strlen( filename ) < sizeof( sf.filename ) );
	Q_strncpy( sf.filename, filename, sizeof( sf.filename ) );
	sf.dirty = false;
	sf.precachealways = precachealways;

	int scriptindex = m_SoundKeyValues.AddToTail( sf );

	// Open the soundscape data file, and abort if we can't
	KeyValues *kv = new KeyValues( filename );

	if ( kv->LoadFromFile( filesystem, filename, "GAME" ) )
	{
		// parse out all of the top level sections and save their names
		KeyValues *pKeys = kv;
		while ( pKeys )
		{
			if ( pKeys->GetFirstSubKey() )
			{
				CSoundEntry entry;
				entry.m_bRemoved			= false;
				entry.m_nScriptFileIndex	= scriptindex;
				entry.m_bPrecacheAlways		= precachealways;

				int lookup = m_Sounds.Find( pKeys->GetName() );
				if ( lookup != m_Sounds.InvalidIndex() )
				{
					DevMsg( "CSoundEmitterSystem::AddSoundsFromFile(%s):  Entry %s duplicated, skipping\n", filename, pKeys->GetName() );
				}
				else
				{
					InitSoundInternalParameters( pKeys->GetName(), pKeys, entry.m_SoundParams );
					m_Sounds.Insert( pKeys->GetName(), entry );
				}
			}
			pKeys = pKeys->GetNextKey();
		}
	}
	else
	{
		Msg( "CSoundEmitterSystem::AddSoundsFromFile:  No such file %s\n", filename );

		// Discard
		m_SoundKeyValues.Remove( scriptindex );

		kv->deleteThis();
		return;
	}

	Assert( scriptindex >= 0 );
}
//-----------------------------------------------------------------------------
// Purpose: 
// Output : Returns true on success, false on failure.
//-----------------------------------------------------------------------------
bool CSoundEmitterSystemBase::BaseInit()
{
	if ( m_SoundKeyValues.Count() > 0 )
	{
		BaseShutdown();
	}

	KeyValues *manifest = new KeyValues( MANIFEST_FILE );
	if ( manifest->LoadFromFile( filesystem, MANIFEST_FILE, "GAME" ) )
	{
		for ( KeyValues *sub = manifest->GetFirstSubKey(); sub != NULL; sub = sub->GetNextKey() )
		{
			if ( !Q_stricmp( sub->GetName(), "precache_file" ) )
			{
				// Add and always precache
				AddSoundsFromFile( sub->GetString(), true );
				continue;
			}
			else if ( !Q_stricmp( sub->GetName(), "declare_file" ) )
			{
				// Add but don't precache
				AddSoundsFromFile( sub->GetString(), false );
				continue;
			}

			Warning( "CSoundEmitterSystemBase::BaseInit:  Manifest '%s' with bogus file type '%s', expecting 'declare_file' or 'precache_file'\n", 
				MANIFEST_FILE, sub->GetName() );
		}
	}
	else
	{
		Error( "Unable to load manifest file '%s'\n", MANIFEST_FILE );
	}


// Only print total once, on server
#if !defined( CLIENT_DLL )
	int missing = CheckForMissingWavFiles( false );

	if ( missing > 0 )
	{
		DevMsg( 1, "CSoundEmitterSystem:  Registered %i sounds ( %i missing .wav files referenced )\n",
			m_Sounds.Count(), missing );
	}
	else
	{
		DevMsg( 1, "CSoundEmitterSystem:  Registered %i sounds\n",
			m_Sounds.Count() );
	}
#endif

	return true;
}
Ejemplo n.º 24
0
static cell_t smn_KvDeleteThis(IPluginContext *pContext, const cell_t *params)
{
	Handle_t hndl = static_cast<Handle_t>(params[1]);
	HandleError herr;
	HandleSecurity sec;
	KeyValueStack *pStk;

	sec.pOwner = NULL;
	sec.pIdentity = g_pCoreIdent;

	if ((herr=handlesys->ReadHandle(hndl, g_KeyValueType, &sec, (void **)&pStk))
		!= HandleError_None)
	{
		return pContext->ThrowNativeError("Invalid key value handle %x (error %d)", hndl, herr);
	}

	if (pStk->pCurRoot.size() < 2)
	{
		return 0;
	}

	KeyValues *pValues = pStk->pCurRoot.front();
	pStk->pCurRoot.pop();
	KeyValues *pRoot = pStk->pCurRoot.front();

	/* We have to manually verify this since Valve sucks
	 * :TODO: make our own KeyValues.h file and make
	 * the sub stuff private so we can do this ourselves!
 	 */
	KeyValues *sub = pRoot->GetFirstSubKey();
	while (sub)
	{
		if (sub == pValues)
		{
			KeyValues *pNext = pValues->GetNextKey();
			pRoot->RemoveSubKey(pValues);
			pValues->deleteThis();
			if (pNext)
			{
				pStk->pCurRoot.push(pNext);
				return 1;
			} else {
				return -1;
			}
		}
		sub = sub->GetNextKey();
	}

	/* Push this back on :( */
	pStk->pCurRoot.push(pValues);

	return 0;
}
Ejemplo n.º 25
0
//-----------------------------------------------------------------------------
// Clear out the stats + their history
//-----------------------------------------------------------------------------
void CPropData::ParsePropDataFile( void )
{
	m_pKVPropData = new KeyValues( "PropDatafile" );
	if ( !m_pKVPropData->LoadFromFile( filesystem, "scripts/propdata.txt" ) )
	{
		m_pKVPropData->deleteThis();
		m_pKVPropData = NULL;
		return;
	}

	m_bPropDataLoaded = true;

	// Now try and parse out the breakable section
	KeyValues *pBreakableSection = m_pKVPropData->FindKey( "BreakableModels" );
	if ( pBreakableSection )
	{
		KeyValues *pChunkSection = pBreakableSection->GetFirstSubKey();
		while ( pChunkSection )
		{
			// Create a new chunk section and add it to our list
			int index = m_BreakableChunks.AddToTail();
			propdata_breakablechunk_t *pBreakableChunk = &m_BreakableChunks[index];
			pBreakableChunk->iszChunkType = AllocPooledString( pChunkSection->GetName() );

			// Read in all the model names
			KeyValues *pModelName = pChunkSection->GetFirstSubKey();
			while ( pModelName )
			{
				const char *pModel = pModelName->GetName();
				string_t pooledName = AllocPooledString( pModel );
				pBreakableChunk->iszChunkModels.AddToTail( pooledName );
				CBaseEntity::PrecacheModel( STRING( pooledName ) );

				pModelName = pModelName->GetNextKey();
			}

			pChunkSection = pChunkSection->GetNextKey();
		}
	}
}	
//-----------------------------------------------------------------------------
// Purpose:
//-----------------------------------------------------------------------------
void CMaterialSubRect::ParseMaterialVars( KeyValues &keyValues )
{
	KeyValues *pKeyValues = &keyValues;

	// I'm not quite sure how this can happen, but we'll see... 
	const char *pShaderName = pKeyValues->GetName();
	if ( !pShaderName )
	{
		DevWarning( 1, "CMaterialSubRect::InitializeShader: Shader not specified in material %s.\n", GetName() );
		Assert( 0 );
		pShaderName = IsPC() ? "Wireframe_DX6" : "Wireframe_DX9";
	}

	// Verify we have the correct "shader."  There is only one type.
	if ( !Q_strcmp( pShaderName, "Subrect" ) )
	{
		KeyValues *pVar = pKeyValues->GetFirstSubKey();
		while ( pVar )
		{
			if ( !Q_strcmp( pVar->GetName(), "$Pos" ) )
			{
				sscanf( pVar->GetString(), "%f %f", &m_vecOffset.x, &m_vecOffset.y );
			}

			if ( !Q_strcmp( pVar->GetName(), "$Size" ) )
			{
				sscanf( pVar->GetString(), "%f %f", &m_vecSize.x, &m_vecSize.y );
			}

			if ( !Q_strcmp( pVar->GetName(), "$Material" ) )
			{
				m_pMaterialPage = static_cast<IMaterialInternal*>( MaterialSystem()->FindMaterial( pVar->GetString(), TEXTURE_GROUP_DECAL ) );
				m_pMaterialPage = m_pMaterialPage->GetRealTimeVersion(); //always work with the realtime material internally
			}

//			if ( !Q_strcmp( pVar->GetName(), "$decalscale" ) )
//			{
//				m_flDecalScale = pVar->GetFloat();
//			}

			// Add var to list.
			IMaterialVar *pNewVar = CreateMaterialVarFromKeyValue( this, pVar );
			if ( pNewVar )
			{
				m_aMaterialVars.AddToTail( pNewVar );		
			}

			// Continue getting the keys until they are all found.
			pVar = pVar->GetNextKey();
		}
	}
}
//---------------------------------------------------------------------
// Purpose: Parse session properties and contexts from the resource file
//---------------------------------------------------------------------
void CSessionBrowserDialog::ApplySettings( KeyValues *pResourceData )
{
	BaseClass::ApplySettings( pResourceData );

	KeyValues *pScenarios = pResourceData->FindKey( "ScenarioInfoPanels" );
	if ( pScenarios )
	{
		for ( KeyValues *pScenario = pScenarios->GetFirstSubKey(); pScenario != NULL; pScenario = pScenario->GetNextKey() )
		{
			CScenarioInfoPanel *pScenarioInfo = new CScenarioInfoPanel( this, "ScenarioInfoPanel" );
			SETUP_PANEL( pScenarioInfo );
			pScenarioInfo->m_pTitle->SetText( pScenario->GetString( "title" ) );
			pScenarioInfo->m_pSubtitle->SetText( pScenario->GetString( "subtitle" ) );
			pScenarioInfo->m_pMapImage->SetImage( pScenario->GetString( "image" ) );

			int nTall = pScenario->GetInt( "tall", -1 );
			if ( nTall > 0 )
			{
				pScenarioInfo->SetTall( nTall );
			}

			int nXPos = pScenario->GetInt( "xpos", -1 );
			if ( nXPos >= 0 )
			{
				int x, y;
				pScenarioInfo->GetPos( x, y );
				pScenarioInfo->SetPos( nXPos, y );
			}

			int nDescOneYpos = pScenario->GetInt( "descOneY", -1 );
			if ( nDescOneYpos > 0 )
			{
				int x, y;
				pScenarioInfo->m_pDescOne->GetPos( x, y );
				pScenarioInfo->m_pDescOne->SetPos( x, nDescOneYpos );
			}

			int nDescTwoYpos = pScenario->GetInt( "descTwoY", -1 );
			if ( nDescTwoYpos > 0 )
			{
				int x, y;
				pScenarioInfo->m_pDescTwo->GetPos( x, y );
				pScenarioInfo->m_pDescTwo->SetPos( x, nDescTwoYpos );
			}

			m_pScenarioInfos.AddToTail( pScenarioInfo );
		}
	}
}
Ejemplo n.º 28
0
void BuildCheckdirList()
{
	vprint( 0, "Checking for dirlist\n" );
	// Search for unusedcontent.cfg file
	if ( g_pFileSystem->FileExists( UNUSEDCONTENT_CFG, "GAME") )
	{
		KeyValues *kv = new KeyValues( UNUSEDCONTENT_CFG );
		if ( kv )
		{
			if ( kv->LoadFromFile( g_pFileSystem, UNUSEDCONTENT_CFG, "GAME" ) )
			{
				for ( KeyValues *sub = kv->GetFirstSubKey(); sub; sub = sub->GetNextKey() )
				{
					if ( !Q_stricmp( sub->GetName(), "dir" ) )
					{
						AddCheckdir( sub->GetString() );
					}
					else if ( !Q_stricmp( sub->GetName(), "ignore" ) )
					{
						AddIgnoredir( sub->GetString() );
					}
					else
					{
						vprint( 1, "Unknown subkey '%s' in %s\n", sub->GetName(), UNUSEDCONTENT_CFG );
					}
				}
			}

			kv->deleteThis();
		}
	}
	else
	{
		int c = ARRAYSIZE( directories_to_check );
		int i;
		for ( i = 0; i < c; ++i )
		{
			AddCheckdir( directories_to_check[ i ] );
		}

		// add the list of dirs to ignore from the others lists
		c = ARRAYSIZE( directories_to_ignore );
		for ( i = 0; i < c; ++i )
		{
			AddIgnoredir( directories_to_ignore[ i ] );
		}
	}
}
Ejemplo n.º 29
0
void OverrideDefaultsForModel( const char *keyname, simplifyparams_t &params )
{
	KeyValues *pKeys = g_pModelConfig;
	while ( pKeys )
	{
		if ( !Q_stricmp( pKeys->GetName(), keyname ) )
		{
			for ( KeyValues *pData = pKeys->GetFirstSubKey(); pData; pData = pData->GetNextKey() )
			{
				if ( !Q_stricmp( pData->GetName(), "tolerance" ) )
				{
					params.tolerance = pData->GetFloat();
					if (!g_bQuiet)
					{
						Msg("%s: tolerance set to %.2f\n", keyname, params.tolerance );
					}
				}
				else if ( !Q_stricmp( pData->GetName(), "addAABB" ) )
				{
					params.addAABBToSimplifiedHull = pData->GetInt() ? true : false;
					if (!g_bQuiet)
					{
						Msg("%s: AABB %s\n", keyname, params.addAABBToSimplifiedHull ? "on" : "off" );
					}
				}
				else if ( !Q_stricmp( pData->GetName(), "singleconvex" ) )
				{
					params.forceSingleConvex = pData->GetInt() ? true : false;
					if (!g_bQuiet)
					{
						Msg("%s: Forced to single convex\n", keyname );
					}
				}
				else if ( !Q_stricmp( pData->GetName(), "mergeconvex" ) )
				{
					params.mergeConvexTolerance = pData->GetFloat();
					params.mergeConvexElements = params.mergeConvexTolerance > 0 ? true : false;
					if (!g_bQuiet)
					{
						Msg("%s: Merge convex %.2f\n", keyname, params.mergeConvexTolerance );
					}
				}
			}
			return;
		}
		pKeys = pKeys->GetNextKey();
	}
}
Ejemplo n.º 30
0
KeyValues* SwarmopediaTopics::GetSubkeyForList(const char *szListName)
{
	// now go through each mission section, adding it
	KeyValues *pkvList = m_pKeys->GetFirstSubKey();
	while ( pkvList )
	{
		if (Q_stricmp(pkvList->GetName(), "LIST")==0)
		{
			const char *szName = pkvList->GetString("ListName");
			if (!Q_stricmp(szName, szListName))
				return pkvList->GetFirstSubKey();
		}
		pkvList = pkvList->GetNextKey();
	}
	return NULL;
}