本文整理汇总了C++中KeyValues::UsesEscapeSequences方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyValues::UsesEscapeSequences方法的具体用法?C++ KeyValues::UsesEscapeSequences怎么用?C++ KeyValues::UsesEscapeSequences使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyValues
的用法示例。
在下文中一共展示了KeyValues::UsesEscapeSequences方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: 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);
}
示例2: PrecacheFileWeaponInfoDatabase
void PrecacheFileWeaponInfoDatabase( IFileSystem *filesystem, const unsigned char *pICEKey )
{
if ( m_WeaponInfoDatabase.Count() )
return;
KeyValues *manifest = new KeyValues( "weaponscripts" );
manifest->UsesEscapeSequences( true );
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
{
Warning( "Expecting 'file', got %s\n", sub->GetName() );
}
}
}
manifest->deleteThis();
}
示例3: LoadFVars
/**
* @brief Initializes all file variables from the file variable database.
*/
void CRPG_FileVar::LoadFVars(void) {
char *fvdb_path, *buf;
unsigned int fsize;
FILE *fptr;
KeyValues *kv;
if(!ll_count)
return;
fvdb_path = (char*)calloc(512, sizeof(char));
s_engine->GetGameDir(fvdb_path, 256);
#ifdef WIN32
CRPG::snprintf(fvdb_path, 512, "%s\\cfg\\cssrpg\\", fvdb_path);
#else
CRPG::snprintf(fvdb_path, 512, "%s/cfg/cssrpg/", fvdb_path);
#endif
s_filesystem->CreateDirHierarchy(fvdb_path);
CRPG::snprintf(fvdb_path, 512, "%s%s", fvdb_path, FVAR_DBNAME);
fptr = fopen(fvdb_path, "rb");
if(!fptr) {
CRPG::ConsoleMsg("No file variable database located at \"%s\", using default values", MTYPE_WARNING, fvdb_path);
free(fvdb_path);
return ;
}
/* Get the file variable database size for allocation */
fseek(fptr, 0, SEEK_END);
fsize = ftell(fptr);
rewind(fptr);
buf = (char*)calloc(fsize+1, sizeof(char));
fread(buf, sizeof(char), fsize, fptr);
fclose(fptr);
/* Check for "EF BB BF" UTF-8 BOM */
if(!memcmp(buf, "\xEF\xBB\xBF", 3))
buf += 3;
/* Load the file variable database into a KeyValues class */
kv = new KeyValues(FVAR_DBNAME);
kv->UsesEscapeSequences(true);
if(!kv->LoadFromBuffer(FVAR_DBNAME, buf)) {
CRPG::ConsoleMsg("Failed to parse file variable database \"%s\", using default values", MTYPE_WARNING, fvdb_path);
kv->deleteThis();
free(buf);
free(fvdb_path);
return ;
}
parse_fvdb(kv);
kv->deleteThis();
free(buf);
free(fvdb_path);
return ;
}
示例4: KeyValues
KeyValues *KeyValues::CreateKey(const char *keyName)
{
KeyValues *dat = new KeyValues(keyName);
dat->UsesEscapeSequences(m_bHasEscapeSequences != 0);
AddSubKey(dat);
return dat;
}
示例5: 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);
}
示例6: SetUserConfigFile
//-----------------------------------------------------------------------------
// Purpose: sets the name of the config file to save/restore from. Settings are loaded immediately.
//-----------------------------------------------------------------------------
void CSystem::SetUserConfigFile(const char *fileName, const char *pathName)
{
if (!m_pUserConfigData)
{
m_pUserConfigData = new KeyValues("UserConfigData");
}
strncpy(m_szFileName, fileName, sizeof(m_szFileName) - 1);
strncpy(m_szPathID, pathName, sizeof(m_szPathID) - 1);
// open
m_pUserConfigData->UsesEscapeSequences( true ); // VGUI may use this
m_pUserConfigData->LoadFromFile(g_pFullFileSystem, m_szFileName, m_szPathID);
}
示例7: ParseIncludedKeys
void KeyValues::ParseIncludedKeys(char const *resourceName, const char *filetoinclude, IFileSystem *pFileSystem, const char *pPathID, CUtlVector<KeyValues *> &includedKeys)
{
Assert(resourceName);
Assert(filetoinclude);
Assert(pFileSystem);
if (!pFileSystem)
return;
char fullpath[512];
Q_strncpy(fullpath, resourceName, sizeof(fullpath));
bool done = false;
int len = Q_strlen(fullpath);
while (!done)
{
if (len <= 0)
break;
if (fullpath[len - 1] == '\\' || fullpath[len - 1] == '/')
break;
fullpath[len - 1] = 0;
--len;
}
Q_strncat(fullpath, filetoinclude, sizeof(fullpath), COPY_ALL_CHARACTERS);
KeyValues *newKV = new KeyValues(fullpath);
newKV->UsesEscapeSequences(m_bHasEscapeSequences);
if (newKV->LoadFromFile(pFileSystem, fullpath, pPathID))
{
includedKeys.AddToTail(newKV);
}
else
{
DevMsg("KeyValues::ParseIncludedKeys: Couldn't load included keyvalue file %s\n", fullpath);
newKV->deleteThis();
}
}
示例8: CreateMenu
void MainMenu::CreateMenu(const char* menu)
{
KeyValues* datafile = new KeyValues("MainMenu");
datafile->UsesEscapeSequences(true);
if (datafile->LoadFromFile(g_pFullFileSystem, menu))
{
for (KeyValues* dat = datafile->GetFirstSubKey(); dat != NULL; dat = dat->GetNextKey())
{
Button_MainMenu* button = new Button_MainMenu(this, this, dat->GetString("command", ""));
button->SetPriority(atoi(dat->GetString("priority", "1")));
button->SetButtonText(dat->GetString("text", "no text"));
button->SetButtonDescription(dat->GetString("description", "no description"));
const char* specifics = dat->GetString("specifics", "shared");
if (Equals(specifics, "ingame"))
m_pButtonsInGame.AddToTail(button);
else if (Equals(specifics, "mainmenu"))
m_pButtonsBackground.AddToTail(button);
else if (Equals(specifics, "shared"))
m_pButtonsShared.AddToTail(button);
}
}
}
示例9: ReadEncryptedKVFile
KeyValues* ReadEncryptedKVFile( IFileSystem *filesystem, const char *szFilenameWithoutExtension, const unsigned char *pICEKey )
{
Assert( strchr( szFilenameWithoutExtension, '.' ) == NULL );
char szFullName[512];
const char *pSearchPath = "GAME";
// Open the weapon data file, and abort if we can't
KeyValues *pKV = new KeyValues( "WeaponDatafile" );
pKV->UsesEscapeSequences( true );
Q_snprintf(szFullName,sizeof(szFullName), "%s.txt", szFilenameWithoutExtension);
if ( !pKV->LoadFromFile( filesystem, szFullName, pSearchPath ) ) // try to load the normal .txt file first
{
#ifndef _XBOX
if ( pICEKey )
{
Q_snprintf(szFullName,sizeof(szFullName), "%s.ctx", szFilenameWithoutExtension); // fall back to the .ctx file
FileHandle_t f = filesystem->Open( szFullName, "rb", pSearchPath );
if (!f)
{
pKV->deleteThis();
return NULL;
}
// load file into a null-terminated buffer
int fileSize = filesystem->Size(f);
char *buffer = (char*)MemAllocScratch(fileSize + 1);
Assert(buffer);
filesystem->Read(buffer, fileSize, f); // read into local buffer
buffer[fileSize] = 0; // null terminate file as EOF
filesystem->Close( f ); // close file after reading
UTIL_DecodeICE( (unsigned char*)buffer, fileSize, pICEKey );
bool retOK = pKV->LoadFromBuffer( szFullName, buffer, filesystem );
MemFreeScratch();
if ( !retOK )
{
pKV->deleteThis();
return NULL;
}
}
else
{
pKV->deleteThis();
return NULL;
}
#else
pKV->deleteThis();
return NULL;
#endif
}
return pKV;
}
示例10: LoadFromBuffer
bool KeyValues::LoadFromBuffer(char const *resourceName, CUtlBuffer &buf, IFileSystem *pFileSystem, const char *pPathID)
{
KeyValues *pPreviousKey = NULL;
KeyValues *pCurrentKey = this;
CUtlVector<KeyValues *> includedKeys;
CUtlVector<KeyValues *> baseKeys;
bool wasQuoted;
g_KeyValuesErrorStack.SetFilename(resourceName);
do
{
const char *s = ReadToken(buf, wasQuoted);
if (!buf.IsValid() || !s || *s == 0)
break;
if (!Q_stricmp(s, "#include"))
{
s = ReadToken(buf, wasQuoted);
if (!s || *s == 0)
{
g_KeyValuesErrorStack.ReportError("#include is NULL ");
}
else
{
ParseIncludedKeys(resourceName, s, pFileSystem, pPathID, includedKeys);
}
continue;
}
else if (!Q_stricmp(s, "#base"))
{
s = ReadToken(buf, wasQuoted);
if (!s || *s == 0)
{
g_KeyValuesErrorStack.ReportError("#base is NULL ");
}
else
{
ParseIncludedKeys(resourceName, s, pFileSystem, pPathID, baseKeys);
}
continue;
}
if (!pCurrentKey)
{
pCurrentKey = new KeyValues(s);
Assert(pCurrentKey);
pCurrentKey->UsesEscapeSequences(m_bHasEscapeSequences != 0);
if (pPreviousKey)
{
pPreviousKey->SetNextKey(pCurrentKey);
}
}
else
{
pCurrentKey->SetName(s);
}
s = ReadToken(buf, wasQuoted);
if (s && *s == '{' && !wasQuoted)
{
pCurrentKey->RecursiveLoadFromBuffer(resourceName, buf);
}
else
{
g_KeyValuesErrorStack.ReportError("LoadFromBuffer: missing {");
}
pPreviousKey = pCurrentKey;
pCurrentKey = NULL;
}
while (buf.IsValid());
AppendIncludedKeys(includedKeys);
{
for (int i = includedKeys.Count() - 1; i > 0; i--)
{
KeyValues *kv = includedKeys[i];
kv->deleteThis();
}
}
MergeBaseKeys(baseKeys);
{
for (int i = baseKeys.Count() - 1; i >= 0; i--)
{
KeyValues *kv = baseKeys[i];
kv->deleteThis();
}
}
//.........这里部分代码省略.........