YamlNode * UIStaticText::SaveToYamlNode(UIYamlLoader * loader)
{
    YamlNode *node = UIControl::SaveToYamlNode(loader);

	UIStaticText *baseControl = new UIStaticText();	

    //Temp variable
    VariantType *nodeValue = new VariantType();
    
    //Control Type
	SetPreferredNodeType(node, "UIStaticText");

    //Font
    //Get font name and put it here
    nodeValue->SetString(FontManager::Instance()->GetFontName(this->GetFont()));
    node->Set("font", nodeValue);

	//TextColor
	nodeValue->SetVector4(Vector4(textColor.r, textColor.g, textColor.b, textColor.a));
	node->Set("textcolor", nodeValue);

	// ShadowColor
	nodeValue->SetVector4(Vector4(shadowColor.r, shadowColor.g, shadowColor.b, shadowColor.a));
	node->Set("shadowcolor", nodeValue);

	// ShadowOffset
	nodeValue->SetVector2(GetShadowOffset());
	node->Set("shadowoffset", nodeValue);

    //Text
    nodeValue->SetWideString(GetText());
    node->Set("text", nodeValue);    
    //Multiline
	if (baseControl->textBlock->GetMultiline() != this->textBlock->GetMultiline())
	{
    	node->Set("multiline", this->textBlock->GetMultiline());
	}
    //multilineBySymbol
	if (baseControl->textBlock->GetMultilineBySymbol() != this->textBlock->GetMultilineBySymbol())
	{
    	node->Set("multilineBySymbol", this->textBlock->GetMultilineBySymbol());
	}
    //fitting - STRING OF INT???
	if (baseControl->textBlock->GetFittingOption() != this->textBlock->GetFittingOption())
	{
    	node->Set("fitting", this->textBlock->GetFittingOption());
	}
    
	// Align
	node->SetNodeToMap("textalign", loader->GetAlignNodeValue(this->GetTextAlign()));

	// Draw type. Must be overriden for UITextControls.
	node->Set("drawType", loader->GetDrawTypeNodeValue(this->GetBackground()->GetDrawType()));

    SafeDelete(nodeValue);
	SafeRelease(baseControl);
    
    return node;
}
YamlNode * UITextField::SaveToYamlNode(UIYamlLoader * loader)
{
    YamlNode *node = UIControl::SaveToYamlNode(loader);

    //Temp variable
    VariantType *nodeValue = new VariantType();

    //Control Type
	SetPreferredNodeType(node, "UITextField");

    //Text
    nodeValue->SetWideString(this->GetText());
    node->Set("text", nodeValue);

    //Font
    //Get font name and put it here
    nodeValue->SetString(FontManager::Instance()->GetFontName(this->GetFont()));
    node->Set("font", nodeValue);
	
	//TextColor
	Color textColor = GetTextColor();
	nodeValue->SetVector4(Vector4(textColor.r, textColor.g, textColor.b, textColor.a));
	node->Set("textcolor", nodeValue);

	// ShadowColor
	Color shadowColor = GetShadowColor();
	nodeValue->SetVector4(Vector4(shadowColor.r, shadowColor.g, shadowColor.b, shadowColor.a));
	node->Set("shadowcolor", nodeValue);

	// ShadowOffset
	nodeValue->SetVector2(GetShadowOffset());
	node->Set("shadowoffset", nodeValue);

	// Text align
	node->SetNodeToMap("textalign", loader->GetAlignNodeValue(this->GetTextAlign()));

	// Draw Type must be overwritten fot UITextField.
	UIControlBackground::eDrawType drawType =  this->GetBackground()->GetDrawType();
	node->Set("drawType", loader->GetDrawTypeNodeValue(drawType));

    SafeDelete(nodeValue);
    
    return node;
}
Beispiel #3
0
YamlNode * UIStaticText::SaveToYamlNode(UIYamlLoader * loader)
{
    YamlNode *node = UIControl::SaveToYamlNode(loader);

    UIStaticText *baseControl = new UIStaticText();

    //Temp variable
    VariantType *nodeValue = new VariantType();

    //Font
    //Get font name and put it here
    nodeValue->SetString(FontManager::Instance()->GetFontName(this->GetFont()));
    node->Set("font", nodeValue);

    //TextColor
    const Color &textColor = GetTextColor();
    if (baseControl->GetTextColor() != textColor)
    {
        nodeValue->SetColor(textColor);
        node->Set("textcolor", nodeValue);
    }

    // Text Color Inherit Type.
    int32 colorInheritType = (int32)GetTextBackground()->GetColorInheritType();
    if (baseControl->GetTextBackground()->GetColorInheritType() != colorInheritType)
    {
        node->Set("textcolorInheritType", loader->GetColorInheritTypeNodeValue(colorInheritType));
    }

    // ShadowColor
    const Color &shadowColor = GetShadowColor();
    if (baseControl->GetShadowColor() != shadowColor)
    {
        nodeValue->SetColor(shadowColor);
        node->Set("shadowcolor", nodeValue);
    }

    // Shadow Color Inherit Type.
    colorInheritType = (int32)GetShadowBackground()->GetColorInheritType();
    if (baseControl->GetShadowBackground()->GetColorInheritType() != colorInheritType)
    {
        node->Set("shadowcolorInheritType", loader->GetColorInheritTypeNodeValue(colorInheritType));
    }

    // ShadowOffset
    const Vector2 &shadowOffset = GetShadowOffset();
    if (baseControl->GetShadowOffset() != shadowOffset)
    {
        nodeValue->SetVector2(shadowOffset);
        node->Set("shadowoffset", nodeValue);
    }

    //Text
    const WideString &text = GetText();
    if (baseControl->GetText() != text)
    {
        node->Set("text", text);
    }
    //Multiline
    if (baseControl->textBlock->GetMultiline() != this->textBlock->GetMultiline())
    {
        node->Set("multiline", this->textBlock->GetMultiline());
    }
    //multilineBySymbol
    if (baseControl->textBlock->GetMultilineBySymbol() != this->textBlock->GetMultilineBySymbol())
    {
        node->Set("multilineBySymbol", this->textBlock->GetMultilineBySymbol());
    }
    //fitting - Array of strings
    if (baseControl->textBlock->GetFittingOption() != this->textBlock->GetFittingOption())
    {
        node->SetNodeToMap("fitting", loader->GetFittingOptionNodeValue(textBlock->GetFittingOption()));
    }

    // Text Align
    if (baseControl->GetTextAlign() != this->GetTextAlign())
    {
        node->SetNodeToMap("textalign", loader->GetAlignNodeValue(this->GetTextAlign()));
    }

    // Draw type. Must be overriden for UITextControls.
    if (baseControl->GetBackground()->GetDrawType() != this->GetBackground()->GetDrawType())
    {
        node->Set("drawType", loader->GetDrawTypeNodeValue(this->GetBackground()->GetDrawType()));
    }

    SafeDelete(nodeValue);
    SafeRelease(baseControl);

    return node;
}