本文整理汇总了C++中YamlNode::AsVector2方法的典型用法代码示例。如果您正苦于以下问题:C++ YamlNode::AsVector2方法的具体用法?C++ YamlNode::AsVector2怎么用?C++ YamlNode::AsVector2使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YamlNode
的用法示例。
在下文中一共展示了YamlNode::AsVector2方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: LoadFromYamlNode
void UIStaticText::LoadFromYamlNode(YamlNode * node, UIYamlLoader * loader)
{
UIControl::LoadFromYamlNode(node, loader);
YamlNode * fontNode = node->Get("font");
YamlNode * textNode = node->Get("text");
YamlNode * multilineNode = node->Get("multiline");
YamlNode * multilineBySymbolNode = node->Get("multilineBySymbol");
YamlNode * fittingNode = node->Get("fitting");
YamlNode * textColorNode = node->Get("textcolor");
YamlNode * shadowColorNode = node->Get("shadowcolor");
YamlNode * shadowOffsetNode = node->Get("shadowoffset");
if (fontNode)
{
const String & fontName = fontNode->AsString();
Font * font = loader->GetFontByName(fontName);
SetFont(font);
}
bool multiline = loader->GetBoolFromYamlNode(multilineNode, false);
bool multilineBySymbol = loader->GetBoolFromYamlNode(multilineBySymbolNode, false);
SetMultiline(multiline, multilineBySymbol);
if(fittingNode)
{
int32 fittingArray[] = {TextBlock::FITTING_DISABLED, TextBlock::FITTING_ENLARGE,
TextBlock::FITTING_REDUCE, TextBlock::FITTING_POINTS};
String fittingValues[] = {"Disabled", "Enlarge", "Reduce", "Points"};
const String & fittinOption = fittingNode->AsString();
int32 fittingType = 0;
for(int32 i = 0 ; i < 4; ++i)
{
size_t find = fittinOption.find(fittingValues[i]);
if(find != fittinOption.npos)
{
fittingType |= fittingArray[i];
}
}
SetFittingOption(fittingType);
}
if (textNode)
{
SetText(LocalizedString(textNode->AsWString()));
}
if(textColorNode)
{
Vector4 c = textColorNode->AsVector4();
SetTextColor(Color(c.x, c.y, c.z, c.w));
}
if(shadowColorNode)
{
Vector4 c = shadowColorNode->AsVector4();
SetShadowColor(Color(c.x, c.y, c.z, c.w));
}
if(shadowOffsetNode)
{
SetShadowOffset(shadowOffsetNode->AsVector2());
}
YamlNode * alignNode = node->Get("align");
SetAlign(loader->GetAlignFromYamlNode(alignNode)); // NULL is also OK here.
}
示例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 UITextField::LoadFromYamlNode(YamlNode * node, UIYamlLoader * loader)
{
UIControl::LoadFromYamlNode(node, loader);
YamlNode * textNode = node->Get("text");
if (textNode)
{
SetText(textNode->AsWString());
}
YamlNode * fontNode = node->Get("font");
if (fontNode)
{
Font * font = loader->GetFontByName(fontNode->AsString());
if (font)
SetFont(font);
}
if(staticText)
{
staticText->SetRect(Rect(0,0,GetRect().dx, GetRect().dy));
YamlNode * textColorNode = node->Get("textcolor");
YamlNode * shadowColorNode = node->Get("shadowcolor");
YamlNode * shadowOffsetNode = node->Get("shadowoffset");
YamlNode * textAlignNode = node->Get("textalign");
if(textColorNode)
{
Vector4 c = textColorNode->AsVector4();
SetTextColor(Color(c.x, c.y, c.z, c.w));
}
if(shadowColorNode)
{
Vector4 c = shadowColorNode->AsVector4();
SetShadowColor(Color(c.x, c.y, c.z, c.w));
}
if(shadowOffsetNode)
{
SetShadowOffset(shadowOffsetNode->AsVector2());
}
if(textAlignNode)
{
SetTextAlign(loader->GetAlignFromYamlNode(textAlignNode));
}
}
//InitAfterYaml();
#if 0
YamlNode * orientNode = node->Get("orientation");
if (orientNode)
{
if (orientNode->AsString() == "Vertical")
orientation = ORIENTATION_VERTICAL;
else if (orientNode->AsString() == "Horizontal")
orientation = ORIENTATION_HORIZONTAL;
}
// TODO
InitAfterYaml();
#endif
}