本文整理汇总了C++中YamlNode::GetCount方法的典型用法代码示例。如果您正苦于以下问题:C++ YamlNode::GetCount方法的具体用法?C++ YamlNode::GetCount怎么用?C++ YamlNode::GetCount使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YamlNode
的用法示例。
在下文中一共展示了YamlNode::GetCount方法的9个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: if
RefPtr<PropertyLine<float32> > PropertyLineYamlReader::CreateFloatPropertyLineFromYamlNode(YamlNode * parentNode, const String & propertyName, RefPtr<PropertyLine<float32> > defaultPropertyLine)
{
YamlNode * node = parentNode->Get(propertyName);
if (!node)return defaultPropertyLine;
if (node->GetType() == YamlNode::TYPE_STRING)
{
return RefPtr< PropertyLine<float32> >(new PropertyLineValue<float32>(node->AsFloat()));
}else if (node->GetType() == YamlNode::TYPE_ARRAY)
{
RefPtr<PropertyLineKeyframes<float32> > keyframes(new PropertyLineKeyframes<float32>());
for (int k = 0; k < node->GetCount() / 2; ++k)
{
YamlNode * time = node->Get(k * 2);
YamlNode * value = node->Get(k * 2 + 1);
if (time && value)
{
keyframes->AddValue(time->AsFloat(), value->AsFloat());
}
}
return keyframes;
}
return RefPtr<PropertyLine<float32> >();
}
示例2: Load
bool HierarchyTreePlatformNode::Load(YamlNode* platform)
{
YamlNode* width = platform->Get(WIDTH_NODE);
YamlNode* height = platform->Get(HEIGHT_NODE);
if (!width || !height)
return false;
bool result = true;
SetSize(width->AsInt(), height->AsInt());
ActivatePlatform();
YamlNode* screens = platform->Get(SCREENS_NODE);
if (screens)
{
for (int i = 0; i < screens->GetCount(); i++)
{
YamlNode* screen = screens->Get(i);
if (!screen)
continue;
String screenName = screen->AsString();
QString screenPath = QString(SCREEN_PATH).arg(GetResourceFolder()).arg(QString::fromStdString(screenName));
HierarchyTreeScreenNode* screenNode = new HierarchyTreeScreenNode(this, QString::fromStdString(screenName));
result &= screenNode->Load(screenPath);
AddTreeNode(screenNode);
}
}
return result;
}
示例3: res
RefPtr< PropertyLine<Vector2> > PropertyLineYamlReader::CreateVector2PropertyLineFromYamlNode( YamlNode * parentNode, const String & propertyName, RefPtr< PropertyLine<Vector2> > defaultPropertyLine /*= 0*/ )
{
YamlNode * node = parentNode->Get(propertyName);
if (!node)return defaultPropertyLine;
if (node->GetType() == YamlNode::TYPE_STRING)
{
float32 v = node->AsFloat();
return RefPtr< PropertyLine<Vector2> >(new PropertyLineValue<Vector2>(Vector2(v, v)));
}else if (node->GetType() == YamlNode::TYPE_ARRAY)
{
if (node->GetCount() == 2)
{
Vector2 res(1.0f, 1.0f);
res = node->AsPoint();
return RefPtr< PropertyLine<Vector2> >(new PropertyLineValue<Vector2>(res));
}
RefPtr< PropertyLineKeyframes<Vector2> > keyframes (new PropertyLineKeyframes<Vector2>());
for (int k = 0; k < node->GetCount() / 2; ++k)
{
YamlNode * time = node->Get(k * 2);
YamlNode * value = node->Get(k * 2 + 1);
if (time && value)
{
if (value->GetType() == YamlNode::TYPE_ARRAY)
{
keyframes->AddValue(time->AsFloat(), value->AsPoint());
}
else
{
float32 v = value->AsFloat();
keyframes->AddValue(time->AsFloat(), Vector2(v, v));
}
}
}
return keyframes;
}
return RefPtr< PropertyLine<Vector2> >();
}
示例4: OnAppStarted
void GameCore::OnAppStarted()
{
DeviceInfo();
SettingsManager::Instance()->InitWithFile("~res:/Config/config.yaml");
cursor = 0;
RenderManager::Instance()->SetFPS(60);
String dirPath = "~res:/3d/Maps/";
Vector<String> levelsPaths;
YamlParser* parser = YamlParser::Create("~res:/maps.yaml");
if(parser)
{
YamlNode* rootNode = parser->GetRootNode();
if(rootNode)
{
int32 sz = rootNode->GetCount();
for(DAVA::int32 i = 0; i < sz; ++i)
{
String k = rootNode->GetItemKeyName(i);
String levelFile = rootNode->Get(i)->AsString();
if(k != "default")
levelsPaths.push_back(levelFile);
}
}
}
for(Vector<String>::const_iterator it = levelsPaths.begin(); it != levelsPaths.end(); ++it)
{
Test *test = new Test(dirPath + (*it));
if(test != NULL)
{
UIScreenManager::Instance()->RegisterScreen(test->GetScreenId(), test);
tests.push_back(test);
}
}
if(levelsPaths.size() > 0)
{
appFinished = false;
testCount = tests.size();
Test *firstTest = tests.front();
UIScreenManager::Instance()->SetFirst(firstTest->GetScreenId());
}
else
{
appFinished = true;
}
ConnectToDB();
}
示例5: LoadColorsArray
void NotPassableTerrain::LoadColorsArray()
{
YamlParser* parser = YamlParser::Create("~res:/Configs/LandscapeAngle.yaml");
if (parser != 0)
{
YamlNode* rootNode = parser->GetRootNode();
int32 anglesCount = rootNode->GetCount();
for (int32 i = 0; i < anglesCount; ++i)
{
YamlNode* node = rootNode->Get(i);
if (!node || node->GetCount() != 3)
continue;
float32 angle1 = node->Get(0)->AsFloat();
float32 angle2 = node->Get(1)->AsFloat();
angle1 = Min(angle1, 89.f);
angle2 = Min(angle2, 89.f);
float32 tangentMin = tan(DegToRad(angle1));
float32 tangentMax = tan(DegToRad(angle2));
YamlNode* colorNode = node->Get(2);
if (!colorNode || colorNode->GetCount() != 4)
continue;
Color color(colorNode->Get(0)->AsFloat()/255.f,
colorNode->Get(1)->AsFloat()/255.f,
colorNode->Get(2)->AsFloat()/255.f,
colorNode->Get(3)->AsFloat()/255.f);
angleColor.push_back(TerrainColor(Vector2(tangentMin, tangentMax), color));
}
}
SafeRelease(parser);
}
示例6: keyframes
RefPtr< PropertyLine<Color> > PropertyLineYamlReader::CreateColorPropertyLineFromYamlNode( YamlNode * parentNode, const String & propertyName, RefPtr< PropertyLine<Color> > defaultPropertyLine)
{
YamlNode * node = parentNode->Get(propertyName);
if (!node)return defaultPropertyLine;
if (node->GetType() == YamlNode::TYPE_ARRAY)
{
bool allString = true;
for (int k = 0; k < node->GetCount(); ++k)
if (node->Get(k)->GetType() != YamlNode::TYPE_STRING)
allString = false;
if (allString && node->GetCount() == 4)
{
return RefPtr< PropertyLine<Color> >(new PropertyLineValue<Color>(ColorFromYamlNode(node)));
}else
{
RefPtr< PropertyLineKeyframes<Color> > keyframes (new PropertyLineKeyframes<Color>());
for (int k = 0; k < node->GetCount() / 2; ++k)
{
YamlNode * time = node->Get(k * 2);
YamlNode * value = node->Get(k * 2 + 1);
if (time && value)
{
if (value->GetType() == YamlNode::TYPE_ARRAY)
{
keyframes->AddValue(time->AsFloat(), ColorFromYamlNode(value));
}
}
}
return keyframes;
}
}
return RefPtr< PropertyLine<Color> >();
}
示例7: LoadFromYamlNode
void UIButton::LoadFromYamlNode(YamlNode * node, UIYamlLoader * loader)
{
UIControl::LoadFromYamlNode(node, loader);
//int32 stateArray[] = {STATE_NORMAL, STATE_PRESSED_INSIDE, STATE_PRESSED_OUTSIDE, STATE_DISABLED, STATE_SELECTED, STATE_HOVER};
//String statePostfix[] = {"Normal", "PressedInside", "PressedOutside", "Disabled", "Selected", "Hover"};
for (int k = 0; k < STATE_COUNT; ++k)
{
YamlNode * stateSpriteNode = node->Get(Format("stateSprite%s", statePostfix[k].c_str()));
if (stateSpriteNode)
{
YamlNode * spriteNode = stateSpriteNode->Get(0);
YamlNode * frameNode = stateSpriteNode->Get(1);
YamlNode * backgroundModificationNode = NULL;
if(stateSpriteNode->GetCount() > 2)
{
backgroundModificationNode = stateSpriteNode->Get(2);
}
int32 frame = 0;
if (frameNode)frame = frameNode->AsInt();
if (spriteNode)
{
SetStateSprite(stateArray[k], spriteNode->AsString(), frame);
}
if (backgroundModificationNode)
{
stateBacks[k]->SetModification(backgroundModificationNode->AsInt());
}
}
YamlNode * stateDrawTypeNode = node->Get(Format("stateDrawType%s", statePostfix[k].c_str()));
if (stateDrawTypeNode)
{
UIControlBackground::eDrawType type = (UIControlBackground::eDrawType)loader->GetDrawTypeFromNode(stateDrawTypeNode);
SetStateDrawType(stateArray[k],type);
YamlNode * leftRightStretchCapNode = node->Get(Format("leftRightStretchCap%s", statePostfix[k].c_str()));
YamlNode * topBottomStretchCapNode = node->Get(Format("topBottomStretchCap%s", statePostfix[k].c_str()));
if(leftRightStretchCapNode)
{
float32 leftStretchCap = leftRightStretchCapNode->AsFloat();
GetActualBackground(stateArray[k])->SetLeftRightStretchCap(leftStretchCap);
}
if(topBottomStretchCapNode)
{
float32 topStretchCap = topBottomStretchCapNode->AsFloat();
GetActualBackground(stateArray[k])->SetTopBottomStretchCap(topStretchCap);
}
}
else
{
SetStateDrawType(stateArray[k],UIControlBackground::DRAW_ALIGNED);
}
YamlNode * stateAlignNode = node->Get(Format("stateAlign%s", statePostfix[k].c_str()));
if (stateAlignNode)
{
int32 align = loader->GetAlignFromYamlNode(stateAlignNode);
SetStateAlign(stateArray[k],align);
}
YamlNode * stateFontNode = node->Get(Format("stateFont%s", statePostfix[k].c_str()));
if (stateFontNode)
{
Font * font = loader->GetFontByName(stateFontNode->AsString());
if (font)SetStateFont(stateArray[k], font);
}
YamlNode * stateTextNode = node->Get(Format("stateText%s", statePostfix[k].c_str()));
if (stateTextNode)
{
SetStateText(stateArray[k], LocalizedString(stateTextNode->AsWString()));
}
YamlNode * stateTextColorNode = node->Get(Format("stateTextcolor%s", statePostfix[k].c_str()));
if (stateTextColorNode)
{
Vector4 c = stateTextColorNode->AsVector4();
SetStateFontColor(stateArray[k], Color(c.x, c.y, c.z, c.w));
}
YamlNode * stateShadowColorNode = node->Get(Format("stateShadowcolor%s", statePostfix[k].c_str()));
if (stateShadowColorNode)
{
Vector4 c = stateShadowColorNode->AsVector4();
SetStateShadowColor(stateArray[k], Color(c.x, c.y, c.z, c.w));
}
YamlNode * stateShadowOffsetNode = node->Get(Format("stateShadowoffset%s", statePostfix[k].c_str()));
if (stateShadowOffsetNode)
{
SetStateShadowOffset(stateArray[k], stateShadowOffsetNode->AsVector2());
}
YamlNode * colorInheritNode = node->Get(Format("stateColorInherit%s", statePostfix[k].c_str()));
if(colorInheritNode)
//.........这里部分代码省略.........
示例8: LoadFromYaml
//.........这里部分代码省略.........
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");
if (depthNode)
_size.y = depthNode->AsFloat();
size = new PropertyLineValue<Vector3>(_size);
}
YamlNode * autorestartNode = emitterNode->Get("autorestart");
if(autorestartNode)
isAutorestart = autorestartNode->AsBool();
YamlNode * particlesFollowNode = emitterNode->Get("particlesFollow");
if(particlesFollowNode)
particlesFollow = particlesFollowNode->AsBool();
}
int cnt = rootNode->GetCount();
for (int k = 0; k < cnt; ++k)
{
YamlNode * node = rootNode->Get(k);
YamlNode * typeNode = node->Get("type");
YamlNode * longNode = node->Get("isLong");
bool isLong = false;
if(longNode && (longNode->AsBool() == true))
{
isLong = true;
}
if (typeNode && typeNode->AsString() == "layer")
{
LoadParticleLayerFromYaml(node, isLong);
}
}
// Yuri Coder, 2013/01/15. The "name" node for Layer was just added and may not exist for
// old yaml files. Generate the default name for nodes with empty names.
UpdateEmptyLayerNames();
SafeRelease(parser);
}
示例9: ParseConfig
//.........这里部分代码省略.........
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)
{
properties[nameStr]->comboValues.push_back(comboValueNodes[i]->AsString());
}
}
}
break;
case PT_COLOR_LIST:
{
int32 defaultValue = 0;
if(defaultNode)
{
defaultValue = defaultNode->AsInt();
}
properties[nameStr]->defaultValue.SetInt32(defaultValue);
YamlNode *colorListNode = propertyNode->Get("list");
if(colorListNode)
{
Vector<YamlNode*> colorListNodes = colorListNode->AsVector();
int32 colorListValuesCount = colorListNodes.size();
for(int32 i = 0; i < colorListValuesCount; ++i)
{
YamlNode* colorNode = colorListNodes[i];
if(!colorNode || colorNode->GetCount() != 4)
continue;
Color color(colorNode->Get(0)->AsFloat()/255.f,
colorNode->Get(1)->AsFloat()/255.f,
colorNode->Get(2)->AsFloat()/255.f,
colorNode->Get(3)->AsFloat()/255.f);
properties[nameStr]->colorListValues.push_back(color);
}
}
}
break;
}
propertyNames.push_back(nameStr);
} //isOk
}
else
{
Logger::Error("EditorConfig::ParseConfig %s ERROR property %d unknown type %s", filePath.c_str(), i, typeStr.c_str());
}
}
else
{
Logger::Error("EditorConfig::ParseConfig %s ERROR property %d type or name is missing", filePath.c_str(), i);
}
}
else
{
Logger::Error("EditorConfig::ParseConfig %s ERROR property %d is missing", filePath.c_str(), i);
}
}
}
// else file is empty - ok, no custom properties
parser->Release();
}
// else file not found - ok, no custom properties
}