本文整理汇总了C++中YamlNode::Get方法的典型用法代码示例。如果您正苦于以下问题:C++ YamlNode::Get方法的具体用法?C++ YamlNode::Get怎么用?C++ YamlNode::Get使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YamlNode
的用法示例。
在下文中一共展示了YamlNode::Get方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ParseConfig
void EditorConfig::ParseConfig(const FilePath &filePath)
{
ClearConfig();
YamlParser *parser = YamlParser::Create(filePath);
if(parser)
{
YamlNode *rootNode = parser->GetRootNode();
if(rootNode)
{
const Vector<YamlNode*> &yamlNodes = rootNode->AsVector();
int32 propertiesCount = yamlNodes.size();
for(int32 i = 0; i < propertiesCount; ++i)
{
YamlNode *propertyNode = yamlNodes[i];
if(propertyNode)
{
const YamlNode *nameNode = propertyNode->Get("name");
const YamlNode *typeNode = propertyNode->Get("type");
const YamlNode *defaultNode = propertyNode->Get("default");
if(nameNode && typeNode)
{
const String &nameStr = nameNode->AsString();
const 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.GetAbsolutePathname().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);
const YamlNode *comboNode = propertyNode->Get("list");
if(comboNode)
{
const Vector<YamlNode*> &comboValueNodes = comboNode->AsVector();
int32 comboValuesCount = comboValueNodes.size();
for(int32 i = 0; i < comboValuesCount; ++i)
//.........这里部分代码省略.........
示例2: res
RefPtr< PropertyLine<Vector3> > PropertyLineYamlReader::CreateVector3PropertyLineFromYamlNode( YamlNode * parentNode, const String & propertyName, RefPtr< PropertyLine<Vector3> > defaultPropertyLine /*= 0*/ )
{
YamlNode * node = parentNode->Get(propertyName);
if (!node)return defaultPropertyLine;
if (node->GetType() == YamlNode::TYPE_STRING)
{
if(propertyName == "emissionAngle") // for old emissionAngle compatibility
{
Vector3 res(0, 0, 0);
float32 angle = DegToRad(node->AsFloat());
res.x = cosf(angle);
res.y = sinf(angle);
return RefPtr< PropertyLine<Vector3> >(new PropertyLineValue<Vector3>(res));
}
float32 v = node->AsFloat();
return RefPtr< PropertyLine<Vector3> >(new PropertyLineValue<Vector3>(Vector3(v, v, v)));
}
else if (node->GetType() == YamlNode::TYPE_ARRAY)
{
if(node->GetCount() == 2) // for 2D forces compatibility
{
Vector3 res(node->AsVector2());
res.z = 0.0f;
return RefPtr< PropertyLine<Vector3> >(new PropertyLineValue<Vector3>(res));
}
if (node->GetCount() == 3 || node->GetCount() == 2)
{
Vector3 res(0.0f, 0.0f, 0.0f);
res = node->AsVector3();
return RefPtr< PropertyLine<Vector3> >(new PropertyLineValue<Vector3>(res));
}
RefPtr< PropertyLineKeyframes<Vector3> > keyframes (new PropertyLineKeyframes<Vector3>());
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->AsVector3());
}
else
{
Vector3 v = value->AsVector3();
if(propertyName == "emissionAngle") // for old emissionAngle compatibility
{
float32 angle = DegToRad(value->AsFloat());
v.x = cosf(angle);
v.y = sinf(angle);
v.z = 0.0f;
}
keyframes->AddValue(time->AsFloat(), v);
}
}
}
return keyframes;
}
return RefPtr< PropertyLine<Vector3> >();
}
示例3: 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);
int32 frame = 0;
if (frameNode)frame = frameNode->AsInt();
if (spriteNode)
{
SetStateSprite(stateArray[k], spriteNode->AsString(), frame);
}
}
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);
}
}
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());
}
}
for (int k = 0; k < STATE_COUNT; ++k)
{
YamlNode * colorInheritNode = node->Get("colorInherit");
UIControlBackground::eColorInheritType type = (UIControlBackground::eColorInheritType)loader->GetColorInheritTypeFromNode(colorInheritNode);
if(colorInheritNode)
{
for(int32 i = 0; i < DRAW_STATE_COUNT; ++i)
{
if(stateBacks[i])
{
stateBacks[i]->SetColorInheritType(type);
}
}
}
}
//.........这里部分代码省略.........
示例4: VariantType
YamlNode * UIButton::SaveToYamlNode(UIYamlLoader * loader)
{
YamlNode *node = UIControl::SaveToYamlNode(loader);
//Temp variable
VariantType *nodeValue = new VariantType();
String stringValue;
UIButton *baseControl = new UIButton();
//Control Type
SetPreferredNodeType(node, "UIButton");
//Remove values of UIControl
//UIButton has state specific properties
YamlNode *spriteNode = node->Get("sprite");
YamlNode *drawTypeNode = node->Get("drawType");
YamlNode *colorInheritNode = node->Get("colorInherit");
YamlNode *alignNode = node->Get("align");
YamlNode *leftRightStretchCapNode = node->Get("leftRightStretchCap");
YamlNode *topBottomStretchCapNode = node->Get("topBottomStretchCap");
if (spriteNode)
{
node->RemoveNodeFromMap("sprite");
}
if (drawTypeNode)
{
node->RemoveNodeFromMap("drawType");
}
if (colorInheritNode)
{
node->RemoveNodeFromMap("colorInherit");
}
if (alignNode)
{
node->RemoveNodeFromMap("align");
}
if (leftRightStretchCapNode)
{
node->RemoveNodeFromMap("leftRightStretchCap");
}
if (topBottomStretchCapNode)
{
node->RemoveNodeFromMap("topBottomStretchCap");
}
//States cycle for values
for (int i = 0; i < STATE_COUNT; ++i)
{
//Get sprite and frame for state
Sprite *stateSprite = this->GetStateSprite(stateArray[i]);
int32 stateFrame = this->GetStateFrame(stateArray[i]);
if (stateSprite)
{
//Create array yamlnode and add it to map
YamlNode *spriteNode = new YamlNode(YamlNode::TYPE_ARRAY);
spriteNode->AddValueToArray(TruncateTxtFileExtension(stateSprite->GetName()));
spriteNode->AddValueToArray(stateFrame);
node->AddNodeToMap(Format("stateSprite%s", statePostfix[i].c_str()), spriteNode);
}
//StateDrawType
UIControlBackground::eDrawType drawType = this->GetStateDrawType(stateArray[i]);
if (baseControl->GetStateDrawType(stateArray[i]) != drawType)
{
node->Set(Format("stateDrawType%s", statePostfix[i].c_str()), loader->GetDrawTypeNodeValue(drawType));
}
//leftRightStretchCap
float32 leftStretchCap = this->GetActualBackground(stateArray[i])->GetLeftRightStretchCap();
float32 baseLeftStretchCap = baseControl->GetActualBackground(stateArray[i])->GetLeftRightStretchCap();
if (baseLeftStretchCap != leftStretchCap)
{
node->Set(Format("leftRightStretchCap%s", statePostfix[i].c_str()), leftStretchCap);
}
//topBottomStretchCap
float32 topBottomStretchCap = this->GetActualBackground(stateArray[i])->GetTopBottomStretchCap();
float32 baseTopBottomStretchCap = baseControl->GetActualBackground(stateArray[i])->GetTopBottomStretchCap();
if (baseTopBottomStretchCap != topBottomStretchCap)
{
node->Set(Format("topBottomStretchCap%s", statePostfix[i].c_str()), topBottomStretchCap);
}
//State align
int32 stateAlign = this->GetStateAlign(stateArray[i]);
int32 baseStateAlign = baseControl->GetStateAlign(stateArray[i]);
if (baseStateAlign != stateAlign)
{
node->AddNodeToMap(Format("stateAlign%s", statePostfix[i].c_str()), loader->GetAlignNodeValue(stateAlign));
}
//State font, state text, text color, shadow color and shadow offset
if (this->GetStateTextControl(stateArray[i]))
{
Font *stateFont = this->GetStateTextControl(stateArray[i])->GetFont();
node->Set(Format("stateFont%s", statePostfix[i].c_str()), FontManager::Instance()->GetFontName(stateFont));
nodeValue->SetWideString(this->GetStateTextControl(stateArray[i])->GetText());
node->Set(Format("stateText%s", statePostfix[i].c_str()), nodeValue);
Color textColor = this->GetStateTextControl(stateArray[i])->GetTextColor();
nodeValue->SetVector4(Vector4(textColor.r, textColor.g, textColor.b, textColor.a));
node->Set(Format("stateTextcolor%s", statePostfix[i].c_str()), nodeValue);
//.........这里部分代码省略.........
示例5: LoadFromYamlNode
void UISlider::LoadFromYamlNode(YamlNode * node, UIYamlLoader * loader)
{
UIControl::LoadFromYamlNode(node, loader);
InitThumb();
YamlNode * thumbSpriteNode = node->Get("thumbSprite");
if (thumbSpriteNode)
{
YamlNode * spriteNode = thumbSpriteNode->Get(0);
YamlNode * frameNode = thumbSpriteNode->Get(1);
if (spriteNode)
SetThumbSprite(spriteNode->AsString(), frameNode->AsInt());
//SetMinSprite("/XGfx/Options/slider_bg", 1);
//SetMaxSprite("/XGfx/Options/slider_bg", 0);
}
YamlNode * minSpriteNode = node->Get("minSprite");
if (minSpriteNode)
{
YamlNode * spriteNode = minSpriteNode->Get(0);
YamlNode * frameNode = minSpriteNode->Get(1);
if (spriteNode)
SetMinSprite(spriteNode->AsString(), frameNode->AsInt());
//SetMinSprite("/XGfx/Options/slider_bg", 1);
//SetMaxSprite("/XGfx/Options/slider_bg", 0);
}
YamlNode * maxSpriteNode = node->Get("maxSprite");
if (maxSpriteNode)
{
YamlNode * spriteNode = maxSpriteNode->Get(0);
YamlNode * frameNode = maxSpriteNode->Get(1);
if (spriteNode)
SetMaxSprite(spriteNode->AsString(), frameNode->AsInt());
//SetMinSprite("/XGfx/Options/slider_bg", 1);
//SetMaxSprite("/XGfx/Options/slider_bg", 0);
}
// Values
YamlNode * valueNode = node->Get("value");
if (valueNode)
SetValue(valueNode->AsFloat());
YamlNode * minValueNode= node->Get("minValue");
if (minValueNode)
SetMinValue(minValueNode->AsFloat());
YamlNode * maxValueNode= node->Get("maxValue");
if (maxValueNode)
SetMaxValue(maxValueNode->AsFloat());
// Min/Max draw type
YamlNode * minDrawTypeNode = node->Get("minDrawType");
if(minDrawTypeNode)
{
UIControlBackground::eDrawType type = (UIControlBackground::eDrawType)loader->GetDrawTypeFromNode(minDrawTypeNode);
SetMinDrawType(type);
}
YamlNode * maxDrawTypeNode = node->Get("maxDrawType");
if(maxDrawTypeNode)
{
UIControlBackground::eDrawType type = (UIControlBackground::eDrawType)loader->GetDrawTypeFromNode(maxDrawTypeNode);
SetMaxDrawType(type);
}
}