当前位置: 首页>>代码示例>>C++>>正文


C++ KeyValues::LoadFromFile方法代码示例

本文整理汇总了C++中KeyValues::LoadFromFile方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyValues::LoadFromFile方法的具体用法?C++ KeyValues::LoadFromFile怎么用?C++ KeyValues::LoadFromFile使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在KeyValues的用法示例。


在下文中一共展示了KeyValues::LoadFromFile方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: GetNumMissionsCompleted

int CASW_Mission_Chooser_Source_Local::GetNumMissionsCompleted(const char *szSaveName)
{
	Msg("GetNumMissionsCompleted %s\n", szSaveName);
	// check the save file exists
	char stripped[MAX_PATH];
	V_StripExtension( szSaveName, stripped, MAX_PATH );
	Msg("  stripped = %s\n", stripped);
	char tempfile[MAX_PATH];
	Q_snprintf( tempfile, sizeof( tempfile ), "save/%s.campaignsave", stripped );
	Msg("  tempfile = %s\n", tempfile);
	Q_strlower( tempfile );
	Msg("  tempfile lowered = %s\n", tempfile);
	if (!g_pFullFileSystem->FileExists(tempfile))
	{
		Msg("  this save doesn't exist! returning -1 missions\n");		
		return -1;
	}

	KeyValues *pSaveKeyValues = new KeyValues( szSaveName );
	if (pSaveKeyValues->LoadFromFile(g_pFullFileSystem, tempfile))
	{
		int iMissions = pSaveKeyValues->GetInt("NumMissionsComplete");
		pSaveKeyValues->deleteThis();
		Msg(" loaded keyvalues from file and it thinks num missions is %d\n", iMissions);
		return iMissions;
	}
	
	Msg("  Couldn't load save keyvalues from file, returning -1\n");
	if (pSaveKeyValues->LoadFromFile(g_pFullFileSystem, tempfile, "MOD"))
		Msg("  but it loaded if we use the MOD path\n");
	else if (pSaveKeyValues->LoadFromFile(g_pFullFileSystem, tempfile, "GAME"))
		Msg("  but it loaded if we use the GAME path\n");
	pSaveKeyValues->deleteThis();
	return -1;
}
开发者ID:Randdalf,项目名称:bliink,代码行数:35,代码来源:asw_mission_chooser_source_local.cpp

示例2: KeyValues

CVGUIProjectable *CProjectableFactory::AllocateProjectableByScript( const char *pszFileName )
{
	CVGUIProjectable *pPanel = NULL;

	KeyValues *pKV = new KeyValues("");

	bool bSuccess = pKV->LoadFromFile( g_pFullFileSystem, VarArgs( "%s/%s", PATHLOCATION_PROJECTABLE_SCRIPTS, pszFileName ) );
	if ( !bSuccess )
		bSuccess = pKV->LoadFromFile( g_pFullFileSystem, VarArgs( "%s/%s.txt", PATHLOCATION_PROJECTABLE_SCRIPTS, pszFileName ) );

	if ( bSuccess )
	{
		const char *pszFactoryName = pKV->GetString( "factory" );

		if ( pszFactoryName != NULL && *pszFactoryName != '\0' )
			pPanel = AllocateProjectableByName( pszFactoryName );

		if ( pPanel != NULL )
		{
			KeyValues *pConfig = pKV->FindKey( "config" );

			if ( pConfig != NULL )
			{
				pPanel->LoadProjectableConfig( pConfig );
				pPanel->InvalidateLayout( true, true );
			}
		}
	}

	pKV->deleteThis();

	return pPanel;
}
开发者ID:AniCator,项目名称:Project-Potato,代码行数:33,代码来源:projectable_factory.cpp

示例3: LoadControlSettings

