YamlNode* UIAggregatorControl::SaveToYamlNode(UIYamlLoader * loader)
{
	YamlNode* node = UIControl::SaveToYamlNode(loader);
	SetPreferredNodeType(node, "UIAggregatorControl");
	node->Set(AGGREGATOR_PATH, aggregatorPath.GetFrameworkPath());
	return node;
}
Пример #2
0
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;
}
Пример #3
0
YamlNode * UIList::SaveToYamlNode(UIYamlLoader * loader)
{
	YamlNode *node = UIControl::SaveToYamlNode(loader);
	//Temp variable
	String stringValue;
    
	//Control Type
	node->Set("type", "UIList");
	//Orientation
	eListOrientation orient = this->GetOrientation();
	switch(orient)
	{
		case ORIENTATION_VERTICAL:
			stringValue = "ORIENTATION_VERTICAL";
			break;
		case ORIENTATION_HORIZONTAL:
			stringValue = "ORIENTATION_HORIZONTAL";
			break;
		default:
			stringValue = "ORIENTATION_VERTICAL";
			break;
	}
	node->Set("orientation", stringValue);
    
	return node;
}
Пример #4
0
void UIScrollView::LoadFromYamlNode(YamlNode * node, UIYamlLoader * loader)
{
	UIControl::LoadFromYamlNode(node, loader);
	
	YamlNode *contentSizeNode = node->Get("contentSize");
	SetContentSize(contentSizeNode->AsPoint());
}		
Пример #5
0
bool Shader::LoadFromYaml(const FilePath & pathname)
{
//#if defined(__DAVAENGINE_ANDROID__) || defined (__DAVAENGINE_MACOS__)
//    relativeFileName = pathname;
//#endif //#if defined(__DAVAENGINE_ANDROID__) 

    uint64 shaderLoadTime = SystemTimer::Instance()->AbsoluteMS();
    
    YamlParser * parser = YamlParser::Create(pathname);
    if (!parser)
        return false;
    
    YamlNode * rootNode = parser->GetRootNode();
    if (!rootNode)
    {
        SafeRelease(rootNode);
        return false;
    }
    
    const YamlNode * vertexShaderNode = rootNode->Get("vertexShader");
    if (!vertexShaderNode)
    {
        SafeRelease(parser);
        return false;
    }

    const YamlNode * glslVertexNode = vertexShaderNode->Get("glsl");
    if (!glslVertexNode)
    {
        SafeRelease(parser);
        return false;
    }
    
    const YamlNode * fragmentShaderNode = rootNode->Get("fragmentShader");
    if (!fragmentShaderNode)
    {
        SafeRelease(parser);
        return false;
    }
    
    const YamlNode * glslFragmentNode = fragmentShaderNode->Get("glsl");
    if (!glslFragmentNode)
    {
        SafeRelease(parser);
        return false;
    }

    FilePath pathOnly(pathname.GetDirectory());
    vertexShaderPath = pathOnly + glslVertexNode->AsString();
    fragmentShaderPath = pathOnly + glslFragmentNode->AsString();
    SafeRelease(parser);

    Load(vertexShaderPath, fragmentShaderPath);
    
    shaderLoadTime = SystemTimer::Instance()->AbsoluteMS() - shaderLoadTime;
    
//    Logger::FrameworkDebug("shader loaded:%s load-time: %lld ms", pathname.c_str(), shaderLoadTime);
    return true;
}
Пример #6
0
bool 
YamlMapping::equalTo(char *k, char *val){
	YamlNode *n = getValue(k);
	if(n != NULL){
		return n->equalTo(val);
	}
	return false;
}
Пример #7
0
YamlScalar *
YamlMapping::getScalar(char *k)
{
	YamlNode *n = getValue(k);
	if(n != NULL){
		return n->toScalar();
	}
	return NULL; 
}
Пример #8
0
YamlMapping *
YamlMapping::getMapping(char *k)
{
	YamlNode *n = getValue(k);
	if(n != NULL){
		return n->toMapping();
	}
	return NULL; 
}
Пример #9
0
YamlSequence *
YamlMapping::getSequence(char *k)
{
	YamlNode *n = getValue(k);
	if(n != NULL){
		return n->toSequence();
	}
	return NULL; 
}
Пример #10
0
bool YamlMapping::read(const std::string &key, double &out_value) const
{
    YamlNode* node = find(toUtf8(key));
    if(node->isValid()){
        out_value = node->toDouble();
        return true;
    }
    return false;
}
Пример #11
0
    void UIListCell::LoadFromYamlNode(YamlNode * node, UIYamlLoader * loader)
	{
        YamlNode * identifierNode = node->Get("identifier");
        if (identifierNode)
        {
            identifier = identifierNode->AsString();
        }
        UIButton::LoadFromYamlNode(node, loader);
    }
