示例#1
0
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);
	}
	
	YamlNode * valueNode = node->Get("value");
	
	if (valueNode)
		SetValue(valueNode->AsFloat());
}
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()));
	}
    
}
示例#3
0
bool KeyedArchive::LoadFromYamlNode(YamlNode* rootNode)
{
    if(NULL == rootNode)
    {
        return  false;
    }

    Vector<YamlNode*> &rootVector = rootNode->Get(VariantType::TYPENAME_KEYED_ARCHIVE)->AsVector();
    
    for (Vector<YamlNode*>::const_iterator it = rootVector.begin(); it != rootVector.end(); ++it)
    {
		YamlNode * node = *it;
		String variableNameToArchMap = node->AsString();

        VariantType *value = new VariantType(node->AsVariantType());
                
        if(value->GetType() == VariantType::TYPE_NONE)
        {
            SafeDelete(value);
            continue;
        }

        objectMap[variableNameToArchMap] = value;
    }
    
    return true;
}
bool HierarchyTreePlatformNode::Load(YamlNode* platform)
{
	YamlNode* width = platform->Get(WIDTH_NODE);
	YamlNode* height = platform->Get(HEIGHT_NODE);
	if (!width || !height)
		return false;
	
	bool result = true;
	SetSize(width->AsInt(), height->AsInt());
	ActivatePlatform();
	
	YamlNode* screens = platform->Get(SCREENS_NODE);
	if (screens)
	{
		for (int i = 0; i < screens->GetCount(); i++)
		{
			YamlNode* screen = screens->Get(i);
			if (!screen)
				continue;
			String screenName = screen->AsString();
			
			QString screenPath = QString(SCREEN_PATH).arg(GetResourceFolder()).arg(QString::fromStdString(screenName));
			HierarchyTreeScreenNode* screenNode = new HierarchyTreeScreenNode(this, QString::fromStdString(screenName));
			result &= screenNode->Load(screenPath);
			AddTreeNode(screenNode);
		}
	}
	return result;
}
示例#5
0
    void UIListCell::LoadFromYamlNode(YamlNode * node, UIYamlLoader * loader)
	{
        YamlNode * identifierNode = node->Get("identifier");
        if (identifierNode)
        {
            identifier = identifierNode->AsString();
        }
        UIButton::LoadFromYamlNode(node, loader);
    }
示例#6
0
bool HierarchyTreePlatformNode::LoadLocalization(YamlNode* platform)
{
    if (!platform)
    {
        return false;
    }
    
    YamlNode* pathNode = platform->Get(LOCALIZATION_PATH_NODE);
    YamlNode* localeNode = platform->Get(LOCALIZATION_LOCALE_NODE);

    if (pathNode && localeNode &&
        !pathNode->AsString().empty() &&
        !localeNode->AsString().empty())
    {
        localizationPath = pathNode->AsString();
        locale = localeNode->AsString();
    }

    return true;
}
示例#7
0
void UIAggregatorControl::LoadFromYamlNode(YamlNode * node, UIYamlLoader * loader)
{
	UIControl::LoadFromYamlNode(node, loader);
	
	YamlNode * pathNode = node->Get(AGGREGATOR_PATH);
	if (pathNode)
	{
		aggregatorPath = pathNode->AsString();
		UIYamlLoader loader;
		loader.Load(this, aggregatorPath);
	}
}
示例#8
0
void UIList::LoadFromYamlNode(YamlNode * node, UIYamlLoader * loader)
{
	UIControl::LoadFromYamlNode(node, loader);
		
	YamlNode * orientNode = node->Get("orientation");
	if (orientNode)
	{
		if (orientNode->AsString() == "ORIENTATION_VERTICAL")
			orientation = ORIENTATION_VERTICAL;
		else if (orientNode->AsString() == "ORIENTATION_HORIZONTAL")
			orientation = ORIENTATION_HORIZONTAL;
		else 
		{
			DVASSERT(0 && "Orientation constant is wrong");
		}
	}
		
		
		
		// TODO
	InitAfterYaml();
}
void UIAggregatorControl::LoadFromYamlNode(YamlNode * node, UIYamlLoader * loader)
{
	UIControl::LoadFromYamlNode(node, loader);
	
	YamlNode * pathNode = node->Get(AGGREGATOR_PATH);
	if (pathNode)
	{
		aggregatorPath = FilePath(pathNode->AsString());
		String aggregatorFileName = aggregatorPath.GetFilename();

		aggregatorPath = loader->GetCurrentPath() + aggregatorFileName;

		UIYamlLoader loader;
		loader.Load(this, aggregatorPath);

		aggregatorPath = FilePath(aggregatorFileName);
	}
}
示例#10
0
void TheoraPlayer::LoadFromYamlNode(YamlNode * node, UIYamlLoader * loader)
{
    UIControl::LoadFromYamlNode(node, loader);
    YamlNode * fileNode = node->Get("file");
    
	if(fileNode)
        OpenFile(fileNode->AsString());
    
    YamlNode * rectNode = node->Get("rect");
    
    if(rectNode)
    {
        Rect rect = rectNode->AsRect();
        if(rect.dx == -1)
            rect.dx = theoraData->thInfo.pic_width;
        if(rect.dy == -1)
            rect.dy = theoraData->thInfo.pic_height;
        
        SetRect(rect);
    }
}
示例#11
0
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);
	}		
}
示例#12
0
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.
}
示例#13
0
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
}
示例#14
0
	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);
				YamlNode * backgroundModificationNode = NULL;
				if(stateSpriteNode->GetCount() > 2)
				{
					backgroundModificationNode = stateSpriteNode->Get(2);
				}
				
				int32 frame = 0;
				if (frameNode)frame = frameNode->AsInt();
				if (spriteNode)
				{
					SetStateSprite(stateArray[k], spriteNode->AsString(), frame);
				}
				if (backgroundModificationNode)
				{
					stateBacks[k]->SetModification(backgroundModificationNode->AsInt());
				}
			}
            
            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);
                }
			}
			else
			{
                SetStateDrawType(stateArray[k],UIControlBackground::DRAW_ALIGNED);
			}
            
            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());
			}
			
			YamlNode * colorInheritNode = node->Get(Format("stateColorInherit%s", statePostfix[k].c_str()));
			if(colorInheritNode)
			{
				UIControlBackground::eColorInheritType type = (UIControlBackground::eColorInheritType)loader->GetColorInheritTypeFromNode(colorInheritNode);
				GetActualBackground(stateArray[k])->SetColorInheritType(type);
			}
			
			YamlNode * colorNode = node->Get(Format("stateColor%s", statePostfix[k].c_str()));
			if(colorNode)
			{
				Color color = loader->GetColorFromYamlNode(colorNode);
				GetActualBackground(stateArray[k])->SetColor(color);
			}
		}
	}
