本文整理汇总了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;
}
示例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;
}
示例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();
}
}
示例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);
}
示例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;
}
示例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);
}
示例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);
}
示例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;
}
示例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;
}
}
示例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();
}
示例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();
}
示例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;
}
}
示例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;
}
示例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();
}
示例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();
}
}