// Load the control settings 
void CBaseModFrame::LoadControlSettings( const char *dialogResourceName, const char *pathID, KeyValues *pPreloadedKeyValues, KeyValues *pConditions )
{
	// Use the keyvalues they passed in or load them using special hook for flyouts generation
	KeyValues *rDat = pPreloadedKeyValues;
	if ( !rDat )
	{
		// load the resource data from the file
		rDat  = new KeyValues(dialogResourceName);

		// check the skins directory first, if an explicit pathID hasn't been set
		bool bSuccess = false;
		if ( !IsX360() && !pathID )
		{
			bSuccess = rDat->LoadFromFile( g_pFullFileSystem, dialogResourceName, "SKIN" );
		}
		if ( !bSuccess )
		{
			bSuccess = rDat->LoadFromFile( g_pFullFileSystem, dialogResourceName, pathID );
		}
		if ( bSuccess )
		{
			if ( IsX360() )
			{
				rDat->ProcessResolutionKeys( surface()->GetResolutionKey() );
			}
			if ( pConditions && pConditions->GetFirstSubKey() )
			{
				GetBuildGroup()->ProcessConditionalKeys( rDat, pConditions );
			}
		}
	}

	// Find the auto-generated-chapter hook
	if ( KeyValues *pHook = rDat->FindKey( "FlmChapterXXautogenerated" ) )
	{
		const int numMaxAutogeneratedFlyouts = 20;
		for ( int k = 1; k <= numMaxAutogeneratedFlyouts; ++ k )
		{
			KeyValues *pFlyoutInfo = pHook->MakeCopy();
			
			CFmtStr strName( "FlmChapter%d", k );
			pFlyoutInfo->SetName( strName );
			pFlyoutInfo->SetString( "fieldName", strName );
			
			pFlyoutInfo->SetString( "ResourceFile", CFmtStr( "FlmChapterXXautogenerated_%d/%s", k, pHook->GetString( "ResourceFile" ) ) );

			rDat->AddSubKey( pFlyoutInfo );
		}

		rDat->RemoveSubKey( pHook );
		pHook->deleteThis();
	}

	BaseClass::LoadControlSettings( dialogResourceName, pathID, rDat, pConditions );
	if ( rDat != pPreloadedKeyValues )
	{
		rDat->deleteThis();
	}
}
开发者ID:Au-heppa,项目名称:swarm-sdk,代码行数:60,代码来源:basemodframe.cpp

示例4: LoadSchemeFromFileEx

// first scheme loaded becomes the default scheme, and all subsequent loaded scheme are derivitives of that
HScheme  CSchemeManager::LoadSchemeFromFileEx( VPANEL sizingPanel, const char *fileName, const char *tag)
{
	// Look to see if we've already got this scheme...
	HScheme hScheme = FindLoadedScheme(fileName);
	if (hScheme != 0)
	{
		CScheme *pScheme = static_cast< CScheme * >( GetIScheme( hScheme ) );
		if ( IsPC() && pScheme )
		{
			pScheme->ReloadFontGlyphs();
		}
		return hScheme;
	}

	KeyValues *data;
	data = new KeyValues("Scheme");

	data->UsesEscapeSequences( true );	// VGUI uses this
	
	// look first in skins directory
	bool result = data->LoadFromFile( g_pFullFileSystem, fileName, "SKIN" );
	if (!result)
	{
		result = data->LoadFromFile( g_pFullFileSystem, fileName, "GAME" );
		if ( !result )
		{
			// look in any directory
			result = data->LoadFromFile( g_pFullFileSystem, fileName, NULL );
		}
	}

	if (!result)
	{
		data->deleteThis();
		return 0;
	}
	
	if ( IsX360() )
	{
		data->ProcessResolutionKeys( g_pSurface->GetResolutionKey() );
	}
	if ( IsPC() )
	{
		ConVarRef cl_hud_minmode( "cl_hud_minmode", true );
		if ( cl_hud_minmode.IsValid() && cl_hud_minmode.GetBool() )
		{
			data->ProcessResolutionKeys( "_minmode" );
		}
	}

	CScheme *newScheme = new CScheme();
	newScheme->LoadFromFile( sizingPanel, fileName, tag, data );

	return m_Schemes.AddToTail(newScheme);
}
开发者ID:DeadZoneLuna,项目名称:SourceEngine2007,代码行数:56,代码来源:Scheme.cpp