示例#15
0
void ParticleEmitter::LoadFromYaml(const String & filename)
{
    Cleanup(true);

    YamlParser * parser = YamlParser::Create(filename);
    if(!parser)
    {
        Logger::Error("ParticleEmitter::LoadFromYaml failed (%s)", filename.c_str());
        return;
    }

    configPath = filename;
    time = 0.0f;
    repeatCount = 0;
    lifeTime = 1000000000.0f;

    YamlNode * rootNode = parser->GetRootNode();

    YamlNode * emitterNode = rootNode->Get("emitter");
    if (emitterNode)
    {
        if (emitterNode->Get("emissionAngle"))
            emissionAngle = PropertyLineYamlReader::CreateFloatPropertyLineFromYamlNode(emitterNode, "emissionAngle");

        if (emitterNode->Get("emissionVector"))
            emissionVector = PropertyLineYamlReader::CreateVector3PropertyLineFromYamlNode(emitterNode, "emissionVector");

        YamlNode* emissionVectorInvertedNode = emitterNode->Get("emissionVectorInverted");
        if (!emissionVectorInvertedNode)
        {
            // Yuri Coder, 2013/04/12. This means that the emission vector in the YAML file is not inverted yet.
            // Because of [DF-1003] fix for such files we have to invert coordinates for this vector.
            InvertEmissionVectorCoordinates();
        }

        if (emitterNode->Get("emissionRange"))
            emissionRange = PropertyLineYamlReader::CreateFloatPropertyLineFromYamlNode(emitterNode, "emissionRange");

        if (emitterNode->Get("colorOverLife"))
            colorOverLife = PropertyLineYamlReader::CreateColorPropertyLineFromYamlNode(emitterNode, "colorOverLife");
        if (emitterNode->Get("radius"))
            radius = PropertyLineYamlReader::CreateFloatPropertyLineFromYamlNode(emitterNode, "radius");

        emitPointsCount = -1;
        YamlNode * emitAtPointsNode = emitterNode->Get("emitAtPoints");
        if (emitAtPointsNode)
            emitPointsCount = emitAtPointsNode->AsInt();

        YamlNode * lifeTimeNode = emitterNode->Get("life");
        if (lifeTimeNode)
        {
            lifeTime = lifeTimeNode->AsFloat();
        } else
        {
            lifeTime = 1000000000.0f;
        }

        is3D = false;
        YamlNode * _3dNode = emitterNode->Get("3d");
        if (_3dNode)
        {
            is3D = _3dNode->AsBool();
        }

        YamlNode * typeNode = emitterNode->Get("type");
        if (typeNode)
        {
            if (typeNode->AsString() == "point")
                emitterType = EMITTER_POINT;
            else if (typeNode->AsString() == "line")
            {
                // Yuri Coder, 2013/04/09. Get rid of the "line" node type -
                // it can be completely replaced by "rect" one.
                emitterType = EMITTER_RECT;
            }
            else if (typeNode->AsString() == "rect")
                emitterType = EMITTER_RECT;
            else if (typeNode->AsString() == "oncircle")
                emitterType = EMITTER_ONCIRCLE;
            else if (typeNode->AsString() == "shockwave")
                emitterType = EMITTER_SHOCKWAVE;
            else
                emitterType = EMITTER_POINT;
        } else
            emitterType = EMITTER_POINT;

        size = PropertyLineYamlReader::CreateVector3PropertyLineFromYamlNode(emitterNode, "size");

        if(size == 0)
        {
            Vector3 _size(0, 0, 0);
            YamlNode * widthNode = emitterNode->Get("width");
            if (widthNode)
                _size.x = widthNode->AsFloat();

            YamlNode * heightNode = emitterNode->Get("height");
            if (heightNode)
                _size.y = heightNode->AsFloat();

            YamlNode * depthNode = emitterNode->Get("depth");
            if (depthNode)
                _size.y = depthNode->AsFloat();

            size = new PropertyLineValue<Vector3>(_size);
        }

        YamlNode * autorestartNode = emitterNode->Get("autorestart");
        if(autorestartNode)
            isAutorestart = autorestartNode->AsBool();

        YamlNode * particlesFollowNode = emitterNode->Get("particlesFollow");
        if(particlesFollowNode)
            particlesFollow = particlesFollowNode->AsBool();
    }

    int cnt = rootNode->GetCount();
    for (int k = 0; k < cnt; ++k)
    {
        YamlNode * node = rootNode->Get(k);
        YamlNode * typeNode = node->Get("type");

        YamlNode * longNode = node->Get("isLong");
        bool isLong = false;
        if(longNode && (longNode->AsBool() == true))
        {
            isLong = true;
        }

        if (typeNode && typeNode->AsString() == "layer")
        {
            LoadParticleLayerFromYaml(node, isLong);
        }
    }

    // Yuri Coder, 2013/01/15. The "name" node for Layer was just added and may not exist for
    // old yaml files. Generate the default name for nodes with empty names.
    UpdateEmptyLayerNames();

    SafeRelease(parser);
}
示例#16
0
	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);
					}
				}
			}
		}
	}