Пример #12
0
YamlMapping *
YamlSequence::getMappingAt(int x)
{
	try{
		YamlNode *n = value.at(x);
		return n->toMapping();
	}catch(std::out_of_range& e){
		return NULL;
	}
}
Пример #13
0
YamlSequence *
YamlSequence::getSequenceAt(int x)
{
	try{
		YamlNode *n = value.at(x);
		return n->toSequence();
	}catch(std::out_of_range& e){
		return NULL;
	}
}
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;
}
Пример #15
0
void GameCore::OnAppStarted()
{
    DeviceInfo();
    
	SettingsManager::Instance()->InitWithFile("~res:/Config/config.yaml");
	
	cursor = 0;
	RenderManager::Instance()->SetFPS(60);

	String dirPath = "~res:/3d/Maps/";
	Vector<String> levelsPaths;
	YamlParser* parser = YamlParser::Create("~res:/maps.yaml");
	if(parser)
	{
		YamlNode* rootNode = parser->GetRootNode();
		if(rootNode)
		{
			int32 sz = rootNode->GetCount();

			for(DAVA::int32 i = 0; i < sz; ++i)
			{
				String k = rootNode->GetItemKeyName(i);
				String levelFile = rootNode->Get(i)->AsString();
				if(k != "default")
					levelsPaths.push_back(levelFile);
			}
		}
	}

	for(Vector<String>::const_iterator it = levelsPaths.begin(); it != levelsPaths.end(); ++it)
    {
		Test *test = new Test(dirPath + (*it));
		if(test != NULL)
        {
			UIScreenManager::Instance()->RegisterScreen(test->GetScreenId(), test);
			tests.push_back(test);
		}
	}

	if(levelsPaths.size() > 0)
    {
		appFinished = false;
		
		testCount = tests.size();
		Test *firstTest = tests.front();
		UIScreenManager::Instance()->SetFirst(firstTest->GetScreenId());
	}
    else
    {
		appFinished = true;
	}
    
	ConnectToDB();
}
Пример #16
0
    YamlNode * UIListCell::SaveToYamlNode(UIYamlLoader * loader)
    {
        YamlNode *node = UIControl::SaveToYamlNode(loader);
        
        //Control Type
		SetPreferredNodeType(node, "UIListCell");

        //Identifier
        node->Set("identifier", this->GetIdentifier());
        
        return node;
    }