示例5: GetCampaignSaveIntroMap

const char* CASW_Mission_Chooser_Source_Local::GetCampaignSaveIntroMap(const char *szSaveName)
{
	// check the save file exists
	char stripped[MAX_PATH];
	V_StripExtension( szSaveName, stripped, MAX_PATH );
	char tempfile[MAX_PATH];
	Q_snprintf( tempfile, sizeof( tempfile ), "save/%s.campaignsave", stripped );
	if (!g_pFullFileSystem->FileExists(tempfile))
		return ASW_DEFAULT_INTRO_MAP;

	KeyValues *pSaveKeyValues = new KeyValues( szSaveName );
	const char* pszCampaign = NULL;
	if (pSaveKeyValues->LoadFromFile(g_pFullFileSystem, tempfile))
	{		
		pszCampaign = pSaveKeyValues->GetString("CampaignName");
	}
	if (!pszCampaign)
	{
		pSaveKeyValues->deleteThis();
		return ASW_DEFAULT_INTRO_MAP;
	}

	char ctempfile[MAX_PATH];
	Q_snprintf( ctempfile, sizeof( ctempfile ), "resource/campaigns/%s.txt", pszCampaign );
	if (!g_pFullFileSystem->FileExists(ctempfile))	/// check it exists
	{
		pSaveKeyValues->deleteThis();
		return ASW_DEFAULT_INTRO_MAP;
	}

	// now read in the campaign txt and find the intro map name
	KeyValues *pCampaignKeyValues = new KeyValues( pszCampaign );
	if (pCampaignKeyValues->LoadFromFile(g_pFullFileSystem, ctempfile))
	{
		static char s_introname[128];
		Q_strncpy( s_introname, pCampaignKeyValues->GetString("IntroMap"), 128 );
		// check we actually got a valid intro map name string
		if ( Q_strlen(s_introname) > 5 && !Q_strnicmp( s_introname, "intro", 5 ) )
		{
			pSaveKeyValues->deleteThis();
			pCampaignKeyValues->deleteThis();
			return s_introname;
		}
	}

	pSaveKeyValues->deleteThis();
	pCampaignKeyValues->deleteThis();
	return ASW_DEFAULT_INTRO_MAP;
}
开发者ID:Randdalf,项目名称:bliink,代码行数:49,代码来源:asw_mission_chooser_source_local.cpp

示例6: EditablePanel

//-----------------------------------------------------------------------------
// 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);
}
开发者ID:NFMynster,项目名称:DoubleAction,代码行数:29,代码来源:da_menubuttonpanel.cpp

示例7: KeyValues