示例#17
0
void EditorConfig::ParseConfig(const String &filePath)
{
	ClearConfig();

    YamlParser *parser = YamlParser::Create(filePath);
    if(parser)
    {
		YamlNode *rootNode = parser->GetRootNode();
		if(rootNode)
		{
			Vector<YamlNode*> &yamlNodes = rootNode->AsVector();
			int32 propertiesCount = yamlNodes.size();
			for(int32 i = 0; i < propertiesCount; ++i)
			{
				YamlNode *propertyNode = yamlNodes[i];
				if(propertyNode)
				{
					YamlNode *nameNode = propertyNode->Get("name");
					YamlNode *typeNode = propertyNode->Get("type");
					YamlNode *defaultNode = propertyNode->Get("default");
					if(nameNode && typeNode)
					{
						String nameStr = nameNode->AsString();
						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.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);

										YamlNode *comboNode = propertyNode->Get("list");
										if(comboNode)
										{
											Vector<YamlNode*> comboValueNodes = comboNode->AsVector();
											int32 comboValuesCount = comboValueNodes.size();
											for(int32 i = 0; i < comboValuesCount; ++i)
											{
												properties[nameStr]->comboValues.push_back(comboValueNodes[i]->AsString());
											}
										}
									}
									break;
                                case PT_COLOR_LIST:
                                    {
                                        int32 defaultValue = 0;
                                        if(defaultNode)
                                        {
                                            defaultValue = defaultNode->AsInt();
                                        }
                                        properties[nameStr]->defaultValue.SetInt32(defaultValue);
                                        
                                        YamlNode *colorListNode = propertyNode->Get("list");
                                        if(colorListNode)
                                        {
                                            Vector<YamlNode*> colorListNodes = colorListNode->AsVector();
                                            int32 colorListValuesCount = colorListNodes.size();
                                            for(int32 i = 0; i < colorListValuesCount; ++i)
                                            {
                                                YamlNode* colorNode = colorListNodes[i];
                                                if(!colorNode || colorNode->GetCount() != 4)
                                                    continue;
                                                
                                                Color color(colorNode->Get(0)->AsFloat()/255.f,
                                                            colorNode->Get(1)->AsFloat()/255.f,
                                                            colorNode->Get(2)->AsFloat()/255.f,
                                                            colorNode->Get(3)->AsFloat()/255.f);

                                                properties[nameStr]->colorListValues.push_back(color);
                                            }
                                        }
                                    }
                                    break;
								}
								propertyNames.push_back(nameStr);
							} //isOk
						}
						else
						{
							Logger::Error("EditorConfig::ParseConfig %s ERROR property %d unknown type %s", filePath.c_str(), i, typeStr.c_str());
						}
					}
					else
					{
						Logger::Error("EditorConfig::ParseConfig %s ERROR property %d type or name is missing", filePath.c_str(), i);
					}
				}
				else
				{
					Logger::Error("EditorConfig::ParseConfig %s ERROR property %d is missing", filePath.c_str(), i);
				}
			}
		} 
		// else file is empty - ok, no custom properties

		parser->Release();
	}
	// else file not found - ok, no custom properties
}