本文整理汇总了C++中YamlNode::AsWString方法的典型用法代码示例。如果您正苦于以下问题:C++ YamlNode::AsWString方法的具体用法?C++ YamlNode::AsWString怎么用?C++ YamlNode::AsWString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类YamlNode
的用法示例。
在下文中一共展示了YamlNode::AsWString方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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");
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()));
}
}
示例2: 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.
}
示例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()));
}
}
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: 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
}