//-----------------------------------------------------------------------------
// Purpose: Constructor
//-----------------------------------------------------------------------------
CGameMenuButton::CGameMenuButton(vgui::Panel *parent, const char *panelName, const char *text)
								: vgui::MenuButton( parent, panelName, text )
{
	g_pGameMenuButton = this;
	vgui::Menu *gameMenu = NULL;

	// load settings from config file
	KeyValues *datafile = new KeyValues("GameMenu");
	datafile->UsesEscapeSequences( true );
	if (datafile->LoadFromFile(filesystem(), "Resource/GameMenu.res"))
	{
		gameMenu = RecursiveLoadGameMenu(datafile);
		datafile->deleteThis();
	}
	else
	{
		// add a bunch of default stuff
		assert(!("Could not load file Resource/GameMenu.res"));
		gameMenu = new vgui::Menu(this, "GameMenu");
		gameMenu->AddMenuItem( "#GameUI_GameMenu_NewGame ", "OpenNewGameDialog", this );
		gameMenu->AddMenuItem( "#GameUI_GameMenu_LoadGame ", "OpenLoadGameDialog", this );
		gameMenu->AddMenuItem( "SaveGame", "#GameUI_GameMenu_SaveGame ", "OpenSaveGameDialog", this );
		gameMenu->AddMenuItem( "#GameUI_GameMenu_Multiplayer ", "OpenMultiplayerDialog", this );
		gameMenu->AddMenuItem( "#GameUI_GameMenu_Options ", "OpenOptionsDialog", this );
		gameMenu->AddMenuItem( "#GameUI_GameMenu_Quit ", "Quit", this );
	}

	m_pMenu = gameMenu;

	gameMenu->MakePopup();
	MenuButton::SetMenu(gameMenu);
	SetOpenDirection(MenuButton::UP);
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:36,代码来源:GameMenuButton.cpp

示例8: RunPlayerInit

bool CMapAdd::RunPlayerInit( const char *mapaddMap, const char *szLabel)
{
	if(AllocPooledString(mapaddMap) == AllocPooledString("") || !mapaddMap)
		return false; //Failed to load!
	if(!szLabel)
		szLabel = "Init";
	//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)
			{
				HandlePlayerEntity(pMapAddEnt, false);
				pMapAddEnt = pMapAddEnt->GetNextTrueSubKey(); //Got to keep this!
			}
		}
	}
	pMapAdd->deleteThis();
	return true;
}
开发者ID:sirmastercombat,项目名称:SirMasters_Mod,代码行数:25,代码来源:mapadd.cpp

示例9: MountExtraContent

//-----------------------------------------------------------------------------
// Purpose: 
//-----------------------------------------------------------------------------
void MountExtraContent()
{
	memset(g_AppStatus, 0, sizeof(g_AppStatus));

	KeyValues *pMountList = new KeyValues( "MountList" );
	if( !pMountList->LoadFromFile( filesystem, "mountlist.txt" ) )
	{
		// Create default
		pMountList->SetString( "dota", "0" );
		pMountList->SetString( "left4dead", "0" );
		pMountList->SetString( "left4dead2", "0" );
		pMountList->SetString( "portal2", "0" );
		pMountList->SetString( "csgo", "0" );
		pMountList->SetString( "dearesther", "0" );
		
		pMountList->SaveToFile( filesystem, "mountlist.txt", "MOD" );
	}

	if( TryMountVPKGame( "DOTA", "../../common/dota 2 beta/dota", APP_DOTA, "dota", pMountList ) )
		PostProcessDota2( "models" );
	TryMountVPKGame( "Portal 2", "../../common/portal 2/portal2", APP_PORTAL2, "portal2", pMountList );
	TryMountVPKGame( "Left 4 Dead 2", "../../common/left 4 dead 2/left4dead2", APP_L4D2, "left4dead2", pMountList );
	TryMountVPKGame( "Left 4 Dead", "../../common/left 4 dead/left4dead", APP_L4D1, "left4dead", pMountList );
	TryMountVPKGame( "Counter-Strike Global Offensive", "../../common/Counter-Strike Global Offensive/csgo", APP_CSGO, "csgo", pMountList );
	TryMountVPKGame( "Dear Esther", "../../common/dear esther/dearesther", APP_DEARESTHER, "dearesther", pMountList );

	if( pMountList )
	{
		pMountList->deleteThis();
		pMountList = NULL;
	}
}
开发者ID:detoxhby,项目名称:lambdawars,代码行数:35,代码来源:wars_mount_system.cpp

示例10: LoadSurfaceProperties

//-----------------------------------------------------------------------------
// 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();
}
开发者ID:0xFEEDC0DE64,项目名称:UltraGame,代码行数:28,代码来源:textures.cpp

示例11: LoadCmdLineFromFile

