Ejemplo n.º 1
0
ci::ColorA QTimeline::getThemeColor( XmlTree tree, string tag )
{
    ColorA col;
    
    if ( tree.hasChild( tag ) )
    {
        tree    = tree.getChild(tag);
        col     = ColorA(   tree.getAttributeValue<float>("r"),
                            tree.getAttributeValue<float>("g"),
                            tree.getAttributeValue<float>("b"),
                            tree.getAttributeValue<float>("a") );
    }
    
    return col;
}
Ejemplo n.º 2
0
WarpList Warp::readSettings( const DataSourceRef &source )
{
	XmlTree  doc;
	WarpList warps;

	// try to load the specified xml file
	try {
		doc = XmlTree( source );
	}
	catch( ... ) {
		return warps;
	}

	// check if this is a valid file
	bool isWarp = doc.hasChild( "warpconfig" );
	if( !isWarp ) return warps;

	//
	if( isWarp ) {
		// get first profile
		XmlTree profileXml = doc.getChild( "warpconfig/profile" );

		// iterate maps
		for( XmlTree::ConstIter child = profileXml.begin( "map" ); child != profileXml.end(); ++child ) {
			XmlTree warpXml = child->getChild( "warp" );

			// create warp of the correct type
			std::string method = warpXml.getAttributeValue<std::string>( "method", "unknown" );
			if( method == "bilinear" ) {
				WarpBilinearRef warp( new WarpBilinear() );
				warp->fromXml( warpXml );
				warps.push_back( warp );
			}
			else if( method == "perspective" ) {
				WarpPerspectiveRef warp( new WarpPerspective() );
				warp->fromXml( warpXml );
				warps.push_back( warp );
			}
			else if( method == "perspectivebilinear" ) {
				WarpPerspectiveBilinearRef warp( new WarpPerspectiveBilinear() );
				warp->fromXml( warpXml );
				warps.push_back( warp );
			}
		}
	}

	return warps;
}
Ejemplo n.º 3
0
void License::init( XmlTree &doc )
{
	if( doc.hasChild( "License" ))
	{
		XmlTree xmlLicense = doc.getChild( "License" );

		string product = xmlLicense.getAttributeValue<string>( "Product", ""  );
		string key     = xmlLicense.getAttributeValue<string>( "Key"    , ""  );

		setProduct( product );
		setKeyPath( getAssetPath( key ));

		for( XmlTree::Iter child = xmlLicense.begin(); child != xmlLicense.end(); ++child )
		{
			if( child->getTag() == "Server" )
			{
				string server = child->getAttributeValue<string>( "Name" );
				addServer( server );
			}
		}
	}
}
Ejemplo n.º 4
0
void Level::loadLevelFromFile(string pathToLevel)
{   
    // root
    id = pathToLevel;
    string realPath = "levels/" + pathToLevel;
    realPath = getAssetPath(realPath).string();
    XmlTree doc((loadFile(realPath)));
    XmlTree root = doc.getChild("level");
    
    // width + height
    width = root.getChild("width").getValue<int>();
    height = root.getChild("height").getValue<int>();
    Map.resize(width, vector<int>(height, -1));
    
    // hero start position
    int hx = root.getChild("heroX").getValue<int>();
    int hy = root.getChild("heroY").getValue<int>();
    hero.position.set(hx * TILESIZE, hy * TILESIZE);
    
    // antenna
    int ax = root.getChild("antennaX").getValue<int>();
    int ay = root.getChild("antennaY").getValue<int>();
    antennaPosition.set(ax * TILESIZE, ay * TILESIZE);
    
    // level-data
    stringstream stream;
    stream << root.getChild("data").getValue();
    int index = 0;
    while (stream.good() && index < width * height) {
        int tileId;
        stream >> tileId;
        setTileAtPosition(index, tileId);
        index++;
    }
    
    // attractors
    if (root.hasChild("attractors")) {
        XmlTree firstAttractor = root.getChild("attractors");
        for (XmlTree::Iter child = firstAttractor.begin(); child != firstAttractor.end(); child++) {
            float x = child->getChild("x").getValue<float>();
            float y = child->getChild("y").getValue<float>();
            Attractor* attractor = new Attractor(x, y);
            attractor->autoConnectTime = child->getChild("autoConnectTime").getValue<float>(attractor->autoConnectTime);
            attractor->autoDisconnectTime = child->getChild("autoDisconnectTime").getValue<float>();
            attractor->autoConnectRadius = child->getChild("autoConnectRadius").getValue<float>();
            attractor->connectTimeout = child->getChild("connectTimeout").getValue<float>();
            attractor->attractForce = child->getChild("attractForce").getValue<float>(attractor->attractForce);
            attractor->maxAttractForce = child->getChild("maxAttractForce").getValue<float>(attractor->maxAttractForce);
            
            addConnector(attractor);
        }
    }
    
    // detractors
    if (root.hasChild("detractors")) {
        XmlTree firstDetractor = root.getChild("detractors");
        for (XmlTree::Iter child = firstDetractor.begin(); child != firstDetractor.end(); child++) {
            float x = child->getChild("x").getValue<float>();
            float y = child->getChild("y").getValue<float>();
            Detractor* detractor = new Detractor(x, y);
            detractor->autoConnectTime = child->getChild("autoConnectTime").getValue<float>(detractor->autoConnectTime);
            detractor->autoDisconnectTime = child->getChild("autoDisconnectTime").getValue<float>();
            detractor->autoConnectRadius = child->getChild("autoConnectRadius").getValue<float>();
            detractor->connectTimeout = child->getChild("connectTimeout").getValue<float>();
            detractor->bounceForce = child->getChild("bounceForce").getValue<float>(detractor->bounceForce);
            detractor->maxBounceForce = child->getChild("maxBounceForce").getValue<float>(detractor->maxBounceForce);
            
            addConnector(detractor);
        }
    }
    
}