Пример #17
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);
	}
}
Пример #18
0
YamlNode *
YamlDocument::ParseYamlDoc()
{
	YamlNode *root = new YamlNode();

	yaml_event_delete(&event);

	do{
		yaml_parser_parse(&parser, &event);
		switch(event.type){
		case YAML_STREAM_END_EVENT:
		case YAML_DOCUMENT_END_EVENT:
			return root;

		case YAML_SEQUENCE_START_EVENT:
			{
				YamlSequence *v;
				v = ParseYamlSequence();
				root->addChild(reinterpret_cast<YamlNode *>(v));
			}
			break;
		case YAML_SEQUENCE_END_EVENT:
			break;
		case YAML_MAPPING_START_EVENT:
			{
				YamlMapping *v;
				v=ParseYamlMapping();
				root->addChild(reinterpret_cast<YamlNode *>(v));
			}
			break;
		case YAML_MAPPING_END_EVENT:
			break;

		case YAML_SCALAR_EVENT:
			{
				YamlScalar *v = new YamlScalar((char *)event.data.scalar.value );
				root->addChild(reinterpret_cast<YamlNode *>(v));
			}
			break;
		default:
			std::cout << "FORMAT ERROR" << std::endl;
			break;
		}
		if(event.type != YAML_DOCUMENT_END_EVENT){
			yaml_event_delete(&event);
		}
	}while(event.type != YAML_DOCUMENT_END_EVENT);

	yaml_event_delete(&event);

	return root;
}
Пример #19
0
YamlSequence* YamlMapping::findSequence(const std::string& key) const
{
    if(!isValid()){
        throwNotMappingException();
    }
    const_iterator p = values.find(toUtf8(key));
    if(p != values.end()){
        YamlNode* node = p->second.get();
        if(node->type() == YAML_SEQUENCE){
            return static_cast<YamlSequence*>(node);
        }
    }
    return invalidSequence.get();
}
Пример #20
0
bool HierarchyTreeAggregatorNode::Load(YamlNode* node, const QString& path)
{
	this->path = path.toStdString();
	YamlNode* width = node->Get(WIDTH_NODE);
	YamlNode* height = node->Get(HEIGHT_NODE);
	if (!width || !height)
		return false;

	rect = Rect(0, 0, width->AsInt(), height->AsInt());
	screen->SetRect(rect);

	bool result = HierarchyTreeScreenNode::Load(path);
	UpdateHierarchyTree();
	return result;
}
Пример #21
0
YamlNode * Font::SaveToYamlNode() const
{
    YamlNode *node = new YamlNode(YamlNode::TYPE_MAP);
    
    VariantType *nodeValue = new VariantType();
    //Type
    node->Set("type", "Font");
    //Font size
    node->Set("size", this->GetSize());
    //Vertical Spacing
    node->Set("verticalSpacing", this->GetVerticalSpacing());

    SafeDelete(nodeValue);
    
    return node;
}
Пример #22
0
/**
   This is for internal use. Text are not converted to UTF-8.
*/
void YamlMapping::writeSub(const std::string &key, const char* text, size_t length, YamlStringStyle stringStyle)
{
    const string uKey(toUtf8(key));
    iterator p = values.find(uKey);
    if(p == values.end()){
        insertSub(uKey, new YamlScalar(text, length, stringStyle));
    } else {
        YamlNode* node = p->second.get();
        if(node->type() == YAML_SCALAR){
            YamlScalar* scalar = static_cast<YamlScalar*>(node);
            scalar->stringValue = string(text, length);
            scalar->stringStyle = stringStyle;
            scalar->indexInMapping = indexCounter++;
        } else {
            throwNotScalrException();
        }
    }
}
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);
	}
}
Пример #24
0
void ParticleEmitter::SaveToYaml(const String & filename)
{
    YamlParser* parser = YamlParser::Create();
    if (!parser)
    {
        Logger::Error("ParticleEmitter::SaveToYaml() - unable to create parser!");
        return;
    }

    YamlNode* rootYamlNode = new YamlNode(YamlNode::TYPE_MAP);
    YamlNode* emitterYamlNode = new YamlNode(YamlNode::TYPE_MAP);
    rootYamlNode->AddNodeToMap("emitter", emitterYamlNode);

    emitterYamlNode->Set("3d", this->is3D);
    emitterYamlNode->Set("type", GetEmitterTypeName());

    // Write the property lines.
    PropertyLineYamlWriter::WritePropertyLineToYamlNode<float32>(emitterYamlNode, "emissionAngle", this->emissionAngle);
    PropertyLineYamlWriter::WritePropertyLineToYamlNode<float32>(emitterYamlNode, "emissionRange", this->emissionRange);
    PropertyLineYamlWriter::WritePropertyLineToYamlNode<Vector3>(emitterYamlNode, "emissionVector", this->emissionVector);

    // Yuri Coder, 2013/04/12. After the coordinates inversion for the emission vector we need to introduce the
    // new "emissionVectorInverted" flag to mark we don't need to invert coordinates after re-loading the YAML.
    PropertyLineYamlWriter::WritePropertyValueToYamlNode<bool>(emitterYamlNode, "emissionVectorInverted", true);

    PropertyLineYamlWriter::WritePropertyLineToYamlNode<float32>(emitterYamlNode, "radius", this->radius);

    PropertyLineYamlWriter::WriteColorPropertyLineToYamlNode(emitterYamlNode, "colorOverLife", this->colorOverLife);

    PropertyLineYamlWriter::WritePropertyLineToYamlNode<Vector3>(emitterYamlNode, "size", this->size);
    PropertyLineYamlWriter::WritePropertyValueToYamlNode<float32>(emitterYamlNode, "life", this->lifeTime);

    // Now write all the Layers. Note - layers are child of root node, not the emitter one.
    int32 layersCount = this->layers.size();
    for (int32 i = 0; i < layersCount; i ++)
    {
        this->layers[i]->SaveToYamlNode(rootYamlNode, i);
    }

    parser->SaveToYamlFile(filename, rootYamlNode, true);
    parser->Release();
}
Пример #25
0
YamlNode * GraphicsFont::SaveToYamlNode()
{
    YamlNode *node = Font::SaveToYamlNode();
    
    //Type
    node->Set("type", "GraphicsFont");
    //horizontalSpacing
    node->Set("horizontalSpacing", this->GetHorizontalSpacing());
    //Sprite    
    Sprite *sprite = this->fontSprite;
    if (sprite)
    {
        //Truncate sprite ".txt" extension before save       
        node->Set("sprite", TruncateTxtFileExtension(sprite->GetName()));
    }    
    //Font Definition
    node->Set("definition", this->GetFontDefinitionName());

    return node;
}
Пример #26
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);
    }
}
Пример #27
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();
}
Пример #28
0
YamlNode * GraphicsFont::SaveToYamlNode()
{
    YamlNode *node = Font::SaveToYamlNode();

    //Type
    node->Set("type", "GraphicsFont");
    //horizontalSpacing
    node->Set("horizontalSpacing", this->GetHorizontalSpacing());
    //Sprite
    Sprite *sprite = this->fontSprite;
    if (sprite)
    {
        //Truncate sprite ".txt" extension before save
        FilePath path(sprite->GetRelativePathname());
        path.TruncateExtension();
        node->Set("sprite", path.GetAbsolutePathname());
    }
    //Font Definition
    node->Set("definition", this->GetFontDefinitionName().GetAbsolutePathname());

    return node;
}
Пример #29
0
void YamlDocument::deleteChildNodes()
{
    Sequence::iterator it = doc.begin();

    while (it != doc.end()) {
        YamlNode *yamlNode = static_cast<YamlNode *> (*it);

        switch (yamlNode->getType()) {
            case DOCUMENT:
                break;
            case SEQUENCE: {
                SequenceNode *sequence = static_cast<SequenceNode *> (yamlNode);
                sequence->deleteChildNodes();
                delete sequence;
                sequence = NULL;
            }
            break;
            case MAPPING: {
                MappingNode *mapping = static_cast<MappingNode *> (yamlNode);
                mapping->deleteChildNodes();
                delete mapping;
                mapping = NULL;
            }
            break;
            case SCALAR: {
                ScalarNode *scalar = static_cast<ScalarNode *> (yamlNode);
                delete scalar;
                scalar = NULL;
            }
            break;
            default:
                break;
        }

        it++;
    }
}
Пример #30
0
void MappingNode::deleteChildNodes()
{
    Mapping::iterator it;

    for (it = map.begin(); it != map.end(); ++it) {
        YamlNode *yamlNode = static_cast<YamlNode *> (it->second);
        if (!yamlNode)
            continue;

        switch (yamlNode->getType()) {
            case DOCUMENT:
                break;
            case SEQUENCE: {
                SequenceNode *sequence = static_cast<SequenceNode *> (yamlNode);
                sequence->deleteChildNodes();
                delete sequence;
                sequence = NULL;
            }
            break;
            case MAPPING: {
                MappingNode *mapping = static_cast<MappingNode *> (yamlNode);
                mapping->deleteChildNodes();
                delete mapping;
                mapping = NULL;
            }
            break;
            case SCALAR: {
                ScalarNode *scalar = static_cast<ScalarNode *> (yamlNode);
                delete scalar;
                scalar = NULL;
            }
            break;
            default:
                break;
        }
    }
}