本文整理汇总了C++中YamlNode::AddValueToArray方法的典型用法代码示例。如果您正苦于以下问题:C++ YamlNode::AddValueToArray方法的具体用法?C++ YamlNode::AddValueToArray怎么用?C++ YamlNode::AddValueToArray使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YamlNode
的用法示例。
在下文中一共展示了YamlNode::AddValueToArray方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: WriteColorPropertyLineToYamlNode
YamlNode* PropertyLineYamlWriter::WriteColorPropertyLineToYamlNode(YamlNode* parentNode, const String& propertyName,
RefPtr<PropertyLine<Color> > propertyLine)
{
// Write the property line.
Vector<PropValue<Color> > wrappedPropertyValues = PropLineWrapper<Color>(propertyLine).GetProps();
if (wrappedPropertyValues.empty())
{
return NULL;
}
if (wrappedPropertyValues.size() == 1)
{
// This has to be single string value. Write Colors as Vectors.
parentNode->Set(propertyName, ColorToVector(wrappedPropertyValues.at(0).v));
return NULL;
}
// Create the child array node.
YamlNode* childNode = new YamlNode(YamlNode::TYPE_ARRAY);
for (Vector<PropValue<Color> >::iterator iter = wrappedPropertyValues.begin();
iter != wrappedPropertyValues.end(); iter ++)
{
childNode->AddValueToArray((*iter).t);
childNode->AddValueToArray(ColorToVector((*iter).v));
}
parentNode->AddNodeToMap(propertyName, childNode);
return childNode;
}
示例2: Save
bool HierarchyTreePlatformNode::Save(YamlNode* node)
{
YamlNode* platform = new YamlNode(YamlNode::TYPE_MAP);
platform->Set(WIDTH_NODE, GetWidth());
platform->Set(HEIGHT_NODE, GetHeight());
Map<String, YamlNode*> &platformsMap = node->AsMap();
platformsMap[GetName().toStdString()] = platform;
ActivatePlatform();
Map<String, YamlNode*> &platformMap = platform->AsMap();
YamlNode* screens = new YamlNode(YamlNode::TYPE_ARRAY);
platformMap[SCREENS_NODE] = screens;
// Add the Localization info - specific for each Platform.
SaveLocalization(platform);
QString projectFolder = GetResourceFolder();
projectFolder += "UI";
QDir dir;
dir.mkpath(projectFolder);
bool result = true;
for (HIERARCHYTREENODESCONSTITER iter = GetChildNodes().begin();
iter != GetChildNodes().end();
++iter)
{
HierarchyTreeScreenNode* screenNode = dynamic_cast<HierarchyTreeScreenNode*>(*iter);
if (!screenNode)
continue;
QString screenPath = QString(SCREEN_PATH).arg(GetResourceFolder()).arg(screenNode->GetName());
result &= screenNode->Save(screenPath);
screens->AddValueToArray(screenNode->GetName().toStdString());
}
return result;
}
示例3: path
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 *colorNode = node->Get("color");
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");
YamlNode *spriteModificationNode = node->Get("spriteModification");
if (colorNode)
{
node->RemoveNodeFromMap("color");
}
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");
}
if (spriteModificationNode)
{
node->RemoveNodeFromMap("spriteModification");
}
//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);
FilePath path(stateSprite->GetRelativePathname());
path.TruncateExtension();
String pathname = path.GetFrameworkPath();
spriteNode->AddValueToArray(pathname);
spriteNode->AddValueToArray(stateFrame);
int32 modification = stateBacks[BackgroundIndexForState((eButtonDrawState)i)]->GetModification();
spriteNode->AddValueToArray(modification);
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
//.........这里部分代码省略.........
示例4: VariantType
YamlNode * UIButton::SaveToYamlNode(UIYamlLoader * loader)
{
YamlNode *node = UIControl::SaveToYamlNode(loader);
//Temp variable
VariantType *nodeValue = new VariantType();
String stringValue;
//Control Type
node->Set("type", "UIButton");
//Remove values of UIControl
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]);
node->Set(Format("stateDrawType%s", statePostfix[i].c_str()), loader->GetDrawTypeNodeValue(drawType));
//leftRightStretchCap
float32 leftStretchCap = this->GetActualBackground(stateArray[i])->GetLeftRightStretchCap();
node->Set(Format("leftRightStretchCap%s", statePostfix[i].c_str()), leftStretchCap);
//topBottomStretchCap
float32 topBottomStretchCap = this->GetActualBackground(stateArray[i])->GetTopBottomStretchCap();
node->Set(Format("topBottomStretchCap%s", statePostfix[i].c_str()), topBottomStretchCap);
//State align
node->Set(Format("stateAlign%s", statePostfix[i].c_str()), this->GetStateAlign(stateArray[i]));
//State font
Font *stateFont = this->GetStateTextControl(stateArray[i])->GetFont();
node->Set(Format("stateFont%s", statePostfix[i].c_str()), FontManager::Instance()->GetFontName(stateFont));
//StateText
if (this->GetStateTextControl(stateArray[i]))
{
nodeValue->SetWideString(this->GetStateTextControl(stateArray[i])->GetText());
node->Set(Format("stateText%s", statePostfix[i].c_str()), nodeValue);
}
//colorInherit ???? For different states?
// Yuri Coder, 2012/11/16. Temporarily commented out until clarification.
//UIControlBackground::eColorInheritType colorInheritType = this->GetStateBackground(stateArray[i])->GetColorInheritType();
//node->Set(Format("stateColorInherit%s", statePostfix[i].c_str()), loader->GetColorInheritTypeNodeValue(colorInheritType));
}
SafeDelete(nodeValue);
return node;
}
示例5: Save
bool HierarchyTreePlatformNode::Save(YamlNode* node, bool saveAll)
{
YamlNode* platform = new YamlNode(YamlNode::TYPE_MAP);
platform->Set(WIDTH_NODE, GetWidth());
platform->Set(HEIGHT_NODE, GetHeight());
MultiMap<String, YamlNode*> &platformsMap = node->AsMap();
platformsMap.erase(GetName().toStdString());
platformsMap.insert(std::pair<String, YamlNode*>(GetName().toStdString(), platform));
ActivatePlatform();
MultiMap<String, YamlNode*> &platformMap = platform->AsMap();
YamlNode* screens = new YamlNode(YamlNode::TYPE_ARRAY);
platformMap.erase(SCREENS_NODE);
platformMap.insert(std::pair<String, YamlNode*>(SCREENS_NODE, screens));
YamlNode* aggregators = new YamlNode(YamlNode::TYPE_MAP);
platformMap.erase(AGGREGATORS_NODE);
platformMap.insert(std::pair<String, YamlNode*>(AGGREGATORS_NODE, aggregators));
// Add the Localization info - specific for each Platform.
SaveLocalization(platform);
QString platformFolder = GetPlatformFolder();
QDir dir;
dir.mkpath(platformFolder);
bool result = true;
//save aggregators node before save screens
for (HIERARCHYTREENODESCONSTITER iter = GetChildNodes().begin();
iter != GetChildNodes().end();
++iter)
{
HierarchyTreeAggregatorNode* node = dynamic_cast<HierarchyTreeAggregatorNode*>(*iter);
if (!node)
continue;
QString path = QString(SCREEN_PATH).arg(platformFolder).arg(node->GetName());
MultiMap<String, YamlNode*> &aggregatorsMap = aggregators->AsMap();
YamlNode* aggregator = new YamlNode(YamlNode::TYPE_MAP);
result &= node->Save(aggregator, path, saveAll);
aggregatorsMap.erase(node->GetName().toStdString());
aggregatorsMap.insert(std::pair<String, YamlNode*>(node->GetName().toStdString(), aggregator));
}
for (HIERARCHYTREENODESCONSTITER iter = GetChildNodes().begin();
iter != GetChildNodes().end();
++iter)
{
HierarchyTreeAggregatorNode* node = dynamic_cast<HierarchyTreeAggregatorNode*>(*iter);
if (node)
continue; //skip aggregators
HierarchyTreeScreenNode* screenNode = dynamic_cast<HierarchyTreeScreenNode*>(*iter);
if (!screenNode)
continue;
QString screenPath = QString(SCREEN_PATH).arg(platformFolder).arg(screenNode->GetName());
result &= screenNode->Save(screenPath, saveAll);
screens->AddValueToArray(screenNode->GetName().toStdString());
}
return result;
}
示例6: YamlNode
YamlNode * UISlider::SaveToYamlNode(UIYamlLoader * loader)
{
YamlNode *node = UIControl::SaveToYamlNode(loader);
// Control Type
SetPreferredNodeType(node, "UISlider");
// Sprite value
float32 value = this->GetValue();
node->Set("value", value);
// Sprite min value
value = this->GetMinValue();
node->Set("minValue", value);
// Sprite max value
value = this->GetMaxValue();
node->Set("maxValue", value);
// Get thumb sprite and frame
if (this->thumbButton != NULL)
{
Sprite *sprite = this->GetThumb()->GetSprite();
int32 spriteFrame = this->GetThumb()->GetFrame();
if (sprite)
{
//Create array yamlnode and add it to map
YamlNode *spriteNode = new YamlNode(YamlNode::TYPE_ARRAY);
spriteNode->AddValueToArray(TruncateTxtFileExtension(sprite->GetName()));
spriteNode->AddValueToArray(spriteFrame);
node->AddNodeToMap("thumbSprite", spriteNode);
}
}
if (this->bgMin != NULL)
{
// Get min sprite and frame
Sprite *sprite = this->GetBgMin()->GetSprite();
int32 spriteFrame = this->GetBgMin()->GetFrame();
if (sprite)
{
// Create array yamlnode and add it to map
YamlNode *spriteNode = new YamlNode(YamlNode::TYPE_ARRAY);
spriteNode->AddValueToArray(TruncateTxtFileExtension(sprite->GetName()));
spriteNode->AddValueToArray(spriteFrame);
node->AddNodeToMap("minSprite", spriteNode);
}
// Min draw type
UIControlBackground::eDrawType drawType = this->GetBgMin()->GetDrawType();
node->Set("minDrawType", loader->GetDrawTypeNodeValue(drawType));
}
if (this->bgMax != NULL)
{
// Get max sprite and frame
Sprite* sprite = this->GetBgMax()->GetSprite();
int32 spriteFrame = this->GetBgMax()->GetFrame();
if (sprite)
{
// Create array yamlnode and add it to map
YamlNode *spriteNode = new YamlNode(YamlNode::TYPE_ARRAY);
spriteNode->AddValueToArray(TruncateTxtFileExtension(sprite->GetName()));
spriteNode->AddValueToArray(spriteFrame);
node->AddNodeToMap("maxSprite", spriteNode);
}
// Max draw type
UIControlBackground::eDrawType drawType = this->GetBgMax()->GetDrawType();
node->Set("maxDrawType", loader->GetDrawTypeNodeValue(drawType));
}
return node;
}