本文整理汇总了C++中KeyValues::GetDataType方法的典型用法代码示例。如果您正苦于以下问题:C++ KeyValues::GetDataType方法的具体用法?C++ KeyValues::GetDataType怎么用?C++ KeyValues::GetDataType使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类KeyValues
的用法示例。
在下文中一共展示了KeyValues::GetDataType方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadFromKeyValues
bool CommandMenu::LoadFromKeyValues( KeyValues * params )
{
if ( !params )
return false;
V_snprintf( m_CurrentTeam, 4, "%i", GetLocalPlayerTeam() );
V_FileBase( engine->GetLevelName(), m_CurrentMap, sizeof(m_CurrentMap) );
if ( params != m_MenuKeys )
{
if ( m_MenuKeys )
m_MenuKeys->deleteThis();
m_MenuKeys = params->MakeCopy(); // save keyvalues
}
// iterate through all menu items
KeyValues * subkey = m_MenuKeys->GetFirstSubKey();
while ( subkey )
{
if ( subkey->GetDataType() == KeyValues::TYPE_NONE )
{
if ( !LoadFromKeyValuesInternal( subkey, 0 ) ) // recursive call
return false;
}
subkey = subkey->GetNextKey();
}
UpdateMenu();
return true;
}
示例2: PaintMappingInfo
void CHudAnimationInfo::PaintMappingInfo( int& x, int& y, Panel *element, PanelAnimationMap *map )
{
if ( !map )
return;
// Draw label
surface()->DrawSetTextFont( m_LabelFont );
surface()->DrawSetTextColor( m_LabelColor );
surface()->DrawSetTextPos( x, y );
const char *className = "";
if ( map->pfnClassName )
{
className = (*map->pfnClassName)();
}
const char *p = className;
while ( *p )
{
surface()->DrawUnicodeChar( *p );
p++;
}
y += surface()->GetFontTall( m_LabelFont ) + 1;
x += 10;
int c = map->entries.Count();
for ( int i = 0; i < c; i++ )
{
PanelAnimationMapEntry *e = &map->entries[ i ];
char sz[ 512 ];
char value[ 256 ];
Color col( 0, 0, 0, 0 );
Color *pColor = NULL;
KeyValues *kv = new KeyValues( e->name() );
if ( element->RequestInfo( kv ) )
{
KeyValues *dat = kv->FindKey(e->name());
if ( dat && dat->GetDataType() == KeyValues::TYPE_COLOR )
{
col = dat->GetColor();
Q_snprintf( value, sizeof( value ), "%i, %i, %i, %i",
col[0], col[1], col[2], col[3] );
pColor = &col;
}
else
{
Q_snprintf( value, sizeof( value ), "%s",
dat->GetString() );
}
}
else
{
Q_strncpy( value, "???", sizeof( value ) );
}
Q_snprintf( sz, sizeof( sz ), "%-30s %-20s (%s)",
e->name(), e->type(), value );
kv->deleteThis();
PaintString( x, y, sz, pColor );
}
x -= 10;
if ( map->baseMap )
{
PaintMappingInfo( x, y, element, map->baseMap );
}
}
示例3: CheckMaterial
//.........这里部分代码省略.........
{
Warning("ENVMAP + ENVMAPTINT : Material \"%s\"\n", pFileName );
}
// else
// {
// Warning("ENVMAP only: Material \"%s\"\n", pFileName );
// }
}
*/
/*
if ( !Q_stristr( pShaderName, "Refract" ) )
{
return;
}
if ( !DoesMaterialHaveKey( pKeyValues, "$envmap" ) )
{
bool bUsesAlpha, bIsCompressed, bIsPalettized;
int nSizeInBytes;
if ( DoesTextureUseNormal( pKeyValues->GetString( "$normalmap" ),
pFileName, bUsesAlpha, bIsCompressed, bIsPalettized, nSizeInBytes ) )
{
if ( bIsCompressed )
{
Warning("Bad : Material compressed \"%s\"\n", pFileName );
}
else
{
Warning("Bad : Material \"%s\"\n", pFileName );
}
}
}
*/
/*
if ( !Q_stristr( pShaderName, "WorldTwoTextureBlend" ) )
{
return;
}
if ( DoesMaterialHaveKey( pKeyValues, "$envmap" ) ||
DoesMaterialHaveKey( pKeyValues, "$parallaxmap" ) ||
DoesMaterialHaveKey( pKeyValues, "$bumpmap" ) ||
DoesMaterialHaveKey( pKeyValues, "$vertexcolor" ) ||
DoesMaterialHaveKey( pKeyValues, "$basetexture2" )
)
{
Warning("Bad : Material \"%s\"\n", pFileName );
}
*/
for ( KeyValues *pSubKey = pKeyValues->GetFirstValue(); pSubKey; pSubKey = pSubKey->GetNextValue() )
{
// Msg( " Checking %s\n", pSubKey->GetString() );
if ( pSubKey->GetDataType() != KeyValues::TYPE_STRING )
continue;
bool bUsesAlpha, bIsCompressed;
int nSizeInBytes;
if ( DoesTextureUseNormal( pSubKey->GetString(), pFileName, bUsesAlpha, bIsCompressed, nSizeInBytes ) )
{
if ( bUsesAlpha )
{
if ( bIsCompressed )
{
s_nNormalWithAlphaCompressedBytes += nSizeInBytes;
}
else
{
s_nNormalWithAlphaBytes += nSizeInBytes;
Msg( "Normal texture w alpha uncompressed %s\n", pSubKey->GetString() );
}
}
else
{
if ( bIsCompressed )
{
s_nNormalCompressedBytes += nSizeInBytes;
}
else
{
s_nNormalBytes += nSizeInBytes;
}
}
}
}
/*
if ( !Q_stristr( pShaderName, "VertexLitGeneric" ) )
return;
if ( !DoesMaterialHaveKey( pKeyValues, "$envmap" ) && DoesMaterialHaveKey( pKeyValues, "$bumpmap" ) )
{
Warning("BUMPMAP + no ENVMAP : Material \"%s\"\n", pFileName );
}
*/
// CheckKeyValues( pKeyValues, vtf );
}
示例4: MaterialVectorKeyValue
static bool MaterialVectorKeyValue( KeyValues *pKeyValues, const char *pKeyName, int nDefaultDim, float *pDefault, int *pDim, float *pVector )
{
int nDim;
float retVal[4];
KeyValues *pValue = pKeyValues->FindKey( pKeyName );
if ( pValue )
{
switch( pValue->GetDataType() )
{
case KeyValues::TYPE_INT:
{
int nInt = pValue->GetInt();
for ( int i = 0; i < 4; ++i )
{
retVal[i] = nInt;
}
if ( !AsVectorsEqual( nDefaultDim, pDefault, nDefaultDim, retVal ) )
{
*pDim = nDefaultDim;
memcpy( pVector, retVal, nDefaultDim * sizeof(float) );
return true;
}
}
break;
case KeyValues::TYPE_FLOAT:
{
float flFloat = pValue->GetFloat();
for ( int i = 0; i < 4; ++i )
{
retVal[i] = flFloat;
}
if ( !AsVectorsEqual( nDefaultDim, pDefault, nDefaultDim, retVal ) )
{
*pDim = nDefaultDim;
memcpy( pVector, retVal, nDefaultDim * sizeof(float) );
return true;
}
}
break;
case KeyValues::TYPE_STRING:
{
nDim = ParseVectorFromKeyValueString( pValue, "", retVal );
if ( !AsVectorsEqual( nDefaultDim, pDefault, nDim, retVal ) )
{
*pDim = nDim;
memcpy( pVector, retVal, nDim * sizeof(float) );
return true;
}
}
break;
}
}
for( KeyValues *pSubKey = pKeyValues->GetFirstTrueSubKey(); pSubKey; pSubKey = pSubKey->GetNextTrueSubKey() )
{
if ( MaterialVectorKeyValue( pSubKey, pKeyName, nDefaultDim, pDefault, &nDim, retVal ) )
{
*pDim = nDim;
memcpy( pVector, retVal, nDim * sizeof(float) );
return true;
}
}
*pDim = nDefaultDim;
memcpy( pVector, pDefault, nDefaultDim * sizeof(float) );
return false;
}
示例5: ParseSurfaceData
int CPhysicsSurfaceProps::ParseSurfaceData(const char* pFilename, const char* pTextfile) {
if (!AddFileToDatabase(pFilename)) return 0;
KeyValues* surfprops = new KeyValues("");
surfprops->LoadFromBuffer(pFilename, pTextfile);
for (KeyValues* surface = surfprops; surface; surface = surface->GetNextKey()) {
CSurface prop;
int baseMaterial = GetSurfaceIndex("default");
memset(&prop.data, 0, sizeof(prop.data));
prop.m_name = m_strings->AddString(surface->GetName());
prop.data.game.material = 0;
prop.data.game.maxSpeedFactor = 1.0f;
prop.data.game.jumpFactor = 1.0f;
prop.data.game.climbable = 0.0f;
CopyPhysicsProperties(&prop, baseMaterial);
for (KeyValues* data = surface->GetFirstSubKey(); data; data = data->GetNextKey()) {
const char* key = data->GetName();
if (!strcmpi(key, "base")) {
baseMaterial = GetSurfaceIndex(data->GetString());
CopyPhysicsProperties(&prop, baseMaterial);
} else if (!strcmpi(key, "thickness")) {
prop.data.physics.thickness = data->GetFloat();
} else if (!strcmpi(key, "density")) {
prop.data.physics.density = data->GetFloat();
} else if (!strcmpi(key, "elasticity")) {
prop.data.physics.elasticity = data->GetFloat();
} else if (!strcmpi(key, "friction")) {
prop.data.physics.friction = data->GetFloat();
} else if (!strcmpi(key, "dampening")) {
prop.data.physics.dampening = data->GetFloat();
} else if (!strcmpi(key, "audioreflectivity")) {
prop.data.audio.reflectivity = data->GetFloat();
} else if (!strcmpi(key, "audiohardnessfactor")) {
prop.data.audio.hardnessFactor = data->GetFloat();
} else if (!strcmpi(key, "audioroughnessfactor")) {
prop.data.audio.roughnessFactor = data->GetFloat();
} else if (!strcmpi(key, "scrapeRoughThreshold")) {
prop.data.audio.roughThreshold = data->GetFloat();
} else if (!strcmpi(key, "impactHardThreshold")) {
prop.data.audio.hardThreshold = data->GetFloat();
} else if (!strcmpi(key, "audioHardMinVelocity")) {
prop.data.audio.hardVelocityThreshold = data->GetFloat();
} else if (!strcmpi(key, "maxspeedfactor")) {
prop.data.game.maxSpeedFactor = data->GetFloat();
} else if (!strcmpi(key, "jumpfactor")) {
prop.data.game.jumpFactor = data->GetFloat();
} else if (!strcmpi(key, "climbable")) {
prop.data.game.climbable = data->GetInt();
} else if (!strcmpi(key, "gamematerial")) {
if (data->GetDataType() == KeyValues::TYPE_STRING && strlen(data->GetString()) == 1) {
prop.data.game.material = toupper(data->GetString()[0]);
} else {
prop.data.game.material = data->GetInt();
}
} else if (!strcmpi(key, "stepleft")) {
CUtlSymbol sym = m_strings->AddString(data->GetString());
prop.data.sounds.stepleft = m_soundList.AddToTail(sym);
} else if (!strcmpi(key, "stepright")) {
CUtlSymbol sym = m_strings->AddString(data->GetString());
prop.data.sounds.stepright = m_soundList.AddToTail(sym);
} else if (!strcmpi(key, "impactsoft")) {
CUtlSymbol sym = m_strings->AddString(data->GetString());
prop.data.sounds.impactSoft = m_soundList.AddToTail(sym);
} else if (!strcmpi(key, "impacthard")) {
CUtlSymbol sym = m_strings->AddString(data->GetString());
prop.data.sounds.impactHard = m_soundList.AddToTail(sym);
} else if (!strcmpi(key, "scrapesmooth")) {
CUtlSymbol sym = m_strings->AddString(data->GetString());
prop.data.sounds.scrapeSmooth = m_soundList.AddToTail(sym);
} else if (!strcmpi(key, "scraperough")) {
CUtlSymbol sym = m_strings->AddString(data->GetString());
prop.data.sounds.scrapeRough = m_soundList.AddToTail(sym);
} else if (!strcmpi(key, "bulletimpact")) {
CUtlSymbol sym = m_strings->AddString(data->GetString());
prop.data.sounds.bulletImpact = m_soundList.AddToTail(sym);
} else if (!strcmpi(key, "break")) {
CUtlSymbol sym = m_strings->AddString(data->GetString());
prop.data.sounds.breakSound = m_soundList.AddToTail(sym);
} else if (!strcmpi(key, "strain")) {
CUtlSymbol sym = m_strings->AddString(data->GetString());
prop.data.sounds.strainSound = m_soundList.AddToTail(sym);
} else if (!strcmpi(key, "rolling")) {
CUtlSymbol sym = m_strings->AddString(data->GetString());
prop.data.sounds.rolling = m_soundList.AddToTail(sym);
} else {
AssertMsg2(0, "Bad surfaceprop key %s (%s)\n", key, data->GetString());
}
}
if (GetSurfaceIndex(m_strings->String(prop.m_name)) >= 0) break;
m_props.AddToTail(prop);
}
surfprops->deleteThis();
return 0;
}
示例6: LoadFromKeyValuesInternal
bool CommandMenu::LoadFromKeyValuesInternal(KeyValues * key, int depth)
{
char text[255];
KeyValues * subkey = NULL;
if ( depth > 100 )
{
Msg("CommandMenu::LoadFromKeyValueInternal: depth > 100.\n");
return false;
}
V_strncpy( text, key->GetString("custom"), sizeof(text) ); // get type
if ( text[0] )
{
AddMenuCustomItem( key ); // do whatever custom item wants to
return true;
}
if ( !CheckRules( key->GetString("rule"), key->GetString("ruledata") ) )
{
return true;
}
// rules OK add subkey
V_strncpy( text, key->GetString("toggle"), sizeof(text) ); // get type
if ( text[0] )
{
AddMenuToggleItem( key );
return true;
}
V_strncpy( text, key->GetString("command"), sizeof(text) ); // get type
if ( text[0] )
{
AddMenuCommandItem( key );
return true;
}
// not a command, nor a toggle. Must be a submenu:
StartNewSubMenu( key ); // create submenu
// iterate through all subkeys
subkey = key->GetFirstSubKey();
while ( subkey )
{
if ( subkey->GetDataType() == KeyValues::TYPE_NONE )
{
LoadFromKeyValuesInternal( subkey, depth+1 ); // recursive call
}
subkey = subkey->GetNextKey();
}
FinishSubMenu(); // go one level back
return true;
}
示例7: GetValue
//-----------------------------------------------------------------------------
// Purpose: Gets the specified value from a panel
//-----------------------------------------------------------------------------
AnimationController::Value_t AnimationController::GetValue(ActiveAnimation_t& anim, Panel *panel, UtlSymId_t var)
{
Value_t val = { 0, 0, 0, 0 };
if (var == m_sPosition)
{
int x, y;
panel->GetPos(x, y);
val.a = (float)(x - GetRelativeOffset( anim.align, true ) );
val.b = (float)(y - GetRelativeOffset( anim.align, false ) );
}
else if (var == m_sSize)
{
int w, t;
panel->GetSize(w, t);
val.a = (float)w;
val.b = (float)t;
}
else if (var == m_sFgColor)
{
Color col = panel->GetFgColor();
val.a = col[0];
val.b = col[1];
val.c = col[2];
val.d = col[3];
}
else if (var == m_sBgColor)
{
Color col = panel->GetBgColor();
val.a = col[0];
val.b = col[1];
val.c = col[2];
val.d = col[3];
}
else if ( var == m_sXPos )
{
int x, y;
panel->GetPos(x, y);
val.a = (float)( x - GetRelativeOffset( anim.align, true ) );
}
else if ( var == m_sYPos )
{
int x, y;
panel->GetPos(x, y);
val.a = (float)( y - GetRelativeOffset( anim.align, false ) );
}
else if ( var == m_sWide )
{
int w, h;
panel->GetSize(w, h);
val.a = (float)w;
}
else if ( var == m_sTall )
{
int w, h;
panel->GetSize(w, h);
val.a = (float)h;
}
else
{
KeyValues *outputData = new KeyValues(g_ScriptSymbols.String(var));
if (panel->RequestInfo(outputData))
{
// find the var and lookup it's type
KeyValues *kv = outputData->FindKey(g_ScriptSymbols.String(var));
if (kv && kv->GetDataType() == KeyValues::TYPE_FLOAT)
{
val.a = kv->GetFloat();
val.b = 0.0f;
val.c = 0.0f;
val.d = 0.0f;
}
else if (kv && kv->GetDataType() == KeyValues::TYPE_COLOR)
{
Color col = kv->GetColor();
val.a = col[0];
val.b = col[1];
val.c = col[2];
val.d = col[3];
}
}
else
{
// Assert(!("Unhandlable var in AnimationController::GetValue())"));
}
outputData->deleteThis();
}
return val;
}