//-----------------------------------------------------------------------------
// Purpose: Loads additional commandline arguments from a config file for an app.
//			Filesystem must be initialized before calling this function.
// keyname: Name of the block containing the key/args pairs (ie map or model name)
// appname: Keyname for the commandline arguments to be loaded - typically the exe name.
//-----------------------------------------------------------------------------
void LoadCmdLineFromFile( int &argc, char **&argv, const char *keyname, const char *appname )
{
	sFoundConfigArgs = false;

	assert( g_pFileSystem );
	if( !g_pFileSystem )
		return;

	// Load the cfg file, and find the keyname
	KeyValues *kv = new KeyValues( "CommandLine" );

	char filename[512];
	Q_snprintf( filename, sizeof( filename ), "%s/cfg/commandline.cfg", gamedir );

	if ( kv->LoadFromFile( g_pFileSystem, filename ) )
	{
		// Load the commandline arguments for this app
		KeyValues  *appKey	= kv->FindKey( keyname );
		if( appKey )
		{
			const char *str	= appKey->GetString( appname );
			Msg( "Command Line found: %s\n", str );

			AddArguments( argc, argv, str );
		}
	}

	kv->deleteThis();
}
开发者ID:Baer42,项目名称:source-sdk-2013,代码行数:35,代码来源:loadcmdline.cpp

示例12: GetValueFromMaterial

bool GetValueFromMaterial( const char *pMaterialName, const char *pKey, char *pValue, int len )
{
	char name[512];
	sprintf( name, "materials/%s.vmt", GetOriginalMaterialNameForPatchedMaterial( pMaterialName ) );
	KeyValues *kv = new KeyValues( "blah" );
	// Load the underlying file so that we can check if env_cubemap is in there.
	if ( !kv->LoadFromFile( g_pFileSystem, name ) )
	{
//		Assert( 0 );
		kv->deleteThis();
		return NULL;
	}

	const char *pTmpValue = kv->GetString( pKey, NULL );
	
	if( pTmpValue )
	{
		Q_strncpy( pValue, pTmpValue, len );
	}

	kv->deleteThis();
	if( pTmpValue )
	{
		return true;
	}
	else
	{
		return false;
	}
}
开发者ID:RaisingTheDerp,项目名称:raisingthebar,代码行数:30,代码来源:materialpatch.cpp

示例13: UTIL_GetMapKeyCount

int UTIL_GetMapKeyCount( const char *pszCustomKey )
{
	if ( !pszCustomKey )
		return 0;

	char szFilename[ _MAX_PATH ];
	if ( !UTIL_GetMapLoadCountFileName( MAP_KEY_FILE, szFilename, _MAX_PATH ) )
		return 0;

	int iCount = 0;

	KeyValues *kvMapLoadFile = new KeyValues( MAP_KEY_FILE );
	if ( kvMapLoadFile )
	{
		kvMapLoadFile->LoadFromFile( g_pFullFileSystem, szFilename, "MOD" );

		char mapname[MAX_MAP_NAME];
		Q_FileBase( engine->GetLevelName(), mapname, sizeof( mapname) );
		Q_strlower( mapname );

		KeyValues *pMapKey = kvMapLoadFile->FindKey( mapname );
		if ( pMapKey )
		{
			iCount = pMapKey->GetInt( pszCustomKey );
		}

		kvMapLoadFile->deleteThis();
	}

	return iCount;
}
开发者ID:Axitonium,项目名称:SourceEngine2007,代码行数:31,代码来源:cdll_util.cpp

示例14: PrecacheFileWeaponInfoDatabase

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();
}
开发者ID:Adidasman1,项目名称:source-sdk-2013,代码行数:32,代码来源:weapon_parse.cpp

示例15: AddSoundScapeFile

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();
	}
}
开发者ID:Entropy-Soldier,项目名称:ges-legacy-code,代码行数:30,代码来源:c_soundscape.cpp


注:本文中的KeyValues::LoadFromFile方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。