本文整理汇总了C++中YamlNode::AsBool方法的典型用法代码示例。如果您正苦于以下问题:C++ YamlNode::AsBool方法的具体用法?C++ YamlNode::AsBool怎么用?C++ YamlNode::AsBool使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YamlNode
的用法示例。
在下文中一共展示了YamlNode::AsBool方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadFromYaml
void ParticleEmitter::LoadFromYaml(const String & filename)
{
Cleanup(true);
YamlParser * parser = YamlParser::Create(filename);
if(!parser)
{
Logger::Error("ParticleEmitter::LoadFromYaml failed (%s)", filename.c_str());
return;
}
configPath = filename;
time = 0.0f;
repeatCount = 0;
lifeTime = 1000000000.0f;
YamlNode * rootNode = parser->GetRootNode();
YamlNode * emitterNode = rootNode->Get("emitter");
if (emitterNode)
{
if (emitterNode->Get("emissionAngle"))
emissionAngle = PropertyLineYamlReader::CreateFloatPropertyLineFromYamlNode(emitterNode, "emissionAngle");
if (emitterNode->Get("emissionVector"))
emissionVector = PropertyLineYamlReader::CreateVector3PropertyLineFromYamlNode(emitterNode, "emissionVector");
YamlNode* emissionVectorInvertedNode = emitterNode->Get("emissionVectorInverted");
if (!emissionVectorInvertedNode)
{
// Yuri Coder, 2013/04/12. This means that the emission vector in the YAML file is not inverted yet.
// Because of [DF-1003] fix for such files we have to invert coordinates for this vector.
InvertEmissionVectorCoordinates();
}
if (emitterNode->Get("emissionRange"))
emissionRange = PropertyLineYamlReader::CreateFloatPropertyLineFromYamlNode(emitterNode, "emissionRange");
if (emitterNode->Get("colorOverLife"))
colorOverLife = PropertyLineYamlReader::CreateColorPropertyLineFromYamlNode(emitterNode, "colorOverLife");
if (emitterNode->Get("radius"))
radius = PropertyLineYamlReader::CreateFloatPropertyLineFromYamlNode(emitterNode, "radius");
emitPointsCount = -1;
YamlNode * emitAtPointsNode = emitterNode->Get("emitAtPoints");
if (emitAtPointsNode)
emitPointsCount = emitAtPointsNode->AsInt();
YamlNode * lifeTimeNode = emitterNode->Get("life");
if (lifeTimeNode)
{
lifeTime = lifeTimeNode->AsFloat();
} else
{
lifeTime = 1000000000.0f;
}
is3D = false;
YamlNode * _3dNode = emitterNode->Get("3d");
if (_3dNode)
{
is3D = _3dNode->AsBool();
}
YamlNode * typeNode = emitterNode->Get("type");
if (typeNode)
{
if (typeNode->AsString() == "point")
emitterType = EMITTER_POINT;
else if (typeNode->AsString() == "line")
{
// Yuri Coder, 2013/04/09. Get rid of the "line" node type -
// it can be completely replaced by "rect" one.
emitterType = EMITTER_RECT;
}
else if (typeNode->AsString() == "rect")
emitterType = EMITTER_RECT;
else if (typeNode->AsString() == "oncircle")
emitterType = EMITTER_ONCIRCLE;
else if (typeNode->AsString() == "shockwave")
emitterType = EMITTER_SHOCKWAVE;
else
emitterType = EMITTER_POINT;
} else
emitterType = EMITTER_POINT;
size = PropertyLineYamlReader::CreateVector3PropertyLineFromYamlNode(emitterNode, "size");
if(size == 0)
{
Vector3 _size(0, 0, 0);
YamlNode * widthNode = emitterNode->Get("width");
if (widthNode)
_size.x = widthNode->AsFloat();
YamlNode * heightNode = emitterNode->Get("height");
if (heightNode)
_size.y = heightNode->AsFloat();
YamlNode * depthNode = emitterNode->Get("depth");
//.........这里部分代码省略.........
示例2: ParseConfig
void EditorConfig::ParseConfig(const String &filePath)
{
ClearConfig();
YamlParser *parser = YamlParser::Create(filePath);
if(parser)
{
YamlNode *rootNode = parser->GetRootNode();
if(rootNode)
{
Vector<YamlNode*> &yamlNodes = rootNode->AsVector();
int32 propertiesCount = yamlNodes.size();
for(int32 i = 0; i < propertiesCount; ++i)
{
YamlNode *propertyNode = yamlNodes[i];
if(propertyNode)
{
YamlNode *nameNode = propertyNode->Get("name");
YamlNode *typeNode = propertyNode->Get("type");
YamlNode *defaultNode = propertyNode->Get("default");
if(nameNode && typeNode)
{
String nameStr = nameNode->AsString();
String typeStr = typeNode->AsString();
int32 type = ParseType(typeStr);
if(type)
{
bool isOk = true;
for(uint32 n = 0; n < propertyNames.size(); ++n)
{
if(propertyNames[n] == nameStr)
{
isOk = false;
Logger::Error("EditorConfig::ParseConfig %s ERROR property %d property %s already exists", filePath.c_str(), i, nameStr.c_str());
break;
}
}
if(isOk)
{
properties[nameStr] = new PropertyDescription();
properties[nameStr]->name = nameStr;
properties[nameStr]->type = type;
switch(type)
{
case PT_BOOL:
{
bool defaultValue = false;
if(defaultNode)
{
defaultValue = defaultNode->AsBool();
}
properties[nameStr]->defaultValue.SetBool(defaultValue);
}
break;
case PT_INT:
{
int32 defaultValue = 0;
if(defaultNode)
{
defaultValue = defaultNode->AsInt();
}
properties[nameStr]->defaultValue.SetInt32(defaultValue);
}
break;
case PT_STRING:
{
String defaultValue;
if(defaultNode)
{
defaultValue = defaultNode->AsString();
}
properties[nameStr]->defaultValue.SetString(defaultValue);
}
break;
case PT_FLOAT:
{
float32 defaultValue = 0.0f;
if(defaultNode)
{
defaultValue = defaultNode->AsFloat();
}
properties[nameStr]->defaultValue.SetFloat(defaultValue);
}
break;
case PT_COMBOBOX:
{
int32 defaultValue = 0;
if(defaultNode)
{
defaultValue = defaultNode->AsInt();
}
properties[nameStr]->defaultValue.SetInt32(defaultValue);
YamlNode *comboNode = propertyNode->Get("list");
if(comboNode)
{
Vector<YamlNode*> comboValueNodes = comboNode->AsVector();
int32 comboValuesCount = comboValueNodes.size();
for(int32 i = 0; i < comboValuesCount; ++i)
//.........这里部分代码省略.........